Fix typos in CVE text
[exim-website.git] / docbook / 4.74 / 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>21 Jan 2011</date>
16 <author><firstname>Exim</firstname><surname>Maintainers</surname></author>
17 <authorinitials>EM</authorinitials>
18 <revhistory><revision>
19   <revnumber>4.74</revnumber>
20   <date>21 Jan 2011</date>
21   <authorinitials>EM</authorinitials>
22 </revision></revhistory>
23 <copyright><year>2011</year><holder>University of Cambridge</holder></copyright>
24 </bookinfo>
25 <chapter id="CHID1">
26 <title>Introduction</title>
27
28 <indexterm role="variable">
29   <primary>$1, $2, etc.</primary>
30   <see><emphasis>numerical variables</emphasis></see>
31 </indexterm>
32 <indexterm role="concept">
33   <primary>address</primary>
34   <secondary>rewriting</secondary>
35   <see><emphasis>rewriting</emphasis></see>
36 </indexterm>
37 <indexterm role="concept">
38   <primary>Bounce Address Tag Validation</primary>
39   <see><emphasis>BATV</emphasis></see>
40 </indexterm>
41 <indexterm role="concept">
42   <primary>Client SMTP Authorization</primary>
43   <see><emphasis>CSA</emphasis></see>
44 </indexterm>
45 <indexterm role="concept">
46   <primary>CR character</primary>
47   <see><emphasis>carriage return</emphasis></see>
48 </indexterm>
49 <indexterm role="concept">
50   <primary>CRL</primary>
51   <see><emphasis>certificate revocation list</emphasis></see>
52 </indexterm>
53 <indexterm role="concept">
54   <primary>delivery</primary>
55   <secondary>failure report</secondary>
56   <see><emphasis>bounce message</emphasis></see>
57 </indexterm>
58 <indexterm role="concept">
59   <primary>dialup</primary>
60   <see><emphasis>intermittently connected hosts</emphasis></see>
61 </indexterm>
62 <indexterm role="concept">
63   <primary>exiscan</primary>
64   <see><emphasis>content scanning</emphasis></see>
65 </indexterm>
66 <indexterm role="concept">
67   <primary>failover</primary>
68   <see><emphasis>fallback</emphasis></see>
69 </indexterm>
70 <indexterm role="concept">
71   <primary>fallover</primary>
72   <see><emphasis>fallback</emphasis></see>
73 </indexterm>
74 <indexterm role="concept">
75   <primary>filter</primary>
76   <secondary>Sieve</secondary>
77   <see><emphasis>Sieve filter</emphasis></see>
78 </indexterm>
79 <indexterm role="concept">
80   <primary>ident</primary>
81   <see><emphasis>RFC 1413</emphasis></see>
82 </indexterm>
83 <indexterm role="concept">
84   <primary>LF character</primary>
85   <see><emphasis>linefeed</emphasis></see>
86 </indexterm>
87 <indexterm role="concept">
88   <primary>maximum</primary>
89   <seealso><emphasis>limit</emphasis></seealso>
90 </indexterm>
91 <indexterm role="concept">
92   <primary>monitor</primary>
93   <see><emphasis>Exim monitor</emphasis></see>
94 </indexterm>
95 <indexterm role="concept">
96   <primary>no_<emphasis>xxx</emphasis></primary>
97   <see>entry for xxx</see>
98 </indexterm>
99 <indexterm role="concept">
100   <primary>NUL</primary>
101   <see><emphasis>binary zero</emphasis></see>
102 </indexterm>
103 <indexterm role="concept">
104   <primary>passwd file</primary>
105   <see><emphasis>/etc/passwd</emphasis></see>
106 </indexterm>
107 <indexterm role="concept">
108   <primary>process id</primary>
109   <see><emphasis>pid</emphasis></see>
110 </indexterm>
111 <indexterm role="concept">
112   <primary>RBL</primary>
113   <see><emphasis>DNS list</emphasis></see>
114 </indexterm>
115 <indexterm role="concept">
116   <primary>redirection</primary>
117   <see><emphasis>address redirection</emphasis></see>
118 </indexterm>
119 <indexterm role="concept">
120   <primary>return path</primary>
121   <seealso><emphasis>envelope sender</emphasis></seealso>
122 </indexterm>
123 <indexterm role="concept">
124   <primary>scanning</primary>
125   <see><emphasis>content scanning</emphasis></see>
126 </indexterm>
127 <indexterm role="concept">
128   <primary>SSL</primary>
129   <see><emphasis>TLS</emphasis></see>
130 </indexterm>
131 <indexterm role="concept">
132   <primary>string</primary>
133   <secondary>expansion</secondary>
134   <see><emphasis>expansion</emphasis></see>
135 </indexterm>
136 <indexterm role="concept">
137   <primary>top bit</primary>
138   <see><emphasis>8-bit characters</emphasis></see>
139 </indexterm>
140 <indexterm role="concept">
141   <primary>variables</primary>
142   <see><emphasis>expansion, variables</emphasis></see>
143 </indexterm>
144 <indexterm role="concept">
145   <primary>zero, binary</primary>
146   <see><emphasis>binary zero</emphasis></see>
147 </indexterm>
148
149 <para>
150 Exim is a mail transfer agent (MTA) for hosts that are running Unix or
151 Unix-like operating systems. It was designed on the assumption that it would be
152 run on hosts that are permanently connected to the Internet. However, it can be
153 used on intermittently connected hosts with suitable configuration adjustments.
154 </para>
155 <para>
156 Configuration files currently exist for the following operating systems: AIX,
157 BSD/OS (aka BSDI), Darwin (Mac OS X), DGUX, Dragonfly, FreeBSD, GNU/Hurd,
158 GNU/Linux, HI-OSF (Hitachi), HI-UX, HP-UX, IRIX, MIPS RISCOS, NetBSD, OpenBSD,
159 OpenUNIX, QNX, SCO, SCO SVR4.2 (aka UNIX-SV), Solaris (aka SunOS5), SunOS4,
160 Tru64-Unix (formerly Digital UNIX, formerly DEC-OSF1), Ultrix, and Unixware.
161 Some of these operating systems are no longer current and cannot easily be
162 tested, so the configuration files may no longer work in practice.
163 </para>
164 <para>
165 There are also configuration files for compiling Exim in the Cygwin environment
166 that can be installed on systems running Windows. However, this document does
167 not contain any information about running Exim in the Cygwin environment.
168 </para>
169 <para>
170 The terms and conditions for the use and distribution of Exim are contained in
171 the file <filename>NOTICE</filename>. Exim is distributed under the terms of the GNU General
172 Public Licence, a copy of which may be found in the file <filename>LICENCE</filename>.
173 </para>
174 <para>
175 The use, supply or promotion of Exim for the purpose of sending bulk,
176 unsolicited electronic mail is incompatible with the basic aims of the program,
177 which revolve around the free provision of a service that enhances the quality
178 of personal communications. The author of Exim regards indiscriminate
179 mass-mailing as an antisocial, irresponsible abuse of the Internet.
180 </para>
181 <para>
182 Exim owes a great deal to Smail 3 and its author, Ron Karr. Without the
183 experience of running and working on the Smail 3 code, I could never have
184 contemplated starting to write a new MTA. Many of the ideas and user interfaces
185 were originally taken from Smail 3, though the actual code of Exim is entirely
186 new, and has developed far beyond the initial concept.
187 </para>
188 <para>
189 Many people, both in Cambridge and around the world, have contributed to the
190 development and the testing of Exim, and to porting it to various operating
191 systems. I am grateful to them all. The distribution now contains a file called
192 <filename>ACKNOWLEDGMENTS</filename>, in which I have started recording the names of
193 contributors.
194 </para>
195 <section id="SECID1">
196 <title>Exim documentation</title>
197 <para revisionflag="changed">
198 <indexterm role="concept">
199 <primary>documentation</primary>
200 </indexterm>
201 This edition of the Exim specification applies to version 4.74 of Exim.
202 Substantive changes from the 4.72 edition are marked in some
203 renditions of the document; this paragraph is so marked if the rendition is
204 capable of showing a change indicator.
205 </para>
206 <para>
207 This document is very much a reference manual; it is not a tutorial. The reader
208 is expected to have some familiarity with the SMTP mail transfer protocol and
209 with general Unix system administration. Although there are some discussions
210 and examples in places, the information is mostly organized in a way that makes
211 it easy to look up, rather than in a natural order for sequential reading.
212 Furthermore, the manual aims to cover every aspect of Exim in detail, including
213 a number of rarely-used, special-purpose features that are unlikely to be of
214 very wide interest.
215 </para>
216 <para>
217 <indexterm role="concept">
218 <primary>books about Exim</primary>
219 </indexterm>
220 An <quote>easier</quote> discussion of Exim which provides more in-depth explanatory,
221 introductory, and tutorial material can be found in a book entitled <emphasis>The Exim
222 SMTP Mail Server</emphasis> (second edition, 2007), published by UIT Cambridge
223 (<emphasis role="bold"><ulink url="http://www.uit.co.uk/exim-book/">http://www.uit.co.uk/exim-book/</ulink></emphasis>).
224 </para>
225 <para>
226 This book also contains a chapter that gives a general introduction to SMTP and
227 Internet mail. Inevitably, however, the book is unlikely to be fully up-to-date
228 with the latest release of Exim. (Note that the earlier book about Exim,
229 published by O&#x2019;Reilly, covers Exim 3, and many things have changed in Exim 4.)
230 </para>
231 <para>
232 <indexterm role="concept">
233 <primary>Debian</primary>
234 <secondary>information sources</secondary>
235 </indexterm>
236 If you are using a Debian distribution of Exim, you will find information about
237 Debian-specific features in the file
238 <filename>/usr/share/doc/exim4-base/README.Debian</filename>.
239 The command <command>man update-exim.conf</command> is another source of Debian-specific
240 information.
241 </para>
242 <para>
243 <indexterm role="concept">
244 <primary><filename>doc/NewStuff</filename></primary>
245 </indexterm>
246 <indexterm role="concept">
247 <primary><filename>doc/ChangeLog</filename></primary>
248 </indexterm>
249 <indexterm role="concept">
250 <primary>change log</primary>
251 </indexterm>
252 As the program develops, there may be features in newer versions that have not
253 yet made it into this document, which is updated only when the most significant
254 digit of the fractional part of the version number changes. Specifications of
255 new features that are not yet in this manual are placed in the file
256 <filename>doc/NewStuff</filename> in the Exim distribution.
257 </para>
258 <para>
259 Some features may be classified as <quote>experimental</quote>. These may change
260 incompatibly while they are developing, or even be withdrawn. For this reason,
261 they are not documented in this manual. Information about experimental features
262 can be found in the file <filename>doc/experimental.txt</filename>.
263 </para>
264 <para>
265 All changes to the program (whether new features, bug fixes, or other kinds of
266 change) are noted briefly in the file called <filename>doc/ChangeLog</filename>.
267 </para>
268 <para>
269 <indexterm role="concept">
270 <primary><filename>doc/spec.txt</filename></primary>
271 </indexterm>
272 This specification itself is available as an ASCII file in <filename>doc/spec.txt</filename> so
273 that it can easily be searched with a text editor. Other files in the <filename>doc</filename>
274 directory are:
275 </para>
276 <informaltable frame="none">
277 <tgroup cols="2" colsep="0" rowsep="0">
278 <colspec colwidth="100pt" align="left"/>
279 <colspec colwidth="254pt" align="left"/>
280 <tbody>
281 <row>
282 <entry><filename>OptionLists.txt</filename></entry>
283 <entry>list of all options in alphabetical order</entry>
284 </row>
285 <row>
286 <entry><filename>dbm.discuss.txt</filename></entry>
287 <entry>discussion about DBM libraries</entry>
288 </row>
289 <row>
290 <entry><filename>exim.8</filename></entry>
291 <entry>a man page of Exim&#x2019;s command line options</entry>
292 </row>
293 <row>
294 <entry><filename>experimental.txt</filename></entry>
295 <entry>documentation of experimental features</entry>
296 </row>
297 <row>
298 <entry><filename>filter.txt</filename></entry>
299 <entry>specification of the filter language</entry>
300 </row>
301 <row>
302 <entry><filename>Exim3.upgrade</filename></entry>
303 <entry>upgrade notes from release 2 to release 3</entry>
304 </row>
305 <row>
306 <entry><filename>Exim4.upgrade</filename></entry>
307 <entry>upgrade notes from release 3 to release 4</entry>
308 </row>
309 </tbody>
310 </tgroup>
311 </informaltable>
312 <para>
313 The main specification and the specification of the filtering language are also
314 available in other formats (HTML, PostScript, PDF, and Texinfo). Section
315 <xref linkend="SECTavail"/> below tells you how to get hold of these.
316 </para>
317 </section>
318 <section id="SECID2">
319 <title>FTP and web sites</title>
320 <para>
321 <indexterm role="concept">
322 <primary>web site</primary>
323 </indexterm>
324 <indexterm role="concept">
325 <primary>FTP site</primary>
326 </indexterm>
327 The primary site for Exim source distributions is currently the University of
328 Cambridge&#x2019;s FTP site, whose contents are described in <emphasis>Where to find the Exim
329 distribution</emphasis> below. In addition, there is a web site and an FTP site at
330 <option>exim.org</option>. These are now also hosted at the University of Cambridge. The
331 <option>exim.org</option> site was previously hosted for a number of years by Energis
332 Squared, formerly Planet Online Ltd, whose support I gratefully acknowledge.
333 </para>
334 <para>
335 <indexterm role="concept">
336 <primary>wiki</primary>
337 </indexterm>
338 <indexterm role="concept">
339 <primary>FAQ</primary>
340 </indexterm>
341 As well as Exim distribution tar files, the Exim web site contains a number of
342 differently formatted versions of the documentation. A recent addition to the
343 online information is the Exim wiki (<emphasis role="bold"><ulink url="http://wiki.exim.org">http://wiki.exim.org</ulink></emphasis>),
344 which contains what used to be a separate FAQ, as well as various other
345 examples, tips, and know-how that have been contributed by Exim users.
346 </para>
347 <para>
348 <indexterm role="concept">
349 <primary>Bugzilla</primary>
350 </indexterm>
351 An Exim Bugzilla exists at <emphasis role="bold"><ulink url="http://bugs.exim.org">http://bugs.exim.org</ulink></emphasis>. You can use
352 this to report bugs, and also to add items to the wish list. Please search
353 first to check that you are not duplicating a previous entry.
354 </para>
355 </section>
356 <section id="SECID3">
357 <title>Mailing lists</title>
358 <para>
359 <indexterm role="concept">
360 <primary>mailing lists</primary>
361 <secondary>for Exim users</secondary>
362 </indexterm>
363 The following Exim mailing lists exist:
364 </para>
365 <informaltable frame="none">
366 <tgroup cols="2" colsep="0" rowsep="0">
367 <colspec colwidth="140pt" align="left"/>
368 <colspec colwidth="254pt" align="left"/>
369 <tbody>
370 <row>
371 <entry><emphasis>exim-users@exim.org</emphasis></entry>
372 <entry>General discussion list</entry>
373 </row>
374 <row>
375 <entry><emphasis>exim-dev@exim.org</emphasis></entry>
376 <entry>Discussion of bugs, enhancements, etc.</entry>
377 </row>
378 <row>
379 <entry><emphasis>exim-announce@exim.org</emphasis></entry>
380 <entry>Moderated, low volume announcements list</entry>
381 </row>
382 <row>
383 <entry><emphasis>exim-future@exim.org</emphasis></entry>
384 <entry>Discussion of long-term development</entry>
385 </row>
386 </tbody>
387 </tgroup>
388 </informaltable>
389 <para>
390 You can subscribe to these lists, change your existing subscriptions, and view
391 or search the archives via the mailing lists link on the Exim home page.
392 <indexterm role="concept">
393 <primary>Debian</primary>
394 <secondary>mailing list for</secondary>
395 </indexterm>
396 If you are using a Debian distribution of Exim, you may wish to subscribe to
397 the Debian-specific mailing list <emphasis>pkg-exim4-users@lists.alioth.debian.org</emphasis>
398 via this web page:
399 </para>
400 <literallayout>
401 <emphasis role="bold"><ulink url="http://lists.alioth.debian.org/mailman/listinfo/pkg-exim4-users">http://lists.alioth.debian.org/mailman/listinfo/pkg-exim4-users</ulink></emphasis>
402 </literallayout>
403 <para>
404 Please ask Debian-specific questions on this list and not on the general Exim
405 lists.
406 </para>
407 </section>
408 <section id="SECID4">
409 <title>Exim training</title>
410 <para>
411 <indexterm role="concept">
412 <primary>training courses</primary>
413 </indexterm>
414 Training courses in Cambridge (UK) used to be run annually by the author of
415 Exim, before he retired. At the time of writing, there are no plans to run
416 further Exim courses in Cambridge. However, if that changes, relevant
417 information will be posted at <emphasis role="bold"><ulink url="http://www-tus.csx.cam.ac.uk/courses/exim/">http://www-tus.csx.cam.ac.uk/courses/exim/</ulink></emphasis>.
418 </para>
419 </section>
420 <section id="SECID5">
421 <title>Bug reports</title>
422 <para>
423 <indexterm role="concept">
424 <primary>bug reports</primary>
425 </indexterm>
426 <indexterm role="concept">
427 <primary>reporting bugs</primary>
428 </indexterm>
429 Reports of obvious bugs can be emailed to <emphasis>bugs@exim.org</emphasis> or reported
430 via the Bugzilla (<emphasis role="bold"><ulink url="http://bugs.exim.org">http://bugs.exim.org</ulink></emphasis>). However, if you are unsure
431 whether some behaviour is a bug or not, the best thing to do is to post a
432 message to the <emphasis>exim-dev</emphasis> mailing list and have it discussed.
433 </para>
434 </section>
435 <section id="SECTavail">
436 <title>Where to find the Exim distribution</title>
437 <para>
438 <indexterm role="concept">
439 <primary>FTP site</primary>
440 </indexterm>
441 <indexterm role="concept">
442 <primary>distribution</primary>
443 <secondary>ftp site</secondary>
444 </indexterm>
445 The master ftp site for the Exim distribution is
446 </para>
447 <literallayout>
448 <emphasis role="bold">ftp://ftp.csx.cam.ac.uk/pub/software/email/exim</emphasis>
449 </literallayout>
450 <para>
451 This is mirrored by
452 </para>
453 <literallayout>
454 <emphasis role="bold">ftp://ftp.exim.org/pub/exim</emphasis>
455 </literallayout>
456 <para>
457 The file references that follow are relative to the <filename>exim</filename> directories at
458 these sites. There are now quite a number of independent mirror sites around
459 the world. Those that I know about are listed in the file called <filename>Mirrors</filename>.
460 </para>
461 <para>
462 Within the <filename>exim</filename> directory there are subdirectories called <filename>exim3</filename> (for
463 previous Exim 3 distributions), <filename>exim4</filename> (for the latest Exim 4
464 distributions), and <filename>Testing</filename> for testing versions. In the <filename>exim4</filename>
465 subdirectory, the current release can always be found in files called
466 </para>
467 <literallayout>
468 <filename>exim-n.nn.tar.gz</filename>
469 <filename>exim-n.nn.tar.bz2</filename>
470 </literallayout>
471 <para>
472 where <emphasis>n.nn</emphasis> is the highest such version number in the directory. The two
473 files contain identical data; the only difference is the type of compression.
474 The <filename>.bz2</filename> file is usually a lot smaller than the <filename>.gz</filename> file.
475 </para>
476 <para>
477 <indexterm role="concept">
478 <primary>distribution</primary>
479 <secondary>signing details</secondary>
480 </indexterm>
481 <indexterm role="concept">
482 <primary>distribution</primary>
483 <secondary>public key</secondary>
484 </indexterm>
485 <indexterm role="concept">
486 <primary>public key for signed distribution</primary>
487 </indexterm>
488 The distributions are currently signed with Nigel Metheringham&#x2019;s GPG key. The
489 corresponding public key is available from a number of keyservers, and there is
490 also a copy in the file <filename>nigel-pubkey.asc</filename>. The signatures for the tar bundles are
491 in:
492 </para>
493 <literallayout>
494 <filename>exim-n.nn.tar.gz.asc</filename>
495 <filename>exim-n.nn.tar.bz2.asc</filename>
496 </literallayout>
497 <para>
498 For each released version, the log of changes is made separately available in a
499 separate file in the directory <filename>ChangeLogs</filename> so that it is possible to
500 find out what has changed without having to download the entire distribution.
501 </para>
502 <para>
503 <indexterm role="concept">
504 <primary>documentation</primary>
505 <secondary>available formats</secondary>
506 </indexterm>
507 The main distribution contains ASCII versions of this specification and other
508 documentation; other formats of the documents are available in separate files
509 inside the <filename>exim4</filename> directory of the FTP site:
510 </para>
511 <literallayout>
512 <filename>exim-html-n.nn.tar.gz</filename>
513 <filename>exim-pdf-n.nn.tar.gz</filename>
514 <filename>exim-postscript-n.nn.tar.gz</filename>
515 <filename>exim-texinfo-n.nn.tar.gz</filename>
516 </literallayout>
517 <para>
518 These tar files contain only the <filename>doc</filename> directory, not the complete
519 distribution, and are also available in <filename>.bz2</filename> as well as <filename>.gz</filename> forms.
520 </para>
521 </section>
522 <section id="SECID6">
523 <title>Limitations</title>
524 <itemizedlist>
525 <listitem>
526 <para>
527 <indexterm role="concept">
528 <primary>limitations of Exim</primary>
529 </indexterm>
530 <indexterm role="concept">
531 <primary>bang paths</primary>
532 <secondary>not handled by Exim</secondary>
533 </indexterm>
534 Exim is designed for use as an Internet MTA, and therefore handles addresses in
535 RFC 2822 domain format only. It cannot handle UUCP <quote>bang paths</quote>, though
536 simple two-component bang paths can be converted by a straightforward rewriting
537 configuration. This restriction does not prevent Exim from being interfaced to
538 UUCP as a transport mechanism, provided that domain addresses are used.
539 </para>
540 </listitem>
541 <listitem>
542 <para>
543 <indexterm role="concept">
544 <primary>domainless addresses</primary>
545 </indexterm>
546 <indexterm role="concept">
547 <primary>address</primary>
548 <secondary>without domain</secondary>
549 </indexterm>
550 Exim insists that every address it handles has a domain attached. For incoming
551 local messages, domainless addresses are automatically qualified with a
552 configured domain value. Configuration options specify from which remote
553 systems unqualified addresses are acceptable. These are then qualified on
554 arrival.
555 </para>
556 </listitem>
557 <listitem>
558 <para>
559 <indexterm role="concept">
560 <primary>transport</primary>
561 <secondary>external</secondary>
562 </indexterm>
563 <indexterm role="concept">
564 <primary>external transports</primary>
565 </indexterm>
566 The only external transport mechanisms that are currently implemented are SMTP
567 and LMTP over a TCP/IP network (including support for IPv6). However, a pipe
568 transport is available, and there are facilities for writing messages to files
569 and pipes, optionally in <emphasis>batched SMTP</emphasis> format; these facilities can be used
570 to send messages to other transport mechanisms such as UUCP, provided they can
571 handle domain-style addresses. Batched SMTP input is also catered for.
572 </para>
573 </listitem>
574 <listitem>
575 <para>
576 Exim is not designed for storing mail for dial-in hosts. When the volumes of
577 such mail are large, it is better to get the messages <quote>delivered</quote> into files
578 (that is, off Exim&#x2019;s queue) and subsequently passed on to the dial-in hosts by
579 other means.
580 </para>
581 </listitem>
582 <listitem>
583 <para>
584 Although Exim does have basic facilities for scanning incoming messages, these
585 are not comprehensive enough to do full virus or spam scanning. Such operations
586 are best carried out using additional specialized software packages. If you
587 compile Exim with the content-scanning extension, straightforward interfaces to
588 a number of common scanners are provided.
589 </para>
590 </listitem>
591 </itemizedlist>
592 </section>
593 <section id="SECID7">
594 <title>Run time configuration</title>
595 <para>
596 Exim&#x2019;s run time configuration is held in a single text file that is divided
597 into a number of sections. The entries in this file consist of keywords and
598 values, in the style of Smail 3 configuration files. A default configuration
599 file which is suitable for simple online installations is provided in the
600 distribution, and is described in chapter <xref linkend="CHAPdefconfil"/> below.
601 </para>
602 </section>
603 <section id="SECID8">
604 <title>Calling interface</title>
605 <para>
606 <indexterm role="concept">
607 <primary>Sendmail compatibility</primary>
608 <secondary>command line interface</secondary>
609 </indexterm>
610 Like many MTAs, Exim has adopted the Sendmail command line interface so that it
611 can be a straight replacement for <filename>/usr/lib/sendmail</filename> or
612 <filename>/usr/sbin/sendmail</filename> when sending mail, but you do not need to know anything
613 about Sendmail in order to run Exim. For actions other than sending messages,
614 Sendmail-compatible options also exist, but those that produce output (for
615 example, <option>-bp</option>, which lists the messages on the queue) do so in Exim&#x2019;s own
616 format. There are also some additional options that are compatible with Smail
617 3, and some further options that are new to Exim. Chapter <xref linkend="CHAPcommandline"/>
618 documents all Exim&#x2019;s command line options. This information is automatically
619 made into the man page that forms part of the Exim distribution.
620 </para>
621 <para>
622 Control of messages on the queue can be done via certain privileged command
623 line options. There is also an optional monitor program called <emphasis>eximon</emphasis>,
624 which displays current information in an X window, and which contains a menu
625 interface to Exim&#x2019;s command line administration options.
626 </para>
627 </section>
628 <section id="SECID9">
629 <title>Terminology</title>
630 <para>
631 <indexterm role="concept">
632 <primary>terminology definitions</primary>
633 </indexterm>
634 <indexterm role="concept">
635 <primary>body of message</primary>
636 <secondary>definition of</secondary>
637 </indexterm>
638 The <emphasis>body</emphasis> of a message is the actual data that the sender wants to transmit.
639 It is the last part of a message, and is separated from the <emphasis>header</emphasis> (see
640 below) by a blank line.
641 </para>
642 <para>
643 <indexterm role="concept">
644 <primary>bounce message</primary>
645 <secondary>definition of</secondary>
646 </indexterm>
647 When a message cannot be delivered, it is normally returned to the sender in a
648 delivery failure message or a <quote>non-delivery report</quote> (NDR). The term
649 <emphasis>bounce</emphasis> is commonly used for this action, and the error reports are often
650 called <emphasis>bounce messages</emphasis>. This is a convenient shorthand for <quote>delivery
651 failure error report</quote>. Such messages have an empty sender address in the
652 message&#x2019;s <emphasis>envelope</emphasis> (see below) to ensure that they cannot themselves give
653 rise to further bounce messages.
654 </para>
655 <para>
656 The term <emphasis>default</emphasis> appears frequently in this manual. It is used to qualify a
657 value which is used in the absence of any setting in the configuration. It may
658 also qualify an action which is taken unless a configuration setting specifies
659 otherwise.
660 </para>
661 <para>
662 The term <emphasis>defer</emphasis> is used when the delivery of a message to a specific
663 destination cannot immediately take place for some reason (a remote host may be
664 down, or a user&#x2019;s local mailbox may be full). Such deliveries are <emphasis>deferred</emphasis>
665 until a later time.
666 </para>
667 <para>
668 The word <emphasis>domain</emphasis> is sometimes used to mean all but the first component of a
669 host&#x2019;s name. It is <emphasis>not</emphasis> used in that sense here, where it normally refers to
670 the part of an email address following the @ sign.
671 </para>
672 <para>
673 <indexterm role="concept">
674 <primary>envelope, definition of</primary>
675 </indexterm>
676 <indexterm role="concept">
677 <primary>sender</primary>
678 <secondary>definition of</secondary>
679 </indexterm>
680 A message in transit has an associated <emphasis>envelope</emphasis>, as well as a header and a
681 body. The envelope contains a sender address (to which bounce messages should
682 be delivered), and any number of recipient addresses. References to the
683 sender or the recipients of a message usually mean the addresses in the
684 envelope. An MTA uses these addresses for delivery, and for returning bounce
685 messages, not the addresses that appear in the header lines.
686 </para>
687 <para>
688 <indexterm role="concept">
689 <primary>message</primary>
690 <secondary>header, definition of</secondary>
691 </indexterm>
692 <indexterm role="concept">
693 <primary>header section</primary>
694 <secondary>definition of</secondary>
695 </indexterm>
696 The <emphasis>header</emphasis> of a message is the first part of a message&#x2019;s text, consisting
697 of a number of lines, each of which has a name such as <emphasis>From:</emphasis>, <emphasis>To:</emphasis>,
698 <emphasis>Subject:</emphasis>, etc. Long header lines can be split over several text lines by
699 indenting the continuations. The header is separated from the body by a blank
700 line.
701 </para>
702 <para>
703 <indexterm role="concept">
704 <primary>local part</primary>
705 <secondary>definition of</secondary>
706 </indexterm>
707 <indexterm role="concept">
708 <primary>domain</primary>
709 <secondary>definition of</secondary>
710 </indexterm>
711 The term <emphasis>local part</emphasis>, which is taken from RFC 2822, is used to refer to that
712 part of an email address that precedes the @ sign. The part that follows the
713 @ sign is called the <emphasis>domain</emphasis> or <emphasis>mail domain</emphasis>.
714 </para>
715 <para>
716 <indexterm role="concept">
717 <primary>local delivery</primary>
718 <secondary>definition of</secondary>
719 </indexterm>
720 <indexterm role="concept">
721 <primary>remote delivery, definition of</primary>
722 </indexterm>
723 The terms <emphasis>local delivery</emphasis> and <emphasis>remote delivery</emphasis> are used to distinguish
724 delivery to a file or a pipe on the local host from delivery by SMTP over
725 TCP/IP to another host. As far as Exim is concerned, all hosts other than the
726 host it is running on are <emphasis>remote</emphasis>.
727 </para>
728 <para>
729 <indexterm role="concept">
730 <primary>return path</primary>
731 <secondary>definition of</secondary>
732 </indexterm>
733 <emphasis>Return path</emphasis> is another name that is used for the sender address in a
734 message&#x2019;s envelope.
735 </para>
736 <para>
737 <indexterm role="concept">
738 <primary>queue</primary>
739 <secondary>definition of</secondary>
740 </indexterm>
741 The term <emphasis>queue</emphasis> is used to refer to the set of messages awaiting delivery,
742 because this term is in widespread use in the context of MTAs. However, in
743 Exim&#x2019;s case the reality is more like a pool than a queue, because there is
744 normally no ordering of waiting messages.
745 </para>
746 <para>
747 <indexterm role="concept">
748 <primary>queue runner</primary>
749 <secondary>definition of</secondary>
750 </indexterm>
751 The term <emphasis>queue runner</emphasis> is used to describe a process that scans the queue
752 and attempts to deliver those messages whose retry times have come. This term
753 is used by other MTAs, and also relates to the command <option>runq</option>, but in Exim
754 the waiting messages are normally processed in an unpredictable order.
755 </para>
756 <para>
757 <indexterm role="concept">
758 <primary>spool directory</primary>
759 <secondary>definition of</secondary>
760 </indexterm>
761 The term <emphasis>spool directory</emphasis> is used for a directory in which Exim keeps the
762 messages on its queue &ndash; that is, those that it is in the process of
763 delivering. This should not be confused with the directory in which local
764 mailboxes are stored, which is called a <quote>spool directory</quote> by some people. In
765 the Exim documentation, <quote>spool</quote> is always used in the first sense.
766 </para>
767 </section>
768 </chapter>
769
770 <chapter id="CHID2">
771 <title>Incorporated code</title>
772 <para>
773 <indexterm role="concept">
774 <primary>incorporated code</primary>
775 </indexterm>
776 <indexterm role="concept">
777 <primary>regular expressions</primary>
778 <secondary>library</secondary>
779 </indexterm>
780 <indexterm role="concept">
781 <primary>PCRE</primary>
782 </indexterm>
783 A number of pieces of external code are included in the Exim distribution.
784 </para>
785 <itemizedlist>
786 <listitem>
787 <para>
788 Regular expressions are supported in the main Exim program and in the
789 Exim monitor using the freely-distributable PCRE library, copyright
790 &copy; University of Cambridge. The source to PCRE is no longer shipped with
791 Exim, so you will need to use the version of PCRE shipped with your system,
792 or obtain and install the full version of the library from
793 <emphasis role="bold"><ulink url="ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre">ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre</ulink></emphasis>.
794 </para>
795 </listitem>
796 <listitem>
797 <para>
798 <indexterm role="concept">
799 <primary>cdb</primary>
800 <secondary>acknowledgment</secondary>
801 </indexterm>
802 Support for the cdb (Constant DataBase) lookup method is provided by code
803 contributed by Nigel Metheringham of (at the time he contributed it) Planet
804 Online Ltd. The implementation is completely contained within the code of Exim.
805 It does not link against an external cdb library. The code contains the
806 following statements:
807 </para>
808 <blockquote>
809 <para>
810 Copyright &copy; 1998 Nigel Metheringham, Planet Online Ltd
811 </para>
812 <para>
813 This program is free software; you can redistribute it and/or modify it under
814 the terms of the GNU General Public License as published by the Free Software
815 Foundation; either version 2 of the License, or (at your option) any later
816 version.
817 This code implements Dan Bernstein&#x2019;s Constant DataBase (cdb) spec. Information,
818 the spec and sample code for cdb can be obtained from
819 <emphasis role="bold"><ulink url="http://www.pobox.com/~djb/cdb.html">http://www.pobox.com/~djb/cdb.html</ulink></emphasis>. This implementation borrows
820 some code from Dan Bernstein&#x2019;s implementation (which has no license
821 restrictions applied to it).
822 </para>
823 </blockquote>
824 </listitem>
825 <listitem>
826 <para>
827 <indexterm role="concept">
828 <primary>SPA authentication</primary>
829 </indexterm>
830 <indexterm role="concept">
831 <primary>Samba project</primary>
832 </indexterm>
833 <indexterm role="concept">
834 <primary>Microsoft Secure Password Authentication</primary>
835 </indexterm>
836 Client support for Microsoft&#x2019;s <emphasis>Secure Password Authentication</emphasis> is provided
837 by code contributed by Marc Prud&#x2019;hommeaux. Server support was contributed by
838 Tom Kistner. This includes code taken from the Samba project, which is released
839 under the Gnu GPL.
840 </para>
841 </listitem>
842 <listitem>
843 <para>
844 <indexterm role="concept">
845 <primary>Cyrus</primary>
846 </indexterm>
847 <indexterm role="concept">
848 <primary><emphasis>pwcheck</emphasis> daemon</primary>
849 </indexterm>
850 <indexterm role="concept">
851 <primary><emphasis>pwauthd</emphasis> daemon</primary>
852 </indexterm>
853 Support for calling the Cyrus <emphasis>pwcheck</emphasis> and <emphasis>saslauthd</emphasis> daemons is provided
854 by code taken from the Cyrus-SASL library and adapted by Alexander S.
855 Sabourenkov. The permission notice appears below, in accordance with the
856 conditions expressed therein.
857 </para>
858 <blockquote>
859 <para>
860 Copyright &copy; 2001 Carnegie Mellon University.  All rights reserved.
861 </para>
862 <para>
863 Redistribution and use in source and binary forms, with or without
864 modification, are permitted provided that the following conditions
865 are met:
866 </para>
867 <orderedlist numeration="arabic">
868 <listitem>
869 <para>
870 Redistributions of source code must retain the above copyright
871 notice, this list of conditions and the following disclaimer.
872 </para>
873 </listitem>
874 <listitem>
875 <para>
876 Redistributions in binary form must reproduce the above copyright
877 notice, this list of conditions and the following disclaimer in
878 the documentation and/or other materials provided with the
879 distribution.
880 </para>
881 </listitem>
882 <listitem>
883 <para>
884 The name <quote>Carnegie Mellon University</quote> must not be used to
885 endorse or promote products derived from this software without
886 prior written permission. For permission or any other legal
887 details, please contact
888 </para>
889 <literallayout>
890               Office of Technology Transfer
891               Carnegie Mellon University
892               5000 Forbes Avenue
893               Pittsburgh, PA  15213-3890
894               (412) 268-4387, fax: (412) 268-7395
895               tech-transfer@andrew.cmu.edu
896 </literallayout>
897 </listitem>
898 <listitem>
899 <para>
900 Redistributions of any form whatsoever must retain the following
901 acknowledgment:
902 </para>
903 <para>
904 <quote>This product includes software developed by Computing Services
905 at Carnegie Mellon University (<emphasis role="bold"><ulink url="http://www.cmu.edu/computing/">http://www.cmu.edu/computing/</ulink></emphasis>.</quote>
906 </para>
907 <para>
908 CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
909 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
910 AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
911 FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
912 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
913 AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
914 OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
915 </para>
916 </listitem>
917 </orderedlist>
918 </blockquote>
919 </listitem>
920 <listitem>
921 <para>
922 <indexterm role="concept">
923 <primary>Exim monitor</primary>
924 <secondary>acknowledgment</secondary>
925 </indexterm>
926 <indexterm role="concept">
927 <primary>X-windows</primary>
928 </indexterm>
929 <indexterm role="concept">
930 <primary>Athena</primary>
931 </indexterm>
932 The Exim Monitor program, which is an X-Window application, includes
933 modified versions of the Athena StripChart and TextPop widgets.
934 This code is copyright by DEC and MIT, and their permission notice appears
935 below, in accordance with the conditions expressed therein.
936 </para>
937 <blockquote>
938 <para>
939 Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
940 and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
941 </para>
942 <para>
943 All Rights Reserved
944 </para>
945 <para>
946 Permission to use, copy, modify, and distribute this software and its
947 documentation for any purpose and without fee is hereby granted,
948 provided that the above copyright notice appear in all copies and that
949 both that copyright notice and this permission notice appear in
950 supporting documentation, and that the names of Digital or MIT not be
951 used in advertising or publicity pertaining to distribution of the
952 software without specific, written prior permission.
953 </para>
954 <para>
955 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
956 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
957 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
958 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
959 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
960 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
961 SOFTWARE.
962 </para>
963 </blockquote>
964 </listitem>
965 <listitem>
966 <para>
967 Many people have contributed code fragments, some large, some small, that were
968 not covered by any specific licence requirements. It is assumed that the
969 contributors are happy to see their code incorporated into Exim under the GPL.
970 </para>
971 </listitem>
972 </itemizedlist>
973 </chapter>
974
975 <chapter id="CHID11">
976 <title>How Exim receives and delivers mail</title>
977 <titleabbrev>Receiving and delivering mail</titleabbrev>
978 <section id="SECID10">
979 <title>Overall philosophy</title>
980 <para>
981 <indexterm role="concept">
982 <primary>design philosophy</primary>
983 </indexterm>
984 Exim is designed to work efficiently on systems that are permanently connected
985 to the Internet and are handling a general mix of mail. In such circumstances,
986 most messages can be delivered immediately. Consequently, Exim does not
987 maintain independent queues of messages for specific domains or hosts, though
988 it does try to send several messages in a single SMTP connection after a host
989 has been down, and it also maintains per-host retry information.
990 </para>
991 </section>
992 <section id="SECID11">
993 <title>Policy control</title>
994 <para>
995 <indexterm role="concept">
996 <primary>policy control</primary>
997 <secondary>overview</secondary>
998 </indexterm>
999 Policy controls are now an important feature of MTAs that are connected to the
1000 Internet. Perhaps their most important job is to stop MTAs being abused as
1001 <quote>open relays</quote> by misguided individuals who send out vast amounts of
1002 unsolicited junk, and want to disguise its source. Exim provides flexible
1003 facilities for specifying policy controls on incoming mail:
1004 </para>
1005 <itemizedlist>
1006 <listitem>
1007 <para>
1008 <indexterm role="concept">
1009 <primary>access control lists (ACLs)</primary>
1010 <secondary>introduction</secondary>
1011 </indexterm>
1012 Exim 4 (unlike previous versions of Exim) implements policy controls on
1013 incoming mail by means of <emphasis>Access Control Lists</emphasis> (ACLs). Each list is a
1014 series of statements that may either grant or deny access. ACLs can be used at
1015 several places in the SMTP dialogue while receiving a message from a remote
1016 host. However, the most common places are after each RCPT command, and at the
1017 very end of the message. The sysadmin can specify conditions for accepting or
1018 rejecting individual recipients or the entire message, respectively, at these
1019 two points (see chapter <xref linkend="CHAPACL"/>). Denial of access results in an SMTP
1020 error code.
1021 </para>
1022 </listitem>
1023 <listitem>
1024 <para>
1025 An ACL is also available for locally generated, non-SMTP messages. In this
1026 case, the only available actions are to accept or deny the entire message.
1027 </para>
1028 </listitem>
1029 <listitem>
1030 <para>
1031 When Exim is compiled with the content-scanning extension, facilities are
1032 provided in the ACL mechanism for passing the message to external virus and/or
1033 spam scanning software. The result of such a scan is passed back to the ACL,
1034 which can then use it to decide what to do with the message.
1035 </para>
1036 </listitem>
1037 <listitem>
1038 <para>
1039 When a message has been received, either from a remote host or from the local
1040 host, but before the final acknowledgment has been sent, a locally supplied C
1041 function called <function>local_scan()</function> can be run to inspect the message and decide
1042 whether to accept it or not (see chapter <xref linkend="CHAPlocalscan"/>). If the message
1043 is accepted, the list of recipients can be modified by the function.
1044 </para>
1045 </listitem>
1046 <listitem>
1047 <para>
1048 Using the <function>local_scan()</function> mechanism is another way of calling external scanner
1049 software. The <option>SA-Exim</option> add-on package works this way. It does not require
1050 Exim to be compiled with the content-scanning extension.
1051 </para>
1052 </listitem>
1053 <listitem>
1054 <para>
1055 After a message has been accepted, a further checking mechanism is available in
1056 the form of the <emphasis>system filter</emphasis> (see chapter <xref linkend="CHAPsystemfilter"/>). This
1057 runs at the start of every delivery process.
1058 </para>
1059 </listitem>
1060 </itemizedlist>
1061 </section>
1062 <section id="SECID12">
1063 <title>User filters</title>
1064 <para>
1065 <indexterm role="concept">
1066 <primary>filter</primary>
1067 <secondary>introduction</secondary>
1068 </indexterm>
1069 <indexterm role="concept">
1070 <primary>Sieve filter</primary>
1071 </indexterm>
1072 In a conventional Exim configuration, users are able to run private filters by
1073 setting up appropriate <filename>.forward</filename> files in their home directories. See
1074 chapter <xref linkend="CHAPredirect"/> (about the <command>redirect</command> router) for the
1075 configuration needed to support this, and the separate document entitled
1076 <emphasis>Exim&#x2019;s interfaces to mail filtering</emphasis> for user details. Two different kinds
1077 of filtering are available:
1078 </para>
1079 <itemizedlist>
1080 <listitem>
1081 <para>
1082 Sieve filters are written in the standard filtering language that is defined
1083 by RFC 3028.
1084 </para>
1085 </listitem>
1086 <listitem>
1087 <para>
1088 Exim filters are written in a syntax that is unique to Exim, but which is more
1089 powerful than Sieve, which it pre-dates.
1090 </para>
1091 </listitem>
1092 </itemizedlist>
1093 <para>
1094 User filters are run as part of the routing process, described below.
1095 </para>
1096 </section>
1097 <section id="SECTmessiden">
1098 <title>Message identification</title>
1099 <para>
1100 <indexterm role="concept">
1101 <primary>message ids</primary>
1102 <secondary>details of format</secondary>
1103 </indexterm>
1104 <indexterm role="concept">
1105 <primary>format</primary>
1106 <secondary>of message id</secondary>
1107 </indexterm>
1108 <indexterm role="concept">
1109 <primary>id of message</primary>
1110 </indexterm>
1111 <indexterm role="concept">
1112 <primary>base62</primary>
1113 </indexterm>
1114 <indexterm role="concept">
1115 <primary>base36</primary>
1116 </indexterm>
1117 <indexterm role="concept">
1118 <primary>Darwin</primary>
1119 </indexterm>
1120 <indexterm role="concept">
1121 <primary>Cygwin</primary>
1122 </indexterm>
1123 Every message handled by Exim is given a <emphasis>message id</emphasis> which is sixteen
1124 characters long. It is divided into three parts, separated by hyphens, for
1125 example <literal>16VDhn-0001bo-D3</literal>. Each part is a sequence of letters and digits,
1126 normally encoding numbers in base 62. However, in the Darwin operating
1127 system (Mac OS X) and when Exim is compiled to run under Cygwin, base 36
1128 (avoiding the use of lower case letters) is used instead, because the message
1129 id is used to construct file names, and the names of files in those systems are
1130 not always case-sensitive.
1131 </para>
1132 <para>
1133 <indexterm role="concept">
1134 <primary>pid (process id)</primary>
1135 <secondary>re-use of</secondary>
1136 </indexterm>
1137 The detail of the contents of the message id have changed as Exim has evolved.
1138 Earlier versions relied on the operating system not re-using a process id (pid)
1139 within one second. On modern operating systems, this assumption can no longer
1140 be made, so the algorithm had to be changed. To retain backward compatibility,
1141 the format of the message id was retained, which is why the following rules are
1142 somewhat eccentric:
1143 </para>
1144 <itemizedlist>
1145 <listitem>
1146 <para>
1147 The first six characters of the message id are the time at which the message
1148 started to be received, to a granularity of one second. That is, this field
1149 contains the number of seconds since the start of the epoch (the normal Unix
1150 way of representing the date and time of day).
1151 </para>
1152 </listitem>
1153 <listitem>
1154 <para>
1155 After the first hyphen, the next six characters are the id of the process that
1156 received the message.
1157 </para>
1158 </listitem>
1159 <listitem>
1160 <para>
1161 There are two different possibilities for the final two characters:
1162 </para>
1163 <orderedlist numeration="arabic">
1164 <listitem>
1165 <para>
1166 <indexterm role="option">
1167 <primary><option>localhost_number</option></primary>
1168 </indexterm>
1169 If <option>localhost_number</option> is not set, this value is the fractional part of the
1170 time of reception, normally in units of 1/2000 of a second, but for systems
1171 that must use base 36 instead of base 62 (because of case-insensitive file
1172 systems), the units are 1/1000 of a second.
1173 </para>
1174 </listitem>
1175 <listitem>
1176 <para>
1177 If <option>localhost_number</option> is set, it is multiplied by 200 (100) and added to
1178 the fractional part of the time, which in this case is in units of 1/200
1179 (1/100) of a second.
1180 </para>
1181 </listitem>
1182 </orderedlist>
1183 </listitem>
1184 </itemizedlist>
1185 <para>
1186 After a message has been received, Exim waits for the clock to tick at the
1187 appropriate resolution before proceeding, so that if another message is
1188 received by the same process, or by another process with the same (re-used)
1189 pid, it is guaranteed that the time will be different. In most cases, the clock
1190 will already have ticked while the message was being received.
1191 </para>
1192 </section>
1193 <section id="SECID13">
1194 <title>Receiving mail</title>
1195 <para>
1196 <indexterm role="concept">
1197 <primary>receiving mail</primary>
1198 </indexterm>
1199 <indexterm role="concept">
1200 <primary>message</primary>
1201 <secondary>reception</secondary>
1202 </indexterm>
1203 The only way Exim can receive mail from another host is using SMTP over
1204 TCP/IP, in which case the sender and recipient addresses are transferred using
1205 SMTP commands. However, from a locally running process (such as a user&#x2019;s MUA),
1206 there are several possibilities:
1207 </para>
1208 <itemizedlist>
1209 <listitem>
1210 <para>
1211 If the process runs Exim with the <option>-bm</option> option, the message is read
1212 non-interactively (usually via a pipe), with the recipients taken from the
1213 command line, or from the body of the message if <option>-t</option> is also used.
1214 </para>
1215 </listitem>
1216 <listitem>
1217 <para>
1218 If the process runs Exim with the <option>-bS</option> option, the message is also read
1219 non-interactively, but in this case the recipients are listed at the start of
1220 the message in a series of SMTP RCPT commands, terminated by a DATA
1221 command. This is so-called <quote>batch SMTP</quote> format,
1222 but it isn&#x2019;t really SMTP. The SMTP commands are just another way of passing
1223 envelope addresses in a non-interactive submission.
1224 </para>
1225 </listitem>
1226 <listitem>
1227 <para>
1228 If the process runs Exim with the <option>-bs</option> option, the message is read
1229 interactively, using the SMTP protocol. A two-way pipe is normally used for
1230 passing data between the local process and the Exim process.
1231 This is <quote>real</quote> SMTP and is handled in the same way as SMTP over TCP/IP. For
1232 example, the ACLs for SMTP commands are used for this form of submission.
1233 </para>
1234 </listitem>
1235 <listitem>
1236 <para>
1237 A local process may also make a TCP/IP call to the host&#x2019;s loopback address
1238 (127.0.0.1) or any other of its IP addresses. When receiving messages, Exim
1239 does not treat the loopback address specially. It treats all such connections
1240 in the same way as connections from other hosts.
1241 </para>
1242 </listitem>
1243 </itemizedlist>
1244 <para>
1245 <indexterm role="concept">
1246 <primary>message sender, constructed by Exim</primary>
1247 </indexterm>
1248 <indexterm role="concept">
1249 <primary>sender</primary>
1250 <secondary>constructed by Exim</secondary>
1251 </indexterm>
1252 In the three cases that do not involve TCP/IP, the sender address is
1253 constructed from the login name of the user that called Exim and a default
1254 qualification domain (which can be set by the <option>qualify_domain</option> configuration
1255 option). For local or batch SMTP, a sender address that is passed using the
1256 SMTP MAIL command is ignored. However, the system administrator may allow
1257 certain users (<quote>trusted users</quote>) to specify a different sender address
1258 unconditionally, or all users to specify certain forms of different sender
1259 address. The <option>-f</option> option or the SMTP MAIL command is used to specify these
1260 different addresses. See section <xref linkend="SECTtrustedadmin"/> for details of trusted
1261 users, and the <option>untrusted_set_sender</option> option for a way of allowing untrusted
1262 users to change sender addresses.
1263 </para>
1264 <para>
1265 Messages received by either of the non-interactive mechanisms are subject to
1266 checking by the non-SMTP ACL, if one is defined. Messages received using SMTP
1267 (either over TCP/IP, or interacting with a local process) can be checked by a
1268 number of ACLs that operate at different times during the SMTP session. Either
1269 individual recipients, or the entire message, can be rejected if local policy
1270 requirements are not met. The <function>local_scan()</function> function (see chapter
1271 <xref linkend="CHAPlocalscan"/>) is run for all incoming messages.
1272 </para>
1273 <para>
1274 Exim can be configured not to start a delivery process when a message is
1275 received; this can be unconditional, or depend on the number of incoming SMTP
1276 connections or the system load. In these situations, new messages wait on the
1277 queue until a queue runner process picks them up. However, in standard
1278 configurations under normal conditions, delivery is started as soon as a
1279 message is received.
1280 </para>
1281 </section>
1282 <section id="SECID14">
1283 <title>Handling an incoming message</title>
1284 <para>
1285 <indexterm role="concept">
1286 <primary>spool directory</primary>
1287 <secondary>files that hold a message</secondary>
1288 </indexterm>
1289 <indexterm role="concept">
1290 <primary>file</primary>
1291 <secondary>how a message is held</secondary>
1292 </indexterm>
1293 When Exim accepts a message, it writes two files in its spool directory. The
1294 first contains the envelope information, the current status of the message, and
1295 the header lines, and the second contains the body of the message. The names of
1296 the two spool files consist of the message id, followed by <literal>-H</literal> for the
1297 file containing the envelope and header, and <literal>-D</literal> for the data file.
1298 </para>
1299 <para>
1300 <indexterm role="concept">
1301 <primary>spool directory</primary>
1302 <secondary><filename>input</filename> sub-directory</secondary>
1303 </indexterm>
1304 By default all these message files are held in a single directory called
1305 <filename>input</filename> inside the general Exim spool directory. Some operating systems do
1306 not perform very well if the number of files in a directory gets large; to
1307 improve performance in such cases, the <option>split_spool_directory</option> option can be
1308 used. This causes Exim to split up the input files into 62 sub-directories
1309 whose names are single letters or digits. When this is done, the queue is
1310 processed one sub-directory at a time instead of all at once, which can improve
1311 overall performance even when there are not enough files in each directory to
1312 affect file system performance.
1313 </para>
1314 <para>
1315 The envelope information consists of the address of the message&#x2019;s sender and
1316 the addresses of the recipients. This information is entirely separate from
1317 any addresses contained in the header lines. The status of the message includes
1318 a list of recipients who have already received the message. The format of the
1319 first spool file is described in chapter <xref linkend="CHAPspool"/>.
1320 </para>
1321 <para>
1322 <indexterm role="concept">
1323 <primary>rewriting</primary>
1324 <secondary>addresses</secondary>
1325 </indexterm>
1326 Address rewriting that is specified in the rewrite section of the configuration
1327 (see chapter <xref linkend="CHAPrewrite"/>) is done once and for all on incoming addresses,
1328 both in the header lines and the envelope, at the time the message is accepted.
1329 If during the course of delivery additional addresses are generated (for
1330 example, via aliasing), these new addresses are rewritten as soon as they are
1331 generated. At the time a message is actually delivered (transported) further
1332 rewriting can take place; because this is a transport option, it can be
1333 different for different forms of delivery. It is also possible to specify the
1334 addition or removal of certain header lines at the time the message is
1335 delivered (see chapters <xref linkend="CHAProutergeneric"/> and
1336 <xref linkend="CHAPtransportgeneric"/>).
1337 </para>
1338 </section>
1339 <section id="SECID15">
1340 <title>Life of a message</title>
1341 <para>
1342 <indexterm role="concept">
1343 <primary>message</primary>
1344 <secondary>life of</secondary>
1345 </indexterm>
1346 <indexterm role="concept">
1347 <primary>message</primary>
1348 <secondary>frozen</secondary>
1349 </indexterm>
1350 A message remains in the spool directory until it is completely delivered to
1351 its recipients or to an error address, or until it is deleted by an
1352 administrator or by the user who originally created it. In cases when delivery
1353 cannot proceed &ndash; for example, when a message can neither be delivered to its
1354 recipients nor returned to its sender, the message is marked <quote>frozen</quote> on the
1355 spool, and no more deliveries are attempted.
1356 </para>
1357 <para>
1358 <indexterm role="concept">
1359 <primary>frozen messages</primary>
1360 <secondary>thawing</secondary>
1361 </indexterm>
1362 <indexterm role="concept">
1363 <primary>message</primary>
1364 <secondary>thawing frozen</secondary>
1365 </indexterm>
1366 An administrator can <quote>thaw</quote> such messages when the problem has been
1367 corrected, and can also freeze individual messages by hand if necessary. In
1368 addition, an administrator can force a delivery error, causing a bounce message
1369 to be sent.
1370 </para>
1371 <para>
1372 <indexterm role="option">
1373 <primary><option>timeout_frozen_after</option></primary>
1374 </indexterm>
1375 <indexterm role="option">
1376 <primary><option>ignore_bounce_errors_after</option></primary>
1377 </indexterm>
1378 There are options called <option>ignore_bounce_errors_after</option> and
1379 <option>timeout_frozen_after</option>, which discard frozen messages after a certain time.
1380 The first applies only to frozen bounces, the second to any frozen messages.
1381 </para>
1382 <para>
1383 <indexterm role="concept">
1384 <primary>message</primary>
1385 <secondary>log file for</secondary>
1386 </indexterm>
1387 <indexterm role="concept">
1388 <primary>log</primary>
1389 <secondary>file for each message</secondary>
1390 </indexterm>
1391 While Exim is working on a message, it writes information about each delivery
1392 attempt to its main log file. This includes successful, unsuccessful, and
1393 delayed deliveries for each recipient (see chapter <xref linkend="CHAPlog"/>). The log
1394 lines are also written to a separate <emphasis>message log</emphasis> file for each message.
1395 These logs are solely for the benefit of the administrator, and are normally
1396 deleted along with the spool files when processing of a message is complete.
1397 The use of individual message logs can be disabled by setting
1398 <option>no_message_logs</option>; this might give an improvement in performance on very busy
1399 systems.
1400 </para>
1401 <para>
1402 <indexterm role="concept">
1403 <primary>journal file</primary>
1404 </indexterm>
1405 <indexterm role="concept">
1406 <primary>file</primary>
1407 <secondary>journal</secondary>
1408 </indexterm>
1409 All the information Exim itself needs to set up a delivery is kept in the first
1410 spool file, along with the header lines. When a successful delivery occurs, the
1411 address is immediately written at the end of a journal file, whose name is the
1412 message id followed by <literal>-J</literal>. At the end of a delivery run, if there are some
1413 addresses left to be tried again later, the first spool file (the <literal>-H</literal> file)
1414 is updated to indicate which these are, and the journal file is then deleted.
1415 Updating the spool file is done by writing a new file and renaming it, to
1416 minimize the possibility of data loss.
1417 </para>
1418 <para>
1419 Should the system or the program crash after a successful delivery but before
1420 the spool file has been updated, the journal is left lying around. The next
1421 time Exim attempts to deliver the message, it reads the journal file and
1422 updates the spool file before proceeding. This minimizes the chances of double
1423 deliveries caused by crashes.
1424 </para>
1425 </section>
1426 <section id="SECTprocaddress">
1427 <title>Processing an address for delivery</title>
1428 <para>
1429 <indexterm role="concept">
1430 <primary>drivers</primary>
1431 <secondary>definition of</secondary>
1432 </indexterm>
1433 <indexterm role="concept">
1434 <primary>router</primary>
1435 <secondary>definition of</secondary>
1436 </indexterm>
1437 <indexterm role="concept">
1438 <primary>transport</primary>
1439 <secondary>definition of</secondary>
1440 </indexterm>
1441 The main delivery processing elements of Exim are called <emphasis>routers</emphasis> and
1442 <emphasis>transports</emphasis>, and collectively these are known as <emphasis>drivers</emphasis>. Code for a
1443 number of them is provided in the source distribution, and compile-time options
1444 specify which ones are included in the binary. Run time options specify which
1445 ones are actually used for delivering messages.
1446 </para>
1447 <para>
1448 <indexterm role="concept">
1449 <primary>drivers</primary>
1450 <secondary>instance definition</secondary>
1451 </indexterm>
1452 Each driver that is specified in the run time configuration is an <emphasis>instance</emphasis>
1453 of that particular driver type. Multiple instances are allowed; for example,
1454 you can set up several different <command>smtp</command> transports, each with different
1455 option values that might specify different ports or different timeouts. Each
1456 instance has its own identifying name. In what follows we will normally use the
1457 instance name when discussing one particular instance (that is, one specific
1458 configuration of the driver), and the generic driver name when discussing
1459 the driver&#x2019;s features in general.
1460 </para>
1461 <para>
1462 A <emphasis>router</emphasis> is a driver that operates on an address, either determining how
1463 its delivery should happen, by assigning it to a specific transport, or
1464 converting the address into one or more new addresses (for example, via an
1465 alias file). A router may also explicitly choose to fail an address, causing it
1466 to be bounced.
1467 </para>
1468 <para>
1469 A <emphasis>transport</emphasis> is a driver that transmits a copy of the message from Exim&#x2019;s
1470 spool to some destination. There are two kinds of transport: for a <emphasis>local</emphasis>
1471 transport, the destination is a file or a pipe on the local host, whereas for a
1472 <emphasis>remote</emphasis> transport the destination is some other host. A message is passed
1473 to a specific transport as a result of successful routing. If a message has
1474 several recipients, it may be passed to a number of different transports.
1475 </para>
1476 <para>
1477 <indexterm role="concept">
1478 <primary>preconditions</primary>
1479 <secondary>definition of</secondary>
1480 </indexterm>
1481 An address is processed by passing it to each configured router instance in
1482 turn, subject to certain preconditions, until a router accepts the address or
1483 specifies that it should be bounced. We will describe this process in more
1484 detail shortly. First, as a simple example, we consider how each recipient
1485 address in a message is processed in a small configuration of three routers.
1486 </para>
1487 <para>
1488 To make this a more concrete example, it is described in terms of some actual
1489 routers, but remember, this is only an example. You can configure Exim&#x2019;s
1490 routers in many different ways, and there may be any number of routers in a
1491 configuration.
1492 </para>
1493 <para>
1494 The first router that is specified in a configuration is often one that handles
1495 addresses in domains that are not recognized specially by the local host. These
1496 are typically addresses for arbitrary domains on the Internet. A precondition
1497 is set up which looks for the special domains known to the host (for example,
1498 its own domain name), and the router is run for addresses that do <emphasis>not</emphasis>
1499 match. Typically, this is a router that looks up domains in the DNS in order to
1500 find the hosts to which this address routes. If it succeeds, the address is
1501 assigned to a suitable SMTP transport; if it does not succeed, the router is
1502 configured to fail the address.
1503 </para>
1504 <para>
1505 The second router is reached only when the domain is recognized as one that
1506 <quote>belongs</quote> to the local host. This router does redirection &ndash; also known as
1507 aliasing and forwarding. When it generates one or more new addresses from the
1508 original, each of them is routed independently from the start. Otherwise, the
1509 router may cause an address to fail, or it may simply decline to handle the
1510 address, in which case the address is passed to the next router.
1511 </para>
1512 <para>
1513 The final router in many configurations is one that checks to see if the
1514 address belongs to a local mailbox. The precondition may involve a check to
1515 see if the local part is the name of a login account, or it may look up the
1516 local part in a file or a database. If its preconditions are not met, or if
1517 the router declines, we have reached the end of the routers. When this happens,
1518 the address is bounced.
1519 </para>
1520 </section>
1521 <section id="SECID16">
1522 <title>Processing an address for verification</title>
1523 <para>
1524 <indexterm role="concept">
1525 <primary>router</primary>
1526 <secondary>for verification</secondary>
1527 </indexterm>
1528 <indexterm role="concept">
1529 <primary>verifying address</primary>
1530 <secondary>overview</secondary>
1531 </indexterm>
1532 As well as being used to decide how to deliver to an address, Exim&#x2019;s routers
1533 are also used for <emphasis>address verification</emphasis>. Verification can be requested as
1534 one of the checks to be performed in an ACL for incoming messages, on both
1535 sender and recipient addresses, and it can be tested using the <option>-bv</option> and
1536 <option>-bvs</option> command line options.
1537 </para>
1538 <para>
1539 When an address is being verified, the routers are run in <quote>verify mode</quote>. This
1540 does not affect the way the routers work, but it is a state that can be
1541 detected. By this means, a router can be skipped or made to behave differently
1542 when verifying. A common example is a configuration in which the first router
1543 sends all messages to a message-scanning program, unless they have been
1544 previously scanned. Thus, the first router accepts all addresses without any
1545 checking, making it useless for verifying. Normally, the <option>no_verify</option> option
1546 would be set for such a router, causing it to be skipped in verify mode.
1547 </para>
1548 </section>
1549 <section id="SECTrunindrou">
1550 <title>Running an individual router</title>
1551 <para>
1552 <indexterm role="concept">
1553 <primary>router</primary>
1554 <secondary>running details</secondary>
1555 </indexterm>
1556 <indexterm role="concept">
1557 <primary>preconditions</primary>
1558 <secondary>checking</secondary>
1559 </indexterm>
1560 <indexterm role="concept">
1561 <primary>router</primary>
1562 <secondary>result of running</secondary>
1563 </indexterm>
1564 As explained in the example above, a number of preconditions are checked before
1565 running a router. If any are not met, the router is skipped, and the address is
1566 passed to the next router. When all the preconditions on a router <emphasis>are</emphasis> met,
1567 the router is run. What happens next depends on the outcome, which is one of
1568 the following:
1569 </para>
1570 <itemizedlist>
1571 <listitem>
1572 <para>
1573 <emphasis>accept</emphasis>: The router accepts the address, and either assigns it to a
1574 transport, or generates one or more <quote>child</quote> addresses. Processing the
1575 original address ceases,
1576 <indexterm role="option">
1577 <primary><option>unseen</option></primary>
1578 </indexterm>
1579 unless the <option>unseen</option> option is set on the router. This option
1580 can be used to set up multiple deliveries with different routing (for example,
1581 for keeping archive copies of messages). When <option>unseen</option> is set, the address is
1582 passed to the next router. Normally, however, an <emphasis>accept</emphasis> return marks the
1583 end of routing.
1584 </para>
1585 <para>
1586 Any child addresses generated by the router are processed independently,
1587 starting with the first router by default. It is possible to change this by
1588 setting the <option>redirect_router</option> option to specify which router to start at for
1589 child addresses. Unlike <option>pass_router</option> (see below) the router specified by
1590 <option>redirect_router</option> may be anywhere in the router configuration.
1591 </para>
1592 </listitem>
1593 <listitem>
1594 <para>
1595 <emphasis>pass</emphasis>: The router recognizes the address, but cannot handle it itself. It
1596 requests that the address be passed to another router. By default the address
1597 is passed to the next router, but this can be changed by setting the
1598 <option>pass_router</option> option. However, (unlike <option>redirect_router</option>) the named router
1599 must be below the current router (to avoid loops).
1600 </para>
1601 </listitem>
1602 <listitem>
1603 <para>
1604 <emphasis>decline</emphasis>: The router declines to accept the address because it does not
1605 recognize it at all. By default, the address is passed to the next router, but
1606 this can be prevented by setting the <option>no_more</option> option. When <option>no_more</option> is
1607 set, all the remaining routers are skipped. In effect, <option>no_more</option> converts
1608 <emphasis>decline</emphasis> into <emphasis>fail</emphasis>.
1609 </para>
1610 </listitem>
1611 <listitem>
1612 <para>
1613 <emphasis>fail</emphasis>: The router determines that the address should fail, and queues it for
1614 the generation of a bounce message. There is no further processing of the
1615 original address unless <option>unseen</option> is set on the router.
1616 </para>
1617 </listitem>
1618 <listitem>
1619 <para>
1620 <emphasis>defer</emphasis>: The router cannot handle the address at the present time. (A
1621 database may be offline, or a DNS lookup may have timed out.) No further
1622 processing of the address happens in this delivery attempt. It is tried again
1623 next time the message is considered for delivery.
1624 </para>
1625 </listitem>
1626 <listitem>
1627 <para>
1628 <emphasis>error</emphasis>: There is some error in the router (for example, a syntax error in
1629 its configuration). The action is as for defer.
1630 </para>
1631 </listitem>
1632 </itemizedlist>
1633 <para>
1634 If an address reaches the end of the routers without having been accepted by
1635 any of them, it is bounced as unrouteable. The default error message in this
1636 situation is <quote>unrouteable address</quote>, but you can set your own message by
1637 making use of the <option>cannot_route_message</option> option. This can be set for any
1638 router; the value from the last router that <quote>saw</quote> the address is used.
1639 </para>
1640 <para>
1641 Sometimes while routing you want to fail a delivery when some conditions are
1642 met but others are not, instead of passing the address on for further routing.
1643 You can do this by having a second router that explicitly fails the delivery
1644 when the relevant conditions are met. The <command>redirect</command> router has a <quote>fail</quote>
1645 facility for this purpose.
1646 </para>
1647 </section>
1648 <section id="SECID17">
1649 <title>Duplicate addresses</title>
1650 <para>
1651 <indexterm role="concept">
1652 <primary>case of local parts</primary>
1653 </indexterm>
1654 <indexterm role="concept">
1655 <primary>address duplicate, discarding</primary>
1656 </indexterm>
1657 <indexterm role="concept">
1658 <primary>duplicate addresses</primary>
1659 </indexterm>
1660 Once routing is complete, Exim scans the addresses that are assigned to local
1661 and remote transports, and discards any duplicates that it finds. During this
1662 check, local parts are treated as case-sensitive. This happens only when
1663 actually delivering a message; when testing routers with <option>-bt</option>, all the
1664 routed addresses are shown.
1665 </para>
1666 </section>
1667 <section id="SECTrouprecon">
1668 <title>Router preconditions</title>
1669 <para>
1670 <indexterm role="concept">
1671 <primary>router</primary>
1672 <secondary>preconditions, order of processing</secondary>
1673 </indexterm>
1674 <indexterm role="concept">
1675 <primary>preconditions</primary>
1676 <secondary>order of processing</secondary>
1677 </indexterm>
1678 The preconditions that are tested for each router are listed below, in the
1679 order in which they are tested. The individual configuration options are
1680 described in more detail in chapter <xref linkend="CHAProutergeneric"/>.
1681 </para>
1682 <itemizedlist>
1683 <listitem>
1684 <para>
1685 The <option>local_part_prefix</option> and <option>local_part_suffix</option> options can specify that
1686 the local parts handled by the router may or must have certain prefixes and/or
1687 suffixes. If a mandatory affix (prefix or suffix) is not present, the router is
1688 skipped. These conditions are tested first. When an affix is present, it is
1689 removed from the local part before further processing, including the evaluation
1690 of any other conditions.
1691 </para>
1692 </listitem>
1693 <listitem>
1694 <para>
1695 Routers can be designated for use only when not verifying an address, that is,
1696 only when routing it for delivery (or testing its delivery routing). If the
1697 <option>verify</option> option is set false, the router is skipped when Exim is verifying an
1698 address.
1699 Setting the <option>verify</option> option actually sets two options, <option>verify_sender</option> and
1700 <option>verify_recipient</option>, which independently control the use of the router for
1701 sender and recipient verification. You can set these options directly if
1702 you want a router to be used for only one type of verification.
1703 </para>
1704 </listitem>
1705 <listitem>
1706 <para>
1707 If the <option>address_test</option> option is set false, the router is skipped when Exim is
1708 run with the <option>-bt</option> option to test an address routing. This can be helpful
1709 when the first router sends all new messages to a scanner of some sort; it
1710 makes it possible to use <option>-bt</option> to test subsequent delivery routing without
1711 having to simulate the effect of the scanner.
1712 </para>
1713 </listitem>
1714 <listitem>
1715 <para>
1716 Routers can be designated for use only when verifying an address, as
1717 opposed to routing it for delivery. The <option>verify_only</option> option controls this.
1718 </para>
1719 </listitem>
1720 <listitem>
1721 <para>
1722 Individual routers can be explicitly skipped when running the routers to
1723 check an address given in the SMTP EXPN command (see the <option>expn</option> option).
1724 </para>
1725 </listitem>
1726 <listitem>
1727 <para>
1728 If the <option>domains</option> option is set, the domain of the address must be in the set
1729 of domains that it defines.
1730 </para>
1731 </listitem>
1732 <listitem>
1733 <para>
1734 <indexterm role="variable">
1735 <primary><varname>$local_part_prefix</varname></primary>
1736 </indexterm>
1737 <indexterm role="variable">
1738 <primary><varname>$local_part</varname></primary>
1739 </indexterm>
1740 <indexterm role="variable">
1741 <primary><varname>$local_part_suffix</varname></primary>
1742 </indexterm>
1743 If the <option>local_parts</option> option is set, the local part of the address must be in
1744 the set of local parts that it defines. If <option>local_part_prefix</option> or
1745 <option>local_part_suffix</option> is in use, the prefix or suffix is removed from the local
1746 part before this check. If you want to do precondition tests on local parts
1747 that include affixes, you can do so by using a <option>condition</option> option (see below)
1748 that uses the variables <varname>$local_part</varname>, <varname>$local_part_prefix</varname>, and
1749 <varname>$local_part_suffix</varname> as necessary.
1750 </para>
1751 </listitem>
1752 <listitem>
1753 <para>
1754 <indexterm role="variable">
1755 <primary><varname>$local_user_uid</varname></primary>
1756 </indexterm>
1757 <indexterm role="variable">
1758 <primary><varname>$local_user_gid</varname></primary>
1759 </indexterm>
1760 <indexterm role="variable">
1761 <primary><varname>$home</varname></primary>
1762 </indexterm>
1763 If the <option>check_local_user</option> option is set, the local part must be the name of
1764 an account on the local host. If this check succeeds, the uid and gid of the
1765 local user are placed in <varname>$local_user_uid</varname> and <varname>$local_user_gid</varname> and the
1766 user&#x2019;s home directory is placed in <varname>$home</varname>; these values can be used in the
1767 remaining preconditions.
1768 </para>
1769 </listitem>
1770 <listitem>
1771 <para>
1772 If the <option>router_home_directory</option> option is set, it is expanded at this point,
1773 because it overrides the value of <varname>$home</varname>. If this expansion were left till
1774 later, the value of <varname>$home</varname> as set by <option>check_local_user</option> would be used in
1775 subsequent tests. Having two different values of <varname>$home</varname> in the same router
1776 could lead to confusion.
1777 </para>
1778 </listitem>
1779 <listitem>
1780 <para>
1781 If the <option>senders</option> option is set, the envelope sender address must be in the
1782 set of addresses that it defines.
1783 </para>
1784 </listitem>
1785 <listitem>
1786 <para>
1787 If the <option>require_files</option> option is set, the existence or non-existence of
1788 specified files is tested.
1789 </para>
1790 </listitem>
1791 <listitem>
1792 <para>
1793 <indexterm role="concept">
1794 <primary>customizing</primary>
1795 <secondary>precondition</secondary>
1796 </indexterm>
1797 If the <option>condition</option> option is set, it is evaluated and tested. This option
1798 uses an expanded string to allow you to set up your own custom preconditions.
1799 Expanded strings are described in chapter <xref linkend="CHAPexpand"/>.
1800 </para>
1801 </listitem>
1802 </itemizedlist>
1803 <para>
1804 Note that <option>require_files</option> comes near the end of the list, so you cannot use
1805 it to check for the existence of a file in which to lookup up a domain, local
1806 part, or sender. However, as these options are all expanded, you can use the
1807 <option>exists</option> expansion condition to make such tests within each condition. The
1808 <option>require_files</option> option is intended for checking files that the router may be
1809 going to use internally, or which are needed by a specific transport (for
1810 example, <filename>.procmailrc</filename>).
1811 </para>
1812 </section>
1813 <section id="SECID18">
1814 <title>Delivery in detail</title>
1815 <para>
1816 <indexterm role="concept">
1817 <primary>delivery</primary>
1818 <secondary>in detail</secondary>
1819 </indexterm>
1820 When a message is to be delivered, the sequence of events is as follows:
1821 </para>
1822 <itemizedlist>
1823 <listitem>
1824 <para>
1825 If a system-wide filter file is specified, the message is passed to it. The
1826 filter may add recipients to the message, replace the recipients, discard the
1827 message, cause a new message to be generated, or cause the message delivery to
1828 fail. The format of the system filter file is the same as for Exim user filter
1829 files, described in the separate document entitled <emphasis>Exim&#x2019;s interfaces to mail
1830 filtering</emphasis>.
1831 <indexterm role="concept">
1832 <primary>Sieve filter</primary>
1833 <secondary>not available for system filter</secondary>
1834 </indexterm>
1835 (<emphasis role="bold">Note</emphasis>: Sieve cannot be used for system filter files.)
1836 </para>
1837 <para>
1838 Some additional features are available in system filters &ndash; see chapter
1839 <xref linkend="CHAPsystemfilter"/> for details. Note that a message is passed to the system
1840 filter only once per delivery attempt, however many recipients it has. However,
1841 if there are several delivery attempts because one or more addresses could not
1842 be immediately delivered, the system filter is run each time. The filter
1843 condition <option>first_delivery</option> can be used to detect the first run of the system
1844 filter.
1845 </para>
1846 </listitem>
1847 <listitem>
1848 <para>
1849 Each recipient address is offered to each configured router in turn, subject to
1850 its preconditions, until one is able to handle it. If no router can handle the
1851 address, that is, if they all decline, the address is failed. Because routers
1852 can be targeted at particular domains, several locally handled domains can be
1853 processed entirely independently of each other.
1854 </para>
1855 </listitem>
1856 <listitem>
1857 <para>
1858 <indexterm role="concept">
1859 <primary>routing</primary>
1860 <secondary>loops in</secondary>
1861 </indexterm>
1862 <indexterm role="concept">
1863 <primary>loop</primary>
1864 <secondary>while routing</secondary>
1865 </indexterm>
1866 A router that accepts an address may assign it to a local or a remote
1867 transport. However, the transport is not run at this time. Instead, the address
1868 is placed on a list for the particular transport, which will be run later.
1869 Alternatively, the router may generate one or more new addresses (typically
1870 from alias, forward, or filter files). New addresses are fed back into this
1871 process from the top, but in order to avoid loops, a router ignores any address
1872 which has an identically-named ancestor that was processed by itself.
1873 </para>
1874 </listitem>
1875 <listitem>
1876 <para>
1877 When all the routing has been done, addresses that have been successfully
1878 handled are passed to their assigned transports. When local transports are
1879 doing real local deliveries, they handle only one address at a time, but if a
1880 local transport is being used as a pseudo-remote transport (for example, to
1881 collect batched SMTP messages for transmission by some other means) multiple
1882 addresses can be handled. Remote transports can always handle more than one
1883 address at a time, but can be configured not to do so, or to restrict multiple
1884 addresses to the same domain.
1885 </para>
1886 </listitem>
1887 <listitem>
1888 <para>
1889 Each local delivery to a file or a pipe runs in a separate process under a
1890 non-privileged uid, and these deliveries are run one at a time. Remote
1891 deliveries also run in separate processes, normally under a uid that is private
1892 to Exim (<quote>the Exim user</quote>), but in this case, several remote deliveries can be
1893 run in parallel. The maximum number of simultaneous remote deliveries for any
1894 one message is set by the <option>remote_max_parallel</option> option.
1895 The order in which deliveries are done is not defined, except that all local
1896 deliveries happen before any remote deliveries.
1897 </para>
1898 </listitem>
1899 <listitem>
1900 <para>
1901 <indexterm role="concept">
1902 <primary>queue runner</primary>
1903 </indexterm>
1904 When it encounters a local delivery during a queue run, Exim checks its retry
1905 database to see if there has been a previous temporary delivery failure for the
1906 address before running the local transport. If there was a previous failure,
1907 Exim does not attempt a new delivery until the retry time for the address is
1908 reached. However, this happens only for delivery attempts that are part of a
1909 queue run. Local deliveries are always attempted when delivery immediately
1910 follows message reception, even if retry times are set for them. This makes for
1911 better behaviour if one particular message is causing problems (for example,
1912 causing quota overflow, or provoking an error in a filter file).
1913 </para>
1914 </listitem>
1915 <listitem>
1916 <para>
1917 <indexterm role="concept">
1918 <primary>delivery</primary>
1919 <secondary>retry in remote transports</secondary>
1920 </indexterm>
1921 Remote transports do their own retry handling, since an address may be
1922 deliverable to one of a number of hosts, each of which may have a different
1923 retry time. If there have been previous temporary failures and no host has
1924 reached its retry time, no delivery is attempted, whether in a queue run or
1925 not. See chapter <xref linkend="CHAPretry"/> for details of retry strategies.
1926 </para>
1927 </listitem>
1928 <listitem>
1929 <para>
1930 If there were any permanent errors, a bounce message is returned to an
1931 appropriate address (the sender in the common case), with details of the error
1932 for each failing address. Exim can be configured to send copies of bounce
1933 messages to other addresses.
1934 </para>
1935 </listitem>
1936 <listitem>
1937 <para>
1938 <indexterm role="concept">
1939 <primary>delivery</primary>
1940 <secondary>deferral</secondary>
1941 </indexterm>
1942 If one or more addresses suffered a temporary failure, the message is left on
1943 the queue, to be tried again later. Delivery of these addresses is said to be
1944 <emphasis>deferred</emphasis>.
1945 </para>
1946 </listitem>
1947 <listitem>
1948 <para>
1949 When all the recipient addresses have either been delivered or bounced,
1950 handling of the message is complete. The spool files and message log are
1951 deleted, though the message log can optionally be preserved if required.
1952 </para>
1953 </listitem>
1954 </itemizedlist>
1955 </section>
1956 <section id="SECID19">
1957 <title>Retry mechanism</title>
1958 <para>
1959 <indexterm role="concept">
1960 <primary>delivery</primary>
1961 <secondary>retry mechanism</secondary>
1962 </indexterm>
1963 <indexterm role="concept">
1964 <primary>retry</primary>
1965 <secondary>description of mechanism</secondary>
1966 </indexterm>
1967 <indexterm role="concept">
1968 <primary>queue runner</primary>
1969 </indexterm>
1970 Exim&#x2019;s mechanism for retrying messages that fail to get delivered at the first
1971 attempt is the queue runner process. You must either run an Exim daemon that
1972 uses the <option>-q</option> option with a time interval to start queue runners at regular
1973 intervals, or use some other means (such as <emphasis>cron</emphasis>) to start them. If you do
1974 not arrange for queue runners to be run, messages that fail temporarily at the
1975 first attempt will remain on your queue for ever. A queue runner process works
1976 its way through the queue, one message at a time, trying each delivery that has
1977 passed its retry time.
1978 You can run several queue runners at once.
1979 </para>
1980 <para>
1981 Exim uses a set of configured rules to determine when next to retry the failing
1982 address (see chapter <xref linkend="CHAPretry"/>). These rules also specify when Exim
1983 should give up trying to deliver to the address, at which point it generates a
1984 bounce message. If no retry rules are set for a particular host, address, and
1985 error combination, no retries are attempted, and temporary errors are treated
1986 as permanent.
1987 </para>
1988 </section>
1989 <section id="SECID20">
1990 <title>Temporary delivery failure</title>
1991 <para>
1992 <indexterm role="concept">
1993 <primary>delivery</primary>
1994 <secondary>temporary failure</secondary>
1995 </indexterm>
1996 There are many reasons why a message may not be immediately deliverable to a
1997 particular address. Failure to connect to a remote machine (because it, or the
1998 connection to it, is down) is one of the most common. Temporary failures may be
1999 detected during routing as well as during the transport stage of delivery.
2000 Local deliveries may be delayed if NFS files are unavailable, or if a mailbox
2001 is on a file system where the user is over quota. Exim can be configured to
2002 impose its own quotas on local mailboxes; where system quotas are set they will
2003 also apply.
2004 </para>
2005 <para revisionflag="changed">
2006 If a host is unreachable for a period of time, a number of messages may be
2007 waiting for it by the time it recovers, and sending them in a single SMTP
2008 connection is clearly beneficial. Whenever a delivery to a remote host is
2009 deferred,
2010 <indexterm role="concept">
2011 <primary>hints database</primary>
2012 </indexterm>
2013 Exim makes a note in its hints database, and whenever a successful
2014 SMTP delivery has happened, it looks to see if any other messages are waiting
2015 for the same host. If any are found, they are sent over the same SMTP
2016 connection, subject to a configuration limit as to the maximum number in any
2017 one connection.
2018 </para>
2019 </section>
2020 <section id="SECID21">
2021 <title>Permanent delivery failure</title>
2022 <para>
2023 <indexterm role="concept">
2024 <primary>delivery</primary>
2025 <secondary>permanent failure</secondary>
2026 </indexterm>
2027 <indexterm role="concept">
2028 <primary>bounce message</primary>
2029 <secondary>when generated</secondary>
2030 </indexterm>
2031 When a message cannot be delivered to some or all of its intended recipients, a
2032 bounce message is generated. Temporary delivery failures turn into permanent
2033 errors when their timeout expires. All the addresses that fail in a given
2034 delivery attempt are listed in a single message. If the original message has
2035 many recipients, it is possible for some addresses to fail in one delivery
2036 attempt and others to fail subsequently, giving rise to more than one bounce
2037 message. The wording of bounce messages can be customized by the administrator.
2038 See chapter <xref linkend="CHAPemsgcust"/> for details.
2039 </para>
2040 <para>
2041 <indexterm role="concept">
2042 <primary><emphasis>X-Failed-Recipients:</emphasis> header line</primary>
2043 </indexterm>
2044 Bounce messages contain an <emphasis>X-Failed-Recipients:</emphasis> header line that lists the
2045 failed addresses, for the benefit of programs that try to analyse such messages
2046 automatically.
2047 </para>
2048 <para>
2049 <indexterm role="concept">
2050 <primary>bounce message</primary>
2051 <secondary>recipient of</secondary>
2052 </indexterm>
2053 A bounce message is normally sent to the sender of the original message, as
2054 obtained from the message&#x2019;s envelope. For incoming SMTP messages, this is the
2055 address given in the MAIL command. However, when an address is expanded via a
2056 forward or alias file, an alternative address can be specified for delivery
2057 failures of the generated addresses. For a mailing list expansion (see section
2058 <xref linkend="SECTmailinglists"/>) it is common to direct bounce messages to the manager
2059 of the list.
2060 </para>
2061 </section>
2062 <section id="SECID22">
2063 <title>Failures to deliver bounce messages</title>
2064 <para>
2065 <indexterm role="concept">
2066 <primary>bounce message</primary>
2067 <secondary>failure to deliver</secondary>
2068 </indexterm>
2069 If a bounce message (either locally generated or received from a remote host)
2070 itself suffers a permanent delivery failure, the message is left on the queue,
2071 but it is frozen, awaiting the attention of an administrator. There are options
2072 that can be used to make Exim discard such failed messages, or to keep them
2073 for only a short time (see <option>timeout_frozen_after</option> and
2074 <option>ignore_bounce_errors_after</option>).
2075 </para>
2076 </section>
2077 </chapter>
2078
2079 <chapter id="CHID3">
2080 <title>Building and installing Exim</title>
2081 <para>
2082 <indexterm role="concept" id="IIDbuex" class="startofrange">
2083 <primary>building Exim</primary>
2084 </indexterm>
2085 </para>
2086 <section id="SECID23">
2087 <title>Unpacking</title>
2088 <para>
2089 Exim is distributed as a gzipped or bzipped tar file which, when unpacked,
2090 creates a directory with the name of the current release (for example,
2091 <filename>exim-4.74</filename>) into which the following files are placed:
2092 </para>
2093 <informaltable frame="none">
2094 <tgroup cols="2" colsep="0" rowsep="0">
2095 <colspec colwidth="140pt" align="left"/>
2096 <colspec colwidth="254pt" align="left"/>
2097 <tbody>
2098 <row>
2099 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<filename>ACKNOWLEDGMENTS</filename></entry>
2100 <entry>contains some acknowledgments</entry>
2101 </row>
2102 <row>
2103 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<filename>CHANGES</filename></entry>
2104 <entry>contains a reference to where changes are documented</entry>
2105 </row>
2106 <row>
2107 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<filename>LICENCE</filename></entry>
2108 <entry>the GNU General Public Licence</entry>
2109 </row>
2110 <row>
2111 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<filename>Makefile</filename></entry>
2112 <entry>top-level make file</entry>
2113 </row>
2114 <row>
2115 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<filename>NOTICE</filename></entry>
2116 <entry>conditions for the use of Exim</entry>
2117 </row>
2118 <row>
2119 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<filename>README</filename></entry>
2120 <entry>list of files, directories and simple build instructions</entry>
2121 </row>
2122 </tbody>
2123 </tgroup>
2124 </informaltable>
2125 <para>
2126 Other files whose names begin with <filename>README</filename> may also be present. The
2127 following subdirectories are created:
2128 </para>
2129 <informaltable frame="none">
2130 <tgroup cols="2" colsep="0" rowsep="0">
2131 <colspec colwidth="140pt" align="left"/>
2132 <colspec colwidth="254pt" align="left"/>
2133 <tbody>
2134 <row>
2135 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<filename>Local</filename></entry>
2136 <entry>an empty directory for local configuration files</entry>
2137 </row>
2138 <row>
2139 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<filename>OS</filename></entry>
2140 <entry>OS-specific files</entry>
2141 </row>
2142 <row>
2143 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<filename>doc</filename></entry>
2144 <entry>documentation files</entry>
2145 </row>
2146 <row>
2147 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<filename>exim_monitor</filename></entry>
2148 <entry>source files for the Exim monitor</entry>
2149 </row>
2150 <row>
2151 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<filename>scripts</filename></entry>
2152 <entry>scripts used in the build process</entry>
2153 </row>
2154 <row>
2155 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<filename>src</filename></entry>
2156 <entry>remaining source files</entry>
2157 </row>
2158 <row>
2159 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<filename>util</filename></entry>
2160 <entry>independent utilities</entry>
2161 </row>
2162 </tbody>
2163 </tgroup>
2164 </informaltable>
2165 <para>
2166 The main utility programs are contained in the <filename>src</filename> directory, and are built
2167 with the Exim binary. The <filename>util</filename> directory contains a few optional scripts
2168 that may be useful to some sites.
2169 </para>
2170 </section>
2171 <section id="SECID24">
2172 <title>Multiple machine architectures and operating systems</title>
2173 <para>
2174 <indexterm role="concept">
2175 <primary>building Exim</primary>
2176 <secondary>multiple OS/architectures</secondary>
2177 </indexterm>
2178 The building process for Exim is arranged to make it easy to build binaries for
2179 a number of different architectures and operating systems from the same set of
2180 source files. Compilation does not take place in the <filename>src</filename> directory.
2181 Instead, a <emphasis>build directory</emphasis> is created for each architecture and operating
2182 system.
2183 <indexterm role="concept">
2184 <primary>symbolic link</primary>
2185 <secondary>to build directory</secondary>
2186 </indexterm>
2187 Symbolic links to the sources are installed in this directory, which is where
2188 the actual building takes place. In most cases, Exim can discover the machine
2189 architecture and operating system for itself, but the defaults can be
2190 overridden if necessary.
2191 </para>
2192 </section>
2193 <section id="SECTpcre">
2194 <title>PCRE library</title>
2195 <para>
2196 <indexterm role="concept">
2197 <primary>PCRE library</primary>
2198 </indexterm>
2199 Exim no longer has an embedded PCRE library as the vast majority of
2200 modern systems include PCRE as a system library, although you may need
2201 to install the PCRE or PCRE development package for your operating
2202 system. If your system has a normal PCRE installation the Exim build
2203 process will need no further configuration. If the library or the
2204 headers are in an unusual location you will need to set the PCRE_LIBS
2205 and INCLUDE directives appropriately. If your operating system has no
2206 PCRE support then you will need to obtain and build the current PCRE
2207 from <emphasis role="bold"><ulink url="ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/">ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/</ulink></emphasis>.
2208 </para>
2209 </section>
2210 <section id="SECTdb">
2211 <title>DBM libraries</title>
2212 <para>
2213 <indexterm role="concept">
2214 <primary>DBM libraries</primary>
2215 <secondary>discussion of</secondary>
2216 </indexterm>
2217 <indexterm role="concept">
2218 <primary>hints database</primary>
2219 <secondary>DBM files used for</secondary>
2220 </indexterm>
2221 Even if you do not use any DBM files in your configuration, Exim still needs a
2222 DBM library in order to operate, because it uses indexed files for its hints
2223 databases. Unfortunately, there are a number of DBM libraries in existence, and
2224 different operating systems often have different ones installed.
2225 </para>
2226 <para>
2227 <indexterm role="concept">
2228 <primary>Solaris</primary>
2229 <secondary>DBM library for</secondary>
2230 </indexterm>
2231 <indexterm role="concept">
2232 <primary>IRIX, DBM library for</primary>
2233 </indexterm>
2234 <indexterm role="concept">
2235 <primary>BSD, DBM library for</primary>
2236 </indexterm>
2237 <indexterm role="concept">
2238 <primary>Linux, DBM library for</primary>
2239 </indexterm>
2240 If you are using Solaris, IRIX, one of the modern BSD systems, or a modern
2241 Linux distribution, the DBM configuration should happen automatically, and you
2242 may be able to ignore this section. Otherwise, you may have to learn more than
2243 you would like about DBM libraries from what follows.
2244 </para>
2245 <para>
2246 <indexterm role="concept">
2247 <primary><emphasis>ndbm</emphasis> DBM library</primary>
2248 </indexterm>
2249 Licensed versions of Unix normally contain a library of DBM functions operating
2250 via the <emphasis>ndbm</emphasis> interface, and this is what Exim expects by default. Free
2251 versions of Unix seem to vary in what they contain as standard. In particular,
2252 some early versions of Linux have no default DBM library, and different
2253 distributors have chosen to bundle different libraries with their packaged
2254 versions. However, the more recent releases seem to have standardized on the
2255 Berkeley DB library.
2256 </para>
2257 <para>
2258 Different DBM libraries have different conventions for naming the files they
2259 use. When a program opens a file called <filename>dbmfile</filename>, there are several
2260 possibilities:
2261 </para>
2262 <orderedlist numeration="arabic">
2263 <listitem>
2264 <para>
2265 A traditional <emphasis>ndbm</emphasis> implementation, such as that supplied as part of
2266 Solaris, operates on two files called <filename>dbmfile.dir</filename> and <filename>dbmfile.pag</filename>.
2267 </para>
2268 </listitem>
2269 <listitem>
2270 <para>
2271 <indexterm role="concept">
2272 <primary><emphasis>gdbm</emphasis> DBM library</primary>
2273 </indexterm>
2274 The GNU library, <emphasis>gdbm</emphasis>, operates on a single file. If used via its <emphasis>ndbm</emphasis>
2275 compatibility interface it makes two different hard links to it with names
2276 <filename>dbmfile.dir</filename> and <filename>dbmfile.pag</filename>, but if used via its native interface, the
2277 file name is used unmodified.
2278 </para>
2279 </listitem>
2280 <listitem>
2281 <para>
2282 <indexterm role="concept">
2283 <primary>Berkeley DB library</primary>
2284 </indexterm>
2285 The Berkeley DB package, if called via its <emphasis>ndbm</emphasis> compatibility interface,
2286 operates on a single file called <filename>dbmfile.db</filename>, but otherwise looks to the
2287 programmer exactly the same as the traditional <emphasis>ndbm</emphasis> implementation.
2288 </para>
2289 </listitem>
2290 <listitem>
2291 <para>
2292 If the Berkeley package is used in its native mode, it operates on a single
2293 file called <filename>dbmfile</filename>; the programmer&#x2019;s interface is somewhat different to
2294 the traditional <emphasis>ndbm</emphasis> interface.
2295 </para>
2296 </listitem>
2297 <listitem>
2298 <para>
2299 To complicate things further, there are several very different versions of the
2300 Berkeley DB package. Version 1.85 was stable for a very long time, releases
2301 2.<emphasis>x</emphasis> and 3.<emphasis>x</emphasis> were current for a while, but the latest versions are now
2302 numbered 4.<emphasis>x</emphasis>. Maintenance of some of the earlier releases has ceased. All
2303 versions of Berkeley DB can be obtained from
2304 <emphasis role="bold"><ulink url="http://www.sleepycat.com/">http://www.sleepycat.com/</ulink></emphasis>.
2305 </para>
2306 </listitem>
2307 <listitem>
2308 <para>
2309 <indexterm role="concept">
2310 <primary><emphasis>tdb</emphasis> DBM library</primary>
2311 </indexterm>
2312 Yet another DBM library, called <emphasis>tdb</emphasis>, is available from
2313 <emphasis role="bold"><ulink url="http://download.sourceforge.net/tdb">http://download.sourceforge.net/tdb</ulink></emphasis>. It has its own interface, and also
2314 operates on a single file.
2315 </para>
2316 </listitem>
2317 </orderedlist>
2318 <para>
2319 <indexterm role="concept">
2320 <primary>USE_DB</primary>
2321 </indexterm>
2322 <indexterm role="concept">
2323 <primary>DBM libraries</primary>
2324 <secondary>configuration for building</secondary>
2325 </indexterm>
2326 Exim and its utilities can be compiled to use any of these interfaces. In order
2327 to use any version of the Berkeley DB package in native mode, you must set
2328 USE_DB in an appropriate configuration file (typically
2329 <filename>Local/Makefile</filename>). For example:
2330 </para>
2331 <literallayout class="monospaced">
2332 USE_DB=yes
2333 </literallayout>
2334 <para>
2335 Similarly, for gdbm you set USE_GDBM, and for tdb you set USE_TDB. An
2336 error is diagnosed if you set more than one of these.
2337 </para>
2338 <para>
2339 At the lowest level, the build-time configuration sets none of these options,
2340 thereby assuming an interface of type (1). However, some operating system
2341 configuration files (for example, those for the BSD operating systems and
2342 Linux) assume type (4) by setting USE_DB as their default, and the
2343 configuration files for Cygwin set USE_GDBM. Anything you set in
2344 <filename>Local/Makefile</filename>, however, overrides these system defaults.
2345 </para>
2346 <para>
2347 As well as setting USE_DB, USE_GDBM, or USE_TDB, it may also be
2348 necessary to set DBMLIB, to cause inclusion of the appropriate library, as
2349 in one of these lines:
2350 </para>
2351 <literallayout class="monospaced">
2352 DBMLIB = -ldb
2353 DBMLIB = -ltdb
2354 </literallayout>
2355 <para>
2356 Settings like that will work if the DBM library is installed in the standard
2357 place. Sometimes it is not, and the library&#x2019;s header file may also not be in
2358 the default path. You may need to set INCLUDE to specify where the header
2359 file is, and to specify the path to the library more fully in DBMLIB, as in
2360 this example:
2361 </para>
2362 <literallayout class="monospaced">
2363 INCLUDE=-I/usr/local/include/db-4.1
2364 DBMLIB=/usr/local/lib/db-4.1/libdb.a
2365 </literallayout>
2366 <para>
2367 There is further detailed discussion about the various DBM libraries in the
2368 file <filename>doc/dbm.discuss.txt</filename> in the Exim distribution.
2369 </para>
2370 </section>
2371 <section id="SECID25">
2372 <title>Pre-building configuration</title>
2373 <para>
2374 <indexterm role="concept">
2375 <primary>building Exim</primary>
2376 <secondary>pre-building configuration</secondary>
2377 </indexterm>
2378 <indexterm role="concept">
2379 <primary>configuration for building Exim</primary>
2380 </indexterm>
2381 <indexterm role="concept">
2382 <primary><filename>Local/Makefile</filename></primary>
2383 </indexterm>
2384 <indexterm role="concept">
2385 <primary><filename>src/EDITME</filename></primary>
2386 </indexterm>
2387 Before building Exim, a local configuration file that specifies options
2388 independent of any operating system has to be created with the name
2389 <filename>Local/Makefile</filename>. A template for this file is supplied as the file
2390 <filename>src/EDITME</filename>, and it contains full descriptions of all the option settings
2391 therein. These descriptions are therefore not repeated here. If you are
2392 building Exim for the first time, the simplest thing to do is to copy
2393 <filename>src/EDITME</filename> to <filename>Local/Makefile</filename>, then read it and edit it appropriately.
2394 </para>
2395 <para>
2396 There are three settings that you must supply, because Exim will not build
2397 without them. They are the location of the run time configuration file
2398 (CONFIGURE_FILE), the directory in which Exim binaries will be installed
2399 (BIN_DIRECTORY), and the identity of the Exim user (EXIM_USER and
2400 maybe EXIM_GROUP as well). The value of CONFIGURE_FILE can in fact be
2401 a colon-separated list of file names; Exim uses the first of them that exists.
2402 </para>
2403 <para>
2404 There are a few other parameters that can be specified either at build time or
2405 at run time, to enable the same binary to be used on a number of different
2406 machines. However, if the locations of Exim&#x2019;s spool directory and log file
2407 directory (if not within the spool directory) are fixed, it is recommended that
2408 you specify them in <filename>Local/Makefile</filename> instead of at run time, so that errors
2409 detected early in Exim&#x2019;s execution (such as a malformed configuration file) can
2410 be logged.
2411 </para>
2412 <para>
2413 <indexterm role="concept">
2414 <primary>content scanning</primary>
2415 <secondary>specifying at build time</secondary>
2416 </indexterm>
2417 Exim&#x2019;s interfaces for calling virus and spam scanning software directly from
2418 access control lists are not compiled by default. If you want to include these
2419 facilities, you need to set
2420 </para>
2421 <literallayout class="monospaced">
2422 WITH_CONTENT_SCAN=yes
2423 </literallayout>
2424 <para>
2425 in your <filename>Local/Makefile</filename>. For details of the facilities themselves, see
2426 chapter <xref linkend="CHAPexiscan"/>.
2427 </para>
2428 <para>
2429 <indexterm role="concept">
2430 <primary><filename>Local/eximon.conf</filename></primary>
2431 </indexterm>
2432 <indexterm role="concept">
2433 <primary><filename>exim_monitor/EDITME</filename></primary>
2434 </indexterm>
2435 If you are going to build the Exim monitor, a similar configuration process is
2436 required. The file <filename>exim_monitor/EDITME</filename> must be edited appropriately for
2437 your installation and saved under the name <filename>Local/eximon.conf</filename>. If you are
2438 happy with the default settings described in <filename>exim_monitor/EDITME</filename>,
2439 <filename>Local/eximon.conf</filename> can be empty, but it must exist.
2440 </para>
2441 <para>
2442 This is all the configuration that is needed in straightforward cases for known
2443 operating systems. However, the building process is set up so that it is easy
2444 to override options that are set by default or by operating-system-specific
2445 configuration files, for example to change the name of the C compiler, which
2446 defaults to <option>gcc</option>. See section <xref linkend="SECToverride"/> below for details of how to
2447 do this.
2448 </para>
2449 </section>
2450 <section id="SECID26">
2451 <title>Support for iconv()</title>
2452 <para>
2453 <indexterm role="concept">
2454 <primary><function>iconv()</function> support</primary>
2455 </indexterm>
2456 <indexterm role="concept">
2457 <primary>RFC 2047</primary>
2458 </indexterm>
2459 The contents of header lines in messages may be encoded according to the rules
2460 described RFC 2047. This makes it possible to transmit characters that are not
2461 in the ASCII character set, and to label them as being in a particular
2462 character set. When Exim is inspecting header lines by means of the <option>$h_</option>
2463 mechanism, it decodes them, and translates them into a specified character set
2464 (default ISO-8859-1). The translation is possible only if the operating system
2465 supports the <function>iconv()</function> function.
2466 </para>
2467 <para>
2468 However, some of the operating systems that supply <function>iconv()</function> do not support
2469 very many conversions. The GNU <option>libiconv</option> library (available from
2470 <emphasis role="bold"><ulink url="http://www.gnu.org/software/libiconv/">http://www.gnu.org/software/libiconv/</ulink></emphasis>) can be installed on such
2471 systems to remedy this deficiency, as well as on systems that do not supply
2472 <function>iconv()</function> at all. After installing <option>libiconv</option>, you should add
2473 </para>
2474 <literallayout class="monospaced">
2475 HAVE_ICONV=yes
2476 </literallayout>
2477 <para>
2478 to your <filename>Local/Makefile</filename> and rebuild Exim.
2479 </para>
2480 </section>
2481 <section id="SECTinctlsssl">
2482 <title>Including TLS/SSL encryption support</title>
2483 <para>
2484 <indexterm role="concept">
2485 <primary>TLS</primary>
2486 <secondary>including support for TLS</secondary>
2487 </indexterm>
2488 <indexterm role="concept">
2489 <primary>encryption</primary>
2490 <secondary>including support for</secondary>
2491 </indexterm>
2492 <indexterm role="concept">
2493 <primary>SUPPORT_TLS</primary>
2494 </indexterm>
2495 <indexterm role="concept">
2496 <primary>OpenSSL</primary>
2497 <secondary>building Exim with</secondary>
2498 </indexterm>
2499 <indexterm role="concept">
2500 <primary>GnuTLS</primary>
2501 <secondary>building Exim with</secondary>
2502 </indexterm>
2503 Exim can be built to support encrypted SMTP connections, using the STARTTLS
2504 command as per RFC 2487. It can also support legacy clients that expect to
2505 start a TLS session immediately on connection to a non-standard port (see the
2506 <option>tls_on_connect_ports</option> runtime option and the <option>-tls-on-connect</option> command
2507 line option).
2508 </para>
2509 <para>
2510 If you want to build Exim with TLS support, you must first install either the
2511 OpenSSL or GnuTLS library. There is no cryptographic code in Exim itself for
2512 implementing SSL.
2513 </para>
2514 <para>
2515 If OpenSSL is installed, you should set
2516 </para>
2517 <literallayout class="monospaced">
2518 SUPPORT_TLS=yes
2519 TLS_LIBS=-lssl -lcrypto
2520 </literallayout>
2521 <para>
2522 in <filename>Local/Makefile</filename>. You may also need to specify the locations of the
2523 OpenSSL library and include files. For example:
2524 </para>
2525 <literallayout class="monospaced">
2526 SUPPORT_TLS=yes
2527 TLS_LIBS=-L/usr/local/openssl/lib -lssl -lcrypto
2528 TLS_INCLUDE=-I/usr/local/openssl/include/
2529 </literallayout>
2530 <para>
2531 <indexterm role="concept">
2532 <primary>USE_GNUTLS</primary>
2533 </indexterm>
2534 If GnuTLS is installed, you should set
2535 </para>
2536 <literallayout class="monospaced">
2537 SUPPORT_TLS=yes
2538 USE_GNUTLS=yes
2539 TLS_LIBS=-lgnutls -ltasn1 -lgcrypt
2540 </literallayout>
2541 <para>
2542 in <filename>Local/Makefile</filename>, and again you may need to specify the locations of the
2543 library and include files. For example:
2544 </para>
2545 <literallayout class="monospaced">
2546 SUPPORT_TLS=yes
2547 USE_GNUTLS=yes
2548 TLS_LIBS=-L/usr/gnu/lib -lgnutls -ltasn1 -lgcrypt
2549 TLS_INCLUDE=-I/usr/gnu/include
2550 </literallayout>
2551 <para>
2552 You do not need to set TLS_INCLUDE if the relevant directory is already
2553 specified in INCLUDE. Details of how to configure Exim to make use of TLS are
2554 given in chapter <xref linkend="CHAPTLS"/>.
2555 </para>
2556 </section>
2557 <section id="SECID27" revisionflag="changed">
2558 <title>Use of tcpwrappers</title>
2559 <para revisionflag="changed">
2560 <indexterm role="concept">
2561 <primary>tcpwrappers, building Exim to support</primary>
2562 </indexterm>
2563 <indexterm role="concept">
2564 <primary>USE_TCP_WRAPPERS</primary>
2565 </indexterm>
2566 <indexterm role="concept">
2567 <primary>TCP_WRAPPERS_DAEMON_NAME</primary>
2568 </indexterm>
2569 <indexterm role="concept">
2570 <primary>tcp_wrappers_daemon_name</primary>
2571 </indexterm>
2572 Exim can be linked with the <emphasis>tcpwrappers</emphasis> library in order to check incoming
2573 SMTP calls using the <emphasis>tcpwrappers</emphasis> control files. This may be a convenient
2574 alternative to Exim&#x2019;s own checking facilities for installations that are
2575 already making use of <emphasis>tcpwrappers</emphasis> for other purposes. To do this, you
2576 should set USE_TCP_WRAPPERS in <filename>Local/Makefile</filename>, arrange for the file
2577 <filename>tcpd.h</filename> to be available at compile time, and also ensure that the library
2578 <filename>libwrap.a</filename> is available at link time, typically by including <option>-lwrap</option> in
2579 EXTRALIBS_EXIM. For example, if <emphasis>tcpwrappers</emphasis> is installed in <filename>/usr/local</filename>,
2580 you might have
2581 </para>
2582 <literallayout class="monospaced" revisionflag="changed">
2583 USE_TCP_WRAPPERS=yes
2584 CFLAGS=-O -I/usr/local/include
2585 EXTRALIBS_EXIM=-L/usr/local/lib -lwrap
2586 </literallayout>
2587 <para revisionflag="changed">
2588 in <filename>Local/Makefile</filename>. The daemon name to use in the <emphasis>tcpwrappers</emphasis> control
2589 files is <quote>exim</quote>. For example, the line
2590 </para>
2591 <literallayout class="monospaced" revisionflag="changed">
2592 exim : LOCAL  192.168.1.  .friendly.domain.example
2593 </literallayout>
2594 <para revisionflag="changed">
2595 in your <filename>/etc/hosts.allow</filename> file allows connections from the local host, from
2596 the subnet 192.168.1.0/24, and from all hosts in <emphasis>friendly.domain.example</emphasis>.
2597 All other connections are denied. The daemon name used by <emphasis>tcpwrappers</emphasis>
2598 can be changed at build time by setting TCP_WRAPPERS_DAEMON_NAME in
2599 in <filename>Local/Makefile</filename>, or by setting tcp_wrappers_daemon_name in the
2600 configure file. Consult the <emphasis>tcpwrappers</emphasis> documentation for
2601 further details.
2602 </para>
2603 </section>
2604 <section id="SECID28">
2605 <title>Including support for IPv6</title>
2606 <para>
2607 <indexterm role="concept">
2608 <primary>IPv6</primary>
2609 <secondary>including support for</secondary>
2610 </indexterm>
2611 Exim contains code for use on systems that have IPv6 support. Setting
2612 <literal>HAVE_IPV6=YES</literal> in <filename>Local/Makefile</filename> causes the IPv6 code to be included;
2613 it may also be necessary to set IPV6_INCLUDE and IPV6_LIBS on systems
2614 where the IPv6 support is not fully integrated into the normal include and
2615 library files.
2616 </para>
2617 <para>
2618 Two different types of DNS record for handling IPv6 addresses have been
2619 defined. AAAA records (analogous to A records for IPv4) are in use, and are
2620 currently seen as the mainstream. Another record type called A6 was proposed
2621 as better than AAAA because it had more flexibility. However, it was felt to be
2622 over-complex, and its status was reduced to <quote>experimental</quote>. It is not known
2623 if anyone is actually using A6 records. Exim has support for A6 records, but
2624 this is included only if you set <literal>SUPPORT_A6=YES</literal> in <filename>Local/Makefile</filename>. The
2625 support has not been tested for some time.
2626 </para>
2627 </section>
2628 <section id="SECTdynamicmodules" revisionflag="changed">
2629 <title>Dynamically loaded lookup module support</title>
2630 <para revisionflag="changed">
2631 <indexterm role="concept">
2632 <primary>lookup modules</primary>
2633 </indexterm>
2634 <indexterm role="concept">
2635 <primary>dynamic modules</primary>
2636 </indexterm>
2637 <indexterm role="concept">
2638 <primary>.so building</primary>
2639 </indexterm>
2640 On some platforms, Exim supports not compiling all lookup types directly into
2641 the main binary, instead putting some into external modules which can be loaded
2642 on demand.
2643 This permits packagers to build Exim with support for lookups with extensive
2644 library dependencies without requiring all users to install all of those
2645 dependencies.
2646 Most, but not all, lookup types can be built this way.
2647 </para>
2648 <para revisionflag="changed">
2649 Set <literal>LOOKUP_MODULE_DIR</literal> to the directory into which the modules will be
2650 installed; Exim will only load modules from that directory, as a security
2651 measure.  You will need to set <literal>CFLAGS_DYNAMIC</literal> if not already defined
2652 for your OS; see <filename>OS/Makefile-Linux</filename> for an example.
2653 Some other requirements for adjusting <literal>EXTRALIBS</literal> may also be necessary,
2654 see <filename>src/EDITME</filename> for details.
2655 </para>
2656 <para revisionflag="changed">
2657 Then, for each module to be loaded dynamically, define the relevant
2658 <literal>LOOKUP_</literal>&lt;<emphasis>lookup_type</emphasis>&gt; flags to have the value "2" instead of "yes".
2659 For example, this will build in lsearch but load sqlite and mysql support
2660 on demand:
2661 </para>
2662 <literallayout class="monospaced" revisionflag="changed">
2663 LOOKUP_LSEARCH=yes
2664 LOOKUP_SQLITE=2
2665 LOOKUP_MYSQL=2
2666 </literallayout>
2667 </section>
2668 <section id="SECID29">
2669 <title>The building process</title>
2670 <para>
2671 <indexterm role="concept">
2672 <primary>build directory</primary>
2673 </indexterm>
2674 Once <filename>Local/Makefile</filename> (and <filename>Local/eximon.conf</filename>, if required) have been
2675 created, run <emphasis>make</emphasis> at the top level. It determines the architecture and
2676 operating system types, and creates a build directory if one does not exist.
2677 For example, on a Sun system running Solaris 8, the directory
2678 <filename>build-SunOS5-5.8-sparc</filename> is created.
2679 <indexterm role="concept">
2680 <primary>symbolic link</primary>
2681 <secondary>to source files</secondary>
2682 </indexterm>
2683 Symbolic links to relevant source files are installed in the build directory.
2684 </para>
2685 <para>
2686 <emphasis role="bold">Warning</emphasis>: The <option>-j</option> (parallel) flag must not be used with <emphasis>make</emphasis>; the
2687 building process fails if it is set.
2688 </para>
2689 <para>
2690 If this is the first time <emphasis>make</emphasis> has been run, it calls a script that builds
2691 a make file inside the build directory, using the configuration files from the
2692 <filename>Local</filename> directory. The new make file is then passed to another instance of
2693 <emphasis>make</emphasis>. This does the real work, building a number of utility scripts, and
2694 then compiling and linking the binaries for the Exim monitor (if configured), a
2695 number of utility programs, and finally Exim itself. The command <literal>make
2696 makefile</literal> can be used to force a rebuild of the make file in the build
2697 directory, should this ever be necessary.
2698 </para>
2699 <para>
2700 If you have problems building Exim, check for any comments there may be in the
2701 <filename>README</filename> file concerning your operating system, and also take a look at the
2702 FAQ, where some common problems are covered.
2703 </para>
2704 </section>
2705 <section id="SECID283">
2706 <title>Output from <quote>make</quote></title>
2707 <para>
2708 The output produced by the <emphasis>make</emphasis> process for compile lines is often very
2709 unreadable, because these lines can be very long. For this reason, the normal
2710 output is suppressed by default, and instead output similar to that which
2711 appears when compiling the 2.6 Linux kernel is generated: just a short line for
2712 each module that is being compiled or linked. However, it is still possible to
2713 get the full output, by calling <emphasis>make</emphasis> like this:
2714 </para>
2715 <literallayout class="monospaced">
2716 FULLECHO='' make -e
2717 </literallayout>
2718 <para>
2719 The value of FULLECHO defaults to <quote>@</quote>, the flag character that suppresses
2720 command reflection in <emphasis>make</emphasis>. When you ask for the full output, it is
2721 given in addition to the short output.
2722 </para>
2723 </section>
2724 <section id="SECToverride">
2725 <title>Overriding build-time options for Exim</title>
2726 <para>
2727 <indexterm role="concept">
2728 <primary>build-time options, overriding</primary>
2729 </indexterm>
2730 The main make file that is created at the beginning of the building process
2731 consists of the concatenation of a number of files which set configuration
2732 values, followed by a fixed set of <emphasis>make</emphasis> instructions. If a value is set
2733 more than once, the last setting overrides any previous ones. This provides a
2734 convenient way of overriding defaults. The files that are concatenated are, in
2735 order:
2736 </para>
2737 <literallayout>
2738 <filename>OS/Makefile-Default</filename>
2739 <filename>OS/Makefile-</filename>&lt;<emphasis>ostype</emphasis>&gt;
2740 <filename>Local/Makefile</filename>
2741 <filename>Local/Makefile-</filename>&lt;<emphasis>ostype</emphasis>&gt;
2742 <filename>Local/Makefile-</filename>&lt;<emphasis>archtype</emphasis>&gt;
2743 <filename>Local/Makefile-</filename>&lt;<emphasis>ostype</emphasis>&gt;-&lt;<emphasis>archtype</emphasis>&gt;
2744 <filename>OS/Makefile-Base</filename>
2745 </literallayout>
2746 <para>
2747 <indexterm role="concept">
2748 <primary><filename>Local/Makefile</filename></primary>
2749 </indexterm>
2750 <indexterm role="concept">
2751 <primary>building Exim</primary>
2752 <secondary>operating system type</secondary>
2753 </indexterm>
2754 <indexterm role="concept">
2755 <primary>building Exim</primary>
2756 <secondary>architecture type</secondary>
2757 </indexterm>
2758 where &lt;<emphasis>ostype</emphasis>&gt; is the operating system type and &lt;<emphasis>archtype</emphasis>&gt; is the
2759 architecture type. <filename>Local/Makefile</filename> is required to exist, and the building
2760 process fails if it is absent. The other three <filename>Local</filename> files are optional,
2761 and are often not needed.
2762 </para>
2763 <para>
2764 The values used for &lt;<emphasis>ostype</emphasis>&gt; and &lt;<emphasis>archtype</emphasis>&gt; are obtained from scripts
2765 called <filename>scripts/os-type</filename> and <filename>scripts/arch-type</filename> respectively. If either of
2766 the environment variables EXIM_OSTYPE or EXIM_ARCHTYPE is set, their
2767 values are used, thereby providing a means of forcing particular settings.
2768 Otherwise, the scripts try to get values from the <option>uname</option> command. If this
2769 fails, the shell variables OSTYPE and ARCHTYPE are inspected. A number
2770 of <emphasis>ad hoc</emphasis> transformations are then applied, to produce the standard names
2771 that Exim expects. You can run these scripts directly from the shell in order
2772 to find out what values are being used on your system.
2773 </para>
2774 <para>
2775 <filename>OS/Makefile-Default</filename> contains comments about the variables that are set
2776 therein. Some (but not all) are mentioned below. If there is something that
2777 needs changing, review the contents of this file and the contents of the make
2778 file for your operating system (<filename>OS/Makefile-&lt;ostype&gt;</filename>) to see what the
2779 default values are.
2780 </para>
2781 <para>
2782 <indexterm role="concept">
2783 <primary>building Exim</primary>
2784 <secondary>overriding default settings</secondary>
2785 </indexterm>
2786 If you need to change any of the values that are set in <filename>OS/Makefile-Default</filename>
2787 or in <filename>OS/Makefile-&lt;ostype&gt;</filename>, or to add any new definitions, you do not
2788 need to change the original files. Instead, you should make the changes by
2789 putting the new values in an appropriate <filename>Local</filename> file. For example,
2790 <indexterm role="concept">
2791 <primary>Tru64-Unix build-time settings</primary>
2792 </indexterm>
2793 when building Exim in many releases of the Tru64-Unix (formerly Digital UNIX,
2794 formerly DEC-OSF1) operating system, it is necessary to specify that the C
2795 compiler is called <emphasis>cc</emphasis> rather than <emphasis>gcc</emphasis>. Also, the compiler must be
2796 called with the option <option>-std1</option>, to make it recognize some of the features of
2797 Standard C that Exim uses. (Most other compilers recognize Standard C by
2798 default.) To do this, you should create a file called <filename>Local/Makefile-OSF1</filename>
2799 containing the lines
2800 </para>
2801 <literallayout class="monospaced">
2802 CC=cc
2803 CFLAGS=-std1
2804 </literallayout>
2805 <para>
2806 If you are compiling for just one operating system, it may be easier to put
2807 these lines directly into <filename>Local/Makefile</filename>.
2808 </para>
2809 <para>
2810 Keeping all your local configuration settings separate from the distributed
2811 files makes it easy to transfer them to new versions of Exim simply by copying
2812 the contents of the <filename>Local</filename> directory.
2813 </para>
2814 <para>
2815 <indexterm role="concept">
2816 <primary>NIS lookup type</primary>
2817 <secondary>including support for</secondary>
2818 </indexterm>
2819 <indexterm role="concept">
2820 <primary>NIS+ lookup type</primary>
2821 <secondary>including support for</secondary>
2822 </indexterm>
2823 <indexterm role="concept">
2824 <primary>LDAP</primary>
2825 <secondary>including support for</secondary>
2826 </indexterm>
2827 <indexterm role="concept">
2828 <primary>lookup</primary>
2829 <secondary>inclusion in binary</secondary>
2830 </indexterm>
2831 Exim contains support for doing LDAP, NIS, NIS+, and other kinds of file
2832 lookup, but not all systems have these components installed, so the default is
2833 not to include the relevant code in the binary. All the different kinds of file
2834 and database lookup that Exim supports are implemented as separate code modules
2835 which are included only if the relevant compile-time options are set. In the
2836 case of LDAP, NIS, and NIS+, the settings for <filename>Local/Makefile</filename> are:
2837 </para>
2838 <literallayout class="monospaced">
2839 LOOKUP_LDAP=yes
2840 LOOKUP_NIS=yes
2841 LOOKUP_NISPLUS=yes
2842 </literallayout>
2843 <para>
2844 and similar settings apply to the other lookup types. They are all listed in
2845 <filename>src/EDITME</filename>. In many cases the relevant include files and interface
2846 libraries need to be installed before compiling Exim.
2847 <indexterm role="concept">
2848 <primary>cdb</primary>
2849 <secondary>including support for</secondary>
2850 </indexterm>
2851 However, there are some optional lookup types (such as cdb) for which
2852 the code is entirely contained within Exim, and no external include
2853 files or libraries are required. When a lookup type is not included in the
2854 binary, attempts to configure Exim to use it cause run time configuration
2855 errors.
2856 </para>
2857 <para>
2858 <indexterm role="concept">
2859 <primary>Perl</primary>
2860 <secondary>including support for</secondary>
2861 </indexterm>
2862 Exim can be linked with an embedded Perl interpreter, allowing Perl
2863 subroutines to be called during string expansion. To enable this facility,
2864 </para>
2865 <literallayout class="monospaced">
2866 EXIM_PERL=perl.o
2867 </literallayout>
2868 <para>
2869 must be defined in <filename>Local/Makefile</filename>. Details of this facility are given in
2870 chapter <xref linkend="CHAPperl"/>.
2871 </para>
2872 <para>
2873 <indexterm role="concept">
2874 <primary>X11 libraries, location of</primary>
2875 </indexterm>
2876 The location of the X11 libraries is something that varies a lot between
2877 operating systems, and there may be different versions of X11 to cope
2878 with. Exim itself makes no use of X11, but if you are compiling the Exim
2879 monitor, the X11 libraries must be available.
2880 The following three variables are set in <filename>OS/Makefile-Default</filename>:
2881 </para>
2882 <literallayout class="monospaced">
2883 X11=/usr/X11R6
2884 XINCLUDE=-I$(X11)/include
2885 XLFLAGS=-L$(X11)/lib
2886 </literallayout>
2887 <para>
2888 These are overridden in some of the operating-system configuration files. For
2889 example, in <filename>OS/Makefile-SunOS5</filename> there is
2890 </para>
2891 <literallayout class="monospaced">
2892 X11=/usr/openwin
2893 XINCLUDE=-I$(X11)/include
2894 XLFLAGS=-L$(X11)/lib -R$(X11)/lib
2895 </literallayout>
2896 <para>
2897 If you need to override the default setting for your operating system, place a
2898 definition of all three of these variables into your
2899 <filename>Local/Makefile-&lt;ostype&gt;</filename> file.
2900 </para>
2901 <para>
2902 <indexterm role="concept">
2903 <primary>EXTRALIBS</primary>
2904 </indexterm>
2905 If you need to add any extra libraries to the link steps, these can be put in a
2906 variable called EXTRALIBS, which appears in all the link commands, but by
2907 default is not defined. In contrast, EXTRALIBS_EXIM is used only on the
2908 command for linking the main Exim binary, and not for any associated utilities.
2909 </para>
2910 <para>
2911 <indexterm role="concept">
2912 <primary>DBM libraries</primary>
2913 <secondary>configuration for building</secondary>
2914 </indexterm>
2915 There is also DBMLIB, which appears in the link commands for binaries that
2916 use DBM functions (see also section <xref linkend="SECTdb"/>). Finally, there is
2917 EXTRALIBS_EXIMON, which appears only in the link step for the Exim monitor
2918 binary, and which can be used, for example, to include additional X11
2919 libraries.
2920 </para>
2921 <para>
2922 <indexterm role="concept">
2923 <primary>configuration file</primary>
2924 <secondary>editing</secondary>
2925 </indexterm>
2926 The make file copes with rebuilding Exim correctly if any of the configuration
2927 files are edited. However, if an optional configuration file is deleted, it is
2928 necessary to touch the associated non-optional file (that is,
2929 <filename>Local/Makefile</filename> or <filename>Local/eximon.conf</filename>) before rebuilding.
2930 </para>
2931 </section>
2932 <section id="SECID30">
2933 <title>OS-specific header files</title>
2934 <para>
2935 <indexterm role="concept">
2936 <primary><filename>os.h</filename></primary>
2937 </indexterm>
2938 <indexterm role="concept">
2939 <primary>building Exim</primary>
2940 <secondary>OS-specific C header files</secondary>
2941 </indexterm>
2942 The <filename>OS</filename> directory contains a number of files with names of the form
2943 <filename>os.h-&lt;ostype&gt;</filename>. These are system-specific C header files that should not
2944 normally need to be changed. There is a list of macro settings that are
2945 recognized in the file <filename>OS/os.configuring</filename>, which should be consulted if you
2946 are porting Exim to a new operating system.
2947 </para>
2948 </section>
2949 <section id="SECID31">
2950 <title>Overriding build-time options for the monitor</title>
2951 <para>
2952 <indexterm role="concept">
2953 <primary>building Eximon</primary>
2954 </indexterm>
2955 A similar process is used for overriding things when building the Exim monitor,
2956 where the files that are involved are
2957 </para>
2958 <literallayout>
2959 <filename>OS/eximon.conf-Default</filename>
2960 <filename>OS/eximon.conf-</filename>&lt;<emphasis>ostype</emphasis>&gt;
2961 <filename>Local/eximon.conf</filename>
2962 <filename>Local/eximon.conf-</filename>&lt;<emphasis>ostype</emphasis>&gt;
2963 <filename>Local/eximon.conf-</filename>&lt;<emphasis>archtype</emphasis>&gt;
2964 <filename>Local/eximon.conf-</filename>&lt;<emphasis>ostype</emphasis>&gt;-&lt;<emphasis>archtype</emphasis>&gt;
2965 </literallayout>
2966 <para>
2967 <indexterm role="concept">
2968 <primary><filename>Local/eximon.conf</filename></primary>
2969 </indexterm>
2970 As with Exim itself, the final three files need not exist, and in this case the
2971 <filename>OS/eximon.conf-&lt;ostype&gt;</filename> file is also optional. The default values in
2972 <filename>OS/eximon.conf-Default</filename> can be overridden dynamically by setting environment
2973 variables of the same name, preceded by EXIMON_. For example, setting
2974 EXIMON_LOG_DEPTH in the environment overrides the value of
2975 LOG_DEPTH at run time.
2976 <indexterm role="concept" startref="IIDbuex" class="endofrange"/>
2977 </para>
2978 </section>
2979 <section id="SECID32">
2980 <title>Installing Exim binaries and scripts</title>
2981 <para>
2982 <indexterm role="concept">
2983 <primary>installing Exim</primary>
2984 </indexterm>
2985 <indexterm role="concept">
2986 <primary>BIN_DIRECTORY</primary>
2987 </indexterm>
2988 The command <literal>make install</literal> runs the <command>exim_install</command> script with no
2989 arguments. The script copies binaries and utility scripts into the directory
2990 whose name is specified by the BIN_DIRECTORY setting in <filename>Local/Makefile</filename>.
2991 <indexterm role="concept">
2992 <primary>setuid</primary>
2993 <secondary>installing Exim with</secondary>
2994 </indexterm>
2995 The install script copies files only if they are newer than the files they are
2996 going to replace. The Exim binary is required to be owned by root and have the
2997 <emphasis>setuid</emphasis> bit set, for normal configurations. Therefore, you must run <literal>make
2998 install</literal> as root so that it can set up the Exim binary in this way. However, in
2999 some special situations (for example, if a host is doing no local deliveries)
3000 it may be possible to run Exim without making the binary setuid root (see
3001 chapter <xref linkend="CHAPsecurity"/> for details).
3002 </para>
3003 <para>
3004 <indexterm role="concept">
3005 <primary>CONFIGURE_FILE</primary>
3006 </indexterm>
3007 Exim&#x2019;s run time configuration file is named by the CONFIGURE_FILE setting
3008 in <filename>Local/Makefile</filename>. If this names a single file, and the file does not
3009 exist, the default configuration file <filename>src/configure.default</filename> is copied there
3010 by the installation script. If a run time configuration file already exists, it
3011 is left alone. If CONFIGURE_FILE is a colon-separated list, naming several
3012 alternative files, no default is installed.
3013 </para>
3014 <para>
3015 <indexterm role="concept">
3016 <primary>system aliases file</primary>
3017 </indexterm>
3018 <indexterm role="concept">
3019 <primary><filename>/etc/aliases</filename></primary>
3020 </indexterm>
3021 One change is made to the default configuration file when it is installed: the
3022 default configuration contains a router that references a system aliases file.
3023 The path to this file is set to the value specified by
3024 SYSTEM_ALIASES_FILE in <filename>Local/Makefile</filename> (<filename>/etc/aliases</filename> by default).
3025 If the system aliases file does not exist, the installation script creates it,
3026 and outputs a comment to the user.
3027 </para>
3028 <para>
3029 The created file contains no aliases, but it does contain comments about the
3030 aliases a site should normally have. Mail aliases have traditionally been
3031 kept in <filename>/etc/aliases</filename>. However, some operating systems are now using
3032 <filename>/etc/mail/aliases</filename>. You should check if yours is one of these, and change
3033 Exim&#x2019;s configuration if necessary.
3034 </para>
3035 <para>
3036 The default configuration uses the local host&#x2019;s name as the only local domain,
3037 and is set up to do local deliveries into the shared directory <filename>/var/mail</filename>,
3038 running as the local user. System aliases and <filename>.forward</filename> files in users&#x2019; home
3039 directories are supported, but no NIS or NIS+ support is configured. Domains
3040 other than the name of the local host are routed using the DNS, with delivery
3041 over SMTP.
3042 </para>
3043 <para>
3044 It is possible to install Exim for special purposes (such as building a binary
3045 distribution) in a private part of the file system. You can do this by a
3046 command such as
3047 </para>
3048 <literallayout class="monospaced">
3049 make DESTDIR=/some/directory/ install
3050 </literallayout>
3051 <para>
3052 This has the effect of pre-pending the specified directory to all the file
3053 paths, except the name of the system aliases file that appears in the default
3054 configuration. (If a default alias file is created, its name <emphasis>is</emphasis> modified.)
3055 For backwards compatibility, ROOT is used if DESTDIR is not set,
3056 but this usage is deprecated.
3057 </para>
3058 <para>
3059 <indexterm role="concept">
3060 <primary>installing Exim</primary>
3061 <secondary>what is not installed</secondary>
3062 </indexterm>
3063 Running <emphasis>make install</emphasis> does not copy the Exim 4 conversion script
3064 <emphasis>convert4r4</emphasis>. You will probably run this only once if you are
3065 upgrading from Exim 3. None of the documentation files in the <filename>doc</filename>
3066 directory are copied, except for the info files when you have set
3067 INFO_DIRECTORY, as described in section <xref linkend="SECTinsinfdoc"/> below.
3068 </para>
3069 <para>
3070 For the utility programs, old versions are renamed by adding the suffix <filename>.O</filename>
3071 to their names. The Exim binary itself, however, is handled differently. It is
3072 installed under a name that includes the version number and the compile number,
3073 for example <filename>exim-4.74-1</filename>. The script then arranges for a symbolic link
3074 called <filename>exim</filename> to point to the binary. If you are updating a previous version
3075 of Exim, the script takes care to ensure that the name <filename>exim</filename> is never absent
3076 from the directory (as seen by other processes).
3077 </para>
3078 <para>
3079 <indexterm role="concept">
3080 <primary>installing Exim</primary>
3081 <secondary>testing the script</secondary>
3082 </indexterm>
3083 If you want to see what the <emphasis>make install</emphasis> will do before running it for
3084 real, you can pass the <option>-n</option> option to the installation script by this
3085 command:
3086 </para>
3087 <literallayout class="monospaced">
3088 make INSTALL_ARG=-n install
3089 </literallayout>
3090 <para>
3091 The contents of the variable INSTALL_ARG are passed to the installation
3092 script. You do not need to be root to run this test. Alternatively, you can run
3093 the installation script directly, but this must be from within the build
3094 directory. For example, from the top-level Exim directory you could use this
3095 command:
3096 </para>
3097 <literallayout class="monospaced">
3098 (cd build-SunOS5-5.5.1-sparc; ../scripts/exim_install -n)
3099 </literallayout>
3100 <para>
3101 <indexterm role="concept">
3102 <primary>installing Exim</primary>
3103 <secondary>install script options</secondary>
3104 </indexterm>
3105 There are two other options that can be supplied to the installation script.
3106 </para>
3107 <itemizedlist>
3108 <listitem>
3109 <para>
3110 <option>-no_chown</option> bypasses the call to change the owner of the installed binary
3111 to root, and the call to make it a setuid binary.
3112 </para>
3113 </listitem>
3114 <listitem>
3115 <para>
3116 <option>-no_symlink</option> bypasses the setting up of the symbolic link <filename>exim</filename> to the
3117 installed binary.
3118 </para>
3119 </listitem>
3120 </itemizedlist>
3121 <para>
3122 INSTALL_ARG can be used to pass these options to the script. For example:
3123 </para>
3124 <literallayout class="monospaced">
3125 make INSTALL_ARG=-no_symlink install
3126 </literallayout>
3127 <para>
3128 The installation script can also be given arguments specifying which files are
3129 to be copied. For example, to install just the Exim binary, and nothing else,
3130 without creating the symbolic link, you could use:
3131 </para>
3132 <literallayout class="monospaced">
3133 make INSTALL_ARG='-no_symlink exim' install
3134 </literallayout>
3135 </section>
3136 <section id="SECTinsinfdoc">
3137 <title>Installing info documentation</title>
3138 <para>
3139 <indexterm role="concept">
3140 <primary>installing Exim</primary>
3141 <secondary><emphasis>info</emphasis> documentation</secondary>
3142 </indexterm>
3143 Not all systems use the GNU <emphasis>info</emphasis> system for documentation, and for this
3144 reason, the Texinfo source of Exim&#x2019;s documentation is not included in the main
3145 distribution. Instead it is available separately from the ftp site (see section
3146 <xref linkend="SECTavail"/>).
3147 </para>
3148 <para>
3149 If you have defined INFO_DIRECTORY in <filename>Local/Makefile</filename> and the Texinfo
3150 source of the documentation is found in the source tree, running <literal>make
3151 install</literal> automatically builds the info files and installs them.
3152 </para>
3153 </section>
3154 <section id="SECID33">
3155 <title>Setting up the spool directory</title>
3156 <para>
3157 <indexterm role="concept">
3158 <primary>spool directory</primary>
3159 <secondary>creating</secondary>
3160 </indexterm>
3161 When it starts up, Exim tries to create its spool directory if it does not
3162 exist. The Exim uid and gid are used for the owner and group of the spool
3163 directory. Sub-directories are automatically created in the spool directory as
3164 necessary.
3165 </para>
3166 </section>
3167 <section id="SECID34">
3168 <title>Testing</title>
3169 <para>
3170 <indexterm role="concept">
3171 <primary>testing</primary>
3172 <secondary>installation</secondary>
3173 </indexterm>
3174 Having installed Exim, you can check that the run time configuration file is
3175 syntactically valid by running the following command, which assumes that the
3176 Exim binary directory is within your PATH environment variable:
3177 </para>
3178 <literallayout class="monospaced">
3179 exim -bV
3180 </literallayout>
3181 <para>
3182 If there are any errors in the configuration file, Exim outputs error messages.
3183 Otherwise it outputs the version number and build date,
3184 the DBM library that is being used, and information about which drivers and
3185 other optional code modules are included in the binary.
3186 Some simple routing tests can be done by using the address testing option. For
3187 example,
3188 </para>
3189 <literallayout>
3190 <literal>exim -bt</literal> &lt;<emphasis>local username</emphasis>&gt;
3191 </literallayout>
3192 <para>
3193 should verify that it recognizes a local mailbox, and
3194 </para>
3195 <literallayout>
3196 <literal>exim -bt</literal> &lt;<emphasis>remote address</emphasis>&gt;
3197 </literallayout>
3198 <para>
3199 a remote one. Then try getting it to deliver mail, both locally and remotely.
3200 This can be done by passing messages directly to Exim, without going through a
3201 user agent. For example:
3202 </para>
3203 <literallayout class="monospaced">
3204 exim -v postmaster@your.domain.example
3205 From: user@your.domain.example
3206 To: postmaster@your.domain.example
3207 Subject: Testing Exim
3208
3209 This is a test message.
3210 ^D
3211 </literallayout>
3212 <para>
3213 The <option>-v</option> option causes Exim to output some verification of what it is doing.
3214 In this case you should see copies of three log lines, one for the message&#x2019;s
3215 arrival, one for its delivery, and one containing <quote>Completed</quote>.
3216 </para>
3217 <para>
3218 <indexterm role="concept">
3219 <primary>delivery</primary>
3220 <secondary>problems with</secondary>
3221 </indexterm>
3222 If you encounter problems, look at Exim&#x2019;s log files (<emphasis>mainlog</emphasis> and
3223 <emphasis>paniclog</emphasis>) to see if there is any relevant information there. Another source
3224 of information is running Exim with debugging turned on, by specifying the
3225 <option>-d</option> option. If a message is stuck on Exim&#x2019;s spool, you can force a delivery
3226 with debugging turned on by a command of the form
3227 </para>
3228 <literallayout>
3229 <literal>exim -d -M</literal> &lt;<emphasis>exim-message-id</emphasis>&gt;
3230 </literallayout>
3231 <para>
3232 You must be root or an <quote>admin user</quote> in order to do this. The <option>-d</option> option
3233 produces rather a lot of output, but you can cut this down to specific areas.
3234 For example, if you use <option>-d-all+route</option> only the debugging information
3235 relevant to routing is included. (See the <option>-d</option> option in chapter
3236 <xref linkend="CHAPcommandline"/> for more details.)
3237 </para>
3238 <para>
3239 <indexterm role="concept">
3240 <primary><quote>sticky</quote> bit</primary>
3241 </indexterm>
3242 <indexterm role="concept">
3243 <primary>lock files</primary>
3244 </indexterm>
3245 One specific problem that has shown up on some sites is the inability to do
3246 local deliveries into a shared mailbox directory, because it does not have the
3247 <quote>sticky bit</quote> set on it. By default, Exim tries to create a lock file before
3248 writing to a mailbox file, and if it cannot create the lock file, the delivery
3249 is deferred. You can get round this either by setting the <quote>sticky bit</quote> on the
3250 directory, or by setting a specific group for local deliveries and allowing
3251 that group to create files in the directory (see the comments above the
3252 <command>local_delivery</command> transport in the default configuration file). Another
3253 approach is to configure Exim not to use lock files, but just to rely on
3254 <function>fcntl()</function> locking instead. However, you should do this only if all user
3255 agents also use <function>fcntl()</function> locking. For further discussion of locking issues,
3256 see chapter <xref linkend="CHAPappendfile"/>.
3257 </para>
3258 <para>
3259 One thing that cannot be tested on a system that is already running an MTA is
3260 the receipt of incoming SMTP mail on the standard SMTP port. However, the
3261 <option>-oX</option> option can be used to run an Exim daemon that listens on some other
3262 port, or <emphasis>inetd</emphasis> can be used to do this. The <option>-bh</option> option and the
3263 <emphasis>exim_checkaccess</emphasis> utility can be used to check out policy controls on
3264 incoming SMTP mail.
3265 </para>
3266 <para>
3267 Testing a new version on a system that is already running Exim can most easily
3268 be done by building a binary with a different CONFIGURE_FILE setting. From
3269 within the run time configuration, all other file and directory names
3270 that Exim uses can be altered, in order to keep it entirely clear of the
3271 production version.
3272 </para>
3273 </section>
3274 <section id="SECID35">
3275 <title>Replacing another MTA with Exim</title>
3276 <para>
3277 <indexterm role="concept">
3278 <primary>replacing another MTA</primary>
3279 </indexterm>
3280 Building and installing Exim for the first time does not of itself put it in
3281 general use. The name by which the system&#x2019;s MTA is called by mail user agents
3282 is either <filename>/usr/sbin/sendmail</filename>, or <filename>/usr/lib/sendmail</filename> (depending on the
3283 operating system), and it is necessary to make this name point to the <emphasis>exim</emphasis>
3284 binary in order to get the user agents to pass messages to Exim. This is
3285 normally done by renaming any existing file and making <filename>/usr/sbin/sendmail</filename>
3286 or <filename>/usr/lib/sendmail</filename>
3287 <indexterm role="concept">
3288 <primary>symbolic link</primary>
3289 <secondary>to <emphasis>exim</emphasis> binary</secondary>
3290 </indexterm>
3291 a symbolic link to the <emphasis>exim</emphasis> binary. It is a good idea to remove any setuid
3292 privilege and executable status from the old MTA. It is then necessary to stop
3293 and restart the mailer daemon, if one is running.
3294 </para>
3295 <para>
3296 <indexterm role="concept">
3297 <primary>FreeBSD, MTA indirection</primary>
3298 </indexterm>
3299 <indexterm role="concept">
3300 <primary><filename>/etc/mail/mailer.conf</filename></primary>
3301 </indexterm>
3302 Some operating systems have introduced alternative ways of switching MTAs. For
3303 example, if you are running FreeBSD, you need to edit the file
3304 <filename>/etc/mail/mailer.conf</filename> instead of setting up a symbolic link as just
3305 described. A typical example of the contents of this file for running Exim is
3306 as follows:
3307 </para>
3308 <literallayout class="monospaced">
3309 sendmail            /usr/exim/bin/exim
3310 send-mail           /usr/exim/bin/exim
3311 mailq               /usr/exim/bin/exim -bp
3312 newaliases          /usr/bin/true
3313 </literallayout>
3314 <para>
3315 Once you have set up the symbolic link, or edited <filename>/etc/mail/mailer.conf</filename>,
3316 your Exim installation is <quote>live</quote>. Check it by sending a message from your
3317 favourite user agent.
3318 </para>
3319 <para>
3320 You should consider what to tell your users about the change of MTA. Exim may
3321 have different capabilities to what was previously running, and there are
3322 various operational differences such as the text of messages produced by
3323 command line options and in bounce messages. If you allow your users to make
3324 use of Exim&#x2019;s filtering capabilities, you should make the document entitled
3325 <emphasis>Exim&#x2019;s interface to mail filtering</emphasis> available to them.
3326 </para>
3327 </section>
3328 <section id="SECID36">
3329 <title>Upgrading Exim</title>
3330 <para>
3331 <indexterm role="concept">
3332 <primary>upgrading Exim</primary>
3333 </indexterm>
3334 If you are already running Exim on your host, building and installing a new
3335 version automatically makes it available to MUAs, or any other programs that
3336 call the MTA directly. However, if you are running an Exim daemon, you do need
3337 to send it a HUP signal, to make it re-execute itself, and thereby pick up the
3338 new binary. You do not need to stop processing mail in order to install a new
3339 version of Exim. The install script does not modify an existing runtime
3340 configuration file.
3341 </para>
3342 </section>
3343 <section id="SECID37">
3344 <title>Stopping the Exim daemon on Solaris</title>
3345 <para>
3346 <indexterm role="concept">
3347 <primary>Solaris</primary>
3348 <secondary>stopping Exim on</secondary>
3349 </indexterm>
3350 The standard command for stopping the mailer daemon on Solaris is
3351 </para>
3352 <literallayout class="monospaced">
3353 /etc/init.d/sendmail stop
3354 </literallayout>
3355 <para>
3356 If <filename>/usr/lib/sendmail</filename> has been turned into a symbolic link, this script
3357 fails to stop Exim because it uses the command <emphasis>ps -e</emphasis> and greps the output
3358 for the text <quote>sendmail</quote>; this is not present because the actual program name
3359 (that is, <quote>exim</quote>) is given by the <emphasis>ps</emphasis> command with these options. A
3360 solution is to replace the line that finds the process id with something like
3361 </para>
3362 <literallayout class="monospaced">
3363 pid=`cat /var/spool/exim/exim-daemon.pid`
3364 </literallayout>
3365 <para>
3366 to obtain the daemon&#x2019;s pid directly from the file that Exim saves it in.
3367 </para>
3368 <para>
3369 Note, however, that stopping the daemon does not <quote>stop Exim</quote>. Messages can
3370 still be received from local processes, and if automatic delivery is configured
3371 (the normal case), deliveries will still occur.
3372 </para>
3373 </section>
3374 </chapter>
3375
3376 <chapter id="CHAPcommandline">
3377 <title>The Exim command line</title>
3378 <para>
3379 <indexterm role="concept" id="IIDclo1" class="startofrange">
3380 <primary>command line</primary>
3381 <secondary>options</secondary>
3382 </indexterm>
3383 <indexterm role="concept" id="IIDclo2" class="startofrange">
3384 <primary>options</primary>
3385 <secondary>command line</secondary>
3386 </indexterm>
3387 Exim&#x2019;s command line takes the standard Unix form of a sequence of options,
3388 each starting with a hyphen character, followed by a number of arguments. The
3389 options are compatible with the main options of Sendmail, and there are also
3390 some additional options, some of which are compatible with Smail 3. Certain
3391 combinations of options do not make sense, and provoke an error if used.
3392 The form of the arguments depends on which options are set.
3393 </para>
3394 <section id="SECID38">
3395 <title>Setting options by program name</title>
3396 <para>
3397 <indexterm role="concept">
3398 <primary><emphasis>mailq</emphasis></primary>
3399 </indexterm>
3400 If Exim is called under the name <emphasis>mailq</emphasis>, it behaves as if the option <option>-bp</option>
3401 were present before any other options.
3402 The <option>-bp</option> option requests a listing of the contents of the mail queue on the
3403 standard output.
3404 This feature is for compatibility with some systems that contain a command of
3405 that name in one of the standard libraries, symbolically linked to
3406 <filename>/usr/sbin/sendmail</filename> or <filename>/usr/lib/sendmail</filename>.
3407 </para>
3408 <para>
3409 <indexterm role="concept">
3410 <primary><emphasis>rsmtp</emphasis></primary>
3411 </indexterm>
3412 If Exim is called under the name <emphasis>rsmtp</emphasis> it behaves as if the option <option>-bS</option>
3413 were present before any other options, for compatibility with Smail. The
3414 <option>-bS</option> option is used for reading in a number of messages in batched SMTP
3415 format.
3416 </para>
3417 <para>
3418 <indexterm role="concept">
3419 <primary><emphasis>rmail</emphasis></primary>
3420 </indexterm>
3421 If Exim is called under the name <emphasis>rmail</emphasis> it behaves as if the <option>-i</option> and
3422 <option>-oee</option> options were present before any other options, for compatibility with
3423 Smail. The name <emphasis>rmail</emphasis> is used as an interface by some UUCP systems.
3424 </para>
3425 <para>
3426 <indexterm role="concept">
3427 <primary><emphasis>runq</emphasis></primary>
3428 </indexterm>
3429 <indexterm role="concept">
3430 <primary>queue runner</primary>
3431 </indexterm>
3432 If Exim is called under the name <emphasis>runq</emphasis> it behaves as if the option <option>-q</option>
3433 were present before any other options, for compatibility with Smail. The <option>-q</option>
3434 option causes a single queue runner process to be started.
3435 </para>
3436 <para>
3437 <indexterm role="concept">
3438 <primary><emphasis>newaliases</emphasis></primary>
3439 </indexterm>
3440 <indexterm role="concept">
3441 <primary>alias file</primary>
3442 <secondary>building</secondary>
3443 </indexterm>
3444 <indexterm role="concept">
3445 <primary>Sendmail compatibility</primary>
3446 <secondary>calling Exim as <emphasis>newaliases</emphasis></secondary>
3447 </indexterm>
3448 If Exim is called under the name <emphasis>newaliases</emphasis> it behaves as if the option
3449 <option>-bi</option> were present before any other options, for compatibility with Sendmail.
3450 This option is used for rebuilding Sendmail&#x2019;s alias file. Exim does not have
3451 the concept of a single alias file, but can be configured to run a given
3452 command if called with the <option>-bi</option> option.
3453 </para>
3454 </section>
3455 <section id="SECTtrustedadmin">
3456 <title>Trusted and admin users</title>
3457 <para>
3458 Some Exim options are available only to <emphasis>trusted users</emphasis> and others are
3459 available only to <emphasis>admin users</emphasis>. In the description below, the phrases <quote>Exim
3460 user</quote> and <quote>Exim group</quote> mean the user and group defined by EXIM_USER and
3461 EXIM_GROUP in <filename>Local/Makefile</filename> or set by the <option>exim_user</option> and
3462 <option>exim_group</option> options. These do not necessarily have to use the name <quote>exim</quote>.
3463 </para>
3464 <itemizedlist>
3465 <listitem>
3466 <para>
3467 <indexterm role="concept">
3468 <primary>trusted users</primary>
3469 <secondary>definition of</secondary>
3470 </indexterm>
3471 <indexterm role="concept">
3472 <primary>user</primary>
3473 <secondary>trusted definition of</secondary>
3474 </indexterm>
3475 The trusted users are root, the Exim user, any user listed in the
3476 <option>trusted_users</option> configuration option, and any user whose current group or any
3477 supplementary group is one of those listed in the <option>trusted_groups</option>
3478 configuration option. Note that the Exim group is not automatically trusted.
3479 </para>
3480 <para>
3481 <indexterm role="concept">
3482 <primary><quote>From</quote> line</primary>
3483 </indexterm>
3484 <indexterm role="concept">
3485 <primary>envelope sender</primary>
3486 </indexterm>
3487 Trusted users are always permitted to use the <option>-f</option> option or a leading
3488 <quote>From&nbsp;</quote> line to specify the envelope sender of a message that is passed to
3489 Exim through the local interface (see the <option>-bm</option> and <option>-f</option> options below).
3490 See the <option>untrusted_set_sender</option> option for a way of permitting non-trusted
3491 users to set envelope senders.
3492 </para>
3493 <para>
3494 <indexterm role="concept">
3495 <primary><emphasis>From:</emphasis> header line</primary>
3496 </indexterm>
3497 <indexterm role="concept">
3498 <primary><emphasis>Sender:</emphasis> header line</primary>
3499 </indexterm>
3500 For a trusted user, there is never any check on the contents of the <emphasis>From:</emphasis>
3501 header line, and a <emphasis>Sender:</emphasis> line is never added. Furthermore, any existing
3502 <emphasis>Sender:</emphasis> line in incoming local (non-TCP/IP) messages is not removed.
3503 </para>
3504 <para>
3505 Trusted users may also specify a host name, host address, interface address,
3506 protocol name, ident value, and authentication data when submitting a message
3507 locally. Thus, they are able to insert messages into Exim&#x2019;s queue locally that
3508 have the characteristics of messages received from a remote host. Untrusted
3509 users may in some circumstances use <option>-f</option>, but can never set the other values
3510 that are available to trusted users.
3511 </para>
3512 </listitem>
3513 <listitem>
3514 <para>
3515 <indexterm role="concept">
3516 <primary>user</primary>
3517 <secondary>admin definition of</secondary>
3518 </indexterm>
3519 <indexterm role="concept">
3520 <primary>admin user</primary>
3521 <secondary>definition of</secondary>
3522 </indexterm>
3523 The admin users are root, the Exim user, and any user that is a member of the
3524 Exim group or of any group listed in the <option>admin_groups</option> configuration option.
3525 The current group does not have to be one of these groups.
3526 </para>
3527 <para>
3528 Admin users are permitted to list the queue, and to carry out certain
3529 operations on messages, for example, to force delivery failures. It is also
3530 necessary to be an admin user in order to see the full information provided by
3531 the Exim monitor, and full debugging output.
3532 </para>
3533 <para>
3534 By default, the use of the <option>-M</option>, <option>-q</option>, <option>-R</option>, and <option>-S</option> options to cause
3535 Exim to attempt delivery of messages on its queue is restricted to admin users.
3536 However, this restriction can be relaxed by setting the <option>prod_requires_admin</option>
3537 option false (that is, specifying <option>no_prod_requires_admin</option>).
3538 </para>
3539 <para>
3540 Similarly, the use of the <option>-bp</option> option to list all the messages in the queue
3541 is restricted to admin users unless <option>queue_list_requires_admin</option> is set
3542 false.
3543 </para>
3544 </listitem>
3545 </itemizedlist>
3546 <para>
3547 <emphasis role="bold">Warning</emphasis>: If you configure your system so that admin users are able to
3548 edit Exim&#x2019;s configuration file, you are giving those users an easy way of
3549 getting root. There is further discussion of this issue at the start of chapter
3550 <xref linkend="CHAPconf"/>.
3551 </para>
3552 </section>
3553 <section id="SECID39">
3554 <title>Command line options</title>
3555 <para>
3556 Exim&#x2019;s command line options are described in alphabetical order below. If none
3557 of the options that specifies a specific action (such as starting the daemon or
3558 a queue runner, or testing an address, or receiving a message in a specific
3559 format, or listing the queue) are present, and there is at least one argument
3560 on the command line, <option>-bm</option> (accept a local message on the standard input,
3561 with the arguments specifying the recipients) is assumed. Otherwise, Exim
3562 outputs a brief message about itself and exits.
3563 </para>
3564 <!-- === Start of command line options === -->
3565 <variablelist>
3566 <varlistentry>
3567 <term><option>--</option></term>
3568 <listitem>
3569 <para>
3570 <indexterm role="option">
3571 <primary>--</primary>
3572 </indexterm>
3573 <indexterm role="concept">
3574 <primary>options</primary>
3575 <secondary>command line; terminating</secondary>
3576 </indexterm>
3577 This is a pseudo-option whose only purpose is to terminate the options and
3578 therefore to cause subsequent command line items to be treated as arguments
3579 rather than options, even if they begin with hyphens.
3580 </para>
3581 </listitem></varlistentry>
3582 <varlistentry>
3583 <term><option>--help</option></term>
3584 <listitem>
3585 <para>
3586 <indexterm role="option">
3587 <primary><option>--help</option></primary>
3588 </indexterm>
3589 This option causes Exim to output a few sentences stating what it is.
3590 The same output is generated if the Exim binary is called with no options and
3591 no arguments.
3592 </para>
3593 </listitem></varlistentry>
3594 <varlistentry revisionflag="changed">
3595 <term><option>--version</option></term>
3596 <listitem>
3597 <para revisionflag="changed">
3598 <indexterm role="option">
3599 <primary><option>--version</option></primary>
3600 </indexterm>
3601 This option is an alias for <option>-bV</option> and causes version information to be
3602 displayed.
3603 </para>
3604 </listitem></varlistentry>
3605 <varlistentry>
3606 <term><option>-B</option>&lt;<emphasis>type</emphasis>&gt;</term>
3607 <listitem>
3608 <para>
3609 <indexterm role="option">
3610 <primary><option>-B</option></primary>
3611 </indexterm>
3612 <indexterm role="concept">
3613 <primary>8-bit characters</primary>
3614 </indexterm>
3615 <indexterm role="concept">
3616 <primary>Sendmail compatibility</primary>
3617 <secondary>8-bit characters</secondary>
3618 </indexterm>
3619 This is a Sendmail option for selecting 7 or 8 bit processing. Exim is 8-bit
3620 clean; it ignores this option.
3621 </para>
3622 </listitem></varlistentry>
3623 <varlistentry>
3624 <term><option>-bd</option></term>
3625 <listitem>
3626 <para>
3627 <indexterm role="option">
3628 <primary><option>-bd</option></primary>
3629 </indexterm>
3630 <indexterm role="concept">
3631 <primary>daemon</primary>
3632 </indexterm>
3633 <indexterm role="concept">
3634 <primary>SMTP</primary>
3635 <secondary>listener</secondary>
3636 </indexterm>
3637 <indexterm role="concept">
3638 <primary>queue runner</primary>
3639 </indexterm>
3640 This option runs Exim as a daemon, awaiting incoming SMTP connections. Usually
3641 the <option>-bd</option> option is combined with the <option>-q</option>&lt;<emphasis>time</emphasis>&gt; option, to specify
3642 that the daemon should also initiate periodic queue runs.
3643 </para>
3644 <para>
3645 The <option>-bd</option> option can be used only by an admin user. If either of the <option>-d</option>
3646 (debugging) or <option>-v</option> (verifying) options are set, the daemon does not
3647 disconnect from the controlling terminal. When running this way, it can be
3648 stopped by pressing ctrl-C.
3649 </para>
3650 <para>
3651 By default, Exim listens for incoming connections to the standard SMTP port on
3652 all the host&#x2019;s running interfaces. However, it is possible to listen on other
3653 ports, on multiple ports, and only on specific interfaces. Chapter
3654 <xref linkend="CHAPinterfaces"/> contains a description of the options that control this.
3655 </para>
3656 <para>
3657 When a listening daemon
3658 <indexterm role="concept">
3659 <primary>daemon</primary>
3660 <secondary>process id (pid)</secondary>
3661 </indexterm>
3662 <indexterm role="concept">
3663 <primary>pid (process id)</primary>
3664 <secondary>of daemon</secondary>
3665 </indexterm>
3666 is started without the use of <option>-oX</option> (that is, without overriding the normal
3667 configuration), it writes its process id to a file called <filename>exim-daemon.pid</filename>
3668 in Exim&#x2019;s spool directory. This location can be overridden by setting
3669 PID_FILE_PATH in <filename>Local/Makefile</filename>. The file is written while Exim is still
3670 running as root.
3671 </para>
3672 <para>
3673 When <option>-oX</option> is used on the command line to start a listening daemon, the
3674 process id is not written to the normal pid file path. However, <option>-oP</option> can be
3675 used to specify a path on the command line if a pid file is required.
3676 </para>
3677 <para>
3678 The SIGHUP signal
3679 <indexterm role="concept">
3680 <primary>SIGHUP</primary>
3681 </indexterm>
3682 <indexterm role="concept">
3683 <primary>daemon</primary>
3684 <secondary>restarting</secondary>
3685 </indexterm>
3686 can be used to cause the daemon to re-execute itself. This should be done
3687 whenever Exim&#x2019;s configuration file, or any file that is incorporated into it by
3688 means of the <option>.include</option> facility, is changed, and also whenever a new version
3689 of Exim is installed. It is not necessary to do this when other files that are
3690 referenced from the configuration (for example, alias files) are changed,
3691 because these are reread each time they are used.
3692 </para>
3693 </listitem></varlistentry>
3694 <varlistentry>
3695 <term><option>-bdf</option></term>
3696 <listitem>
3697 <para>
3698 <indexterm role="option">
3699 <primary><option>-bdf</option></primary>
3700 </indexterm>
3701 This option has the same effect as <option>-bd</option> except that it never disconnects
3702 from the controlling terminal, even when no debugging is specified.
3703 </para>
3704 </listitem></varlistentry>
3705 <varlistentry>
3706 <term><option>-be</option></term>
3707 <listitem>
3708 <para>
3709 <indexterm role="option">
3710 <primary><option>-be</option></primary>
3711 </indexterm>
3712 <indexterm role="concept">
3713 <primary>testing</primary>
3714 <secondary>string expansion</secondary>
3715 </indexterm>
3716 <indexterm role="concept">
3717 <primary>expansion</primary>
3718 <secondary>testing</secondary>
3719 </indexterm>
3720 Run Exim in expansion testing mode. Exim discards its root privilege, to
3721 prevent ordinary users from using this mode to read otherwise inaccessible
3722 files. If no arguments are given, Exim runs interactively, prompting for lines
3723 of data. Otherwise, it processes each argument in turn.
3724 </para>
3725 <para>
3726 If Exim was built with USE_READLINE=yes in <filename>Local/Makefile</filename>, it tries
3727 to load the <option>libreadline</option> library dynamically whenever the <option>-be</option> option is
3728 used without command line arguments. If successful, it uses the <function>readline()</function>
3729 function, which provides extensive line-editing facilities, for reading the
3730 test data. A line history is supported.
3731 </para>
3732 <para>
3733 Long expansion expressions can be split over several lines by using backslash
3734 continuations. As in Exim&#x2019;s run time configuration, white space at the start of
3735 continuation lines is ignored. Each argument or data line is passed through the
3736 string expansion mechanism, and the result is output. Variable values from the
3737 configuration file (for example, <varname>$qualify_domain</varname>) are available, but no
3738 message-specific values (such as <varname>$sender_domain</varname>) are set, because no message
3739 is being processed (but see <option>-bem</option> and <option>-Mset</option>).
3740 </para>
3741 <para>
3742 <emphasis role="bold">Note</emphasis>: If you use this mechanism to test lookups, and you change the data
3743 files or databases you are using, you must exit and restart Exim before trying
3744 the same lookup again. Otherwise, because each Exim process caches the results
3745 of lookups, you will just get the same result as before.
3746 </para>
3747 </listitem></varlistentry>
3748 <varlistentry>
3749 <term><option>-bem</option>&nbsp;&lt;<emphasis>filename</emphasis>&gt;</term>
3750 <listitem>
3751 <para>
3752 <indexterm role="option">
3753 <primary><option>-bem</option></primary>
3754 </indexterm>
3755 <indexterm role="concept">
3756 <primary>testing</primary>
3757 <secondary>string expansion</secondary>
3758 </indexterm>
3759 <indexterm role="concept">
3760 <primary>expansion</primary>
3761 <secondary>testing</secondary>
3762 </indexterm>
3763 This option operates like <option>-be</option> except that it must be followed by the name
3764 of a file. For example:
3765 </para>
3766 <literallayout class="monospaced">
3767 exim -bem /tmp/testmessage
3768 </literallayout>
3769 <para>
3770 The file is read as a message (as if receiving a locally-submitted non-SMTP
3771 message) before any of the test expansions are done. Thus, message-specific
3772 variables such as <varname>$message_size</varname> and <varname>$header_from:</varname> are available. However,
3773 no <emphasis>Received:</emphasis> header is added to the message. If the <option>-t</option> option is set,
3774 recipients are read from the headers in the normal way, and are shown in the
3775 <varname>$recipients</varname> variable. Note that recipients cannot be given on the command
3776 line, because further arguments are taken as strings to expand (just like
3777 <option>-be</option>).
3778 </para>
3779 </listitem></varlistentry>
3780 <varlistentry>
3781 <term><option>-bF</option>&nbsp;&lt;<emphasis>filename</emphasis>&gt;</term>
3782 <listitem>
3783 <para>
3784 <indexterm role="option">
3785 <primary><option>-bF</option></primary>
3786 </indexterm>
3787 <indexterm role="concept">
3788 <primary>system filter</primary>
3789 <secondary>testing</secondary>
3790 </indexterm>
3791 <indexterm role="concept">
3792 <primary>testing</primary>
3793 <secondary>system filter</secondary>
3794 </indexterm>
3795 This option is the same as <option>-bf</option> except that it assumes that the filter being
3796 tested is a system filter. The additional commands that are available only in
3797 system filters are recognized.
3798 </para>
3799 </listitem></varlistentry>
3800 <varlistentry>
3801 <term><option>-bf</option>&nbsp;&lt;<emphasis>filename</emphasis>&gt;</term>
3802 <listitem>
3803 <para>
3804 <indexterm role="option">
3805 <primary><option>-bf</option></primary>
3806 </indexterm>
3807 <indexterm role="concept">
3808 <primary>filter</primary>
3809 <secondary>testing</secondary>
3810 </indexterm>
3811 <indexterm role="concept">
3812 <primary>testing</primary>
3813 <secondary>filter file</secondary>
3814 </indexterm>
3815 <indexterm role="concept">
3816 <primary>forward file</primary>
3817 <secondary>testing</secondary>
3818 </indexterm>
3819 <indexterm role="concept">
3820 <primary>testing</primary>
3821 <secondary>forward file</secondary>
3822 </indexterm>
3823 <indexterm role="concept">
3824 <primary>Sieve filter</primary>
3825 <secondary>testing</secondary>
3826 </indexterm>
3827 This option runs Exim in user filter testing mode; the file is the filter file
3828 to be tested, and a test message must be supplied on the standard input. If
3829 there are no message-dependent tests in the filter, an empty file can be
3830 supplied.
3831 </para>
3832 <para>
3833 If you want to test a system filter file, use <option>-bF</option> instead of <option>-bf</option>. You
3834 can use both <option>-bF</option> and <option>-bf</option> on the same command, in order to test a system
3835 filter and a user filter in the same run. For example:
3836 </para>
3837 <literallayout class="monospaced">
3838 exim -bF /system/filter -bf /user/filter &lt;/test/message
3839 </literallayout>
3840 <para>
3841 This is helpful when the system filter adds header lines or sets filter
3842 variables that are used by the user filter.
3843 </para>
3844 <para>
3845 If the test filter file does not begin with one of the special lines
3846 </para>
3847 <literallayout class="monospaced">
3848 # Exim filter
3849 # Sieve filter
3850 </literallayout>
3851 <para>
3852 it is taken to be a normal <filename>.forward</filename> file, and is tested for validity under
3853 that interpretation. See sections <xref linkend="SECTitenonfilred"/> to
3854 <xref linkend="SECTspecitredli"/> for a description of the possible contents of non-filter
3855 redirection lists.
3856 </para>
3857 <para>
3858 The result of an Exim command that uses <option>-bf</option>, provided no errors are
3859 detected, is a list of the actions that Exim would try to take if presented
3860 with the message for real. More details of filter testing are given in the
3861 separate document entitled <emphasis>Exim&#x2019;s interfaces to mail filtering</emphasis>.
3862 </para>
3863 <para>
3864 When testing a filter file,
3865 <indexterm role="concept">
3866 <primary><quote>From</quote> line</primary>
3867 </indexterm>
3868 <indexterm role="concept">
3869 <primary>envelope sender</primary>
3870 </indexterm>
3871 <indexterm role="option">
3872 <primary><option>-f</option></primary>
3873 <secondary>for filter testing</secondary>
3874 </indexterm>
3875 the envelope sender can be set by the <option>-f</option> option,
3876 or by a <quote>From&nbsp;</quote> line at the start of the test message. Various parameters
3877 that would normally be taken from the envelope recipient address of the message
3878 can be set by means of additional command line options (see the next four
3879 options).
3880 </para>
3881 </listitem></varlistentry>
3882 <varlistentry>
3883 <term><option>-bfd</option>&nbsp;&lt;<emphasis>domain</emphasis>&gt;</term>
3884 <listitem>
3885 <para>
3886 <indexterm role="option">
3887 <primary><option>-bfd</option></primary>
3888 </indexterm>
3889 <indexterm role="variable">
3890 <primary><varname>$qualify_domain</varname></primary>
3891 </indexterm>
3892 This sets the domain of the recipient address when a filter file is being
3893 tested by means of the <option>-bf</option> option. The default is the value of
3894 <varname>$qualify_domain</varname>.
3895 </para>
3896 </listitem></varlistentry>
3897 <varlistentry>
3898 <term><option>-bfl</option>&nbsp;&lt;<emphasis>local&nbsp;part</emphasis>&gt;</term>
3899 <listitem>
3900 <para>
3901 <indexterm role="option">
3902 <primary><option>-bfl</option></primary>
3903 </indexterm>
3904 This sets the local part of the recipient address when a filter file is being
3905 tested by means of the <option>-bf</option> option. The default is the username of the
3906 process that calls Exim. A local part should be specified with any prefix or
3907 suffix stripped, because that is how it appears to the filter when a message is
3908 actually being delivered.
3909 </para>
3910 </listitem></varlistentry>
3911 <varlistentry>
3912 <term><option>-bfp</option>&nbsp;&lt;<emphasis>prefix</emphasis>&gt;</term>
3913 <listitem>
3914 <para>
3915 <indexterm role="option">
3916 <primary><option>-bfp</option></primary>
3917 </indexterm>
3918 This sets the prefix of the local part of the recipient address when a filter
3919 file is being tested by means of the <option>-bf</option> option. The default is an empty
3920 prefix.
3921 </para>
3922 </listitem></varlistentry>
3923 <varlistentry>
3924 <term><option>-bfs</option>&nbsp;&lt;<emphasis>suffix</emphasis>&gt;</term>
3925 <listitem>
3926 <para>
3927 <indexterm role="option">
3928 <primary><option>-bfs</option></primary>
3929 </indexterm>
3930 This sets the suffix of the local part of the recipient address when a filter
3931 file is being tested by means of the <option>-bf</option> option. The default is an empty
3932 suffix.
3933 </para>
3934 </listitem></varlistentry>
3935 <varlistentry>
3936 <term><option>-bh</option>&nbsp;&lt;<emphasis>IP&nbsp;address</emphasis>&gt;</term>
3937 <listitem>
3938 <para>
3939 <indexterm role="option">
3940 <primary><option>-bh</option></primary>
3941 </indexterm>
3942 <indexterm role="concept">
3943 <primary>testing</primary>
3944 <secondary>incoming SMTP</secondary>
3945 </indexterm>
3946 <indexterm role="concept">
3947 <primary>SMTP</primary>
3948 <secondary>testing incoming</secondary>
3949 </indexterm>
3950 <indexterm role="concept">
3951 <primary>testing</primary>
3952 <secondary>relay control</secondary>
3953 </indexterm>
3954 <indexterm role="concept">
3955 <primary>relaying</primary>
3956 <secondary>testing configuration</secondary>
3957 </indexterm>
3958 <indexterm role="concept">
3959 <primary>policy control</primary>
3960 <secondary>testing</secondary>
3961 </indexterm>
3962 <indexterm role="concept">
3963 <primary>debugging</primary>
3964 <secondary><option>-bh</option> option</secondary>
3965 </indexterm>
3966 This option runs a fake SMTP session as if from the given IP address, using the
3967 standard input and output. The IP address may include a port number at the end,
3968 after a full stop. For example:
3969 </para>
3970 <literallayout class="monospaced">
3971 exim -bh 10.9.8.7.1234
3972 exim -bh fe80::a00:20ff:fe86:a061.5678
3973 </literallayout>
3974 <para>
3975 When an IPv6 address is given, it is converted into canonical form. In the case
3976 of the second example above, the value of <varname>$sender_host_address</varname> after
3977 conversion to the canonical form is
3978 <literal>fe80:0000:0000:0a00:20ff:fe86:a061.5678</literal>.
3979 </para>
3980 <para>
3981 Comments as to what is going on are written to the standard error file. These
3982 include lines beginning with <quote>LOG</quote> for anything that would have been logged.
3983 This facility is provided for testing configuration options for incoming
3984 messages, to make sure they implement the required policy. For example, you can
3985 test your relay controls using <option>-bh</option>.
3986 </para>
3987 <para>
3988 <emphasis role="bold">Warning 1</emphasis>:
3989 <indexterm role="concept">
3990 <primary>RFC 1413</primary>
3991 </indexterm>
3992 You can test features of the configuration that rely on ident (RFC 1413)
3993 information by using the <option>-oMt</option> option. However, Exim cannot actually perform
3994 an ident callout when testing using <option>-bh</option> because there is no incoming SMTP
3995 connection.
3996 </para>
3997 <para>
3998 <emphasis role="bold">Warning 2</emphasis>: Address verification callouts (see section <xref linkend="SECTcallver"/>)
3999 are also skipped when testing using <option>-bh</option>. If you want these callouts to
4000 occur, use <option>-bhc</option> instead.
4001 </para>
4002 <para>
4003 Messages supplied during the testing session are discarded, and nothing is
4004 written to any of the real log files. There may be pauses when DNS (and other)
4005 lookups are taking place, and of course these may time out. The <option>-oMi</option> option
4006 can be used to specify a specific IP interface and port if this is important,
4007 and <option>-oMaa</option> and <option>-oMai</option> can be used to set parameters as if the SMTP
4008 session were authenticated.
4009 </para>
4010 <para>
4011 The <emphasis>exim_checkaccess</emphasis> utility is a <quote>packaged</quote> version of <option>-bh</option> whose
4012 output just states whether a given recipient address from a given host is
4013 acceptable or not. See section <xref linkend="SECTcheckaccess"/>.
4014 </para>
4015 <para>
4016 Features such as authentication and encryption, where the client input is not
4017 plain text, cannot easily be tested with <option>-bh</option>. Instead, you should use a
4018 specialized SMTP test program such as
4019 <emphasis role="bold"><ulink url="http://jetmore.org/john/code/#swaks">swaks</ulink></emphasis>.
4020 </para>
4021 </listitem></varlistentry>
4022 <varlistentry>
4023 <term><option>-bhc</option>&nbsp;&lt;<emphasis>IP&nbsp;address</emphasis>&gt;</term>
4024 <listitem>
4025 <para>
4026 <indexterm role="option">
4027 <primary><option>-bhc</option></primary>
4028 </indexterm>
4029 This option operates in the same way as <option>-bh</option>, except that address
4030 verification callouts are performed if required. This includes consulting and
4031 updating the callout cache database.
4032 </para>
4033 </listitem></varlistentry>
4034 <varlistentry>
4035 <term><option>-bi</option></term>
4036 <listitem>
4037 <para>
4038 <indexterm role="option">
4039 <primary><option>-bi</option></primary>
4040 </indexterm>
4041 <indexterm role="concept">
4042 <primary>alias file</primary>
4043 <secondary>building</secondary>
4044 </indexterm>
4045 <indexterm role="concept">
4046 <primary>building alias file</primary>
4047 </indexterm>
4048 <indexterm role="concept">
4049 <primary>Sendmail compatibility</primary>
4050 <secondary><option>-bi</option> option</secondary>
4051 </indexterm>
4052 Sendmail interprets the <option>-bi</option> option as a request to rebuild its alias file.
4053 Exim does not have the concept of a single alias file, and so it cannot mimic
4054 this behaviour. However, calls to <filename>/usr/lib/sendmail</filename> with the <option>-bi</option> option
4055 tend to appear in various scripts such as NIS make files, so the option must be
4056 recognized.
4057 </para>
4058 <para>
4059 If <option>-bi</option> is encountered, the command specified by the <option>bi_command</option>
4060 configuration option is run, under the uid and gid of the caller of Exim. If
4061 the <option>-oA</option> option is used, its value is passed to the command as an argument.
4062 The command set by <option>bi_command</option> may not contain arguments. The command can
4063 use the <emphasis>exim_dbmbuild</emphasis> utility, or some other means, to rebuild alias files
4064 if this is required. If the <option>bi_command</option> option is not set, calling Exim with
4065 <option>-bi</option> is a no-op.
4066 </para>
4067 </listitem></varlistentry>
4068 <varlistentry>
4069 <term><option>-bm</option></term>
4070 <listitem>
4071 <para>
4072 <indexterm role="option">
4073 <primary><option>-bm</option></primary>
4074 </indexterm>
4075 <indexterm role="concept">
4076 <primary>local message reception</primary>
4077 </indexterm>
4078 This option runs an Exim receiving process that accepts an incoming,
4079 locally-generated message on the current input. The recipients are given as the
4080 command arguments (except when <option>-t</option> is also present &ndash; see below). Each
4081 argument can be a comma-separated list of RFC 2822 addresses. This is the
4082 default option for selecting the overall action of an Exim call; it is assumed
4083 if no other conflicting option is present.
4084 </para>
4085 <para>
4086 If any addresses in the message are unqualified (have no domain), they are
4087 qualified by the values of the <option>qualify_domain</option> or <option>qualify_recipient</option>
4088 options, as appropriate. The <option>-bnq</option> option (see below) provides a way of
4089 suppressing this for special cases.
4090 </para>
4091 <para>
4092 Policy checks on the contents of local messages can be enforced by means of
4093 the non-SMTP ACL. See chapter <xref linkend="CHAPACL"/> for details.
4094 </para>
4095 <para>
4096 <indexterm role="concept">
4097 <primary>return code</primary>
4098 <secondary>for <option>-bm</option></secondary>
4099 </indexterm>
4100 The return code is zero if the message is successfully accepted. Otherwise, the
4101 action is controlled by the <option>-oe</option><emphasis>x</emphasis> option setting &ndash; see below.
4102 </para>
4103 <para>
4104 The format
4105 <indexterm role="concept">
4106 <primary>message</primary>
4107 <secondary>format</secondary>
4108 </indexterm>
4109 <indexterm role="concept">
4110 <primary>format</primary>
4111 <secondary>message</secondary>
4112 </indexterm>
4113 <indexterm role="concept">
4114 <primary><quote>From</quote> line</primary>
4115 </indexterm>
4116 <indexterm role="concept">
4117 <primary>UUCP</primary>
4118 <secondary><quote>From</quote> line</secondary>
4119 </indexterm>
4120 <indexterm role="concept">
4121 <primary>Sendmail compatibility</primary>
4122 <secondary><quote>From</quote> line</secondary>
4123 </indexterm>
4124 of the message must be as defined in RFC 2822, except that, for
4125 compatibility with Sendmail and Smail, a line in one of the forms
4126 </para>
4127 <literallayout class="monospaced">
4128 From sender Fri Jan  5 12:55 GMT 1997
4129 From sender Fri, 5 Jan 97 12:55:01
4130 </literallayout>
4131 <para>
4132 (with the weekday optional, and possibly with additional text after the date)
4133 is permitted to appear at the start of the message. There appears to be no
4134 authoritative specification of the format of this line. Exim recognizes it by
4135 matching against the regular expression defined by the <option>uucp_from_pattern</option>
4136 option, which can be changed if necessary.
4137 </para>
4138 <para>
4139 <indexterm role="option">
4140 <primary><option>-f</option></primary>
4141 <secondary>overriding <quote>From</quote> line</secondary>
4142 </indexterm>
4143 The specified sender is treated as if it were given as the argument to the
4144 <option>-f</option> option, but if a <option>-f</option> option is also present, its argument is used in
4145 preference to the address taken from the message. The caller of Exim must be a
4146 trusted user for the sender of a message to be set in this way.
4147 </para>
4148 </listitem></varlistentry>
4149 <varlistentry>
4150 <term><option>-bnq</option></term>
4151 <listitem>
4152 <para>
4153 <indexterm role="option">
4154 <primary><option>-bnq</option></primary>
4155 </indexterm>
4156 <indexterm role="concept">
4157 <primary>address qualification, suppressing</primary>
4158 </indexterm>
4159 By default, Exim automatically qualifies unqualified addresses (those
4160 without domains) that appear in messages that are submitted locally (that
4161 is, not over TCP/IP). This qualification applies both to addresses in
4162 envelopes, and addresses in header lines. Sender addresses are qualified using
4163 <option>qualify_domain</option>, and recipient addresses using <option>qualify_recipient</option> (which
4164 defaults to the value of <option>qualify_domain</option>).
4165 </para>
4166 <para>
4167 Sometimes, qualification is not wanted. For example, if <option>-bS</option> (batch SMTP) is
4168 being used to re-submit messages that originally came from remote hosts after
4169 content scanning, you probably do not want to qualify unqualified addresses in
4170 header lines. (Such lines will be present only if you have not enabled a header
4171 syntax check in the appropriate ACL.)
4172 </para>
4173 <para>
4174 The <option>-bnq</option> option suppresses all qualification of unqualified addresses in
4175 messages that originate on the local host. When this is used, unqualified
4176 addresses in the envelope provoke errors (causing message rejection) and
4177 unqualified addresses in header lines are left alone.
4178 </para>
4179 </listitem></varlistentry>
4180 <varlistentry>
4181 <term><option>-bP</option></term>
4182 <listitem>
4183 <para>
4184 <indexterm role="option">
4185 <primary><option>-bP</option></primary>
4186 </indexterm>
4187 <indexterm role="concept">
4188 <primary>configuration options</primary>
4189 <secondary>extracting</secondary>
4190 </indexterm>
4191 <indexterm role="concept">
4192 <primary>options</primary>
4193 <secondary>configuration &ndash; extracting</secondary>
4194 </indexterm>
4195 If this option is given with no arguments, it causes the values of all Exim&#x2019;s
4196 main configuration options to be written to the standard output. The values
4197 of one or more specific options can be requested by giving their names as
4198 arguments, for example:
4199 </para>
4200 <literallayout class="monospaced">
4201 exim -bP qualify_domain hold_domains
4202 </literallayout>
4203 <para>
4204 <indexterm role="concept">
4205 <primary>hiding configuration option values</primary>
4206 </indexterm>
4207 <indexterm role="concept">
4208 <primary>configuration options</primary>
4209 <secondary>hiding value of</secondary>
4210 </indexterm>
4211 <indexterm role="concept">
4212 <primary>options</primary>
4213 <secondary>hiding value of</secondary>
4214 </indexterm>
4215 However, any option setting that is preceded by the word <quote>hide</quote> in the
4216 configuration file is not shown in full, except to an admin user. For other
4217 users, the output is as in this example:
4218 </para>
4219 <literallayout class="monospaced">
4220 mysql_servers = &lt;value not displayable&gt;
4221 </literallayout>
4222 <para>
4223 If <option>configure_file</option> is given as an argument, the name of the run time
4224 configuration file is output.
4225 If a list of configuration files was supplied, the value that is output here
4226 is the name of the file that was actually used.
4227 </para>
4228 <para>
4229 <indexterm role="concept">
4230 <primary>daemon</primary>
4231 <secondary>process id (pid)</secondary>
4232 </indexterm>
4233 <indexterm role="concept">
4234 <primary>pid (process id)</primary>
4235 <secondary>of daemon</secondary>
4236 </indexterm>
4237 If <option>log_file_path</option> or <option>pid_file_path</option> are given, the names of the
4238 directories where log files and daemon pid files are written are output,
4239 respectively. If these values are unset, log files are written in a
4240 sub-directory of the spool directory called <option>log</option>, and the pid file is
4241 written directly into the spool directory.
4242 </para>
4243 <para>
4244 If <option>-bP</option> is followed by a name preceded by <literal>+</literal>, for example,
4245 </para>
4246 <literallayout class="monospaced">
4247 exim -bP +local_domains
4248 </literallayout>
4249 <para>
4250 it searches for a matching named list of any type (domain, host, address, or
4251 local part) and outputs what it finds.
4252 </para>
4253 <para>
4254 <indexterm role="concept">
4255 <primary>options</primary>
4256 <secondary>router &ndash; extracting</secondary>
4257 </indexterm>
4258 <indexterm role="concept">
4259 <primary>options</primary>
4260 <secondary>transport &ndash; extracting</secondary>
4261 </indexterm>
4262 <indexterm role="concept">
4263 <primary>options</primary>
4264 <secondary>authenticator &ndash; extracting</secondary>
4265 </indexterm>
4266 If one of the words <option>router</option>, <option>transport</option>, or <option>authenticator</option> is given,
4267 followed by the name of an appropriate driver instance, the option settings for
4268 that driver are output. For example:
4269 </para>
4270 <literallayout class="monospaced">
4271 exim -bP transport local_delivery
4272 </literallayout>
4273 <para>
4274 The generic driver options are output first, followed by the driver&#x2019;s private
4275 options. A list of the names of drivers of a particular type can be obtained by
4276 using one of the words <option>router_list</option>, <option>transport_list</option>, or
4277 <option>authenticator_list</option>, and a complete list of all drivers with their option
4278 settings can be obtained by using <option>routers</option>, <option>transports</option>, or
4279 <option>authenticators</option>.
4280 </para>
4281 <para>
4282 <indexterm role="concept">
4283 <primary>options</primary>
4284 <secondary>macro &ndash; extracting</secondary>
4285 </indexterm>
4286 If invoked by an admin user, then <option>macro</option>, <option>macro_list</option> and <option>macros</option>
4287 are available, similarly to the drivers.  Because macros are sometimes used
4288 for storing passwords, this option is restricted.
4289 The output format is one item per line.
4290 </para>
4291 </listitem></varlistentry>
4292 <varlistentry>
4293 <term><option>-bp</option></term>
4294 <listitem>
4295 <para>
4296 <indexterm role="option">
4297 <primary><option>-bp</option></primary>
4298 </indexterm>
4299 <indexterm role="concept">
4300 <primary>queue</primary>
4301 <secondary>listing messages on</secondary>
4302 </indexterm>
4303 <indexterm role="concept">
4304 <primary>listing</primary>
4305 <secondary>messages on the queue</secondary>
4306 </indexterm>
4307 This option requests a listing of the contents of the mail queue on the
4308 standard output. If the <option>-bp</option> option is followed by a list of message ids,
4309 just those messages are listed. By default, this option can be used only by an
4310 admin user. However, the <option>queue_list_requires_admin</option> option can be set false
4311 to allow any user to see the queue.
4312 </para>
4313 <para>
4314 Each message on the queue is displayed as in the following example:
4315 </para>
4316 <literallayout class="monospaced">
4317 25m  2.9K 0t5C6f-0000c8-00 &lt;alice@wonderland.fict.example&gt;
4318           red.king@looking-glass.fict.example
4319           &lt;other addresses&gt;
4320 </literallayout>
4321 <para>
4322 <indexterm role="concept">
4323 <primary>message</primary>
4324 <secondary>size in queue listing</secondary>
4325 </indexterm>
4326 <indexterm role="concept">
4327 <primary>size</primary>
4328 <secondary>of message</secondary>
4329 </indexterm>
4330 The first line contains the length of time the message has been on the queue
4331 (in this case 25 minutes), the size of the message (2.9K), the unique local
4332 identifier for the message, and the message sender, as contained in the
4333 envelope. For bounce messages, the sender address is empty, and appears as
4334 <quote>&lt;&gt;</quote>. If the message was submitted locally by an untrusted user who overrode
4335 the default sender address, the user&#x2019;s login name is shown in parentheses
4336 before the sender address.
4337 </para>
4338 <para>
4339 <indexterm role="concept">
4340 <primary>frozen messages</primary>
4341 <secondary>in queue listing</secondary>
4342 </indexterm>
4343 If the message is frozen (attempts to deliver it are suspended) then the text
4344 <quote>*** frozen ***</quote> is displayed at the end of this line.
4345 </para>
4346 <para>
4347 The recipients of the message (taken from the envelope, not the headers) are
4348 displayed on subsequent lines. Those addresses to which the message has already
4349 been delivered are marked with the letter D. If an original address gets
4350 expanded into several addresses via an alias or forward file, the original is
4351 displayed with a D only when deliveries for all of its child addresses are
4352 complete.
4353 </para>
4354 </listitem></varlistentry>
4355 <varlistentry>
4356 <term><option>-bpa</option></term>
4357 <listitem>
4358 <para>
4359 <indexterm role="option">
4360 <primary><option>-bpa</option></primary>
4361 </indexterm>
4362 This option operates like <option>-bp</option>, but in addition it shows delivered addresses
4363 that were generated from the original top level address(es) in each message by
4364 alias or forwarding operations. These addresses are flagged with <quote>+D</quote> instead
4365 of just <quote>D</quote>.
4366 </para>
4367 </listitem></varlistentry>
4368 <varlistentry>
4369 <term><option>-bpc</option></term>
4370 <listitem>
4371 <para>
4372 <indexterm role="option">
4373 <primary><option>-bpc</option></primary>
4374 </indexterm>
4375 <indexterm role="concept">
4376 <primary>queue</primary>
4377 <secondary>count of messages on</secondary>
4378 </indexterm>
4379 This option counts the number of messages on the queue, and writes the total
4380 to the standard output. It is restricted to admin users, unless
4381 <option>queue_list_requires_admin</option> is set false.
4382 </para>
4383 </listitem></varlistentry>
4384 <varlistentry>
4385 <term><option>-bpr</option></term>
4386 <listitem>
4387 <para>
4388 <indexterm role="option">
4389 <primary><option>-bpr</option></primary>
4390 </indexterm>
4391 This option operates like <option>-bp</option>, but the output is not sorted into
4392 chronological order of message arrival. This can speed it up when there are
4393 lots of messages on the queue, and is particularly useful if the output is
4394 going to be post-processed in a way that doesn&#x2019;t need the sorting.
4395 </para>
4396 </listitem></varlistentry>
4397 <varlistentry>
4398 <term><option>-bpra</option></term>
4399 <listitem>
4400 <para>
4401 <indexterm role="option">
4402 <primary><option>-bpra</option></primary>
4403 </indexterm>
4404 This option is a combination of <option>-bpr</option> and <option>-bpa</option>.
4405 </para>
4406 </listitem></varlistentry>
4407 <varlistentry>
4408 <term><option>-bpru</option></term>
4409 <listitem>
4410 <para>
4411 <indexterm role="option">
4412 <primary><option>-bpru</option></primary>
4413 </indexterm>
4414 This option is a combination of <option>-bpr</option> and <option>-bpu</option>.
4415 </para>
4416 </listitem></varlistentry>
4417 <varlistentry>
4418 <term><option>-bpu</option></term>
4419 <listitem>
4420 <para>
4421 <indexterm role="option">
4422 <primary><option>-bpu</option></primary>
4423 </indexterm>
4424 This option operates like <option>-bp</option> but shows only undelivered top-level
4425 addresses for each message displayed. Addresses generated by aliasing or
4426 forwarding are not shown, unless the message was deferred after processing by a
4427 router with the <option>one_time</option> option set.
4428 </para>
4429 </listitem></varlistentry>
4430 <varlistentry>
4431 <term><option>-brt</option></term>
4432 <listitem>
4433 <para>
4434 <indexterm role="option">
4435 <primary><option>-brt</option></primary>
4436 </indexterm>
4437 <indexterm role="concept">
4438 <primary>testing</primary>
4439 <secondary>retry configuration</secondary>
4440 </indexterm>
4441 <indexterm role="concept">
4442 <primary>retry</primary>
4443 <secondary>configuration testing</secondary>
4444 </indexterm>
4445 This option is for testing retry rules, and it must be followed by up to three
4446 arguments. It causes Exim to look for a retry rule that matches the values
4447 and to write it to the standard output. For example:
4448 </para>
4449 <literallayout class="monospaced">
4450 exim -brt bach.comp.mus.example
4451 Retry rule: *.comp.mus.example  F,2h,15m; F,4d,30m;
4452 </literallayout>
4453 <para>
4454 See chapter <xref linkend="CHAPretry"/> for a description of Exim&#x2019;s retry rules. The first
4455 argument, which is required, can be a complete address in the form
4456 <emphasis>local_part@domain</emphasis>, or it can be just a domain name. If the second argument
4457 contains a dot, it is interpreted as an optional second domain name; if no
4458 retry rule is found for the first argument, the second is tried. This ties in
4459 with Exim&#x2019;s behaviour when looking for retry rules for remote hosts &ndash; if no
4460 rule is found that matches the host, one that matches the mail domain is
4461 sought. Finally, an argument that is the name of a specific delivery error, as
4462 used in setting up retry rules, can be given. For example:
4463 </para>
4464 <literallayout class="monospaced">
4465 exim -brt haydn.comp.mus.example quota_3d
4466 Retry rule: *@haydn.comp.mus.example quota_3d  F,1h,15m
4467 </literallayout>
4468 </listitem></varlistentry>
4469 <varlistentry>
4470 <term><option>-brw</option></term>
4471 <listitem>
4472 <para>
4473 <indexterm role="option">
4474 <primary><option>-brw</option></primary>
4475 </indexterm>
4476 <indexterm role="concept">
4477 <primary>testing</primary>
4478 <secondary>rewriting</secondary>
4479 </indexterm>
4480 <indexterm role="concept">
4481 <primary>rewriting</primary>
4482 <secondary>testing</secondary>
4483 </indexterm>
4484 This option is for testing address rewriting rules, and it must be followed by
4485 a single argument, consisting of either a local part without a domain, or a
4486 complete address with a fully qualified domain. Exim outputs how this address
4487 would be rewritten for each possible place it might appear. See chapter
4488 <xref linkend="CHAPrewrite"/> for further details.
4489 </para>
4490 </listitem></varlistentry>
4491 <varlistentry>
4492 <term><option>-bS</option></term>
4493 <listitem>
4494 <para>
4495 <indexterm role="option">
4496 <primary><option>-bS</option></primary>
4497 </indexterm>
4498 <indexterm role="concept">
4499 <primary>SMTP</primary>
4500 <secondary>batched incoming</secondary>
4501 </indexterm>
4502 <indexterm role="concept">
4503 <primary>batched SMTP input</primary>
4504 </indexterm>
4505 This option is used for batched SMTP input, which is an alternative interface
4506 for non-interactive local message submission. A number of messages can be
4507 submitted in a single run. However, despite its name, this is not really SMTP
4508 input. Exim reads each message&#x2019;s envelope from SMTP commands on the standard
4509 input, but generates no responses. If the caller is trusted, or
4510 <option>untrusted_set_sender</option> is set, the senders in the SMTP MAIL commands are
4511 believed; otherwise the sender is always the caller of Exim.
4512 </para>
4513 <para>
4514 The message itself is read from the standard input, in SMTP format (leading
4515 dots doubled), terminated by a line containing just a single dot. An error is
4516 provoked if the terminating dot is missing. A further message may then follow.
4517 </para>
4518 <para>
4519 As for other local message submissions, the contents of incoming batch SMTP
4520 messages can be checked using the non-SMTP ACL (see chapter <xref linkend="CHAPACL"/>).
4521 Unqualified addresses are automatically qualified using <option>qualify_domain</option> and
4522 <option>qualify_recipient</option>, as appropriate, unless the <option>-bnq</option> option is used.
4523 </para>
4524 <para>
4525 Some other SMTP commands are recognized in the input. HELO and EHLO act
4526 as RSET; VRFY, EXPN, ETRN, and HELP act as NOOP;
4527 QUIT quits, ignoring the rest of the standard input.
4528 </para>
4529 <para>
4530 <indexterm role="concept">
4531 <primary>return code</primary>
4532 <secondary>for <option>-bS</option></secondary>
4533 </indexterm>
4534 If any error is encountered, reports are written to the standard output and
4535 error streams, and Exim gives up immediately. The return code is 0 if no error
4536 was detected; it is 1 if one or more messages were accepted before the error
4537 was detected; otherwise it is 2.
4538 </para>
4539 <para>
4540 More details of input using batched SMTP are given in section
4541 <xref linkend="SECTincomingbatchedSMTP"/>.
4542 </para>
4543 </listitem></varlistentry>
4544 <varlistentry>
4545 <term><option>-bs</option></term>
4546 <listitem>
4547 <para>
4548 <indexterm role="option">
4549 <primary><option>-bs</option></primary>
4550 </indexterm>
4551 <indexterm role="concept">
4552 <primary>SMTP</primary>
4553 <secondary>local input</secondary>
4554 </indexterm>
4555 <indexterm role="concept">
4556 <primary>local SMTP input</primary>
4557 </indexterm>
4558 This option causes Exim to accept one or more messages by reading SMTP commands
4559 on the standard input, and producing SMTP replies on the standard output. SMTP
4560 policy controls, as defined in ACLs (see chapter <xref linkend="CHAPACL"/>) are applied.
4561 Some user agents use this interface as a way of passing locally-generated
4562 messages to the MTA.
4563 </para>
4564 <para>
4565 In
4566 <indexterm role="concept">
4567 <primary>sender</primary>
4568 <secondary>source of</secondary>
4569 </indexterm>
4570 this usage, if the caller of Exim is trusted, or <option>untrusted_set_sender</option> is
4571 set, the senders of messages are taken from the SMTP MAIL commands.
4572 Otherwise the content of these commands is ignored and the sender is set up as
4573 the calling user. Unqualified addresses are automatically qualified using
4574 <option>qualify_domain</option> and <option>qualify_recipient</option>, as appropriate, unless the
4575 <option>-bnq</option> option is used.
4576 </para>
4577 <para>
4578 <indexterm role="concept">
4579 <primary>inetd</primary>
4580 </indexterm>
4581 The
4582 <option>-bs</option> option is also used to run Exim from <emphasis>inetd</emphasis>, as an alternative to
4583 using a listening daemon. Exim can distinguish the two cases by checking
4584 whether the standard input is a TCP/IP socket. When Exim is called from
4585 <emphasis>inetd</emphasis>, the source of the mail is assumed to be remote, and the comments
4586 above concerning senders and qualification do not apply. In this situation,
4587 Exim behaves in exactly the same way as it does when receiving a message via
4588 the listening daemon.
4589 </para>
4590 </listitem></varlistentry>
4591 <varlistentry revisionflag="changed">
4592 <term><option>-bmalware</option>&nbsp;&lt;<emphasis>filename</emphasis>&gt;</term>
4593 <listitem>
4594 <para revisionflag="changed">
4595 <indexterm role="option">
4596 <primary><option>-bmalware</option></primary>
4597 </indexterm>
4598 <indexterm role="concept">
4599 <primary>testing</primary>
4600 <secondary>,</secondary>
4601 </indexterm>
4602 <indexterm role="concept">
4603 <primary>malware scan test</primary>
4604 </indexterm>
4605 This debugging option causes Exim to scan the given file,
4606 using the malware scanning framework.  The option of <option>av_scanner</option> influences
4607 this option, so if <option>av_scanner</option>&#x2019;s value is dependent upon an expansion then
4608 the expansion should have defaults which apply to this invocation.  ACLs are
4609 not invoked, so if <option>av_scanner</option> references an ACL variable then that variable
4610 will never be populated and <option>-bmalware</option> will fail.
4611 </para>
4612 <para revisionflag="changed">
4613 Exim will have changed working directory before resolving the filename, so
4614 using fully qualified pathnames is advisable.  Exim will be running as the Exim
4615 user when it tries to open the file, rather than as the invoking user.
4616 This option requires admin privileges.
4617 </para>
4618 <para revisionflag="changed">
4619 The <option>-bmalware</option> option will not be extended to be more generally useful,
4620 there are better tools for file-scanning.  This option exists to help
4621 administrators verify their Exim and AV scanner configuration.
4622 </para>
4623 </listitem></varlistentry>
4624 <varlistentry>
4625 <term><option>-bt</option></term>
4626 <listitem>
4627 <para>
4628 <indexterm role="option">
4629 <primary><option>-bt</option></primary>
4630 </indexterm>
4631 <indexterm role="concept">
4632 <primary>testing</primary>
4633 <secondary>addresses</secondary>
4634 </indexterm>
4635 <indexterm role="concept">
4636 <primary>address</primary>
4637 <secondary>testing</secondary>
4638 </indexterm>
4639 This option runs Exim in address testing mode, in which each argument is taken
4640 as a recipient address to be tested for deliverability. The results are
4641 written to the standard output. If a test fails, and the caller is not an admin
4642 user, no details of the failure are output, because these might contain
4643 sensitive information such as usernames and passwords for database lookups.
4644 </para>
4645 <para>
4646 If no arguments are given, Exim runs in an interactive manner, prompting with a
4647 right angle bracket for addresses to be tested.
4648 </para>
4649 <para>
4650 Unlike the <option>-be</option> test option, you cannot arrange for Exim to use the
4651 <function>readline()</function> function, because it is running as <emphasis>root</emphasis> and there are
4652 security issues.
4653 </para>
4654 <para>
4655 Each address is handled as if it were the recipient address of a message
4656 (compare the <option>-bv</option> option). It is passed to the routers and the result is
4657 written to the standard output. However, any router that has
4658 <option>no_address_test</option> set is bypassed. This can make <option>-bt</option> easier to use for
4659 genuine routing tests if your first router passes everything to a scanner
4660 program.
4661 </para>
4662 <para>
4663 <indexterm role="concept">
4664 <primary>return code</primary>
4665 <secondary>for <option>-bt</option></secondary>
4666 </indexterm>
4667 The return code is 2 if any address failed outright; it is 1 if no address
4668 failed outright but at least one could not be resolved for some reason. Return
4669 code 0 is given only when all addresses succeed.
4670 </para>
4671 <para>
4672 <indexterm role="concept">
4673 <primary>duplicate addresses</primary>
4674 </indexterm>
4675 <emphasis role="bold">Note</emphasis>: When actually delivering a message, Exim removes duplicate recipient
4676 addresses after routing is complete, so that only one delivery takes place.
4677 This does not happen when testing with <option>-bt</option>; the full results of routing are
4678 always shown.
4679 </para>
4680 <para>
4681 <emphasis role="bold">Warning</emphasis>: <option>-bt</option> can only do relatively simple testing. If any of the
4682 routers in the configuration makes any tests on the sender address of a
4683 message,
4684 <indexterm role="option">
4685 <primary><option>-f</option></primary>
4686 <secondary>for address testing</secondary>
4687 </indexterm>
4688 you can use the <option>-f</option> option to set an appropriate sender when running
4689 <option>-bt</option> tests. Without it, the sender is assumed to be the calling user at the
4690 default qualifying domain. However, if you have set up (for example) routers
4691 whose behaviour depends on the contents of an incoming message, you cannot test
4692 those conditions using <option>-bt</option>. The <option>-N</option> option provides a possible way of
4693 doing such tests.
4694 </para>
4695 </listitem></varlistentry>
4696 <varlistentry revisionflag="changed">
4697 <term><option>-bV</option></term>
4698 <listitem>
4699 <para revisionflag="changed">
4700 <indexterm role="option">
4701 <primary><option>-bV</option></primary>
4702 </indexterm>
4703 <indexterm role="concept">
4704 <primary>version number of Exim</primary>
4705 </indexterm>
4706 This option causes Exim to write the current version number, compilation
4707 number, and compilation date of the <emphasis>exim</emphasis> binary to the standard output.
4708 It also lists the DBM library that is being used, the optional modules (such as
4709 specific lookup types), the drivers that are included in the binary, and the
4710 name of the run time configuration file that is in use.
4711 </para>
4712 <para>
4713 As part of its operation, <option>-bV</option> causes Exim to read and syntax check its
4714 configuration file. However, this is a static check only. It cannot check
4715 values that are to be expanded. For example, although a misspelt ACL verb is
4716 detected, an error in the verb&#x2019;s arguments is not. You cannot rely on <option>-bV</option>
4717 alone to discover (for example) all the typos in the configuration; some
4718 realistic testing is needed. The <option>-bh</option> and <option>-N</option> options provide more
4719 dynamic testing facilities.
4720 </para>
4721 </listitem></varlistentry>
4722 <varlistentry>
4723 <term><option>-bv</option></term>
4724 <listitem>
4725 <para>
4726 <indexterm role="option">
4727 <primary><option>-bv</option></primary>
4728 </indexterm>
4729 <indexterm role="concept">
4730 <primary>verifying address</primary>
4731 <secondary>using <option>-bv</option></secondary>
4732 </indexterm>
4733 <indexterm role="concept">
4734 <primary>address</primary>
4735 <secondary>verification</secondary>
4736 </indexterm>
4737 This option runs Exim in address verification mode, in which each argument is
4738 taken as a recipient address to be verified by the routers. (This does
4739 not involve any verification callouts). During normal operation, verification
4740 happens mostly as a consequence processing a <option>verify</option> condition in an ACL
4741 (see chapter <xref linkend="CHAPACL"/>). If you want to test an entire ACL, possibly
4742 including callouts, see the <option>-bh</option> and <option>-bhc</option> options.
4743 </para>
4744 <para>
4745 If verification fails, and the caller is not an admin user, no details of the
4746 failure are output, because these might contain sensitive information such as
4747 usernames and passwords for database lookups.
4748 </para>
4749 <para>
4750 If no arguments are given, Exim runs in an interactive manner, prompting with a
4751 right angle bracket for addresses to be verified.
4752 </para>
4753 <para>
4754 Unlike the <option>-be</option> test option, you cannot arrange for Exim to use the
4755 <function>readline()</function> function, because it is running as <emphasis>exim</emphasis> and there are
4756 security issues.
4757 </para>
4758 <para>
4759 Verification differs from address testing (the <option>-bt</option> option) in that routers
4760 that have <option>no_verify</option> set are skipped, and if the address is accepted by a
4761 router that has <option>fail_verify</option> set, verification fails. The address is
4762 verified as a recipient if <option>-bv</option> is used; to test verification for a sender
4763 address, <option>-bvs</option> should be used.
4764 </para>
4765 <para>
4766 If the <option>-v</option> option is not set, the output consists of a single line for each
4767 address, stating whether it was verified or not, and giving a reason in the
4768 latter case. Without <option>-v</option>, generating more than one address by redirection
4769 causes verification to end successfully, without considering the generated
4770 addresses. However, if just one address is generated, processing continues,
4771 and the generated address must verify successfully for the overall verification
4772 to succeed.
4773 </para>
4774 <para>
4775 When <option>-v</option> is set, more details are given of how the address has been handled,
4776 and in the case of address redirection, all the generated addresses are also
4777 considered. Verification may succeed for some and fail for others.
4778 </para>
4779 <para>
4780 The
4781 <indexterm role="concept">
4782 <primary>return code</primary>
4783 <secondary>for <option>-bv</option></secondary>
4784 </indexterm>
4785 return code is 2 if any address failed outright; it is 1 if no address
4786 failed outright but at least one could not be resolved for some reason. Return
4787 code 0 is given only when all addresses succeed.
4788 </para>
4789 <para>
4790 If any of the routers in the configuration makes any tests on the sender
4791 address of a message, you should use the <option>-f</option> option to set an appropriate
4792 sender when running <option>-bv</option> tests. Without it, the sender is assumed to be the
4793 calling user at the default qualifying domain.
4794 </para>
4795 </listitem></varlistentry>
4796 <varlistentry>
4797 <term><option>-bvs</option></term>
4798 <listitem>
4799 <para>
4800 <indexterm role="option">
4801 <primary><option>-bvs</option></primary>
4802 </indexterm>
4803 This option acts like <option>-bv</option>, but verifies the address as a sender rather
4804 than a recipient address. This affects any rewriting and qualification that
4805 might happen.
4806 </para>
4807 </listitem></varlistentry>
4808 <varlistentry>
4809 <term><option>-C</option>&nbsp;&lt;<emphasis>filelist</emphasis>&gt;</term>
4810 <listitem>
4811 <para>
4812 <indexterm role="option">
4813 <primary><option>-C</option></primary>
4814 </indexterm>
4815 <indexterm role="concept">
4816 <primary>configuration file</primary>
4817 <secondary>alternate</secondary>
4818 </indexterm>
4819 <indexterm role="concept">
4820 <primary>CONFIGURE_FILE</primary>
4821 </indexterm>
4822 <indexterm role="concept">
4823 <primary>alternate configuration file</primary>
4824 </indexterm>
4825 This option causes Exim to find the run time configuration file from the given
4826 list instead of from the list specified by the CONFIGURE_FILE
4827 compile-time setting. Usually, the list will consist of just a single file
4828 name, but it can be a colon-separated list of names. In this case, the first
4829 file that exists is used. Failure to open an existing file stops Exim from
4830 proceeding any further along the list, and an error is generated.
4831 </para>
4832 <para revisionflag="changed">
4833 When this option is used by a caller other than root, and the list is different
4834 from the compiled-in list, Exim gives up its root privilege immediately, and
4835 runs with the real and effective uid and gid set to those of the caller.
4836 However, if a TRUSTED_CONFIG_LIST file is defined in <filename>Local/Makefile</filename>, that
4837 file contains a list of full pathnames, one per line, for configuration files
4838 which are trusted. Root privilege is retained for any configuration file so
4839 listed, as long as the caller is the Exim user (or the user specified in the
4840 CONFIGURE_OWNER option, if any), and as long as the configuration file is
4841 not writeable by inappropriate users or groups.
4842 </para>
4843 <para revisionflag="changed">
4844 Leaving TRUSTED_CONFIG_LIST unset precludes the possibility of testing a
4845 configuration using <option>-C</option> right through message reception and delivery,
4846 even if the caller is root. The reception works, but by that time, Exim is
4847 running as the Exim user, so when it re-executes to regain privilege for the
4848 delivery, the use of <option>-C</option> causes privilege to be lost. However, root can
4849 test reception and delivery using two separate commands (one to put a message
4850 on the queue, using <option>-odq</option>, and another to do the delivery, using <option>-M</option>).
4851 </para>
4852 <para>
4853 If ALT_CONFIG_PREFIX is defined <filename>in Local/Makefile</filename>, it specifies a
4854 prefix string with which any file named in a <option>-C</option> command line option
4855 must start. In addition, the file name must not contain the sequence <literal>/../</literal>.
4856 However, if the value of the <option>-C</option> option is identical to the value of
4857 CONFIGURE_FILE in <filename>Local/Makefile</filename>, Exim ignores <option>-C</option> and proceeds as
4858 usual. There is no default setting for ALT_CONFIG_PREFIX; when it is
4859 unset, any file name can be used with <option>-C</option>.
4860 </para>
4861 <para>
4862 ALT_CONFIG_PREFIX can be used to confine alternative configuration files
4863 to a directory to which only root has access. This prevents someone who has
4864 broken into the Exim account from running a privileged Exim with an arbitrary
4865 configuration file.
4866 </para>
4867 <para>
4868 The <option>-C</option> facility is useful for ensuring that configuration files are
4869 syntactically correct, but cannot be used for test deliveries, unless the
4870 caller is privileged, or unless it is an exotic configuration that does not
4871 require privilege. No check is made on the owner or group of the files
4872 specified by this option.
4873 </para>
4874 </listitem></varlistentry>
4875 <varlistentry>
4876 <term><option>-D</option>&lt;<emphasis>macro</emphasis>&gt;=&lt;<emphasis>value</emphasis>&gt;</term>
4877 <listitem>
4878 <para>
4879 <indexterm role="option">
4880 <primary><option>-D</option></primary>
4881 </indexterm>
4882 <indexterm role="concept">
4883 <primary>macro</primary>
4884 <secondary>setting on command line</secondary>
4885 </indexterm>
4886 This option can be used to override macro definitions in the configuration file
4887 (see section <xref linkend="SECTmacrodefs"/>). However, like <option>-C</option>, if it is used by an
4888 unprivileged caller, it causes Exim to give up its root privilege.
4889 If DISABLE_D_OPTION is defined in <filename>Local/Makefile</filename>, the use of <option>-D</option> is
4890 completely disabled, and its use causes an immediate error exit.
4891 </para>
4892 <para revisionflag="changed">
4893 If WHITELIST_D_MACROS is defined in <filename>Local/Makefile</filename> then it should be a
4894 colon-separated list of macros which are considered safe and, if <option>-D</option> only
4895 supplies macros from this list, and the values are acceptable, then Exim will
4896 not give up root privilege if the caller is root, the Exim run-time user, or
4897 the CONFIGURE_OWNER, if set.  This is a transition mechanism and is expected
4898 to be removed in the future.  Acceptable values for the macros satisfy the
4899 regexp: <literal>^[A-Za-z0-9_/.-]*$</literal>
4900 </para>
4901 <para>
4902 The entire option (including equals sign if present) must all be within one
4903 command line item. <option>-D</option> can be used to set the value of a macro to the empty
4904 string, in which case the equals sign is optional. These two commands are
4905 synonymous:
4906 </para>
4907 <literallayout class="monospaced">
4908 exim -DABC  ...
4909 exim -DABC= ...
4910 </literallayout>
4911 <para>
4912 To include spaces in a macro definition item, quotes must be used. If you use
4913 quotes, spaces are permitted around the macro name and the equals sign. For
4914 example:
4915 </para>
4916 <literallayout class="monospaced">
4917 exim '-D ABC = something' ...
4918 </literallayout>
4919 <para>
4920 <option>-D</option> may be repeated up to 10 times on a command line.
4921 </para>
4922 </listitem></varlistentry>
4923 <varlistentry>
4924 <term><option>-d</option>&lt;<emphasis>debug&nbsp;options</emphasis>&gt;</term>
4925 <listitem>
4926 <para>
4927 <indexterm role="option">
4928 <primary><option>-d</option></primary>
4929 </indexterm>
4930 <indexterm role="concept">
4931 <primary>debugging</primary>
4932 <secondary>list of selectors</secondary>
4933 </indexterm>
4934 <indexterm role="concept">
4935 <primary>debugging</primary>
4936 <secondary><option>-d</option> option</secondary>
4937 </indexterm>
4938 This option causes debugging information to be written to the standard
4939 error stream. It is restricted to admin users because debugging output may show
4940 database queries that contain password information. Also, the details of users&#x2019;
4941 filter files should be protected. If a non-admin user uses <option>-d</option>, Exim
4942 writes an error message to the standard error stream and exits with a non-zero
4943 return code.
4944 </para>
4945 <para>
4946 When <option>-d</option> is used, <option>-v</option> is assumed. If <option>-d</option> is given on its own, a lot of
4947 standard debugging data is output. This can be reduced, or increased to include
4948 some more rarely needed information, by directly following <option>-d</option> with a string
4949 made up of names preceded by plus or minus characters. These add or remove sets
4950 of debugging data, respectively. For example, <option>-d+filter</option> adds filter
4951 debugging, whereas <option>-d-all+filter</option> selects only filter debugging. Note that
4952 no spaces are allowed in the debug setting. The available debugging categories
4953 are:
4954 </para>
4955 <literallayout>
4956 <literal>acl            </literal> ACL interpretation
4957 <literal>auth           </literal> authenticators
4958 <literal>deliver        </literal> general delivery logic
4959 <literal>dns            </literal> DNS lookups (see also resolver)
4960 <literal>dnsbl          </literal> DNS black list (aka RBL) code
4961 <literal>exec           </literal> arguments for <function>execv()</function> calls
4962 <literal>expand         </literal> detailed debugging for string expansions
4963 <literal>filter         </literal> filter handling
4964 <literal>hints_lookup   </literal> hints data lookups
4965 <literal>host_lookup    </literal> all types of name-to-IP address handling
4966 <literal>ident          </literal> ident lookup
4967 <literal>interface      </literal> lists of local interfaces
4968 <literal>lists          </literal> matching things in lists
4969 <literal>load           </literal> system load checks
4970 <literal>local_scan     </literal> can be used by <function>local_scan()</function> (see chapter <xref linkend="CHAPlocalscan"/>)
4971 <literal>lookup         </literal> general lookup code and all lookups
4972 <literal>memory         </literal> memory handling
4973 <literal>pid            </literal> add pid to debug output lines
4974 <literal>process_info   </literal> setting info for the process log
4975 <literal>queue_run      </literal> queue runs
4976 <literal>receive        </literal> general message reception logic
4977 <literal>resolver       </literal> turn on the DNS resolver&#x2019;s debugging output
4978 <literal>retry          </literal> retry handling
4979 <literal>rewrite        </literal> address rewriting
4980 <literal>route          </literal> address routing
4981 <literal>timestamp      </literal> add timestamp to debug output lines
4982 <literal>tls            </literal> TLS logic
4983 <literal>transport      </literal> transports
4984 <literal>uid            </literal> changes of uid/gid and looking up uid/gid
4985 <literal>verify         </literal> address verification logic
4986 <literal>all            </literal> almost all of the above (see below), and also <option>-v</option>
4987 </literallayout>
4988 <para>
4989 The <literal>all</literal> option excludes <literal>memory</literal> when used as <literal>+all</literal>, but includes it
4990 for <literal>-all</literal>. The reason for this is that <literal>+all</literal> is something that people
4991 tend to use when generating debug output for Exim maintainers. If <literal>+memory</literal>
4992 is included, an awful lot of output that is very rarely of interest is
4993 generated, so it now has to be explicitly requested. However, <literal>-all</literal> does
4994 turn everything off.
4995 </para>
4996 <para>
4997 <indexterm role="concept">
4998 <primary>resolver, debugging output</primary>
4999 </indexterm>
5000 <indexterm role="concept">
5001 <primary>DNS resolver, debugging output</primary>
5002 </indexterm>
5003 The <literal>resolver</literal> option produces output only if the DNS resolver was compiled
5004 with DEBUG enabled. This is not the case in some operating systems. Also,
5005 unfortunately, debugging output from the DNS resolver is written to stdout
5006 rather than stderr.
5007 </para>
5008 <para>
5009 The default (<option>-d</option> with no argument) omits <literal>expand</literal>, <literal>filter</literal>,
5010 <literal>interface</literal>, <literal>load</literal>, <literal>memory</literal>, <literal>pid</literal>, <literal>resolver</literal>, and <literal>timestamp</literal>.
5011 However, the <literal>pid</literal> selector is forced when debugging is turned on for a
5012 daemon, which then passes it on to any re-executed Exims. Exim also
5013 automatically adds the pid to debug lines when several remote deliveries are
5014 run in parallel.
5015 </para>
5016 <para>
5017 The <literal>timestamp</literal> selector causes the current time to be inserted at the start
5018 of all debug output lines. This can be useful when trying to track down delays
5019 in processing.
5020 </para>
5021 <para>
5022 If the <option>debug_print</option> option is set in any driver, it produces output whenever
5023 any debugging is selected, or if <option>-v</option> is used.
5024 </para>
5025 </listitem></varlistentry>
5026 <varlistentry>
5027 <term><option>-dd</option>&lt;<emphasis>debug&nbsp;options</emphasis>&gt;</term>
5028 <listitem>
5029 <para>
5030 <indexterm role="option">
5031 <primary><option>-dd</option></primary>
5032 </indexterm>
5033 This option behaves exactly like <option>-d</option> except when used on a command that
5034 starts a daemon process. In that case, debugging is turned off for the
5035 subprocesses that the daemon creates. Thus, it is useful for monitoring the
5036 behaviour of the daemon without creating as much output as full debugging does.
5037 </para>
5038 </listitem></varlistentry>
5039 <varlistentry>
5040 <term><option>-dropcr</option></term>
5041 <listitem>
5042 <para>
5043 <indexterm role="option">
5044 <primary><option>-dropcr</option></primary>
5045 </indexterm>
5046 This is an obsolete option that is now a no-op. It used to affect the way Exim
5047 handled CR and LF characters in incoming messages. What happens now is
5048 described in section <xref linkend="SECTlineendings"/>.
5049 </para>
5050 </listitem></varlistentry>
5051 <varlistentry>
5052 <term><option>-E</option></term>
5053 <listitem>
5054 <para>
5055 <indexterm role="option">
5056 <primary><option>-E</option></primary>
5057 </indexterm>
5058 <indexterm role="concept">
5059 <primary>bounce message</primary>
5060 <secondary>generating</secondary>
5061 </indexterm>
5062 This option specifies that an incoming message is a locally-generated delivery
5063 failure report. It is used internally by Exim when handling delivery failures
5064 and is not intended for external use. Its only effect is to stop Exim
5065 generating certain messages to the postmaster, as otherwise message cascades
5066 could occur in some situations. As part of the same option, a message id may
5067 follow the characters <option>-E</option>. If it does, the log entry for the receipt of the
5068 new message contains the id, following <quote>R=</quote>, as a cross-reference.
5069 </para>
5070 </listitem></varlistentry>
5071 <varlistentry>
5072 <term><option>-e</option><emphasis>x</emphasis></term>
5073 <listitem>
5074 <para>
5075 <indexterm role="option">
5076 <primary><option>-e</option><emphasis>x</emphasis></primary>
5077 </indexterm>
5078 There are a number of Sendmail options starting with <option>-oe</option> which seem to be
5079 called by various programs without the leading <option>o</option> in the option. For
5080 example, the <option>vacation</option> program uses <option>-eq</option>. Exim treats all options of the
5081 form <option>-e</option><emphasis>x</emphasis> as synonymous with the corresponding <option>-oe</option><emphasis>x</emphasis> options.
5082 </para>
5083 </listitem></varlistentry>
5084 <varlistentry>
5085 <term><option>-F</option>&nbsp;&lt;<emphasis>string</emphasis>&gt;</term>
5086 <listitem>
5087 <para>
5088 <indexterm role="option">
5089 <primary><option>-F</option></primary>
5090 </indexterm>
5091 <indexterm role="concept">
5092 <primary>sender</primary>
5093 <secondary>name</secondary>
5094 </indexterm>
5095 <indexterm role="concept">
5096 <primary>name</primary>
5097 <secondary>of sender</secondary>
5098 </indexterm>
5099 This option sets the sender&#x2019;s full name for use when a locally-generated
5100 message is being accepted. In the absence of this option, the user&#x2019;s <emphasis>gecos</emphasis>
5101 entry from the password data is used. As users are generally permitted to alter
5102 their <emphasis>gecos</emphasis> entries, no security considerations are involved. White space
5103 between <option>-F</option> and the &lt;<emphasis>string</emphasis>&gt; is optional.
5104 </para>
5105 </listitem></varlistentry>
5106 <varlistentry>
5107 <term><option>-f</option>&nbsp;&lt;<emphasis>address</emphasis>&gt;</term>
5108 <listitem>
5109 <para>
5110 <indexterm role="option">
5111 <primary><option>-f</option></primary>
5112 </indexterm>
5113 <indexterm role="concept">
5114 <primary>sender</primary>
5115 <secondary>address</secondary>
5116 </indexterm>
5117 <indexterm role="concept">
5118 <primary>address</primary>
5119 <secondary>sender</secondary>
5120 </indexterm>
5121 <indexterm role="concept">
5122 <primary>trusted users</primary>
5123 </indexterm>
5124 <indexterm role="concept">
5125 <primary>envelope sender</primary>
5126 </indexterm>
5127 <indexterm role="concept">
5128 <primary>user</primary>
5129 <secondary>trusted</secondary>
5130 </indexterm>
5131 This option sets the address of the envelope sender of a locally-generated
5132 message (also known as the return path). The option can normally be used only
5133 by a trusted user, but <option>untrusted_set_sender</option> can be set to allow untrusted
5134 users to use it.
5135 </para>
5136 <para>
5137 Processes running as root or the Exim user are always trusted. Other
5138 trusted users are defined by the <option>trusted_users</option> or <option>trusted_groups</option>
5139 options. In the absence of <option>-f</option>, or if the caller is not trusted, the sender
5140 of a local message is set to the caller&#x2019;s login name at the default qualify
5141 domain.
5142 </para>
5143 <para>
5144 There is one exception to the restriction on the use of <option>-f</option>: an empty sender
5145 can be specified by any user, trusted or not, to create a message that can
5146 never provoke a bounce. An empty sender can be specified either as an empty
5147 string, or as a pair of angle brackets with nothing between them, as in these
5148 examples of shell commands:
5149 </para>
5150 <literallayout class="monospaced">
5151 exim -f '&lt;&gt;' user@domain
5152 exim -f "" user@domain
5153 </literallayout>
5154 <para>
5155 In addition, the use of <option>-f</option> is not restricted when testing a filter file
5156 with <option>-bf</option> or when testing or verifying addresses using the <option>-bt</option> or
5157 <option>-bv</option> options.
5158 </para>
5159 <para>
5160 Allowing untrusted users to change the sender address does not of itself make
5161 it possible to send anonymous mail. Exim still checks that the <emphasis>From:</emphasis> header
5162 refers to the local user, and if it does not, it adds a <emphasis>Sender:</emphasis> header,
5163 though this can be overridden by setting <option>no_local_from_check</option>.
5164 </para>
5165 <para>
5166 White
5167 <indexterm role="concept">
5168 <primary><quote>From</quote> line</primary>
5169 </indexterm>
5170 space between <option>-f</option> and the &lt;<emphasis>address</emphasis>&gt; is optional (that is, they can be
5171 given as two arguments or one combined argument). The sender of a
5172 locally-generated message can also be set (when permitted) by an initial
5173 <quote>From&nbsp;</quote> line in the message &ndash; see the description of <option>-bm</option> above &ndash; but
5174 if <option>-f</option> is also present, it overrides <quote>From&nbsp;</quote>.
5175 </para>
5176 </listitem></varlistentry>
5177 <varlistentry>
5178 <term><option>-G</option></term>
5179 <listitem>
5180 <para>
5181 <indexterm role="option">
5182 <primary><option>-G</option></primary>
5183 </indexterm>
5184 <indexterm role="concept">
5185 <primary>Sendmail compatibility</primary>
5186 <secondary><option>-G</option> option ignored</secondary>
5187 </indexterm>
5188 This is a Sendmail option which is ignored by Exim.
5189 </para>
5190 </listitem></varlistentry>
5191 <varlistentry>
5192 <term><option>-h</option>&nbsp;&lt;<emphasis>number</emphasis>&gt;</term>
5193 <listitem>
5194 <para>
5195 <indexterm role="option">
5196 <primary><option>-h</option></primary>
5197 </indexterm>
5198 <indexterm role="concept">
5199 <primary>Sendmail compatibility</primary>
5200 <secondary><option>-h</option> option ignored</secondary>
5201 </indexterm>
5202 This option is accepted for compatibility with Sendmail, but has no effect. (In
5203 Sendmail it overrides the <quote>hop count</quote> obtained by counting <emphasis>Received:</emphasis>
5204 headers.)
5205 </para>
5206 </listitem></varlistentry>
5207 <varlistentry>
5208 <term><option>-i</option></term>
5209 <listitem>
5210 <para>
5211 <indexterm role="option">
5212 <primary><option>-i</option></primary>
5213 </indexterm>
5214 <indexterm role="concept">
5215 <primary>Solaris</primary>
5216 <secondary><emphasis>mail</emphasis> command</secondary>
5217 </indexterm>
5218 <indexterm role="concept">
5219 <primary>dot</primary>
5220 <secondary>in incoming non-SMTP message</secondary>
5221 </indexterm>
5222 This option, which has the same effect as <option>-oi</option>, specifies that a dot on a
5223 line by itself should not terminate an incoming, non-SMTP message. I can find
5224 no documentation for this option in Solaris 2.4 Sendmail, but the <emphasis>mailx</emphasis>
5225 command in Solaris 2.4 uses it. See also <option>-ti</option>.
5226 </para>
5227 </listitem></varlistentry>
5228 <varlistentry>
5229 <term><option>-M</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;...</term>
5230 <listitem>
5231 <para>
5232 <indexterm role="option">
5233 <primary><option>-M</option></primary>
5234 </indexterm>
5235 <indexterm role="concept">
5236 <primary>forcing delivery</primary>
5237 </indexterm>
5238 <indexterm role="concept">
5239 <primary>delivery</primary>
5240 <secondary>forcing attempt</secondary>
5241 </indexterm>
5242 <indexterm role="concept">
5243 <primary>frozen messages</primary>
5244 <secondary>forcing delivery</secondary>
5245 </indexterm>
5246 This option requests Exim to run a delivery attempt on each message in turn. If
5247 any of the messages are frozen, they are automatically thawed before the
5248 delivery attempt. The settings of <option>queue_domains</option>, <option>queue_smtp_domains</option>,
5249 and <option>hold_domains</option> are ignored.
5250 </para>
5251 <para>
5252 Retry
5253 <indexterm role="concept">
5254 <primary>hints database</primary>
5255 <secondary>overriding retry hints</secondary>
5256 </indexterm>
5257 hints for any of the addresses are overridden &ndash; Exim tries to deliver even if
5258 the normal retry time has not yet been reached. This option requires the caller
5259 to be an admin user. However, there is an option called <option>prod_requires_admin</option>
5260 which can be set false to relax this restriction (and also the same requirement
5261 for the <option>-q</option>, <option>-R</option>, and <option>-S</option> options).
5262 </para>
5263 <para>
5264 The deliveries happen synchronously, that is, the original Exim process does
5265 not terminate until all the delivery attempts have finished. No output is
5266 produced unless there is a serious error. If you want to see what is happening,
5267 use the <option>-v</option> option as well, or inspect Exim&#x2019;s main log.
5268 </para>
5269 </listitem></varlistentry>
5270 <varlistentry>
5271 <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>
5272 <listitem>
5273 <para>
5274 <indexterm role="option">
5275 <primary><option>-Mar</option></primary>
5276 </indexterm>
5277 <indexterm role="concept">
5278 <primary>message</primary>
5279 <secondary>adding recipients</secondary>
5280 </indexterm>
5281 <indexterm role="concept">
5282 <primary>recipient</primary>
5283 <secondary>adding</secondary>
5284 </indexterm>
5285 This option requests Exim to add the addresses to the list of recipients of the
5286 message (<quote>ar</quote> for <quote>add recipients</quote>). The first argument must be a message
5287 id, and the remaining ones must be email addresses. However, if the message is
5288 active (in the middle of a delivery attempt), it is not altered. This option
5289 can be used only by an admin user.
5290 </para>
5291 </listitem></varlistentry>
5292 <varlistentry>
5293 <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>
5294 <listitem>
5295 <para>
5296 <indexterm role="option">
5297 <primary><option>-MC</option></primary>
5298 </indexterm>
5299 <indexterm role="concept">
5300 <primary>SMTP</primary>
5301 <secondary>passed connection</secondary>
5302 </indexterm>
5303 <indexterm role="concept">
5304 <primary>SMTP</primary>
5305 <secondary>multiple deliveries</secondary>
5306 </indexterm>
5307 <indexterm role="concept">
5308 <primary>multiple SMTP deliveries</primary>
5309 </indexterm>
5310 This option is not intended for use by external callers. It is used internally
5311 by Exim to invoke another instance of itself to deliver a waiting message using
5312 an existing SMTP connection, which is passed as the standard input. Details are
5313 given in chapter <xref linkend="CHAPSMTP"/>. This must be the final option, and the caller
5314 must be root or the Exim user in order to use it.
5315 </para>
5316 </listitem></varlistentry>
5317 <varlistentry>
5318 <term><option>-MCA</option></term>
5319 <listitem>
5320 <para>
5321 <indexterm role="option">
5322 <primary><option>-MCA</option></primary>
5323 </indexterm>
5324 This option is not intended for use by external callers. It is used internally
5325 by Exim in conjunction with the <option>-MC</option> option. It signifies that the
5326 connection to the remote host has been authenticated.
5327 </para>
5328 </listitem></varlistentry>
5329 <varlistentry>
5330 <term><option>-MCP</option></term>
5331 <listitem>
5332 <para>
5333 <indexterm role="option">
5334 <primary><option>-MCP</option></primary>
5335 </indexterm>
5336 This option is not intended for use by external callers. It is used internally
5337 by Exim in conjunction with the <option>-MC</option> option. It signifies that the server to
5338 which Exim is connected supports pipelining.
5339 </para>
5340 </listitem></varlistentry>
5341 <varlistentry>
5342 <term><option>-MCQ</option>&nbsp;&lt;<emphasis>process&nbsp;id</emphasis>&gt;&nbsp;&lt;<emphasis>pipe&nbsp;fd</emphasis>&gt;</term>
5343 <listitem>
5344 <para>
5345 <indexterm role="option">
5346 <primary><option>-MCQ</option></primary>
5347 </indexterm>
5348 This option is not intended for use by external callers. It is used internally
5349 by Exim in conjunction with the <option>-MC</option> option when the original delivery was
5350 started by a queue runner. It passes on the process id of the queue runner,
5351 together with the file descriptor number of an open pipe. Closure of the pipe
5352 signals the final completion of the sequence of processes that are passing
5353 messages through the same SMTP connection.
5354 </para>
5355 </listitem></varlistentry>
5356 <varlistentry>
5357 <term><option>-MCS</option></term>
5358 <listitem>
5359 <para>
5360 <indexterm role="option">
5361 <primary><option>-MCS</option></primary>
5362 </indexterm>
5363 This option is not intended for use by external callers. It is used internally
5364 by Exim in conjunction with the <option>-MC</option> option, and passes on the fact that the
5365 SMTP SIZE option should be used on messages delivered down the existing
5366 connection.
5367 </para>
5368 </listitem></varlistentry>
5369 <varlistentry>
5370 <term><option>-MCT</option></term>
5371 <listitem>
5372 <para>
5373 <indexterm role="option">
5374 <primary><option>-MCT</option></primary>
5375 </indexterm>
5376 This option is not intended for use by external callers. It is used internally
5377 by Exim in conjunction with the <option>-MC</option> option, and passes on the fact that the
5378 host to which Exim is connected supports TLS encryption.
5379 </para>
5380 </listitem></varlistentry>
5381 <varlistentry>
5382 <term><option>-Mc</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;...</term>
5383 <listitem>
5384 <para>
5385 <indexterm role="option">
5386 <primary><option>-Mc</option></primary>
5387 </indexterm>
5388 <indexterm role="concept">
5389 <primary>hints database</primary>
5390 <secondary>not overridden by <option>-Mc</option></secondary>
5391 </indexterm>
5392 <indexterm role="concept">
5393 <primary>delivery</primary>
5394 <secondary>manually started &ndash; not forced</secondary>
5395 </indexterm>
5396 This option requests Exim to run a delivery attempt on each message in turn,
5397 but unlike the <option>-M</option> option, it does check for retry hints, and respects any
5398 that are found. This option is not very useful to external callers. It is
5399 provided mainly for internal use by Exim when it needs to re-invoke itself in
5400 order to regain root privilege for a delivery (see chapter <xref linkend="CHAPsecurity"/>).
5401 However, <option>-Mc</option> can be useful when testing, in order to run a delivery that
5402 respects retry times and other options such as <option>hold_domains</option> that are
5403 overridden when <option>-M</option> is used. Such a delivery does not count as a queue run.
5404 If you want to run a specific delivery as if in a queue run, you should use
5405 <option>-q</option> with a message id argument. A distinction between queue run deliveries
5406 and other deliveries is made in one or two places.
5407 </para>
5408 </listitem></varlistentry>
5409 <varlistentry>
5410 <term><option>-Mes</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;&lt;<emphasis>address</emphasis>&gt;</term>
5411 <listitem>
5412 <para>
5413 <indexterm role="option">
5414 <primary><option>-Mes</option></primary>
5415 </indexterm>
5416 <indexterm role="concept">
5417 <primary>message</primary>
5418 <secondary>changing sender</secondary>
5419 </indexterm>
5420 <indexterm role="concept">
5421 <primary>sender</primary>
5422 <secondary>changing</secondary>
5423 </indexterm>
5424 This option requests Exim to change the sender address in the message to the
5425 given address, which must be a fully qualified address or <quote>&lt;&gt;</quote> (<quote>es</quote> for
5426 <quote>edit sender</quote>). There must be exactly two arguments. The first argument must
5427 be a message id, and the second one an email address. However, if the message
5428 is active (in the middle of a delivery attempt), its status is not altered.
5429 This option can be used only by an admin user.
5430 </para>
5431 </listitem></varlistentry>
5432 <varlistentry>
5433 <term><option>-Mf</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;...</term>
5434 <listitem>
5435 <para>
5436 <indexterm role="option">
5437 <primary><option>-Mf</option></primary>
5438 </indexterm>
5439 <indexterm role="concept">
5440 <primary>freezing messages</primary>
5441 </indexterm>
5442 <indexterm role="concept">
5443 <primary>message</primary>
5444 <secondary>manually freezing</secondary>
5445 </indexterm>
5446 This option requests Exim to mark each listed message as <quote>frozen</quote>. This
5447 prevents any delivery attempts taking place until the message is <quote>thawed</quote>,
5448 either manually or as a result of the <option>auto_thaw</option> configuration option.
5449 However, if any of the messages are active (in the middle of a delivery
5450 attempt), their status is not altered. This option can be used only by an admin
5451 user.
5452 </para>
5453 </listitem></varlistentry>
5454 <varlistentry>
5455 <term><option>-Mg</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;...</term>
5456 <listitem>
5457 <para>
5458 <indexterm role="option">
5459 <primary><option>-Mg</option></primary>
5460 </indexterm>
5461 <indexterm role="concept">
5462 <primary>giving up on messages</primary>
5463 </indexterm>
5464 <indexterm role="concept">
5465 <primary>message</primary>
5466 <secondary>abandoning delivery attempts</secondary>
5467 </indexterm>
5468 <indexterm role="concept">
5469 <primary>delivery</primary>
5470 <secondary>abandoning further attempts</secondary>
5471 </indexterm>
5472 This option requests Exim to give up trying to deliver the listed messages,
5473 including any that are frozen. However, if any of the messages are active,
5474 their status is not altered. For non-bounce messages, a delivery error message
5475 is sent to the sender, containing the text <quote>cancelled by administrator</quote>.
5476 Bounce messages are just discarded. This option can be used only by an admin
5477 user.
5478 </para>
5479 </listitem></varlistentry>
5480 <varlistentry>
5481 <term><option>-Mmad</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;...</term>
5482 <listitem>
5483 <para>
5484 <indexterm role="option">
5485 <primary><option>-Mmad</option></primary>
5486 </indexterm>
5487 <indexterm role="concept">
5488 <primary>delivery</primary>
5489 <secondary>cancelling all</secondary>
5490 </indexterm>
5491 This option requests Exim to mark all the recipient addresses in the messages
5492 as already delivered (<quote>mad</quote> for <quote>mark all delivered</quote>). However, if any
5493 message is active (in the middle of a delivery attempt), its status is not
5494 altered. This option can be used only by an admin user.
5495 </para>
5496 </listitem></varlistentry>
5497 <varlistentry>
5498 <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>
5499 <listitem>
5500 <para>
5501 <indexterm role="option">
5502 <primary><option>-Mmd</option></primary>
5503 </indexterm>
5504 <indexterm role="concept">
5505 <primary>delivery</primary>
5506 <secondary>cancelling by address</secondary>
5507 </indexterm>
5508 <indexterm role="concept">
5509 <primary>recipient</primary>
5510 <secondary>removing</secondary>
5511 </indexterm>
5512 <indexterm role="concept">
5513 <primary>removing recipients</primary>
5514 </indexterm>
5515 This option requests Exim to mark the given addresses as already delivered
5516 (<quote>md</quote> for <quote>mark delivered</quote>). The first argument must be a message id, and
5517 the remaining ones must be email addresses. These are matched to recipient
5518 addresses in the message in a case-sensitive manner. If the message is active
5519 (in the middle of a delivery attempt), its status is not altered. This option
5520 can be used only by an admin user.
5521 </para>
5522 </listitem></varlistentry>
5523 <varlistentry>
5524 <term><option>-Mrm</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;...</term>
5525 <listitem>
5526 <para>
5527 <indexterm role="option">
5528 <primary><option>-Mrm</option></primary>
5529 </indexterm>
5530 <indexterm role="concept">
5531 <primary>removing messages</primary>
5532 </indexterm>
5533 <indexterm role="concept">
5534 <primary>abandoning mail</primary>
5535 </indexterm>
5536 <indexterm role="concept">
5537 <primary>message</primary>
5538 <secondary>manually discarding</secondary>
5539 </indexterm>
5540 This option requests Exim to remove the given messages from the queue. No
5541 bounce messages are sent; each message is simply forgotten. However, if any of
5542 the messages are active, their status is not altered. This option can be used
5543 only by an admin user or by the user who originally caused the message to be
5544 placed on the queue.
5545 </para>
5546 </listitem></varlistentry>
5547 <varlistentry>
5548 <term><option>-Mset</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;</term>
5549 <listitem>
5550 <para>
5551 <indexterm role="option">
5552 <primary><option>-Mset</option></primary>
5553 </indexterm>
5554 <indexterm role="concept">
5555 <primary>testing</primary>
5556 <secondary>string expansion</secondary>
5557 </indexterm>
5558 <indexterm role="concept">
5559 <primary>expansion</primary>
5560 <secondary>testing</secondary>
5561 </indexterm>
5562 This option is useful only in conjunction with <option>-be</option> (that is, when testing
5563 string expansions). Exim loads the given message from its spool before doing
5564 the test expansions, thus setting message-specific variables such as
5565 <varname>$message_size</varname> and the header variables. The <varname>$recipients</varname> variable is made
5566 available. This feature is provided to make it easier to test expansions that
5567 make use of these variables. However, this option can be used only by an admin
5568 user. See also <option>-bem</option>.
5569 </para>
5570 </listitem></varlistentry>
5571 <varlistentry>
5572 <term><option>-Mt</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;&nbsp;...</term>
5573 <listitem>
5574 <para>
5575 <indexterm role="option">
5576 <primary><option>-Mt</option></primary>
5577 </indexterm>
5578 <indexterm role="concept">
5579 <primary>thawing messages</primary>
5580 </indexterm>
5581 <indexterm role="concept">
5582 <primary>unfreezing messages</primary>
5583 </indexterm>
5584 <indexterm role="concept">
5585 <primary>frozen messages</primary>
5586 <secondary>thawing</secondary>
5587 </indexterm>
5588 <indexterm role="concept">
5589 <primary>message</primary>
5590 <secondary>thawing frozen</secondary>
5591 </indexterm>
5592 This option requests Exim to <quote>thaw</quote> any of the listed messages that are
5593 <quote>frozen</quote>, so that delivery attempts can resume. However, if any of the
5594 messages are active, their status is not altered. This option can be used only
5595 by an admin user.
5596 </para>
5597 </listitem></varlistentry>
5598 <varlistentry>
5599 <term><option>-Mvb</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;</term>
5600 <listitem>
5601 <para>
5602 <indexterm role="option">
5603 <primary><option>-Mvb</option></primary>
5604 </indexterm>
5605 <indexterm role="concept">
5606 <primary>listing</primary>
5607 <secondary>message body</secondary>
5608 </indexterm>
5609 <indexterm role="concept">
5610 <primary>message</primary>
5611 <secondary>listing body of</secondary>
5612 </indexterm>
5613 This option causes the contents of the message body (-D) spool file to be
5614 written to the standard output. This option can be used only by an admin user.
5615 </para>
5616 </listitem></varlistentry>
5617 <varlistentry revisionflag="changed">
5618 <term><option>-Mvc</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;</term>
5619 <listitem>
5620 <para revisionflag="changed">
5621 <indexterm role="option">
5622 <primary><option>-Mvc</option></primary>
5623 </indexterm>
5624 <indexterm role="concept">
5625 <primary>message</primary>
5626 <secondary>listing in RFC 2822 format</secondary>
5627 </indexterm>
5628 <indexterm role="concept">
5629 <primary>listing</primary>
5630 <secondary>message in RFC 2822 format</secondary>
5631 </indexterm>
5632 This option causes a copy of the complete message (header lines plus body) to
5633 be written to the standard output in RFC 2822 format. This option can be used
5634 only by an admin user.
5635 </para>
5636 </listitem></varlistentry>
5637 <varlistentry>
5638 <term><option>-Mvh</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;</term>
5639 <listitem>
5640 <para>
5641 <indexterm role="option">
5642 <primary><option>-Mvh</option></primary>
5643 </indexterm>
5644 <indexterm role="concept">
5645 <primary>listing</primary>
5646 <secondary>message headers</secondary>
5647 </indexterm>
5648 <indexterm role="concept">
5649 <primary>header lines</primary>
5650 <secondary>listing</secondary>
5651 </indexterm>
5652 <indexterm role="concept">
5653 <primary>message</primary>
5654 <secondary>listing header lines</secondary>
5655 </indexterm>
5656 This option causes the contents of the message headers (-H) spool file to be
5657 written to the standard output. This option can be used only by an admin user.
5658 </para>
5659 </listitem></varlistentry>
5660 <varlistentry>
5661 <term><option>-Mvl</option>&nbsp;&lt;<emphasis>message&nbsp;id</emphasis>&gt;</term>
5662 <listitem>
5663 <para>
5664 <indexterm role="option">
5665 <primary><option>-Mvl</option></primary>
5666 </indexterm>
5667 <indexterm role="concept">
5668 <primary>listing</primary>
5669 <secondary>message log</secondary>
5670 </indexterm>
5671 <indexterm role="concept">
5672 <primary>message</primary>
5673 <secondary>listing message log</secondary>
5674 </indexterm>
5675 This option causes the contents of the message log spool file to be written to
5676 the standard output. This option can be used only by an admin user.
5677 </para>
5678 </listitem></varlistentry>
5679 <varlistentry>
5680 <term><option>-m</option></term>
5681 <listitem>
5682 <para>
5683 <indexterm role="option">
5684 <primary><option>-m</option></primary>
5685 </indexterm>
5686 This is apparently a synonym for <option>-om</option> that is accepted by Sendmail, so Exim
5687 treats it that way too.
5688 </para>
5689 </listitem></varlistentry>
5690 <varlistentry>
5691 <term><option>-N</option></term>
5692 <listitem>
5693 <para>
5694 <indexterm role="option">
5695 <primary><option>-N</option></primary>
5696 </indexterm>
5697 <indexterm role="concept">
5698 <primary>debugging</primary>
5699 <secondary><option>-N</option> option</secondary>
5700 </indexterm>
5701 <indexterm role="concept">
5702 <primary>debugging</primary>
5703 <secondary>suppressing delivery</secondary>
5704 </indexterm>
5705 This is a debugging option that inhibits delivery of a message at the transport
5706 level. It implies <option>-v</option>. Exim goes through many of the motions of delivery &ndash;
5707 it just doesn&#x2019;t actually transport the message, but instead behaves as if it
5708 had successfully done so. However, it does not make any updates to the retry
5709 database, and the log entries for deliveries are flagged with <quote>*&gt;</quote> rather
5710 than <quote>=&gt;</quote>.
5711 </para>
5712 <para>
5713 Because <option>-N</option> discards any message to which it applies, only root or the Exim
5714 user are allowed to use it with <option>-bd</option>, <option>-q</option>, <option>-R</option> or <option>-M</option>. In other
5715 words, an ordinary user can use it only when supplying an incoming message to
5716 which it will apply. Although transportation never fails when <option>-N</option> is set, an
5717 address may be deferred because of a configuration problem on a transport, or a
5718 routing problem. Once <option>-N</option> has been used for a delivery attempt, it sticks to
5719 the message, and applies to any subsequent delivery attempts that may happen
5720 for that message.
5721 </para>
5722 </listitem></varlistentry>
5723 <varlistentry>
5724 <term><option>-n</option></term>
5725 <listitem>
5726 <para>
5727 <indexterm role="option">
5728 <primary><option>-n</option></primary>
5729 </indexterm>
5730 <indexterm role="concept">
5731 <primary>Sendmail compatibility</primary>
5732 <secondary><option>-n</option> option ignored</secondary>
5733 </indexterm>
5734 This option is interpreted by Sendmail to mean <quote>no aliasing</quote>. It is ignored
5735 by Exim.
5736 </para>
5737 </listitem></varlistentry>
5738 <varlistentry>
5739 <term><option>-O</option>&nbsp;&lt;<emphasis>data</emphasis>&gt;</term>
5740 <listitem>
5741 <para>
5742 <indexterm role="option">
5743 <primary><option>-O</option></primary>
5744 </indexterm>
5745 This option is interpreted by Sendmail to mean <literal>set option</literal>. It is ignored by
5746 Exim.
5747 </para>
5748 </listitem></varlistentry>
5749 <varlistentry>
5750 <term><option>-oA</option>&nbsp;&lt;<emphasis>file&nbsp;name</emphasis>&gt;</term>
5751 <listitem>
5752 <para>
5753 <indexterm role="option">
5754 <primary><option>-oA</option></primary>
5755 </indexterm>
5756 <indexterm role="concept">
5757 <primary>Sendmail compatibility</primary>
5758 <secondary><option>-oA</option> option</secondary>
5759 </indexterm>
5760 This option is used by Sendmail in conjunction with <option>-bi</option> to specify an
5761 alternative alias file name. Exim handles <option>-bi</option> differently; see the
5762 description above.
5763 </para>
5764 </listitem></varlistentry>
5765 <varlistentry>
5766 <term><option>-oB</option>&nbsp;&lt;<emphasis>n</emphasis>&gt;</term>
5767 <listitem>
5768 <para>
5769 <indexterm role="option">
5770 <primary><option>-oB</option></primary>
5771 </indexterm>
5772 <indexterm role="concept">
5773 <primary>SMTP</primary>
5774 <secondary>passed connection</secondary>
5775 </indexterm>
5776 <indexterm role="concept">
5777 <primary>SMTP</primary>
5778 <secondary>multiple deliveries</secondary>
5779 </indexterm>
5780 <indexterm role="concept">
5781 <primary>multiple SMTP deliveries</primary>
5782 </indexterm>
5783 This is a debugging option which limits the maximum number of messages that can
5784 be delivered down one SMTP connection, overriding the value set in any <command>smtp</command>
5785 transport. If &lt;<emphasis>n</emphasis>&gt; is omitted, the limit is set to 1.
5786 </para>
5787 </listitem></varlistentry>
5788 <varlistentry>
5789 <term><option>-odb</option></term>
5790 <listitem>
5791 <para>
5792 <indexterm role="option">
5793 <primary><option>-odb</option></primary>
5794 </indexterm>
5795 <indexterm role="concept">
5796 <primary>background delivery</primary>
5797 </indexterm>
5798 <indexterm role="concept">
5799 <primary>delivery</primary>
5800 <secondary>in the background</secondary>
5801 </indexterm>
5802 This option applies to all modes in which Exim accepts incoming messages,
5803 including the listening daemon. It requests <quote>background</quote> delivery of such
5804 messages, which means that the accepting process automatically starts a
5805 delivery process for each message received, but does not wait for the delivery
5806 processes to finish.
5807 </para>
5808 <para>
5809 When all the messages have been received, the reception process exits,
5810 leaving the delivery processes to finish in their own time. The standard output
5811 and error streams are closed at the start of each delivery process.
5812 This is the default action if none of the <option>-od</option> options are present.
5813 </para>
5814 <para>
5815 If one of the queueing options in the configuration file
5816 (<option>queue_only</option> or <option>queue_only_file</option>, for example) is in effect, <option>-odb</option>
5817 overrides it if <option>queue_only_override</option> is set true, which is the default
5818 setting. If <option>queue_only_override</option> is set false, <option>-odb</option> has no effect.
5819 </para>
5820 </listitem></varlistentry>
5821 <varlistentry>
5822 <term><option>-odf</option></term>
5823 <listitem>
5824 <para>
5825 <indexterm role="option">
5826 <primary><option>-odf</option></primary>
5827 </indexterm>
5828 <indexterm role="concept">
5829 <primary>foreground delivery</primary>
5830 </indexterm>
5831 <indexterm role="concept">
5832 <primary>delivery</primary>
5833 <secondary>in the foreground</secondary>
5834 </indexterm>
5835 This option requests <quote>foreground</quote> (synchronous) delivery when Exim has
5836 accepted a locally-generated message. (For the daemon it is exactly the same as
5837 <option>-odb</option>.) A delivery process is automatically started to deliver the message,
5838 and Exim waits for it to complete before proceeding.
5839 </para>
5840 <para>
5841 The original Exim reception process does not finish until the delivery
5842 process for the final message has ended. The standard error stream is left open
5843 during deliveries.
5844 </para>
5845 <para>
5846 However, like <option>-odb</option>, this option has no effect if <option>queue_only_override</option> is
5847 false and one of the queueing options in the configuration file is in effect.
5848 </para>
5849 <para>
5850 If there is a temporary delivery error during foreground delivery, the
5851 message is left on the queue for later delivery, and the original reception
5852 process exits. See chapter <xref linkend="CHAPnonqueueing"/> for a way of setting up a
5853 restricted configuration that never queues messages.
5854 </para>
5855 </listitem></varlistentry>
5856 <varlistentry>
5857 <term><option>-odi</option></term>
5858 <listitem>
5859 <para>
5860 <indexterm role="option">
5861 <primary><option>-odi</option></primary>
5862 </indexterm>
5863 This option is synonymous with <option>-odf</option>. It is provided for compatibility with
5864 Sendmail.
5865 </para>
5866 </listitem></varlistentry>
5867 <varlistentry>
5868 <term><option>-odq</option></term>
5869 <listitem>
5870 <para>
5871 <indexterm role="option">
5872 <primary><option>-odq</option></primary>
5873 </indexterm>
5874 <indexterm role="concept">
5875 <primary>non-immediate delivery</primary>
5876 </indexterm>
5877 <indexterm role="concept">
5878 <primary>delivery</primary>
5879 <secondary>suppressing immediate</secondary>
5880 </indexterm>
5881 <indexterm role="concept">
5882 <primary>queueing incoming messages</primary>
5883 </indexterm>
5884 This option applies to all modes in which Exim accepts incoming messages,
5885 including the listening daemon. It specifies that the accepting process should
5886 not automatically start a delivery process for each message received. Messages
5887 are placed on the queue, and remain there until a subsequent queue runner
5888 process encounters them. There are several configuration options (such as
5889 <option>queue_only</option>) that can be used to queue incoming messages under certain
5890 conditions. This option overrides all of them and also <option>-odqs</option>. It always
5891 forces queueing.
5892 </para>
5893 </listitem></varlistentry>
5894 <varlistentry>
5895 <term><option>-odqs</option></term>
5896 <listitem>
5897 <para>
5898 <indexterm role="option">
5899 <primary><option>-odqs</option></primary>
5900 </indexterm>
5901 <indexterm role="concept">
5902 <primary>SMTP</primary>
5903 <secondary>delaying delivery</secondary>
5904 </indexterm>
5905 This option is a hybrid between <option>-odb</option>/<option>-odi</option> and <option>-odq</option>.
5906 However, like <option>-odb</option> and <option>-odi</option>, this option has no effect if
5907 <option>queue_only_override</option> is false and one of the queueing options in the
5908 configuration file is in effect.
5909 </para>
5910 <para>
5911 When <option>-odqs</option> does operate, a delivery process is started for each incoming
5912 message, in the background by default, but in the foreground if <option>-odi</option> is
5913 also present. The recipient addresses are routed, and local deliveries are done
5914 in the normal way. However, if any SMTP deliveries are required, they are not
5915 done at this time, so the message remains on the queue until a subsequent queue
5916 runner process encounters it. Because routing was done, Exim knows which
5917 messages are waiting for which hosts, and so a number of messages for the same
5918 host can be sent in a single SMTP connection. The <option>queue_smtp_domains</option>
5919 configuration option has the same effect for specific domains. See also the
5920 <option>-qq</option> option.
5921 </para>
5922 </listitem></varlistentry>
5923 <varlistentry>
5924 <term><option>-oee</option></term>
5925 <listitem>
5926 <para>
5927 <indexterm role="option">
5928 <primary><option>-oee</option></primary>
5929 </indexterm>
5930 <indexterm role="concept">
5931 <primary>error</primary>
5932 <secondary>reporting</secondary>
5933 </indexterm>
5934 If an error is detected while a non-SMTP message is being received (for
5935 example, a malformed address), the error is reported to the sender in a mail
5936 message.
5937 </para>
5938 <para>
5939 <indexterm role="concept">
5940 <primary>return code</primary>
5941 <secondary>for <option>-oee</option></secondary>
5942 </indexterm>
5943 Provided
5944 this error message is successfully sent, the Exim receiving process
5945 exits with a return code of zero. If not, the return code is 2 if the problem
5946 is that the original message has no recipients, or 1 any other error. This is
5947 the default <option>-oe</option><emphasis>x</emphasis> option if Exim is called as <emphasis>rmail</emphasis>.
5948 </para>
5949 </listitem></varlistentry>
5950 <varlistentry>
5951 <term><option>-oem</option></term>
5952 <listitem>
5953 <para>
5954 <indexterm role="option">
5955 <primary><option>-oem</option></primary>
5956 </indexterm>
5957 <indexterm role="concept">
5958 <primary>error</primary>
5959 <secondary>reporting</secondary>
5960 </indexterm>
5961 <indexterm role="concept">
5962 <primary>return code</primary>
5963 <secondary>for <option>-oem</option></secondary>
5964 </indexterm>
5965 This is the same as <option>-oee</option>, except that Exim always exits with a non-zero
5966 return code, whether or not the error message was successfully sent.
5967 This is the default <option>-oe</option><emphasis>x</emphasis> option, unless Exim is called as <emphasis>rmail</emphasis>.
5968 </para>
5969 </listitem></varlistentry>
5970 <varlistentry>
5971 <term><option>-oep</option></term>
5972 <listitem>
5973 <para>
5974 <indexterm role="option">
5975 <primary><option>-oep</option></primary>
5976 </indexterm>
5977 <indexterm role="concept">
5978 <primary>error</primary>
5979 <secondary>reporting</secondary>
5980 </indexterm>
5981 If an error is detected while a non-SMTP message is being received, the
5982 error is reported by writing a message to the standard error file (stderr).
5983 <indexterm role="concept">
5984 <primary>return code</primary>
5985 <secondary>for <option>-oep</option></secondary>
5986 </indexterm>
5987 The return code is 1 for all errors.
5988 </para>
5989 </listitem></varlistentry>
5990 <varlistentry>
5991 <term><option>-oeq</option></term>
5992 <listitem>
5993 <para>
5994 <indexterm role="option">
5995 <primary><option>-oeq</option></primary>
5996 </indexterm>
5997 <indexterm role="concept">
5998 <primary>error</primary>
5999 <secondary>reporting</secondary>
6000 </indexterm>
6001 This option is supported for compatibility with Sendmail, but has the same
6002 effect as <option>-oep</option>.
6003 </para>
6004 </listitem></varlistentry>
6005 <varlistentry>
6006 <term><option>-oew</option></term>
6007 <listitem>
6008 <para>
6009 <indexterm role="option">
6010 <primary><option>-oew</option></primary>
6011 </indexterm>
6012 <indexterm role="concept">
6013 <primary>error</primary>
6014 <secondary>reporting</secondary>
6015 </indexterm>
6016 This option is supported for compatibility with Sendmail, but has the same
6017 effect as <option>-oem</option>.
6018 </para>
6019 </listitem></varlistentry>
6020 <varlistentry>
6021 <term><option>-oi</option></term>
6022 <listitem>
6023 <para>
6024 <indexterm role="option">
6025 <primary><option>-oi</option></primary>
6026 </indexterm>
6027 <indexterm role="concept">
6028 <primary>dot</primary>
6029 <secondary>in incoming non-SMTP message</secondary>
6030 </indexterm>
6031 This option, which has the same effect as <option>-i</option>, specifies that a dot on a
6032 line by itself should not terminate an incoming, non-SMTP message. Otherwise, a
6033 single dot does terminate, though Exim does no special processing for other
6034 lines that start with a dot. This option is set by default if Exim is called as
6035 <emphasis>rmail</emphasis>. See also <option>-ti</option>.
6036 </para>
6037 </listitem></varlistentry>
6038 <varlistentry>
6039 <term><option>-oitrue</option></term>
6040 <listitem>
6041 <para>
6042 <indexterm role="option">
6043 <primary><option>-oitrue</option></primary>
6044 </indexterm>
6045 This option is treated as synonymous with <option>-oi</option>.
6046 </para>
6047 </listitem></varlistentry>
6048 <varlistentry>
6049 <term><option>-oMa</option>&nbsp;&lt;<emphasis>host&nbsp;address</emphasis>&gt;</term>
6050 <listitem>
6051 <para>
6052 <indexterm role="option">
6053 <primary><option>-oMa</option></primary>
6054 </indexterm>
6055 <indexterm role="concept">
6056 <primary>sender</primary>
6057 <secondary>host address, specifying for local message</secondary>
6058 </indexterm>
6059 A number of options starting with <option>-oM</option> can be used to set values associated
6060 with remote hosts on locally-submitted messages (that is, messages not received
6061 over TCP/IP). These options can be used by any caller in conjunction with the
6062 <option>-bh</option>, <option>-be</option>, <option>-bf</option>, <option>-bF</option>, <option>-bt</option>, or <option>-bv</option> testing options. In
6063 other circumstances, they are ignored unless the caller is trusted.
6064 </para>
6065 <para>
6066 The <option>-oMa</option> option sets the sender host address. This may include a port
6067 number at the end, after a full stop (period). For example:
6068 </para>
6069 <literallayout class="monospaced">
6070 exim -bs -oMa 10.9.8.7.1234
6071 </literallayout>
6072 <para>
6073 An alternative syntax is to enclose the IP address in square brackets,
6074 followed by a colon and the port number:
6075 </para>
6076 <literallayout class="monospaced">
6077 exim -bs -oMa [10.9.8.7]:1234
6078 </literallayout>
6079 <para>
6080 The IP address is placed in the <varname>$sender_host_address</varname> variable, and the
6081 port, if present, in <varname>$sender_host_port</varname>. If both <option>-oMa</option> and <option>-bh</option>
6082 are present on the command line, the sender host IP address is taken from
6083 whichever one is last.
6084 </para>
6085 </listitem></varlistentry>
6086 <varlistentry>
6087 <term><option>-oMaa</option>&nbsp;&lt;<emphasis>name</emphasis>&gt;</term>
6088 <listitem>
6089 <para>
6090 <indexterm role="option">
6091 <primary><option>-oMaa</option></primary>
6092 </indexterm>
6093 <indexterm role="concept">
6094 <primary>authentication</primary>
6095 <secondary>name, specifying for local message</secondary>
6096 </indexterm>
6097 See <option>-oMa</option> above for general remarks about the <option>-oM</option> options. The <option>-oMaa</option>
6098 option sets the value of <varname>$sender_host_authenticated</varname> (the authenticator
6099 name). See chapter <xref linkend="CHAPSMTPAUTH"/> for a discussion of SMTP authentication.
6100 This option can be used with <option>-bh</option> and <option>-bs</option> to set up an
6101 authenticated SMTP session without actually using the SMTP AUTH command.
6102 </para>
6103 </listitem></varlistentry>
6104 <varlistentry>
6105 <term><option>-oMai</option>&nbsp;&lt;<emphasis>string</emphasis>&gt;</term>
6106 <listitem>
6107 <para>
6108 <indexterm role="option">
6109 <primary><option>-oMai</option></primary>
6110 </indexterm>
6111 <indexterm role="concept">
6112 <primary>authentication</primary>
6113 <secondary>id, specifying for local message</secondary>
6114 </indexterm>
6115 See <option>-oMa</option> above for general remarks about the <option>-oM</option> options. The <option>-oMai</option>
6116 option sets the value of <varname>$authenticated_id</varname> (the id that was authenticated).
6117 This overrides the default value (the caller&#x2019;s login id, except with <option>-bh</option>,
6118 where there is no default) for messages from local sources. See chapter
6119 <xref linkend="CHAPSMTPAUTH"/> for a discussion of authenticated ids.
6120 </para>
6121 </listitem></varlistentry>
6122 <varlistentry>
6123 <term><option>-oMas</option>&nbsp;&lt;<emphasis>address</emphasis>&gt;</term>
6124 <listitem>
6125 <para>
6126 <indexterm role="option">
6127 <primary><option>-oMas</option></primary>
6128 </indexterm>
6129 <indexterm role="concept">
6130 <primary>authentication</primary>
6131 <secondary>sender, specifying for local message</secondary>
6132 </indexterm>
6133 See <option>-oMa</option> above for general remarks about the <option>-oM</option> options. The <option>-oMas</option>
6134 option sets the authenticated sender value in <varname>$authenticated_sender</varname>. It
6135 overrides the sender address that is created from the caller&#x2019;s login id for
6136 messages from local sources, except when <option>-bh</option> is used, when there is no
6137 default. For both <option>-bh</option> and <option>-bs</option>, an authenticated sender that is
6138 specified on a MAIL command overrides this value. See chapter
6139 <xref linkend="CHAPSMTPAUTH"/> for a discussion of authenticated senders.
6140 </para>
6141 </listitem></varlistentry>
6142 <varlistentry>
6143 <term><option>-oMi</option>&nbsp;&lt;<emphasis>interface&nbsp;address</emphasis>&gt;</term>
6144 <listitem>
6145 <para>
6146 <indexterm role="option">
6147 <primary><option>-oMi</option></primary>
6148 </indexterm>
6149 <indexterm role="concept">
6150 <primary>interface</primary>
6151 <secondary>address, specifying for local message</secondary>
6152 </indexterm>
6153 See <option>-oMa</option> above for general remarks about the <option>-oM</option> options. The <option>-oMi</option>
6154 option sets the IP interface address value. A port number may be included,
6155 using the same syntax as for <option>-oMa</option>. The interface address is placed in
6156 <varname>$received_ip_address</varname> and the port number, if present, in <varname>$received_port</varname>.
6157 </para>
6158 </listitem></varlistentry>
6159 <varlistentry>
6160 <term><option>-oMr</option>&nbsp;&lt;<emphasis>protocol&nbsp;name</emphasis>&gt;</term>
6161 <listitem>
6162 <para>
6163 <indexterm role="option">
6164 <primary><option>-oMr</option></primary>
6165 </indexterm>
6166 <indexterm role="concept">
6167 <primary>protocol, specifying for local message</primary>
6168 </indexterm>
6169 <indexterm role="variable">
6170 <primary><varname>$received_protocol</varname></primary>
6171 </indexterm>
6172 See <option>-oMa</option> above for general remarks about the <option>-oM</option> options. The <option>-oMr</option>
6173 option sets the received protocol value that is stored in
6174 <varname>$received_protocol</varname>. However, it does not apply (and is ignored) when <option>-bh</option>
6175 or <option>-bs</option> is used. For <option>-bh</option>, the protocol is forced to one of the standard
6176 SMTP protocol names (see the description of <varname>$received_protocol</varname> in section
6177 <xref linkend="SECTexpvar"/>). For <option>-bs</option>, the protocol is always <quote>local-</quote> followed by
6178 one of those same names. For <option>-bS</option> (batched SMTP) however, the protocol can
6179 be set by <option>-oMr</option>.
6180 </para>
6181 </listitem></varlistentry>
6182 <varlistentry>
6183 <term><option>-oMs</option>&nbsp;&lt;<emphasis>host&nbsp;name</emphasis>&gt;</term>
6184 <listitem>
6185 <para>
6186 <indexterm role="option">
6187 <primary><option>-oMs</option></primary>
6188 </indexterm>
6189 <indexterm role="concept">
6190 <primary>sender</primary>
6191 <secondary>host name, specifying for local message</secondary>
6192 </indexterm>
6193 See <option>-oMa</option> above for general remarks about the <option>-oM</option> options. The <option>-oMs</option>
6194 option sets the sender host name in <varname>$sender_host_name</varname>. When this option is
6195 present, Exim does not attempt to look up a host name from an IP address; it
6196 uses the name it is given.
6197 </para>
6198 </listitem></varlistentry>
6199 <varlistentry>
6200 <term><option>-oMt</option>&nbsp;&lt;<emphasis>ident&nbsp;string</emphasis>&gt;</term>
6201 <listitem>
6202 <para>
6203 <indexterm role="option">
6204 <primary><option>-oMt</option></primary>
6205 </indexterm>
6206 <indexterm role="concept">
6207 <primary>sender</primary>
6208 <secondary>ident string, specifying for local message</secondary>
6209 </indexterm>
6210 See <option>-oMa</option> above for general remarks about the <option>-oM</option> options. The <option>-oMt</option>
6211 option sets the sender ident value in <varname>$sender_ident</varname>. The default setting for
6212 local callers is the login id of the calling process, except when <option>-bh</option> is
6213 used, when there is no default.
6214 </para>
6215 </listitem></varlistentry>
6216 <varlistentry>
6217 <term><option>-om</option></term>
6218 <listitem>
6219 <para>
6220 <indexterm role="option">
6221 <primary><option>-om</option></primary>
6222 </indexterm>
6223 <indexterm role="concept">
6224 <primary>Sendmail compatibility</primary>
6225 <secondary><option>-om</option> option ignored</secondary>
6226 </indexterm>
6227 In Sendmail, this option means <quote>me too</quote>, indicating that the sender of a
6228 message should receive a copy of the message if the sender appears in an alias
6229 expansion. Exim always does this, so the option does nothing.
6230 </para>
6231 </listitem></varlistentry>
6232 <varlistentry>
6233 <term><option>-oo</option></term>
6234 <listitem>
6235 <para>
6236 <indexterm role="option">
6237 <primary><option>-oo</option></primary>
6238 </indexterm>
6239 <indexterm role="concept">
6240 <primary>Sendmail compatibility</primary>
6241 <secondary><option>-oo</option> option ignored</secondary>
6242 </indexterm>
6243 This option is ignored. In Sendmail it specifies <quote>old style headers</quote>,
6244 whatever that means.
6245 </para>
6246 </listitem></varlistentry>
6247 <varlistentry>
6248 <term><option>-oP</option>&nbsp;&lt;<emphasis>path</emphasis>&gt;</term>
6249 <listitem>
6250 <para>
6251 <indexterm role="option">
6252 <primary><option>-oP</option></primary>
6253 </indexterm>
6254 <indexterm role="concept">
6255 <primary>pid (process id)</primary>
6256 <secondary>of daemon</secondary>
6257 </indexterm>
6258 <indexterm role="concept">
6259 <primary>daemon</primary>
6260 <secondary>process id (pid)</secondary>
6261 </indexterm>
6262 This option is useful only in conjunction with <option>-bd</option> or <option>-q</option> with a time
6263 value. The option specifies the file to which the process id of the daemon is
6264 written. When <option>-oX</option> is used with <option>-bd</option>, or when <option>-q</option> with a time is used
6265 without <option>-bd</option>, this is the only way of causing Exim to write a pid file,
6266 because in those cases, the normal pid file is not used.
6267 </para>
6268 </listitem></varlistentry>
6269 <varlistentry>
6270 <term><option>-or</option>&nbsp;&lt;<emphasis>time</emphasis>&gt;</term>
6271 <listitem>
6272 <para>
6273 <indexterm role="option">
6274 <primary><option>-or</option></primary>
6275 </indexterm>
6276 <indexterm role="concept">
6277 <primary>timeout</primary>
6278 <secondary>for non-SMTP input</secondary>
6279 </indexterm>
6280 This option sets a timeout value for incoming non-SMTP messages. If it is not
6281 set, Exim will wait forever for the standard input. The value can also be set
6282 by the <option>receive_timeout</option> option. The format used for specifying times is
6283 described in section <xref linkend="SECTtimeformat"/>.
6284 </para>
6285 </listitem></varlistentry>
6286 <varlistentry>
6287 <term><option>-os</option>&nbsp;&lt;<emphasis>time</emphasis>&gt;</term>
6288 <listitem>
6289 <para>
6290 <indexterm role="option">
6291 <primary><option>-os</option></primary>
6292 </indexterm>
6293 <indexterm role="concept">
6294 <primary>timeout</primary>
6295 <secondary>for SMTP input</secondary>
6296 </indexterm>
6297 <indexterm role="concept">
6298 <primary>SMTP</primary>
6299 <secondary>input timeout</secondary>
6300 </indexterm>
6301 This option sets a timeout value for incoming SMTP messages. The timeout
6302 applies to each SMTP command and block of data. The value can also be set by
6303 the <option>smtp_receive_timeout</option> option; it defaults to 5 minutes. The format used
6304 for specifying times is described in section <xref linkend="SECTtimeformat"/>.
6305 </para>
6306 </listitem></varlistentry>
6307 <varlistentry>
6308 <term><option>-ov</option></term>
6309 <listitem>
6310 <para>
6311 <indexterm role="option">
6312 <primary><option>-ov</option></primary>
6313 </indexterm>
6314 This option has exactly the same effect as <option>-v</option>.
6315 </para>
6316 </listitem></varlistentry>
6317 <varlistentry>
6318 <term><option>-oX</option>&nbsp;&lt;<emphasis>number&nbsp;or&nbsp;string</emphasis>&gt;</term>
6319 <listitem>
6320 <para>
6321 <indexterm role="option">
6322 <primary><option>-oX</option></primary>
6323 </indexterm>
6324 <indexterm role="concept">
6325 <primary>TCP/IP</primary>
6326 <secondary>setting listening ports</secondary>
6327 </indexterm>
6328 <indexterm role="concept">
6329 <primary>TCP/IP</primary>
6330 <secondary>setting listening interfaces</secondary>
6331 </indexterm>
6332 <indexterm role="concept">
6333 <primary>port</primary>
6334 <secondary>receiving TCP/IP</secondary>
6335 </indexterm>
6336 This option is relevant only when the <option>-bd</option> (start listening daemon) option
6337 is also given. It controls which ports and interfaces the daemon uses. Details
6338 of the syntax, and how it interacts with configuration file options, are given
6339 in chapter <xref linkend="CHAPinterfaces"/>. When <option>-oX</option> is used to start a daemon, no pid
6340 file is written unless <option>-oP</option> is also present to specify a pid file name.
6341 </para>
6342 </listitem></varlistentry>
6343 <varlistentry>
6344 <term><option>-pd</option></term>
6345 <listitem>
6346 <para>
6347 <indexterm role="option">
6348 <primary><option>-pd</option></primary>
6349 </indexterm>
6350 <indexterm role="concept">
6351 <primary>Perl</primary>
6352 <secondary>starting the interpreter</secondary>
6353 </indexterm>
6354 This option applies when an embedded Perl interpreter is linked with Exim (see
6355 chapter <xref linkend="CHAPperl"/>). It overrides the setting of the <option>perl_at_start</option>
6356 option, forcing the starting of the interpreter to be delayed until it is
6357 needed.
6358 </para>
6359 </listitem></varlistentry>
6360 <varlistentry>
6361 <term><option>-ps</option></term>
6362 <listitem>
6363 <para>
6364 <indexterm role="option">
6365 <primary><option>-ps</option></primary>
6366 </indexterm>
6367 <indexterm role="concept">
6368 <primary>Perl</primary>
6369 <secondary>starting the interpreter</secondary>
6370 </indexterm>
6371 This option applies when an embedded Perl interpreter is linked with Exim (see
6372 chapter <xref linkend="CHAPperl"/>). It overrides the setting of the <option>perl_at_start</option>
6373 option, forcing the starting of the interpreter to occur as soon as Exim is
6374 started.
6375 </para>
6376 </listitem></varlistentry>
6377 <varlistentry>
6378 <term><option>-p</option>&lt;<emphasis>rval</emphasis>&gt;:&lt;<emphasis>sval</emphasis>&gt;</term>
6379 <listitem>
6380 <para>
6381 <indexterm role="option">
6382 <primary><option>-p</option></primary>
6383 </indexterm>
6384 For compatibility with Sendmail, this option is equivalent to
6385 </para>
6386 <literallayout>
6387 <literal>-oMr</literal> &lt;<emphasis>rval</emphasis>&gt; <literal>-oMs</literal> &lt;<emphasis>sval</emphasis>&gt;
6388 </literallayout>
6389 <para>
6390 It sets the incoming protocol and host name (for trusted callers). The
6391 host name and its colon can be omitted when only the protocol is to be set.
6392 Note the Exim already has two private options, <option>-pd</option> and <option>-ps</option>, that refer
6393 to embedded Perl. It is therefore impossible to set a protocol value of <literal>p</literal>
6394 or <literal>s</literal> using this option (but that does not seem a real limitation).
6395 </para>
6396 </listitem></varlistentry>
6397 <varlistentry>
6398 <term><option>-q</option></term>
6399 <listitem>
6400 <para>
6401 <indexterm role="option">
6402 <primary><option>-q</option></primary>
6403 </indexterm>
6404 <indexterm role="concept">
6405 <primary>queue runner</primary>
6406 <secondary>starting manually</secondary>
6407 </indexterm>
6408 This option is normally restricted to admin users. However, there is a
6409 configuration option called <option>prod_requires_admin</option> which can be set false to
6410 relax this restriction (and also the same requirement for the <option>-M</option>, <option>-R</option>,
6411 and <option>-S</option> options).
6412 </para>
6413 <para>
6414 <indexterm role="concept">
6415 <primary>queue runner</primary>
6416 <secondary>description of operation</secondary>
6417 </indexterm>
6418 The <option>-q</option> option starts one queue runner process. This scans the queue of
6419 waiting messages, and runs a delivery process for each one in turn. It waits
6420 for each delivery process to finish before starting the next one. A delivery
6421 process may not actually do any deliveries if the retry times for the addresses
6422 have not been reached. Use <option>-qf</option> (see below) if you want to override this.
6423 </para>
6424 <para>
6425 If
6426 <indexterm role="concept">
6427 <primary>SMTP</primary>
6428 <secondary>passed connection</secondary>
6429 </indexterm>
6430 <indexterm role="concept">
6431 <primary>SMTP</primary>
6432 <secondary>multiple deliveries</secondary>
6433 </indexterm>
6434 <indexterm role="concept">
6435 <primary>multiple SMTP deliveries</primary>
6436 </indexterm>
6437 the delivery process spawns other processes to deliver other messages down
6438 passed SMTP connections, the queue runner waits for these to finish before
6439 proceeding.
6440 </para>
6441 <para>
6442 When all the queued messages have been considered, the original queue runner
6443 process terminates. In other words, a single pass is made over the waiting
6444 mail, one message at a time. Use <option>-q</option> with a time (see below) if you want
6445 this to be repeated periodically.
6446 </para>
6447 <para>
6448 Exim processes the waiting messages in an unpredictable order. It isn&#x2019;t very
6449 random, but it is likely to be different each time, which is all that matters.
6450 If one particular message screws up a remote MTA, other messages to the same
6451 MTA have a chance of getting through if they get tried first.
6452 </para>
6453 <para>
6454 It is possible to cause the messages to be processed in lexical message id
6455 order, which is essentially the order in which they arrived, by setting the
6456 <option>queue_run_in_order</option> option, but this is not recommended for normal use.
6457 </para>
6458 </listitem></varlistentry>
6459 <varlistentry>
6460 <term><option>-q</option>&lt;<emphasis>qflags</emphasis>&gt;</term>
6461 <listitem>
6462 <para>
6463 The <option>-q</option> option may be followed by one or more flag letters that change its
6464 behaviour. They are all optional, but if more than one is present, they must
6465 appear in the correct order. Each flag is described in a separate item below.
6466 </para>
6467 </listitem></varlistentry>
6468 <varlistentry>
6469 <term><option>-qq...</option></term>
6470 <listitem>
6471 <para>
6472 <indexterm role="option">
6473 <primary><option>-qq</option></primary>
6474 </indexterm>
6475 <indexterm role="concept">
6476 <primary>queue</primary>
6477 <secondary>double scanning</secondary>
6478 </indexterm>
6479 <indexterm role="concept">
6480 <primary>queue</primary>
6481 <secondary>routing</secondary>
6482 </indexterm>
6483 <indexterm role="concept">
6484 <primary>routing</primary>
6485 <secondary>whole queue before delivery</secondary>
6486 </indexterm>
6487 An option starting with <option>-qq</option> requests a two-stage queue run. In the first
6488 stage, the queue is scanned as if the <option>queue_smtp_domains</option> option matched
6489 every domain. Addresses are routed, local deliveries happen, but no remote
6490 transports are run.
6491 </para>
6492 <para>
6493 <indexterm role="concept">
6494 <primary>hints database</primary>
6495 <secondary>remembering routing</secondary>
6496 </indexterm>
6497 The hints database that remembers which messages are waiting for specific hosts
6498 is updated, as if delivery to those hosts had been deferred. After this is
6499 complete, a second, normal queue scan happens, with routing and delivery taking
6500 place as normal. Messages that are routed to the same host should mostly be
6501 delivered down a single SMTP
6502 <indexterm role="concept">
6503 <primary>SMTP</primary>
6504 <secondary>passed connection</secondary>
6505 </indexterm>
6506 <indexterm role="concept">
6507 <primary>SMTP</primary>
6508 <secondary>multiple deliveries</secondary>
6509 </indexterm>
6510 <indexterm role="concept">
6511 <primary>multiple SMTP deliveries</primary>
6512 </indexterm>
6513 connection because of the hints that were set up during the first queue scan.
6514 This option may be useful for hosts that are connected to the Internet
6515 intermittently.
6516 </para>
6517 </listitem></varlistentry>
6518 <varlistentry>
6519 <term><option>-q[q]i...</option></term>
6520 <listitem>
6521 <para>
6522 <indexterm role="option">
6523 <primary><option>-qi</option></primary>
6524 </indexterm>
6525 <indexterm role="concept">
6526 <primary>queue</primary>
6527 <secondary>initial delivery</secondary>
6528 </indexterm>
6529 If the <emphasis>i</emphasis> flag is present, the queue runner runs delivery processes only for
6530 those messages that haven&#x2019;t previously been tried. (<emphasis>i</emphasis> stands for <quote>initial
6531 delivery</quote>.) This can be helpful if you are putting messages on the queue using
6532 <option>-odq</option> and want a queue runner just to process the new messages.
6533 </para>
6534 </listitem></varlistentry>
6535 <varlistentry>
6536 <term><option>-q[q][i]f...</option></term>
6537 <listitem>
6538 <para>
6539 <indexterm role="option">
6540 <primary><option>-qf</option></primary>
6541 </indexterm>
6542 <indexterm role="concept">
6543 <primary>queue</primary>
6544 <secondary>forcing delivery</secondary>
6545 </indexterm>
6546 <indexterm role="concept">
6547 <primary>delivery</primary>
6548 <secondary>forcing in queue run</secondary>
6549 </indexterm>
6550 If one <emphasis>f</emphasis> flag is present, a delivery attempt is forced for each non-frozen
6551 message, whereas without <emphasis>f</emphasis> only those non-frozen addresses that have passed
6552 their retry times are tried.
6553 </para>
6554 </listitem></varlistentry>
6555 <varlistentry>
6556 <term><option>-q[q][i]ff...</option></term>
6557 <listitem>
6558 <para>
6559 <indexterm role="option">
6560 <primary><option>-qff</option></primary>
6561 </indexterm>
6562 <indexterm role="concept">
6563 <primary>frozen messages</primary>
6564 <secondary>forcing delivery</secondary>
6565 </indexterm>
6566 If <emphasis>ff</emphasis> is present, a delivery attempt is forced for every message, whether
6567 frozen or not.
6568 </para>
6569 </listitem></varlistentry>
6570 <varlistentry>
6571 <term><option>-q[q][i][f[f]]l</option></term>
6572 <listitem>
6573 <para>
6574 <indexterm role="option">
6575 <primary><option>-ql</option></primary>
6576 </indexterm>
6577 <indexterm role="concept">
6578 <primary>queue</primary>
6579 <secondary>local deliveries only</secondary>
6580 </indexterm>
6581 The <emphasis>l</emphasis> (the letter <quote>ell</quote>) flag specifies that only local deliveries are to
6582 be done. If a message requires any remote deliveries, it remains on the queue
6583 for later delivery.
6584 </para>
6585 </listitem></varlistentry>
6586 <varlistentry>
6587 <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>
6588 <listitem>
6589 <para>
6590 <indexterm role="concept">
6591 <primary>queue</primary>
6592 <secondary>delivering specific messages</secondary>
6593 </indexterm>
6594 When scanning the queue, Exim can be made to skip over messages whose ids are
6595 lexically less than a given value by following the <option>-q</option> option with a
6596 starting message id. For example:
6597 </para>
6598 <literallayout class="monospaced">
6599 exim -q 0t5C6f-0000c8-00
6600 </literallayout>
6601 <para>
6602 Messages that arrived earlier than <literal>0t5C6f-0000c8-00</literal> are not inspected. If a
6603 second message id is given, messages whose ids are lexically greater than it
6604 are also skipped. If the same id is given twice, for example,
6605 </para>
6606 <literallayout class="monospaced">
6607 exim -q 0t5C6f-0000c8-00 0t5C6f-0000c8-00
6608 </literallayout>
6609 <para>
6610 just one delivery process is started, for that message. This differs from
6611 <option>-M</option> in that retry data is respected, and it also differs from <option>-Mc</option> in
6612 that it counts as a delivery from a queue run. Note that the selection
6613 mechanism does not affect the order in which the messages are scanned. There
6614 are also other ways of selecting specific sets of messages for delivery in a
6615 queue run &ndash; see <option>-R</option> and <option>-S</option>.
6616 </para>
6617 </listitem></varlistentry>
6618 <varlistentry>
6619 <term><option>-q</option>&lt;<emphasis>qflags</emphasis>&gt;&lt;<emphasis>time</emphasis>&gt;</term>
6620 <listitem>
6621 <para>
6622 <indexterm role="concept">
6623 <primary>queue runner</primary>
6624 <secondary>starting periodically</secondary>
6625 </indexterm>
6626 <indexterm role="concept">
6627 <primary>periodic queue running</primary>
6628 </indexterm>
6629 When a time value is present, the <option>-q</option> option causes Exim to run as a daemon,
6630 starting a queue runner process at intervals specified by the given time value
6631 (whose format is described in section <xref linkend="SECTtimeformat"/>). This form of the
6632 <option>-q</option> option is commonly combined with the <option>-bd</option> option, in which case a
6633 single daemon process handles both functions. A common way of starting up a
6634 combined daemon at system boot time is to use a command such as
6635 </para>
6636 <literallayout class="monospaced">
6637 /usr/exim/bin/exim -bd -q30m
6638 </literallayout>
6639 <para>
6640 Such a daemon listens for incoming SMTP calls, and also starts a queue runner
6641 process every 30 minutes.
6642 </para>
6643 <para>
6644 When a daemon is started by <option>-q</option> with a time value, but without <option>-bd</option>, no
6645 pid file is written unless one is explicitly requested by the <option>-oP</option> option.
6646 </para>
6647 </listitem></varlistentry>
6648 <varlistentry>
6649 <term><option>-qR</option>&lt;<emphasis>rsflags</emphasis>&gt;&nbsp;&lt;<emphasis>string</emphasis>&gt;</term>
6650 <listitem>
6651 <para>
6652 <indexterm role="option">
6653 <primary><option>-qR</option></primary>
6654 </indexterm>
6655 This option is synonymous with <option>-R</option>. It is provided for Sendmail
6656 compatibility.
6657 </para>
6658 </listitem></varlistentry>
6659 <varlistentry>
6660 <term><option>-qS</option>&lt;<emphasis>rsflags</emphasis>&gt;&nbsp;&lt;<emphasis>string</emphasis>&gt;</term>
6661 <listitem>
6662 <para>
6663 <indexterm role="option">
6664 <primary><option>-qS</option></primary>
6665 </indexterm>
6666 This option is synonymous with <option>-S</option>.
6667 </para>
6668 </listitem></varlistentry>
6669 <varlistentry>
6670 <term><option>-R</option>&lt;<emphasis>rsflags</emphasis>&gt;&nbsp;&lt;<emphasis>string</emphasis>&gt;</term>
6671 <listitem>
6672 <para>
6673 <indexterm role="option">
6674 <primary><option>-R</option></primary>
6675 </indexterm>
6676 <indexterm role="concept">
6677 <primary>queue runner</primary>
6678 <secondary>for specific recipients</secondary>
6679 </indexterm>
6680 <indexterm role="concept">
6681 <primary>delivery</primary>
6682 <secondary>to given domain</secondary>
6683 </indexterm>
6684 <indexterm role="concept">
6685 <primary>domain</primary>
6686 <secondary>delivery to</secondary>
6687 </indexterm>
6688 The &lt;<emphasis>rsflags</emphasis>&gt; may be empty, in which case the white space before the string
6689 is optional, unless the string is <emphasis>f</emphasis>, <emphasis>ff</emphasis>, <emphasis>r</emphasis>, <emphasis>rf</emphasis>, or <emphasis>rff</emphasis>,
6690 which are the possible values for &lt;<emphasis>rsflags</emphasis>&gt;. White space is required if
6691 &lt;<emphasis>rsflags</emphasis>&gt; is not empty.
6692 </para>
6693 <para>
6694 This option is similar to <option>-q</option> with no time value, that is, it causes Exim to
6695 perform a single queue run, except that, when scanning the messages on the
6696 queue, Exim processes only those that have at least one undelivered recipient
6697 address containing the given string, which is checked in a case-independent
6698 way. If the &lt;<emphasis>rsflags</emphasis>&gt; start with <emphasis>r</emphasis>, &lt;<emphasis>string</emphasis>&gt; is interpreted as a
6699 regular expression; otherwise it is a literal string.
6700 </para>
6701 <para>
6702 If you want to do periodic queue runs for messages with specific recipients,
6703 you can combine <option>-R</option> with <option>-q</option> and a time value. For example:
6704 </para>
6705 <literallayout class="monospaced">
6706 exim -q25m -R @special.domain.example
6707 </literallayout>
6708 <para>
6709 This example does a queue run for messages with recipients in the given domain
6710 every 25 minutes. Any additional flags that are specified with <option>-q</option> are
6711 applied to each queue run.
6712 </para>
6713 <para>
6714 Once a message is selected for delivery by this mechanism, all its addresses
6715 are processed. For the first selected message, Exim overrides any retry
6716 information and forces a delivery attempt for each undelivered address. This
6717 means that if delivery of any address in the first message is successful, any
6718 existing retry information is deleted, and so delivery attempts for that
6719 address in subsequently selected messages (which are processed without forcing)
6720 will run. However, if delivery of any address does not succeed, the retry
6721 information is updated, and in subsequently selected messages, the failing
6722 address will be skipped.
6723 </para>
6724 <para>
6725 <indexterm role="concept">
6726 <primary>frozen messages</primary>
6727 <secondary>forcing delivery</secondary>
6728 </indexterm>
6729 If the &lt;<emphasis>rsflags</emphasis>&gt; contain <emphasis>f</emphasis> or <emphasis>ff</emphasis>, the delivery forcing applies to
6730 all selected messages, not just the first; frozen messages are included when
6731 <emphasis>ff</emphasis> is present.
6732 </para>
6733 <para>
6734 The <option>-R</option> option makes it straightforward to initiate delivery of all messages
6735 to a given domain after a host has been down for some time. When the SMTP
6736 command ETRN is accepted by its ACL (see chapter <xref linkend="CHAPACL"/>), its default
6737 effect is to run Exim with the <option>-R</option> option, but it can be configured to run
6738 an arbitrary command instead.
6739 </para>
6740 </listitem></varlistentry>
6741 <varlistentry>
6742 <term><option>-r</option></term>
6743 <listitem>
6744 <para>
6745 <indexterm role="option">
6746 <primary><option>-r</option></primary>
6747 </indexterm>
6748 This is a documented (for Sendmail) obsolete alternative name for <option>-f</option>.
6749 </para>
6750 </listitem></varlistentry>
6751 <varlistentry>
6752 <term><option>-S</option>&lt;<emphasis>rsflags</emphasis>&gt;&nbsp;&lt;<emphasis>string</emphasis>&gt;</term>
6753 <listitem>
6754 <para>
6755 <indexterm role="option">
6756 <primary><option>-S</option></primary>
6757 </indexterm>
6758 <indexterm role="concept">
6759 <primary>delivery</primary>
6760 <secondary>from given sender</secondary>
6761 </indexterm>
6762 <indexterm role="concept">
6763 <primary>queue runner</primary>
6764 <secondary>for specific senders</secondary>
6765 </indexterm>
6766 This option acts like <option>-R</option> except that it checks the string against each
6767 message&#x2019;s sender instead of against the recipients. If <option>-R</option> is also set, both
6768 conditions must be met for a message to be selected. If either of the options
6769 has <emphasis>f</emphasis> or <emphasis>ff</emphasis> in its flags, the associated action is taken.
6770 </para>
6771 </listitem></varlistentry>
6772 <varlistentry>
6773 <term><option>-Tqt</option>&nbsp;&lt;<emphasis>times</emphasis>&gt;</term>
6774 <listitem>
6775 <para>
6776 <indexterm role="option">
6777 <primary><option>-Tqt</option></primary>
6778 </indexterm>
6779 This an option that is exclusively for use by the Exim testing suite. It is not
6780 recognized when Exim is run normally. It allows for the setting up of explicit
6781 <quote>queue times</quote> so that various warning/retry features can be tested.
6782 </para>
6783 </listitem></varlistentry>
6784 <varlistentry>
6785 <term><option>-t</option></term>
6786 <listitem>
6787 <para>
6788 <indexterm role="option">
6789 <primary><option>-t</option></primary>
6790 </indexterm>
6791 <indexterm role="concept">
6792 <primary>recipient</primary>
6793 <secondary>extracting from header lines</secondary>
6794 </indexterm>
6795 <indexterm role="concept">
6796 <primary><emphasis>Bcc:</emphasis> header line</primary>
6797 </indexterm>
6798 <indexterm role="concept">
6799 <primary><emphasis>Cc:</emphasis> header line</primary>
6800 </indexterm>
6801 <indexterm role="concept">
6802 <primary><emphasis>To:</emphasis> header line</primary>
6803 </indexterm>
6804 When Exim is receiving a locally-generated, non-SMTP message on its standard
6805 input, the <option>-t</option> option causes the recipients of the message to be obtained
6806 from the <emphasis>To:</emphasis>, <emphasis>Cc:</emphasis>, and <emphasis>Bcc:</emphasis> header lines in the message instead of
6807 from the command arguments. The addresses are extracted before any rewriting
6808 takes place and the <emphasis>Bcc:</emphasis> header line, if present, is then removed.
6809 </para>
6810 <para>
6811 <indexterm role="concept">
6812 <primary>Sendmail compatibility</primary>
6813 <secondary><option>-t</option> option</secondary>
6814 </indexterm>
6815 If the command has any arguments, they specify addresses to which the message
6816 is <emphasis>not</emphasis> to be delivered. That is, the argument addresses are removed from
6817 the recipients list obtained from the headers. This is compatible with Smail 3
6818 and in accordance with the documented behaviour of several versions of
6819 Sendmail, as described in man pages on a number of operating systems (e.g.
6820 Solaris 8, IRIX 6.5, HP-UX 11). However, some versions of Sendmail <emphasis>add</emphasis>
6821 argument addresses to those obtained from the headers, and the O&#x2019;Reilly
6822 Sendmail book documents it that way. Exim can be made to add argument addresses
6823 instead of subtracting them by setting the option
6824 <option>extract_addresses_remove_arguments</option> false.
6825 </para>
6826 <para>
6827 <indexterm role="concept">
6828 <primary><option>Resent-</option> header lines</primary>
6829 <secondary>with <option>-t</option></secondary>
6830 </indexterm>
6831 If there are any <option>Resent-</option> header lines in the message, Exim extracts
6832 recipients from all <emphasis>Resent-To:</emphasis>, <emphasis>Resent-Cc:</emphasis>, and <emphasis>Resent-Bcc:</emphasis> header
6833 lines instead of from <emphasis>To:</emphasis>, <emphasis>Cc:</emphasis>, and <emphasis>Bcc:</emphasis>. This is for compatibility
6834 with Sendmail and other MTAs. (Prior to release 4.20, Exim gave an error if
6835 <option>-t</option> was used in conjunction with <option>Resent-</option> header lines.)
6836 </para>
6837 <para>
6838 RFC 2822 talks about different sets of <option>Resent-</option> header lines (for when a
6839 message is resent several times). The RFC also specifies that they should be
6840 added at the front of the message, and separated by <emphasis>Received:</emphasis> lines. It is
6841 not at all clear how <option>-t</option> should operate in the present of multiple sets,
6842 nor indeed exactly what constitutes a <quote>set</quote>.
6843 In practice, it seems that MUAs do not follow the RFC. The <option>Resent-</option> lines
6844 are often added at the end of the header, and if a message is resent more than
6845 once, it is common for the original set of <option>Resent-</option> headers to be renamed as
6846 <option>X-Resent-</option> when a new set is added. This removes any possible ambiguity.
6847 </para>
6848 </listitem></varlistentry>
6849 <varlistentry>
6850 <term><option>-ti</option></term>
6851 <listitem>
6852 <para>
6853 <indexterm role="option">
6854 <primary><option>-ti</option></primary>
6855 </indexterm>
6856 This option is exactly equivalent to <option>-t</option> <option>-i</option>. It is provided for
6857 compatibility with Sendmail.
6858 </para>
6859 </listitem></varlistentry>
6860 <varlistentry>
6861 <term><option>-tls-on-connect</option></term>
6862 <listitem>
6863 <para>
6864 <indexterm role="option">
6865 <primary><option>-tls-on-connect</option></primary>
6866 </indexterm>
6867 <indexterm role="concept">
6868 <primary>TLS</primary>
6869 <secondary>use without STARTTLS</secondary>
6870 </indexterm>
6871 <indexterm role="concept">
6872 <primary>TLS</primary>
6873 <secondary>automatic start</secondary>
6874 </indexterm>
6875 This option is available when Exim is compiled with TLS support. It forces all
6876 incoming SMTP connections to behave as if the incoming port is listed in the
6877 <option>tls_on_connect_ports</option> option. See section <xref linkend="SECTsupobssmt"/> and chapter
6878 <xref linkend="CHAPTLS"/> for further details.
6879 </para>
6880 </listitem></varlistentry>
6881 <varlistentry>
6882 <term><option>-U</option></term>
6883 <listitem>
6884 <para>
6885 <indexterm role="option">
6886 <primary><option>-U</option></primary>
6887 </indexterm>
6888 <indexterm role="concept">
6889 <primary>Sendmail compatibility</primary>
6890 <secondary><option>-U</option> option ignored</secondary>
6891 </indexterm>
6892 Sendmail uses this option for <quote>initial message submission</quote>, and its
6893 documentation states that in future releases, it may complain about
6894 syntactically invalid messages rather than fixing them when this flag is not
6895 set. Exim ignores this option.
6896 </para>
6897 </listitem></varlistentry>
6898 <varlistentry>
6899 <term><option>-v</option></term>
6900 <listitem>
6901 <para>
6902 <indexterm role="option">
6903 <primary><option>-v</option></primary>
6904 </indexterm>
6905 This option causes Exim to write information to the standard error stream,
6906 describing what it is doing. In particular, it shows the log lines for
6907 receiving and delivering a message, and if an SMTP connection is made, the SMTP
6908 dialogue is shown. Some of the log lines shown may not actually be written to
6909 the log if the setting of <option>log_selector</option> discards them. Any relevant
6910 selectors are shown with each log line. If none are shown, the logging is
6911 unconditional.
6912 </para>
6913 </listitem></varlistentry>
6914 <varlistentry>
6915 <term><option>-x</option></term>
6916 <listitem>
6917 <para>
6918 <indexterm role="option">
6919 <primary><option>-x</option></primary>
6920 </indexterm>
6921 AIX uses <option>-x</option> for a private purpose (<quote>mail from a local mail program has
6922 National Language Support extended characters in the body of the mail item</quote>).
6923 It sets <option>-x</option> when calling the MTA from its <option>mail</option> command. Exim ignores
6924 this option.
6925 </para>
6926 </listitem></varlistentry>
6927 </variablelist>
6928 <para>
6929 <indexterm role="concept" startref="IIDclo1" class="endofrange"/>
6930 <indexterm role="concept" startref="IIDclo2" class="endofrange"/>
6931 </para>
6932 <!-- === End of command line options === -->
6933 </section>
6934 </chapter>
6935
6936 <chapter id="CHAPconf">
6937 <title>The Exim run time configuration file</title>
6938 <titleabbrev>The runtime configuration file</titleabbrev>
6939 <para>
6940 <indexterm role="concept">
6941 <primary>run time configuration</primary>
6942 </indexterm>
6943 <indexterm role="concept">
6944 <primary>configuration file</primary>
6945 <secondary>general description</secondary>
6946 </indexterm>
6947 <indexterm role="concept">
6948 <primary>CONFIGURE_FILE</primary>
6949 </indexterm>
6950 <indexterm role="concept">
6951 <primary>configuration file</primary>
6952 <secondary>errors in</secondary>
6953 </indexterm>
6954 <indexterm role="concept">
6955 <primary>error</primary>
6956 <secondary>in configuration file</secondary>
6957 </indexterm>
6958 <indexterm role="concept">
6959 <primary>return code</primary>
6960 <secondary>for bad configuration</secondary>
6961 </indexterm>
6962 Exim uses a single run time configuration file that is read whenever an Exim
6963 binary is executed. Note that in normal operation, this happens frequently,
6964 because Exim is designed to operate in a distributed manner, without central
6965 control.
6966 </para>
6967 <para>
6968 If a syntax error is detected while reading the configuration file, Exim
6969 writes a message on the standard error, and exits with a non-zero return code.
6970 The message is also written to the panic log. <emphasis role="bold">Note</emphasis>: Only simple syntax
6971 errors can be detected at this time. The values of any expanded options are
6972 not checked until the expansion happens, even when the expansion does not
6973 actually alter the string.
6974 </para>
6975 <para>
6976 The name of the configuration file is compiled into the binary for security
6977 reasons, and is specified by the CONFIGURE_FILE compilation option. In
6978 most configurations, this specifies a single file. However, it is permitted to
6979 give a colon-separated list of file names, in which case Exim uses the first
6980 existing file in the list.
6981 </para>
6982 <para revisionflag="changed">
6983 <indexterm role="concept">
6984 <primary>EXIM_USER</primary>
6985 </indexterm>
6986 <indexterm role="concept">
6987 <primary>EXIM_GROUP</primary>
6988 </indexterm>
6989 <indexterm role="concept">
6990 <primary>CONFIGURE_OWNER</primary>
6991 </indexterm>
6992 <indexterm role="concept">
6993 <primary>CONFIGURE_GROUP</primary>
6994 </indexterm>
6995 <indexterm role="concept">
6996 <primary>configuration file</primary>
6997 <secondary>ownership</secondary>
6998 </indexterm>
6999 <indexterm role="concept">
7000 <primary>ownership</primary>
7001 <secondary>configuration file</secondary>
7002 </indexterm>
7003 The run time configuration file must be owned by root or by the user that is
7004 specified at compile time by the CONFIGURE_OWNER option (if set). The
7005 configuration file must not be world-writeable, or group-writeable unless its
7006 group is the root group or the one specified at compile time by the
7007 CONFIGURE_GROUP option.
7008 </para>
7009 <para revisionflag="changed">
7010 <emphasis role="bold">Warning</emphasis>: In a conventional configuration, where the Exim binary is setuid
7011 to root, anybody who is able to edit the run time configuration file has an
7012 easy way to run commands as root. If you specify a user or group in the
7013 CONFIGURE_OWNER or CONFIGURE_GROUP options, then that user and/or any users
7014 who are members of that group will trivially be able to obtain root privileges.
7015 </para>
7016 <para revisionflag="changed">
7017 Up to Exim version 4.72, the run time configuration file was also permitted to
7018 be writeable by the Exim user and/or group. That has been changed in Exim 4.73
7019 since it offered a simple privilege escalation for any attacker who managed to
7020 compromise the Exim user account.
7021 </para>
7022 <para>
7023 A default configuration file, which will work correctly in simple situations,
7024 is provided in the file <filename>src/configure.default</filename>. If CONFIGURE_FILE
7025 defines just one file name, the installation process copies the default
7026 configuration to a new file of that name if it did not previously exist. If
7027 CONFIGURE_FILE is a list, no default is automatically installed. Chapter
7028 <xref linkend="CHAPdefconfil"/> is a <quote>walk-through</quote> discussion of the default
7029 configuration.
7030 </para>
7031 <section id="SECID40" revisionflag="changed">
7032 <title>Using a different configuration file</title>
7033 <para revisionflag="changed">
7034 <indexterm role="concept">
7035 <primary>configuration file</primary>
7036 <secondary>alternate</secondary>
7037 </indexterm>
7038 A one-off alternate configuration can be specified by the <option>-C</option> command line
7039 option, which may specify a single file or a list of files. However, when
7040 <option>-C</option> is used, Exim gives up its root privilege, unless called by root (or
7041 unless the argument for <option>-C</option> is identical to the built-in value from
7042 CONFIGURE_FILE), or is listed in the TRUSTED_CONFIG_LIST file and the caller
7043 is the Exim user or the user specified in the CONFIGURE_OWNER setting. <option>-C</option>
7044 is useful mainly for checking the syntax of configuration files before
7045 installing them. No owner or group checks are done on a configuration file
7046 specified by <option>-C</option>, if root privilege has been dropped.
7047 </para>
7048 <para revisionflag="changed">
7049 Even the Exim user is not trusted to specify an arbitrary configuration file
7050 with the <option>-C</option> option to be used with root privileges, unless that file is
7051 listed in the TRUSTED_CONFIG_LIST file. This locks out the possibility of
7052 testing a configuration using <option>-C</option> right through message reception and
7053 delivery, even if the caller is root. The reception works, but by that time,
7054 Exim is running as the Exim user, so when it re-execs to regain privilege for
7055 the delivery, the use of <option>-C</option> causes privilege to be lost. However, root
7056 can test reception and delivery using two separate commands (one to put a
7057 message on the queue, using <option>-odq</option>, and another to do the delivery, using
7058 <option>-M</option>).
7059 </para>
7060 <para>
7061 If ALT_CONFIG_PREFIX is defined <filename>in Local/Makefile</filename>, it specifies a
7062 prefix string with which any file named in a <option>-C</option> command line option must
7063 start. In addition, the file name must not contain the sequence <quote><literal>/../</literal></quote>.
7064 There is no default setting for ALT_CONFIG_PREFIX; when it is unset, any file
7065 name can be used with <option>-C</option>.
7066 </para>
7067 <para>
7068 One-off changes to a configuration can be specified by the <option>-D</option> command line
7069 option, which defines and overrides values for macros used inside the
7070 configuration file. However, like <option>-C</option>, the use of this option by a
7071 non-privileged user causes Exim to discard its root privilege.
7072 If DISABLE_D_OPTION is defined in <filename>Local/Makefile</filename>, the use of <option>-D</option> is
7073 completely disabled, and its use causes an immediate error exit.
7074 </para>
7075 <para revisionflag="changed">
7076 The WHITELIST_D_MACROS option in <filename>Local/Makefile</filename> permits the binary builder
7077 to declare certain macro names trusted, such that root privilege will not
7078 necessarily be discarded.
7079 WHITELIST_D_MACROS defines a colon-separated list of macros which are
7080 considered safe and, if <option>-D</option> only supplies macros from this list, and the
7081 values are acceptable, then Exim will not give up root privilege if the caller
7082 is root, the Exim run-time user, or the CONFIGURE_OWNER, if set.  This is a
7083 transition mechanism and is expected to be removed in the future.  Acceptable
7084 values for the macros satisfy the regexp: <literal>^[A-Za-z0-9_/.-]*$</literal>
7085 </para>
7086 <para>
7087 Some sites may wish to use the same Exim binary on different machines that
7088 share a file system, but to use different configuration files on each machine.
7089 If CONFIGURE_FILE_USE_NODE is defined in <filename>Local/Makefile</filename>, Exim first
7090 looks for a file whose name is the configuration file name followed by a dot
7091 and the machine&#x2019;s node name, as obtained from the <function>uname()</function> function. If this
7092 file does not exist, the standard name is tried. This processing occurs for
7093 each file name in the list given by CONFIGURE_FILE or <option>-C</option>.
7094 </para>
7095 <para>
7096 In some esoteric situations different versions of Exim may be run under
7097 different effective uids and the CONFIGURE_FILE_USE_EUID is defined to
7098 help with this. See the comments in <filename>src/EDITME</filename> for details.
7099 </para>
7100 </section>
7101 <section id="SECTconffilfor">
7102 <title>Configuration file format</title>
7103 <para>
7104 <indexterm role="concept">
7105 <primary>configuration file</primary>
7106 <secondary>format of</secondary>
7107 </indexterm>
7108 <indexterm role="concept">
7109 <primary>format</primary>
7110 <secondary>configuration file</secondary>
7111 </indexterm>
7112 Exim&#x2019;s configuration file is divided into a number of different parts. General
7113 option settings must always appear at the start of the file. The other parts
7114 are all optional, and may appear in any order. Each part other than the first
7115 is introduced by the word <quote>begin</quote> followed by the name of the part. The
7116 optional parts are:
7117 </para>
7118 <itemizedlist>
7119 <listitem>
7120 <para>
7121 <emphasis>ACL</emphasis>: Access control lists for controlling incoming SMTP mail (see chapter
7122 <xref linkend="CHAPACL"/>).
7123 </para>
7124 </listitem>
7125 <listitem>
7126 <para>
7127 <indexterm role="concept">
7128 <primary>AUTH</primary>
7129 <secondary>configuration</secondary>
7130 </indexterm>
7131 <emphasis>authenticators</emphasis>: Configuration settings for the authenticator drivers. These
7132 are concerned with the SMTP AUTH command (see chapter <xref linkend="CHAPSMTPAUTH"/>).
7133 </para>
7134 </listitem>
7135 <listitem>
7136 <para>
7137 <emphasis>routers</emphasis>: Configuration settings for the router drivers. Routers process
7138 addresses and determine how the message is to be delivered (see chapters
7139 <xref linkend="CHAProutergeneric"/>&ndash;<xref linkend="CHAPredirect"/>).
7140 </para>
7141 </listitem>
7142 <listitem>
7143 <para>
7144 <emphasis>transports</emphasis>: Configuration settings for the transport drivers. Transports
7145 define mechanisms for copying messages to destinations (see chapters
7146 <xref linkend="CHAPtransportgeneric"/>&ndash;<xref linkend="CHAPsmtptrans"/>).
7147 </para>
7148 </listitem>
7149 <listitem>
7150 <para>
7151 <emphasis>retry</emphasis>: Retry rules, for use when a message cannot be delivered immediately.
7152 If there is no retry section, or if it is empty (that is, no retry rules are
7153 defined), Exim will not retry deliveries. In this situation, temporary errors
7154 are treated the same as permanent errors. Retry rules are discussed in chapter
7155 <xref linkend="CHAPretry"/>.
7156 </para>
7157 </listitem>
7158 <listitem>
7159 <para>
7160 <emphasis>rewrite</emphasis>: Global address rewriting rules, for use when a message arrives and
7161 when new addresses are generated during delivery. Rewriting is discussed in
7162 chapter <xref linkend="CHAPrewrite"/>.
7163 </para>
7164 </listitem>
7165 <listitem>
7166 <para>
7167 <emphasis>local_scan</emphasis>: Private options for the <function>local_scan()</function> function. If you
7168 want to use this feature, you must set
7169 </para>
7170 <literallayout class="monospaced">
7171 LOCAL_SCAN_HAS_OPTIONS=yes
7172 </literallayout>
7173 <para>
7174 in <filename>Local/Makefile</filename> before building Exim. Details of the <function>local_scan()</function>
7175 facility are given in chapter <xref linkend="CHAPlocalscan"/>.
7176 </para>
7177 </listitem>
7178 </itemizedlist>
7179 <para>
7180 <indexterm role="concept">
7181 <primary>configuration file</primary>
7182 <secondary>leading white space in</secondary>
7183 </indexterm>
7184 <indexterm role="concept">
7185 <primary>configuration file</primary>
7186 <secondary>trailing white space in</secondary>
7187 </indexterm>
7188 <indexterm role="concept">
7189 <primary>white space</primary>
7190 <secondary>in configuration file</secondary>
7191 </indexterm>
7192 Leading and trailing white space in configuration lines is always ignored.
7193 </para>
7194 <para>
7195 Blank lines in the file, and lines starting with a # character (ignoring
7196 leading white space) are treated as comments and are ignored. <emphasis role="bold">Note</emphasis>: A
7197 # character other than at the beginning of a line is not treated specially,
7198 and does not introduce a comment.
7199 </para>
7200 <para>
7201 Any non-comment line can be continued by ending it with a backslash. Note that
7202 the general rule for white space means that trailing white space after the
7203 backslash and leading white space at the start of continuation
7204 lines is ignored. Comment lines beginning with # (but not empty lines) may
7205 appear in the middle of a sequence of continuation lines.
7206 </para>
7207 <para>
7208 A convenient way to create a configuration file is to start from the
7209 default, which is supplied in <filename>src/configure.default</filename>, and add, delete, or
7210 change settings as required.
7211 </para>
7212 <para>
7213 The ACLs, retry rules, and rewriting rules have their own syntax which is
7214 described in chapters <xref linkend="CHAPACL"/>, <xref linkend="CHAPretry"/>, and <xref linkend="CHAPrewrite"/>,
7215 respectively. The other parts of the configuration file have some syntactic
7216 items in common, and these are described below, from section <xref linkend="SECTcos"/>
7217 onwards. Before that, the inclusion, macro, and conditional facilities are
7218 described.
7219 </para>
7220 </section>
7221 <section id="SECID41">
7222 <title>File inclusions in the configuration file</title>
7223 <para>
7224 <indexterm role="concept">
7225 <primary>inclusions in configuration file</primary>
7226 </indexterm>
7227 <indexterm role="concept">
7228 <primary>configuration file</primary>
7229 <secondary>including other files</secondary>
7230 </indexterm>
7231 <indexterm role="concept">
7232 <primary><literal>.include</literal> in configuration file</primary>
7233 </indexterm>
7234 <indexterm role="concept">
7235 <primary><literal>.include_if_exists</literal> in configuration file</primary>
7236 </indexterm>
7237 You can include other files inside Exim&#x2019;s run time configuration file by
7238 using this syntax:
7239 </para>
7240 <literallayout>
7241 <literal>.include</literal> &lt;<emphasis>file name</emphasis>&gt;
7242 <literal>.include_if_exists</literal> &lt;<emphasis>file name</emphasis>&gt;
7243 </literallayout>
7244 <para>
7245 on a line by itself. Double quotes round the file name are optional. If you use
7246 the first form, a configuration error occurs if the file does not exist; the
7247 second form does nothing for non-existent files. In all cases, an absolute file
7248 name is required.
7249 </para>
7250 <para>
7251 Includes may be nested to any depth, but remember that Exim reads its
7252 configuration file often, so it is a good idea to keep them to a minimum.
7253 If you change the contents of an included file, you must HUP the daemon,
7254 because an included file is read only when the configuration itself is read.
7255 </para>
7256 <para>
7257 The processing of inclusions happens early, at a physical line level, so, like
7258 comment lines, an inclusion can be used in the middle of an option setting,
7259 for example:
7260 </para>
7261 <literallayout class="monospaced">
7262 hosts_lookup = a.b.c \
7263                .include /some/file
7264 </literallayout>
7265 <para>
7266 Include processing happens after macro processing (see below). Its effect is to
7267 process the lines of the included file as if they occurred inline where the
7268 inclusion appears.
7269 </para>
7270 </section>
7271 <section id="SECTmacrodefs">
7272 <title>Macros in the configuration file</title>
7273 <para>
7274 <indexterm role="concept">
7275 <primary>macro</primary>
7276 <secondary>description of</secondary>
7277 </indexterm>
7278 <indexterm role="concept">
7279 <primary>configuration file</primary>
7280 <secondary>macros</secondary>
7281 </indexterm>
7282 If a line in the main part of the configuration (that is, before the first
7283 <quote>begin</quote> line) begins with an upper case letter, it is taken as a macro
7284 definition, and must be of the form
7285 </para>
7286 <literallayout>
7287 &lt;<emphasis>name</emphasis>&gt; = &lt;<emphasis>rest of line</emphasis>&gt;
7288 </literallayout>
7289 <para>
7290 The name must consist of letters, digits, and underscores, and need not all be
7291 in upper case, though that is recommended. The rest of the line, including any
7292 continuations, is the replacement text, and has leading and trailing white
7293 space removed. Quotes are not removed. The replacement text can never end with
7294 a backslash character, but this doesn&#x2019;t seem to be a serious limitation.
7295 </para>
7296 <para>
7297 Macros may also be defined between router, transport, authenticator, or ACL
7298 definitions. They may not, however, be defined within an individual driver or
7299 ACL, or in the <option>local_scan</option>, retry, or rewrite sections of the configuration.
7300 </para>
7301 </section>
7302 <section id="SECID42">
7303 <title>Macro substitution</title>
7304 <para>
7305 Once a macro is defined, all subsequent lines in the file (and any included
7306 files) are scanned for the macro name; if there are several macros, the line is
7307 scanned for each in turn, in the order in which the macros are defined. The
7308 replacement text is not re-scanned for the current macro, though it is scanned
7309 for subsequently defined macros. For this reason, a macro name may not contain
7310 the name of a previously defined macro as a substring. You could, for example,
7311 define
7312 </para>
7313 <literallayout>
7314 <literal>ABCD_XYZ = </literal>&lt;<emphasis>something</emphasis>&gt;
7315 <literal>ABCD = </literal>&lt;<emphasis>something else</emphasis>&gt;
7316 </literallayout>
7317 <para>
7318 but putting the definitions in the opposite order would provoke a configuration
7319 error. Macro expansion is applied to individual physical lines from the file,
7320 before checking for line continuation or file inclusion (see above). If a line
7321 consists solely of a macro name, and the expansion of the macro is empty, the
7322 line is ignored. A macro at the start of a line may turn the line into a
7323 comment line or a <literal>.include</literal> line.
7324 </para>
7325 </section>
7326 <section id="SECID43">
7327 <title>Redefining macros</title>
7328 <para>
7329 Once defined, the value of a macro can be redefined later in the configuration
7330 (or in an included file). Redefinition is specified by using <emphasis>==</emphasis> instead of
7331 <emphasis>=</emphasis>. For example:
7332 </para>
7333 <literallayout class="monospaced">
7334 MAC =  initial value
7335 ...
7336 MAC == updated value
7337 </literallayout>
7338 <para>
7339 Redefinition does not alter the order in which the macros are applied to the
7340 subsequent lines of the configuration file. It is still the same order in which
7341 the macros were originally defined. All that changes is the macro&#x2019;s value.
7342 Redefinition makes it possible to accumulate values. For example:
7343 </para>
7344 <literallayout class="monospaced">
7345 MAC =  initial value
7346 ...
7347 MAC == MAC and something added
7348 </literallayout>
7349 <para>
7350 This can be helpful in situations where the configuration file is built
7351 from a number of other files.
7352 </para>
7353 </section>
7354 <section id="SECID44">
7355 <title>Overriding macro values</title>
7356 <para>
7357 The values set for macros in the configuration file can be overridden by the
7358 <option>-D</option> command line option, but Exim gives up its root privilege when <option>-D</option> is
7359 used, unless called by root or the Exim user. A definition on the command line
7360 using the <option>-D</option> option causes all definitions and redefinitions within the
7361 file to be ignored.
7362 </para>
7363 </section>
7364 <section id="SECID45">
7365 <title>Example of macro usage</title>
7366 <para>
7367 As an example of macro usage, consider a configuration where aliases are looked
7368 up in a MySQL database. It helps to keep the file less cluttered if long
7369 strings such as SQL statements are defined separately as macros, for example:
7370 </para>
7371 <literallayout class="monospaced">
7372 ALIAS_QUERY = select mailbox from user where \
7373               login='${quote_mysql:$local_part}';
7374 </literallayout>
7375 <para>
7376 This can then be used in a <command>redirect</command> router setting like this:
7377 </para>
7378 <literallayout class="monospaced">
7379 data = ${lookup mysql{ALIAS_QUERY}}
7380 </literallayout>
7381 <para>
7382 In earlier versions of Exim macros were sometimes used for domain, host, or
7383 address lists. In Exim 4 these are handled better by named lists &ndash; see
7384 section <xref linkend="SECTnamedlists"/>.
7385 </para>
7386 </section>
7387 <section id="SECID46">
7388 <title>Conditional skips in the configuration file</title>
7389 <para>
7390 <indexterm role="concept">
7391 <primary>configuration file</primary>
7392 <secondary>conditional skips</secondary>
7393 </indexterm>
7394 <indexterm role="concept">
7395 <primary><literal>.ifdef</literal></primary>
7396 </indexterm>
7397 You can use the directives <literal>.ifdef</literal>, <literal>.ifndef</literal>, <literal>.elifdef</literal>,
7398 <literal>.elifndef</literal>, <literal>.else</literal>, and <literal>.endif</literal> to dynamically include or exclude
7399 portions of the configuration file. The processing happens whenever the file is
7400 read (that is, when an Exim binary starts to run).
7401 </para>
7402 <para>
7403 The implementation is very simple. Instances of the first four directives must
7404 be followed by text that includes the names of one or macros. The condition
7405 that is tested is whether or not any macro substitution has taken place in the
7406 line. Thus:
7407 </para>
7408 <literallayout class="monospaced">
7409 .ifdef AAA
7410 message_size_limit = 50M
7411 .else
7412 message_size_limit = 100M
7413 .endif
7414 </literallayout>
7415 <para>
7416 sets a message size limit of 50M if the macro <literal>AAA</literal> is defined, and 100M
7417 otherwise. If there is more than one macro named on the line, the condition
7418 is true if any of them are defined. That is, it is an <quote>or</quote> condition. To
7419 obtain an <quote>and</quote> condition, you need to use nested <literal>.ifdef</literal>s.
7420 </para>
7421 <para>
7422 Although you can use a macro expansion to generate one of these directives,
7423 it is not very useful, because the condition <quote>there was a macro substitution
7424 in this line</quote> will always be true.
7425 </para>
7426 <para>
7427 Text following <literal>.else</literal> and <literal>.endif</literal> is ignored, and can be used as comment
7428 to clarify complicated nestings.
7429 </para>
7430 </section>
7431 <section id="SECTcos">
7432 <title>Common option syntax</title>
7433 <para>
7434 <indexterm role="concept">
7435 <primary>common option syntax</primary>
7436 </indexterm>
7437 <indexterm role="concept">
7438 <primary>syntax of common options</primary>
7439 </indexterm>
7440 <indexterm role="concept">
7441 <primary>configuration file</primary>
7442 <secondary>common option syntax</secondary>
7443 </indexterm>
7444 For the main set of options, driver options, and <function>local_scan()</function> options,
7445 each setting is on a line by itself, and starts with a name consisting of
7446 lower-case letters and underscores. Many options require a data value, and in
7447 these cases the name must be followed by an equals sign (with optional white
7448 space) and then the value. For example:
7449 </para>
7450 <literallayout class="monospaced">
7451 qualify_domain = mydomain.example.com
7452 </literallayout>
7453 <para>
7454 <indexterm role="concept">
7455 <primary>hiding configuration option values</primary>
7456 </indexterm>
7457 <indexterm role="concept">
7458 <primary>configuration options</primary>
7459 <secondary>hiding value of</secondary>
7460 </indexterm>
7461 <indexterm role="concept">
7462 <primary>options</primary>
7463 <secondary>hiding value of</secondary>
7464 </indexterm>
7465 Some option settings may contain sensitive data, for example, passwords for
7466 accessing databases. To stop non-admin users from using the <option>-bP</option> command
7467 line option to read these values, you can precede the option settings with the
7468 word <quote>hide</quote>. For example:
7469 </para>
7470 <literallayout class="monospaced">
7471 hide mysql_servers = localhost/users/admin/secret-password
7472 </literallayout>
7473 <para>
7474 For non-admin users, such options are displayed like this:
7475 </para>
7476 <literallayout class="monospaced">
7477 mysql_servers = &lt;value not displayable&gt;
7478 </literallayout>
7479 <para>
7480 If <quote>hide</quote> is used on a driver option, it hides the value of that option on
7481 all instances of the same driver.
7482 </para>
7483 <para>
7484 The following sections describe the syntax used for the different data types
7485 that are found in option settings.
7486 </para>
7487 </section>
7488 <section id="SECID47">
7489 <title>Boolean options</title>
7490 <para>
7491 <indexterm role="concept">
7492 <primary>format</primary>
7493 <secondary>boolean</secondary>
7494 </indexterm>
7495 <indexterm role="concept">
7496 <primary>boolean configuration values</primary>
7497 </indexterm>
7498 <indexterm role="option">
7499 <primary><option>no_</option><emphasis>xxx</emphasis></primary>
7500 </indexterm>
7501 <indexterm role="option">
7502 <primary><option>not_</option><emphasis>xxx</emphasis></primary>
7503 </indexterm>
7504 Options whose type is given as boolean are on/off switches. There are two
7505 different ways of specifying such options: with and without a data value. If
7506 the option name is specified on its own without data, the switch is turned on;
7507 if it is preceded by <quote>no_</quote> or <quote>not_</quote> the switch is turned off. However,
7508 boolean options may be followed by an equals sign and one of the words
7509 <quote>true</quote>, <quote>false</quote>, <quote>yes</quote>, or <quote>no</quote>, as an alternative syntax. For example,
7510 the following two settings have exactly the same effect:
7511 </para>
7512 <literallayout class="monospaced">
7513 queue_only
7514 queue_only = true
7515 </literallayout>
7516 <para>
7517 The following two lines also have the same (opposite) effect:
7518 </para>
7519 <literallayout class="monospaced">
7520 no_queue_only
7521 queue_only = false
7522 </literallayout>
7523 <para>
7524 You can use whichever syntax you prefer.
7525 </para>
7526 </section>
7527 <section id="SECID48">
7528 <title>Integer values</title>
7529 <para>
7530 <indexterm role="concept">
7531 <primary>integer configuration values</primary>
7532 </indexterm>
7533 <indexterm role="concept">
7534 <primary>format</primary>
7535 <secondary>integer</secondary>
7536 </indexterm>
7537 If an option&#x2019;s type is given as <quote>integer</quote>, the value can be given in decimal,
7538 hexadecimal, or octal. If it starts with a digit greater than zero, a decimal
7539 number is assumed. Otherwise, it is treated as an octal number unless it starts
7540 with the characters <quote>0x</quote>, in which case the remainder is interpreted as a
7541 hexadecimal number.
7542 </para>
7543 <para>
7544 If an integer value is followed by the letter K, it is multiplied by 1024; if
7545 it is followed by the letter M, it is multiplied by 1024x1024. When the values
7546 of integer option settings are output, values which are an exact multiple of
7547 1024 or 1024x1024 are sometimes, but not always, printed using the letters K
7548 and M. The printing style is independent of the actual input format that was
7549 used.
7550 </para>
7551 </section>
7552 <section id="SECID49">
7553 <title>Octal integer values</title>
7554 <para>
7555 <indexterm role="concept">
7556 <primary>integer format</primary>
7557 </indexterm>
7558 <indexterm role="concept">
7559 <primary>format</primary>
7560 <secondary>octal integer</secondary>
7561 </indexterm>
7562 If an option&#x2019;s type is given as <quote>octal integer</quote>, its value is always
7563 interpreted as an octal number, whether or not it starts with the digit zero.
7564 Such options are always output in octal.
7565 </para>
7566 </section>
7567 <section id="SECID50">
7568 <title>Fixed point numbers</title>
7569 <para>
7570 <indexterm role="concept">
7571 <primary>fixed point configuration values</primary>
7572 </indexterm>
7573 <indexterm role="concept">
7574 <primary>format</primary>
7575 <secondary>fixed point</secondary>
7576 </indexterm>
7577 If an option&#x2019;s type is given as <quote>fixed-point</quote>, its value must be a decimal
7578 integer, optionally followed by a decimal point and up to three further digits.
7579 </para>
7580 </section>
7581 <section id="SECTtimeformat">
7582 <title>Time intervals</title>
7583 <para>
7584 <indexterm role="concept">
7585 <primary>time interval</primary>
7586 <secondary>specifying in configuration</secondary>
7587 </indexterm>
7588 <indexterm role="concept">
7589 <primary>format</primary>
7590 <secondary>time interval</secondary>
7591 </indexterm>
7592 A time interval is specified as a sequence of numbers, each followed by one of
7593 the following letters, with no intervening white space:
7594 </para>
7595 <informaltable frame="none">
7596 <tgroup cols="2" colsep="0" rowsep="0">
7597 <colspec colwidth="30pt" align="left"/>
7598 <colspec colwidth="254pt" align="left"/>
7599 <tbody>
7600 <row>
7601 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>s</option></entry>
7602 <entry>seconds</entry>
7603 </row>
7604 <row>
7605 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>m</option></entry>
7606 <entry>minutes</entry>
7607 </row>
7608 <row>
7609 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>h</option></entry>
7610 <entry>hours</entry>
7611 </row>
7612 <row>
7613 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>d</option></entry>
7614 <entry>days</entry>
7615 </row>
7616 <row>
7617 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>w</option></entry>
7618 <entry>weeks</entry>
7619 </row>
7620 </tbody>
7621 </tgroup>
7622 </informaltable>
7623 <para>
7624 For example, <quote>3h50m</quote> specifies 3 hours and 50 minutes. The values of time
7625 intervals are output in the same format. Exim does not restrict the values; it
7626 is perfectly acceptable, for example, to specify <quote>90m</quote> instead of <quote>1h30m</quote>.
7627 </para>
7628 </section>
7629 <section id="SECTstrings">
7630 <title>String values</title>
7631 <para>
7632 <indexterm role="concept">
7633 <primary>string</primary>
7634 <secondary>format of configuration values</secondary>
7635 </indexterm>
7636 <indexterm role="concept">
7637 <primary>format</primary>
7638 <secondary>string</secondary>
7639 </indexterm>
7640 If an option&#x2019;s type is specified as <quote>string</quote>, the value can be specified with
7641 or without double-quotes. If it does not start with a double-quote, the value
7642 consists of the remainder of the line plus any continuation lines, starting at
7643 the first character after any leading white space, with trailing white space
7644 removed, and with no interpretation of the characters in the string. Because
7645 Exim removes comment lines (those beginning with #) at an early stage, they can
7646 appear in the middle of a multi-line string. The following two settings are
7647 therefore equivalent:
7648 </para>
7649 <literallayout class="monospaced">
7650 trusted_users = uucp:mail
7651 trusted_users = uucp:\
7652                 # This comment line is ignored
7653                 mail
7654 </literallayout>
7655 <para>
7656 <indexterm role="concept">
7657 <primary>string</primary>
7658 <secondary>quoted</secondary>
7659 </indexterm>
7660 <indexterm role="concept">
7661 <primary>escape characters in quoted strings</primary>
7662 </indexterm>
7663 If a string does start with a double-quote, it must end with a closing
7664 double-quote, and any backslash characters other than those used for line
7665 continuation are interpreted as escape characters, as follows:
7666 </para>
7667 <informaltable frame="none">
7668 <tgroup cols="2" colsep="0" rowsep="0">
7669 <colspec colwidth="100pt" align="left"/>
7670 <colspec colwidth="254pt" align="left"/>
7671 <tbody>
7672 <row>
7673 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>\\</literal></entry>
7674 <entry>single backslash</entry>
7675 </row>
7676 <row>
7677 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>\n</literal></entry>
7678 <entry>newline</entry>
7679 </row>
7680 <row>
7681 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>\r</literal></entry>
7682 <entry>carriage return</entry>
7683 </row>
7684 <row>
7685 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>\t</literal></entry>
7686 <entry>tab</entry>
7687 </row>
7688 <row>
7689 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>\</literal>&lt;<emphasis>octal digits</emphasis>&gt;</entry>
7690 <entry>up to 3 octal digits specify one character</entry>
7691 </row>
7692 <row>
7693 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>\x</literal>&lt;<emphasis>hex digits</emphasis>&gt;</entry>
7694 <entry>up to 2 hexadecimal digits specify one character</entry>
7695 </row>
7696 </tbody>
7697 </tgroup>
7698 </informaltable>
7699 <para>
7700 If a backslash is followed by some other character, including a double-quote
7701 character, that character replaces the pair.
7702 </para>
7703 <para>
7704 Quoting is necessary only if you want to make use of the backslash escapes to
7705 insert special characters, or if you need to specify a value with leading or
7706 trailing spaces. These cases are rare, so quoting is almost never needed in
7707 current versions of Exim. In versions of Exim before 3.14, quoting was required
7708 in order to continue lines, so you may come across older configuration files
7709 and examples that apparently quote unnecessarily.
7710 </para>
7711 </section>
7712 <section id="SECID51">
7713 <title>Expanded strings</title>
7714 <para>
7715 <indexterm role="concept">
7716 <primary>expansion</primary>
7717 <secondary>definition of</secondary>
7718 </indexterm>
7719 Some strings in the configuration file are subjected to <emphasis>string expansion</emphasis>,
7720 by which means various parts of the string may be changed according to the
7721 circumstances (see chapter <xref linkend="CHAPexpand"/>). The input syntax for such strings
7722 is as just described; in particular, the handling of backslashes in quoted
7723 strings is done as part of the input process, before expansion takes place.
7724 However, backslash is also an escape character for the expander, so any
7725 backslashes that are required for that reason must be doubled if they are
7726 within a quoted configuration string.
7727 </para>
7728 </section>
7729 <section id="SECID52">
7730 <title>User and group names</title>
7731 <para>
7732 <indexterm role="concept">
7733 <primary>user name</primary>
7734 <secondary>format of</secondary>
7735 </indexterm>
7736 <indexterm role="concept">
7737 <primary>format</primary>
7738 <secondary>user name</secondary>
7739 </indexterm>
7740 <indexterm role="concept">
7741 <primary>groups</primary>
7742 <secondary>name format</secondary>
7743 </indexterm>
7744 <indexterm role="concept">
7745 <primary>format</primary>
7746 <secondary>group name</secondary>
7747 </indexterm>
7748 User and group names are specified as strings, using the syntax described
7749 above, but the strings are interpreted specially. A user or group name must
7750 either consist entirely of digits, or be a name that can be looked up using the
7751 <function>getpwnam()</function> or <function>getgrnam()</function> function, as appropriate.
7752 </para>
7753 </section>
7754 <section id="SECTlistconstruct">
7755 <title>List construction</title>
7756 <para>
7757 <indexterm role="concept">
7758 <primary>list</primary>
7759 <secondary>syntax of in configuration</secondary>
7760 </indexterm>
7761 <indexterm role="concept">
7762 <primary>format</primary>
7763 <secondary>list item in configuration</secondary>
7764 </indexterm>
7765 <indexterm role="concept">
7766 <primary>string</primary>
7767 <secondary>list, definition of</secondary>
7768 </indexterm>
7769 The data for some configuration options is a list of items, with colon as the
7770 default separator. Many of these options are shown with type <quote>string list</quote> in
7771 the descriptions later in this document. Others are listed as <quote>domain list</quote>,
7772 <quote>host list</quote>, <quote>address list</quote>, or <quote>local part list</quote>. Syntactically, they
7773 are all the same; however, those other than <quote>string list</quote> are subject to
7774 particular kinds of interpretation, as described in chapter
7775 <xref linkend="CHAPdomhosaddlists"/>.
7776 </para>
7777 <para>
7778 In all these cases, the entire list is treated as a single string as far as the
7779 input syntax is concerned. The <option>trusted_users</option> setting in section
7780 <xref linkend="SECTstrings"/> above is an example. If a colon is actually needed in an item
7781 in a list, it must be entered as two colons. Leading and trailing white space
7782 on each item in a list is ignored. This makes it possible to include items that
7783 start with a colon, and in particular, certain forms of IPv6 address. For
7784 example, the list
7785 </para>
7786 <literallayout class="monospaced">
7787 local_interfaces = 127.0.0.1 : ::::1
7788 </literallayout>
7789 <para>
7790 contains two IP addresses, the IPv4 address 127.0.0.1 and the IPv6 address ::1.
7791 </para>
7792 <para>
7793 <emphasis role="bold">Note</emphasis>: Although leading and trailing white space is ignored in individual
7794 list items, it is not ignored when parsing the list. The space after the first
7795 colon in the example above is necessary. If it were not there, the list would
7796 be interpreted as the two items 127.0.0.1:: and 1.
7797 </para>
7798 </section>
7799 <section id="SECID53">
7800 <title>Changing list separators</title>
7801 <para>
7802 <indexterm role="concept">
7803 <primary>list separator</primary>
7804 <secondary>changing</secondary>
7805 </indexterm>
7806 <indexterm role="concept">
7807 <primary>IPv6</primary>
7808 <secondary>addresses in lists</secondary>
7809 </indexterm>
7810 Doubling colons in IPv6 addresses is an unwelcome chore, so a mechanism was
7811 introduced to allow the separator character to be changed. If a list begins
7812 with a left angle bracket, followed by any punctuation character, that
7813 character is used instead of colon as the list separator. For example, the list
7814 above can be rewritten to use a semicolon separator like this:
7815 </para>
7816 <literallayout class="monospaced">
7817 local_interfaces = &lt;; 127.0.0.1 ; ::1
7818 </literallayout>
7819 <para>
7820 This facility applies to all lists, with the exception of the list in
7821 <option>log_file_path</option>. It is recommended that the use of non-colon separators be
7822 confined to circumstances where they really are needed.
7823 </para>
7824 <para>
7825 <indexterm role="concept">
7826 <primary>list separator</primary>
7827 <secondary>newline as</secondary>
7828 </indexterm>
7829 <indexterm role="concept">
7830 <primary>newline</primary>
7831 <secondary>as list separator</secondary>
7832 </indexterm>
7833 It is also possible to use newline and other control characters (those with
7834 code values less than 32, plus DEL) as separators in lists. Such separators
7835 must be provided literally at the time the list is processed. For options that
7836 are string-expanded, you can write the separator using a normal escape
7837 sequence. This will be processed by the expander before the string is
7838 interpreted as a list. For example, if a newline-separated list of domains is
7839 generated by a lookup, you can process it directly by a line such as this:
7840 </para>
7841 <literallayout class="monospaced">
7842 domains = &lt;\n ${lookup mysql{.....}}
7843 </literallayout>
7844 <para>
7845 This avoids having to change the list separator in such data. You are unlikely
7846 to want to use a control character as a separator in an option that is not
7847 expanded, because the value is literal text. However, it can be done by giving
7848 the value in quotes. For example:
7849 </para>
7850 <literallayout class="monospaced">
7851 local_interfaces = "&lt;\n 127.0.0.1 \n ::1"
7852 </literallayout>
7853 <para>
7854 Unlike printing character separators, which can be included in list items by
7855 doubling, it is not possible to include a control character as data when it is
7856 set as the separator. Two such characters in succession are interpreted as
7857 enclosing an empty list item.
7858 </para>
7859 </section>
7860 <section id="SECTempitelis">
7861 <title>Empty items in lists</title>
7862 <para>
7863 <indexterm role="concept">
7864 <primary>list</primary>
7865 <secondary>empty item in</secondary>
7866 </indexterm>
7867 An empty item at the end of a list is always ignored. In other words, trailing
7868 separator characters are ignored. Thus, the list in
7869 </para>
7870 <literallayout class="monospaced">
7871 senders = user@domain :
7872 </literallayout>
7873 <para>
7874 contains only a single item. If you want to include an empty string as one item
7875 in a list, it must not be the last item. For example, this list contains three
7876 items, the second of which is empty:
7877 </para>
7878 <literallayout class="monospaced">
7879 senders = user1@domain : : user2@domain
7880 </literallayout>
7881 <para>
7882 <emphasis role="bold">Note</emphasis>: There must be white space between the two colons, as otherwise they
7883 are interpreted as representing a single colon data character (and the list
7884 would then contain just one item). If you want to specify a list that contains
7885 just one, empty item, you can do it as in this example:
7886 </para>
7887 <literallayout class="monospaced">
7888 senders = :
7889 </literallayout>
7890 <para>
7891 In this case, the first item is empty, and the second is discarded because it
7892 is at the end of the list.
7893 </para>
7894 </section>
7895 <section id="SECTfordricon">
7896 <title>Format of driver configurations</title>
7897 <para>
7898 <indexterm role="concept">
7899 <primary>drivers</primary>
7900 <secondary>configuration format</secondary>
7901 </indexterm>
7902 There are separate parts in the configuration for defining routers, transports,
7903 and authenticators. In each part, you are defining a number of driver
7904 instances, each with its own set of options. Each driver instance is defined by
7905 a sequence of lines like this:
7906 </para>
7907 <literallayout>
7908 &lt;<emphasis>instance name</emphasis>&gt;:
7909   &lt;<emphasis>option</emphasis>&gt;
7910   ...
7911   &lt;<emphasis>option</emphasis>&gt;
7912 </literallayout>
7913 <para>
7914 In the following example, the instance name is <command>localuser</command>, and it is
7915 followed by three options settings:
7916 </para>
7917 <literallayout class="monospaced">
7918 localuser:
7919   driver = accept
7920   check_local_user
7921   transport = local_delivery
7922 </literallayout>
7923 <para>
7924 For each driver instance, you specify which Exim code module it uses &ndash; by the
7925 setting of the <option>driver</option> option &ndash; and (optionally) some configuration
7926 settings. For example, in the case of transports, if you want a transport to
7927 deliver with SMTP you would use the <command>smtp</command> driver; if you want to deliver to
7928 a local file you would use the <command>appendfile</command> driver. Each of the drivers is
7929 described in detail in its own separate chapter later in this manual.
7930 </para>
7931 <para>
7932 You can have several routers, transports, or authenticators that are based on
7933 the same underlying driver (each must have a different instance name).
7934 </para>
7935 <para>
7936 The order in which routers are defined is important, because addresses are
7937 passed to individual routers one by one, in order. The order in which
7938 transports are defined does not matter at all. The order in which
7939 authenticators are defined is used only when Exim, as a client, is searching
7940 them to find one that matches an authentication mechanism offered by the
7941 server.
7942 </para>
7943 <para>
7944 <indexterm role="concept">
7945 <primary>generic options</primary>
7946 </indexterm>
7947 <indexterm role="concept">
7948 <primary>options</primary>
7949 <secondary>generic &ndash; definition of</secondary>
7950 </indexterm>
7951 Within a driver instance definition, there are two kinds of option: <emphasis>generic</emphasis>
7952 and <emphasis>private</emphasis>. The generic options are those that apply to all drivers of the
7953 same type (that is, all routers, all transports or all authenticators). The
7954 <option>driver</option> option is a generic option that must appear in every definition.
7955 <indexterm role="concept">
7956 <primary>private options</primary>
7957 </indexterm>
7958 The private options are special for each driver, and none need appear, because
7959 they all have default values.
7960 </para>
7961 <para>
7962 The options may appear in any order, except that the <option>driver</option> option must
7963 precede any private options, since these depend on the particular driver. For
7964 this reason, it is recommended that <option>driver</option> always be the first option.
7965 </para>
7966 <para>
7967 Driver instance names, which are used for reference in log entries and
7968 elsewhere, can be any sequence of letters, digits, and underscores (starting
7969 with a letter) and must be unique among drivers of the same type. A router and
7970 a transport (for example) can each have the same name, but no two router
7971 instances can have the same name. The name of a driver instance should not be
7972 confused with the name of the underlying driver module. For example, the
7973 configuration lines:
7974 </para>
7975 <literallayout class="monospaced">
7976 remote_smtp:
7977   driver = smtp
7978 </literallayout>
7979 <para>
7980 create an instance of the <command>smtp</command> transport driver whose name is
7981 <command>remote_smtp</command>. The same driver code can be used more than once, with
7982 different instance names and different option settings each time. A second
7983 instance of the <command>smtp</command> transport, with different options, might be defined
7984 thus:
7985 </para>
7986 <literallayout class="monospaced">
7987 special_smtp:
7988   driver = smtp
7989   port = 1234
7990   command_timeout = 10s
7991 </literallayout>
7992 <para>
7993 The names <command>remote_smtp</command> and <command>special_smtp</command> would be used to reference
7994 these transport instances from routers, and these names would appear in log
7995 lines.
7996 </para>
7997 <para>
7998 Comment lines may be present in the middle of driver specifications. The full
7999 list of option settings for any particular driver instance, including all the
8000 defaulted values, can be extracted by making use of the <option>-bP</option> command line
8001 option.
8002 </para>
8003 </section>
8004 </chapter>
8005
8006 <chapter id="CHAPdefconfil">
8007 <title>The default configuration file</title>
8008 <para>
8009 <indexterm role="concept" id="IIDconfiwal" class="startofrange">
8010 <primary>configuration file</primary>
8011 <secondary>default <quote>walk through</quote></secondary>
8012 </indexterm>
8013 <indexterm role="concept">
8014 <primary>default</primary>
8015 <secondary>configuration file <quote>walk through</quote></secondary>
8016 </indexterm>
8017 The default configuration file supplied with Exim as <filename>src/configure.default</filename>
8018 is sufficient for a host with simple mail requirements. As an introduction to
8019 the way Exim is configured, this chapter <quote>walks through</quote> the default
8020 configuration, giving brief explanations of the settings. Detailed descriptions
8021 of the options are given in subsequent chapters. The default configuration file
8022 itself contains extensive comments about ways you might want to modify the
8023 initial settings. However, note that there are many options that are not
8024 mentioned at all in the default configuration.
8025 </para>
8026 <section id="SECTdefconfmain">
8027 <title>Main configuration settings</title>
8028 <para>
8029 The main (global) configuration option settings must always come first in the
8030 file. The first thing you&#x2019;ll see in the file, after some initial comments, is
8031 the line
8032 </para>
8033 <literallayout class="monospaced">
8034 # primary_hostname =
8035 </literallayout>
8036 <para>
8037 This is a commented-out setting of the <option>primary_hostname</option> option. Exim needs
8038 to know the official, fully qualified name of your host, and this is where you
8039 can specify it. However, in most cases you do not need to set this option. When
8040 it is unset, Exim uses the <function>uname()</function> system function to obtain the host name.
8041 </para>
8042 <para>
8043 The first three non-comment configuration lines are as follows:
8044 </para>
8045 <literallayout class="monospaced">
8046 domainlist local_domains = @
8047 domainlist relay_to_domains =
8048 hostlist   relay_from_hosts = 127.0.0.1
8049 </literallayout>
8050 <para>
8051 These are not, in fact, option settings. They are definitions of two named
8052 domain lists and one named host list. Exim allows you to give names to lists of
8053 domains, hosts, and email addresses, in order to make it easier to manage the
8054 configuration file (see section <xref linkend="SECTnamedlists"/>).
8055 </para>
8056 <para>
8057 The first line defines a domain list called <emphasis>local_domains</emphasis>; this is used
8058 later in the configuration to identify domains that are to be delivered
8059 on the local host.
8060 </para>
8061 <para>
8062 <indexterm role="concept">
8063 <primary>@ in a domain list</primary>
8064 </indexterm>
8065 There is just one item in this list, the string <quote>@</quote>. This is a special form
8066 of entry which means <quote>the name of the local host</quote>. Thus, if the local host is
8067 called <emphasis>a.host.example</emphasis>, mail to <emphasis>any.user@a.host.example</emphasis> is expected to
8068 be delivered locally. Because the local host&#x2019;s name is referenced indirectly,
8069 the same configuration file can be used on different hosts.
8070 </para>
8071 <para>
8072 The second line defines a domain list called <emphasis>relay_to_domains</emphasis>, but the
8073 list itself is empty. Later in the configuration we will come to the part that
8074 controls mail relaying through the local host; it allows relaying to any
8075 domains in this list. By default, therefore, no relaying on the basis of a mail
8076 domain is permitted.
8077 </para>
8078 <para>
8079 The third line defines a host list called <emphasis>relay_from_hosts</emphasis>. This list is
8080 used later in the configuration to permit relaying from any host or IP address
8081 that matches the list. The default contains just the IP address of the IPv4
8082 loopback interface, which means that processes on the local host are able to
8083 submit mail for relaying by sending it over TCP/IP to that interface. No other
8084 hosts are permitted to submit messages for relaying.
8085 </para>
8086 <para>
8087 Just to be sure there&#x2019;s no misunderstanding: at this point in the configuration
8088 we aren&#x2019;t actually setting up any controls. We are just defining some domains
8089 and hosts that will be used in the controls that are specified later.
8090 </para>
8091 <para>
8092 The next two configuration lines are genuine option settings:
8093 </para>
8094 <literallayout class="monospaced">
8095 acl_smtp_rcpt = acl_check_rcpt
8096 acl_smtp_data = acl_check_data
8097 </literallayout>
8098 <para>
8099 These options specify <emphasis>Access Control Lists</emphasis> (ACLs) that are to be used
8100 during an incoming SMTP session for every recipient of a message (every RCPT
8101 command), and after the contents of the message have been received,
8102 respectively. The names of the lists are <emphasis>acl_check_rcpt</emphasis> and
8103 <emphasis>acl_check_data</emphasis>, and we will come to their definitions below, in the ACL
8104 section of the configuration. The RCPT ACL controls which recipients are
8105 accepted for an incoming message &ndash; if a configuration does not provide an ACL
8106 to check recipients, no SMTP mail can be accepted. The DATA ACL allows the
8107 contents of a message to be checked.
8108 </para>
8109 <para>
8110 Two commented-out option settings are next:
8111 </para>
8112 <literallayout class="monospaced">
8113 # av_scanner = clamd:/tmp/clamd
8114 # spamd_address = 127.0.0.1 783
8115 </literallayout>
8116 <para>
8117 These are example settings that can be used when Exim is compiled with the
8118 content-scanning extension. The first specifies the interface to the virus
8119 scanner, and the second specifies the interface to SpamAssassin. Further
8120 details are given in chapter <xref linkend="CHAPexiscan"/>.
8121 </para>
8122 <para>
8123 Three more commented-out option settings follow:
8124 </para>
8125 <literallayout class="monospaced">
8126 # tls_advertise_hosts = *
8127 # tls_certificate = /etc/ssl/exim.crt
8128 # tls_privatekey = /etc/ssl/exim.pem
8129 </literallayout>
8130 <para>
8131 These are example settings that can be used when Exim is compiled with
8132 support for TLS (aka SSL) as described in section <xref linkend="SECTinctlsssl"/>. The
8133 first one specifies the list of clients that are allowed to use TLS when
8134 connecting to this server; in this case the wildcard means all clients. The
8135 other options specify where Exim should find its TLS certificate and private
8136 key, which together prove the server&#x2019;s identity to any clients that connect.
8137 More details are given in chapter <xref linkend="CHAPTLS"/>.
8138 </para>
8139 <para>
8140 Another two commented-out option settings follow:
8141 </para>
8142 <literallayout class="monospaced">
8143 # daemon_smtp_ports = 25 : 465 : 587
8144 # tls_on_connect_ports = 465
8145 </literallayout>
8146 <para>
8147 <indexterm role="concept">
8148 <primary>port</primary>
8149 <secondary>465 and 587</secondary>
8150 </indexterm>
8151 <indexterm role="concept">
8152 <primary>port</primary>
8153 <secondary>for message submission</secondary>
8154 </indexterm>
8155 <indexterm role="concept">
8156 <primary>message</primary>
8157 <secondary>submission, ports for</secondary>
8158 </indexterm>
8159 <indexterm role="concept">
8160 <primary>ssmtp protocol</primary>
8161 </indexterm>
8162 <indexterm role="concept">
8163 <primary>smtps protocol</primary>
8164 </indexterm>
8165 <indexterm role="concept">
8166 <primary>SMTP</primary>
8167 <secondary>ssmtp protocol</secondary>
8168 </indexterm>
8169 <indexterm role="concept">
8170 <primary>SMTP</primary>
8171 <secondary>smtps protocol</secondary>
8172 </indexterm>
8173 These options provide better support for roaming users who wish to use this
8174 server for message submission. They are not much use unless you have turned on
8175 TLS (as described in the previous paragraph) and authentication (about which
8176 more in section <xref linkend="SECTdefconfauth"/>). The usual SMTP port 25 is often blocked
8177 on end-user networks, so RFC 4409 specifies that message submission should use
8178 port 587 instead. However some software (notably Microsoft Outlook) cannot be
8179 configured to use port 587 correctly, so these settings also enable the
8180 non-standard <quote>smtps</quote> (aka <quote>ssmtp</quote>) port 465 (see section
8181 <xref linkend="SECTsupobssmt"/>).
8182 </para>
8183 <para>
8184 Two more commented-out options settings follow:
8185 </para>
8186 <literallayout class="monospaced">
8187 # qualify_domain =
8188 # qualify_recipient =
8189 </literallayout>
8190 <para>
8191 The first of these specifies a domain that Exim uses when it constructs a
8192 complete email address from a local login name. This is often needed when Exim
8193 receives a message from a local process. If you do not set <option>qualify_domain</option>,
8194 the value of <option>primary_hostname</option> is used. If you set both of these options,
8195 you can have different qualification domains for sender and recipient
8196 addresses. If you set only the first one, its value is used in both cases.
8197 </para>
8198 <para>
8199 <indexterm role="concept">
8200 <primary>domain literal</primary>
8201 <secondary>recognizing format</secondary>
8202 </indexterm>
8203 The following line must be uncommented if you want Exim to recognize
8204 addresses of the form <emphasis>user@[10.11.12.13]</emphasis> that is, with a <quote>domain literal</quote>
8205 (an IP address within square brackets) instead of a named domain.
8206 </para>
8207 <literallayout class="monospaced">
8208 # allow_domain_literals
8209 </literallayout>
8210 <para>
8211 The RFCs still require this form, but many people think that in the modern
8212 Internet it makes little sense to permit mail to be sent to specific hosts by
8213 quoting their IP addresses. This ancient format has been used by people who
8214 try to abuse hosts by using them for unwanted relaying. However, some
8215 people believe there are circumstances (for example, messages addressed to
8216 <emphasis>postmaster</emphasis>) where domain literals are still useful.
8217 </para>
8218 <para>
8219 The next configuration line is a kind of trigger guard:
8220 </para>
8221 <literallayout class="monospaced">
8222 never_users = root
8223 </literallayout>
8224 <para>
8225 It specifies that no delivery must ever be run as the root user. The normal
8226 convention is to set up <emphasis>root</emphasis> as an alias for the system administrator. This
8227 setting is a guard against slips in the configuration.
8228 The list of users specified by <option>never_users</option> is not, however, the complete
8229 list; the build-time configuration in <filename>Local/Makefile</filename> has an option called
8230 FIXED_NEVER_USERS specifying a list that cannot be overridden. The
8231 contents of <option>never_users</option> are added to this list. By default
8232 FIXED_NEVER_USERS also specifies root.
8233 </para>
8234 <para>
8235 When a remote host connects to Exim in order to send mail, the only information
8236 Exim has about the host&#x2019;s identity is its IP address. The next configuration
8237 line,
8238 </para>
8239 <literallayout class="monospaced">
8240 host_lookup = *
8241 </literallayout>
8242 <para>
8243 specifies that Exim should do a reverse DNS lookup on all incoming connections,
8244 in order to get a host name. This improves the quality of the logging
8245 information, but if you feel it is too expensive, you can remove it entirely,
8246 or restrict the lookup to hosts on <quote>nearby</quote> networks.
8247 Note that it is not always possible to find a host name from an IP address,
8248 because not all DNS reverse zones are maintained, and sometimes DNS servers are
8249 unreachable.
8250 </para>
8251 <para>
8252 The next two lines are concerned with <emphasis>ident</emphasis> callbacks, as defined by RFC
8253 1413 (hence their names):
8254 </para>
8255 <literallayout class="monospaced">
8256 rfc1413_hosts = *
8257 rfc1413_query_timeout = 5s
8258 </literallayout>
8259 <para>
8260 These settings cause Exim to make ident callbacks for all incoming SMTP calls.
8261 You can limit the hosts to which these calls are made, or change the timeout
8262 that is used. If you set the timeout to zero, all ident calls are disabled.
8263 Although they are cheap and can provide useful information for tracing problem
8264 messages, some hosts and firewalls have problems with ident calls. This can
8265 result in a timeout instead of an immediate refused connection, leading to
8266 delays on starting up an incoming SMTP session.
8267 </para>
8268 <para>
8269 When Exim receives messages over SMTP connections, it expects all addresses to
8270 be fully qualified with a domain, as required by the SMTP definition. However,
8271 if you are running a server to which simple clients submit messages, you may
8272 find that they send unqualified addresses. The two commented-out options:
8273 </para>
8274 <literallayout class="monospaced">
8275 # sender_unqualified_hosts =
8276 # recipient_unqualified_hosts =
8277 </literallayout>
8278 <para>
8279 show how you can specify hosts that are permitted to send unqualified sender
8280 and recipient addresses, respectively.
8281 </para>
8282 <para>
8283 The <option>percent_hack_domains</option> option is also commented out:
8284 </para>
8285 <literallayout class="monospaced">
8286 # percent_hack_domains =
8287 </literallayout>
8288 <para>
8289 It provides a list of domains for which the <quote>percent hack</quote> is to operate.
8290 This is an almost obsolete form of explicit email routing. If you do not know
8291 anything about it, you can safely ignore this topic.
8292 </para>
8293 <para>
8294 The last two settings in the main part of the default configuration are
8295 concerned with messages that have been <quote>frozen</quote> on Exim&#x2019;s queue. When a
8296 message is frozen, Exim no longer continues to try to deliver it. Freezing
8297 occurs when a bounce message encounters a permanent failure because the sender
8298 address of the original message that caused the bounce is invalid, so the
8299 bounce cannot be delivered. This is probably the most common case, but there
8300 are also other conditions that cause freezing, and frozen messages are not
8301 always bounce messages.
8302 </para>
8303 <literallayout class="monospaced">
8304 ignore_bounce_errors_after = 2d
8305 timeout_frozen_after = 7d
8306 </literallayout>
8307 <para>
8308 The first of these options specifies that failing bounce messages are to be
8309 discarded after 2 days on the queue. The second specifies that any frozen
8310 message (whether a bounce message or not) is to be timed out (and discarded)
8311 after a week. In this configuration, the first setting ensures that no failing
8312 bounce message ever lasts a week.
8313 </para>
8314 </section>
8315 <section id="SECID54">
8316 <title>ACL configuration</title>
8317 <para>
8318 <indexterm role="concept">
8319 <primary>default</primary>
8320 <secondary>ACLs</secondary>
8321 </indexterm>
8322 <indexterm role="concept">
8323 <primary>access control lists (ACLs)</primary>
8324 <secondary>default configuration</secondary>
8325 </indexterm>
8326 In the default configuration, the ACL section follows the main configuration.
8327 It starts with the line
8328 </para>
8329 <literallayout class="monospaced">
8330 begin acl
8331 </literallayout>
8332 <para>
8333 and it contains the definitions of two ACLs, called <emphasis>acl_check_rcpt</emphasis> and
8334 <emphasis>acl_check_data</emphasis>, that were referenced in the settings of <option>acl_smtp_rcpt</option>
8335 and <option>acl_smtp_data</option> above.
8336 </para>
8337 <para>
8338 <indexterm role="concept">
8339 <primary>RCPT</primary>
8340 <secondary>ACL for</secondary>
8341 </indexterm>
8342 The first ACL is used for every RCPT command in an incoming SMTP message. Each
8343 RCPT command specifies one of the message&#x2019;s recipients. The ACL statements
8344 are considered in order, until the recipient address is either accepted or
8345 rejected. The RCPT command is then accepted or rejected, according to the
8346 result of the ACL processing.
8347 </para>
8348 <literallayout class="monospaced">
8349 acl_check_rcpt:
8350 </literallayout>
8351 <para>
8352 This line, consisting of a name terminated by a colon, marks the start of the
8353 ACL, and names it.
8354 </para>
8355 <literallayout class="monospaced">
8356 accept  hosts = :
8357 </literallayout>
8358 <para>
8359 This ACL statement accepts the recipient if the sending host matches the list.
8360 But what does that strange list mean? It doesn&#x2019;t actually contain any host
8361 names or IP addresses. The presence of the colon puts an empty item in the
8362 list; Exim matches this only if the incoming message did not come from a remote
8363 host, because in that case, the remote hostname is empty. The colon is
8364 important. Without it, the list itself is empty, and can never match anything.
8365 </para>
8366 <para>
8367 What this statement is doing is to accept unconditionally all recipients in
8368 messages that are submitted by SMTP from local processes using the standard
8369 input and output (that is, not using TCP/IP). A number of MUAs operate in this
8370 manner.
8371 </para>
8372 <literallayout class="monospaced">
8373 deny    message       = Restricted characters in address
8374         domains       = +local_domains
8375         local_parts   = ^[.] : ^.*[@%!/|]
8376
8377 deny    message       = Restricted characters in address
8378         domains       = !+local_domains
8379         local_parts   = ^[./|] : ^.*[@%!] : ^.*/\\.\\./
8380 </literallayout>
8381 <para>
8382 These statements are concerned with local parts that contain any of the
8383 characters <quote>@</quote>, <quote>%</quote>, <quote>!</quote>, <quote>/</quote>, <quote>|</quote>, or dots in unusual places.
8384 Although these characters are entirely legal in local parts (in the case of
8385 <quote>@</quote> and leading dots, only if correctly quoted), they do not commonly occur
8386 in Internet mail addresses.
8387 </para>
8388 <para>
8389 The first three have in the past been associated with explicitly routed
8390 addresses (percent is still sometimes used &ndash; see the <option>percent_hack_domains</option>
8391 option). Addresses containing these characters are regularly tried by spammers
8392 in an attempt to bypass relaying restrictions, and also by open relay testing
8393 programs. Unless you really need them it is safest to reject these characters
8394 at this early stage. This configuration is heavy-handed in rejecting these
8395 characters for all messages it accepts from remote hosts. This is a deliberate
8396 policy of being as safe as possible.
8397 </para>
8398 <para>
8399 The first rule above is stricter, and is applied to messages that are addressed
8400 to one of the local domains handled by this host. This is implemented by the
8401 first condition, which restricts it to domains that are listed in the
8402 <emphasis>local_domains</emphasis> domain list. The <quote>+</quote> character is used to indicate a
8403 reference to a named list. In this configuration, there is just one domain in
8404 <emphasis>local_domains</emphasis>, but in general there may be many.
8405 </para>
8406 <para>
8407 The second condition on the first statement uses two regular expressions to
8408 block local parts that begin with a dot or contain <quote>@</quote>, <quote>%</quote>, <quote>!</quote>, <quote>/</quote>,
8409 or <quote>|</quote>. If you have local accounts that include these characters, you will
8410 have to modify this rule.
8411 </para>
8412 <para>
8413 Empty components (two dots in a row) are not valid in RFC 2822, but Exim
8414 allows them because they have been encountered in practice. (Consider the
8415 common convention of local parts constructed as
8416 <quote><emphasis>first-initial.second-initial.family-name</emphasis></quote> when applied to someone like
8417 the author of Exim, who has no second initial.) However, a local part starting
8418 with a dot or containing <quote>/../</quote> can cause trouble if it is used as part of a
8419 file name (for example, for a mailing list). This is also true for local parts
8420 that contain slashes. A pipe symbol can also be troublesome if the local part
8421 is incorporated unthinkingly into a shell command line.
8422 </para>
8423 <para>
8424 The second rule above applies to all other domains, and is less strict. This
8425 allows your own users to send outgoing messages to sites that use slashes
8426 and vertical bars in their local parts. It blocks local parts that begin
8427 with a dot, slash, or vertical bar, but allows these characters within the
8428 local part. However, the sequence <quote>/../</quote> is barred. The use of <quote>@</quote>, <quote>%</quote>,
8429 and <quote>!</quote> is blocked, as before. The motivation here is to prevent your users
8430 (or your users&#x2019; viruses) from mounting certain kinds of attack on remote sites.
8431 </para>
8432 <literallayout class="monospaced">
8433 accept  local_parts   = postmaster
8434         domains       = +local_domains
8435 </literallayout>
8436 <para>
8437 This statement, which has two conditions, accepts an incoming address if the
8438 local part is <emphasis>postmaster</emphasis> and the domain is one of those listed in the
8439 <emphasis>local_domains</emphasis> domain list. The <quote>+</quote> character is used to indicate a
8440 reference to a named list. In this configuration, there is just one domain in
8441 <emphasis>local_domains</emphasis>, but in general there may be many.
8442 </para>
8443 <para>
8444 The presence of this statement means that mail to postmaster is never blocked
8445 by any of the subsequent tests. This can be helpful while sorting out problems
8446 in cases where the subsequent tests are incorrectly denying access.
8447 </para>
8448 <literallayout class="monospaced">
8449 require verify        = sender
8450 </literallayout>
8451 <para>
8452 This statement requires the sender address to be verified before any subsequent
8453 ACL statement can be used. If verification fails, the incoming recipient
8454 address is refused. Verification consists of trying to route the address, to
8455 see if a bounce message could be delivered to it. In the case of remote
8456 addresses, basic verification checks only the domain, but <emphasis>callouts</emphasis> can be
8457 used for more verification if required. Section <xref linkend="SECTaddressverification"/>
8458 discusses the details of address verification.
8459 </para>
8460 <literallayout class="monospaced">
8461 accept  hosts         = +relay_from_hosts
8462         control       = submission
8463 </literallayout>
8464 <para>
8465 This statement accepts the address if the message is coming from one of the
8466 hosts that are defined as being allowed to relay through this host. Recipient
8467 verification is omitted here, because in many cases the clients are dumb MUAs
8468 that do not cope well with SMTP error responses. For the same reason, the
8469 second line specifies <quote>submission mode</quote> for messages that are accepted. This
8470 is described in detail in section <xref linkend="SECTsubmodnon"/>; it causes Exim to fix
8471 messages that are deficient in some way, for example, because they lack a
8472 <emphasis>Date:</emphasis> header line. If you are actually relaying out from MTAs, you should
8473 probably add recipient verification here, and disable submission mode.
8474 </para>
8475 <literallayout class="monospaced">
8476 accept  authenticated = *
8477         control       = submission
8478 </literallayout>
8479 <para>
8480 This statement accepts the address if the client host has authenticated itself.
8481 Submission mode is again specified, on the grounds that such messages are most
8482 likely to come from MUAs. The default configuration does not define any
8483 authenticators, though it does include some nearly complete commented-out
8484 examples described in <xref linkend="SECTdefconfauth"/>. This means that no client can in
8485 fact authenticate until you complete the authenticator definitions.
8486 </para>
8487 <literallayout class="monospaced">
8488 require message = relay not permitted
8489         domains = +local_domains : +relay_domains
8490 </literallayout>
8491 <para>
8492 This statement rejects the address if its domain is neither a local domain nor
8493 one of the domains for which this host is a relay.
8494 </para>
8495 <literallayout class="monospaced">
8496 require verify = recipient
8497 </literallayout>
8498 <para>
8499 This statement requires the recipient address to be verified; if verification
8500 fails, the address is rejected.
8501 </para>
8502 <literallayout class="monospaced">
8503 # deny    message     = rejected because $sender_host_address \
8504 #                       is in a black list at $dnslist_domain\n\
8505 #                       $dnslist_text
8506 #         dnslists    = black.list.example
8507 #
8508 # warn    dnslists    = black.list.example
8509 #         add_header  = X-Warning: $sender_host_address is in \
8510 #                       a black list at $dnslist_domain
8511 #         log_message = found in $dnslist_domain
8512 </literallayout>
8513 <para>
8514 These commented-out lines are examples of how you could configure Exim to check
8515 sending hosts against a DNS black list. The first statement rejects messages
8516 from blacklisted hosts, whereas the second just inserts a warning header
8517 line.
8518 </para>
8519 <literallayout class="monospaced">
8520 # require verify = csa
8521 </literallayout>
8522 <para>
8523 This commented-out line is an example of how you could turn on client SMTP
8524 authorization (CSA) checking. Such checks do DNS lookups for special SRV
8525 records.
8526 </para>
8527 <literallayout class="monospaced">
8528 accept
8529 </literallayout>
8530 <para>
8531 The final statement in the first ACL unconditionally accepts any recipient
8532 address that has successfully passed all the previous tests.
8533 </para>
8534 <literallayout class="monospaced">
8535 acl_check_data:
8536 </literallayout>
8537 <para>
8538 This line marks the start of the second ACL, and names it. Most of the contents
8539 of this ACL are commented out:
8540 </para>
8541 <literallayout class="monospaced">
8542 # deny    malware   = *
8543 #         message   = This message contains a virus \
8544 #                     ($malware_name).
8545 </literallayout>
8546 <para>
8547 These lines are examples of how to arrange for messages to be scanned for
8548 viruses when Exim has been compiled with the content-scanning extension, and a
8549 suitable virus scanner is installed. If the message is found to contain a
8550 virus, it is rejected with the given custom error message.
8551 </para>
8552 <literallayout class="monospaced">
8553 # warn    spam      = nobody
8554 #         message   = X-Spam_score: $spam_score\n\
8555 #                     X-Spam_score_int: $spam_score_int\n\
8556 #                     X-Spam_bar: $spam_bar\n\
8557 #                     X-Spam_report: $spam_report
8558 </literallayout>
8559 <para>
8560 These lines are an example of how to arrange for messages to be scanned by
8561 SpamAssassin when Exim has been compiled with the content-scanning extension,
8562 and SpamAssassin has been installed. The SpamAssassin check is run with
8563 <literal>nobody</literal> as its user parameter, and the results are added to the message as a
8564 series of extra header line. In this case, the message is not rejected,
8565 whatever the spam score.
8566 </para>
8567 <literallayout class="monospaced">
8568 accept
8569 </literallayout>
8570 <para>
8571 This final line in the DATA ACL accepts the message unconditionally.
8572 </para>
8573 </section>
8574 <section id="SECID55">
8575 <title>Router configuration</title>
8576 <para>
8577 <indexterm role="concept">
8578 <primary>default</primary>
8579 <secondary>routers</secondary>
8580 </indexterm>
8581 <indexterm role="concept">
8582 <primary>routers</primary>
8583 <secondary>default</secondary>
8584 </indexterm>
8585 The router configuration comes next in the default configuration, introduced
8586 by the line
8587 </para>
8588 <literallayout class="monospaced">
8589 begin routers
8590 </literallayout>
8591 <para>
8592 Routers are the modules in Exim that make decisions about where to send
8593 messages. An address is passed to each router in turn, until it is either
8594 accepted, or failed. This means that the order in which you define the routers
8595 matters. Each router is fully described in its own chapter later in this
8596 manual. Here we give only brief overviews.
8597 </para>
8598 <literallayout class="monospaced">
8599 # domain_literal:
8600 #   driver = ipliteral
8601 #   domains = !+local_domains
8602 #   transport = remote_smtp
8603 </literallayout>
8604 <para>
8605 <indexterm role="concept">
8606 <primary>domain literal</primary>
8607 <secondary>default router</secondary>
8608 </indexterm>
8609 This router is commented out because the majority of sites do not want to
8610 support domain literal addresses (those of the form <emphasis>user@[10.9.8.7]</emphasis>). If
8611 you uncomment this router, you also need to uncomment the setting of
8612 <option>allow_domain_literals</option> in the main part of the configuration.
8613 </para>
8614 <literallayout class="monospaced">
8615 dnslookup:
8616   driver = dnslookup
8617   domains = ! +local_domains
8618   transport = remote_smtp
8619   ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8
8620   no_more
8621 </literallayout>
8622 <para>
8623 The first uncommented router handles addresses that do not involve any local
8624 domains. This is specified by the line
8625 </para>
8626 <literallayout class="monospaced">
8627 domains = ! +local_domains
8628 </literallayout>
8629 <para>
8630 The <option>domains</option> option lists the domains to which this router applies, but the
8631 exclamation mark is a negation sign, so the router is used only for domains
8632 that are not in the domain list called <emphasis>local_domains</emphasis> (which was defined at
8633 the start of the configuration). The plus sign before <emphasis>local_domains</emphasis>
8634 indicates that it is referring to a named list. Addresses in other domains are
8635 passed on to the following routers.
8636 </para>
8637 <para>
8638 The name of the router driver is <command>dnslookup</command>,
8639 and is specified by the <option>driver</option> option. Do not be confused by the fact that
8640 the name of this router instance is the same as the name of the driver. The
8641 instance name is arbitrary, but the name set in the <option>driver</option> option must be
8642 one of the driver modules that is in the Exim binary.
8643 </para>
8644 <para>
8645 The <command>dnslookup</command> router routes addresses by looking up their domains in the
8646 DNS in order to obtain a list of hosts to which the address is routed. If the
8647 router succeeds, the address is queued for the <command>remote_smtp</command> transport, as
8648 specified by the <option>transport</option> option. If the router does not find the domain
8649 in the DNS, no further routers are tried because of the <option>no_more</option> setting, so
8650 the address fails and is bounced.
8651 </para>
8652 <para>
8653 The <option>ignore_target_hosts</option> option specifies a list of IP addresses that are to
8654 be entirely ignored. This option is present because a number of cases have been
8655 encountered where MX records in the DNS point to host names
8656 whose IP addresses are 0.0.0.0 or are in the 127 subnet (typically 127.0.0.1).
8657 Completely ignoring these IP addresses causes Exim to fail to route the
8658 email address, so it bounces. Otherwise, Exim would log a routing problem, and
8659 continue to try to deliver the message periodically until the address timed
8660 out.
8661 </para>
8662 <literallayout class="monospaced">
8663 system_aliases:
8664   driver = redirect
8665   allow_fail
8666   allow_defer
8667   data = ${lookup{$local_part}lsearch{/etc/aliases}}
8668 # user = exim
8669   file_transport = address_file
8670   pipe_transport = address_pipe
8671 </literallayout>
8672 <para>
8673 Control reaches this and subsequent routers only for addresses in the local
8674 domains. This router checks to see whether the local part is defined as an
8675 alias in the <filename>/etc/aliases</filename> file, and if so, redirects it according to the
8676 data that it looks up from that file. If no data is found for the local part,
8677 the value of the <option>data</option> option is empty, causing the address to be passed to
8678 the next router.
8679 </para>
8680 <para>
8681 <filename>/etc/aliases</filename> is a conventional name for the system aliases file that is
8682 often used. That is why it is referenced by from the default configuration
8683 file. However, you can change this by setting SYSTEM_ALIASES_FILE in
8684 <filename>Local/Makefile</filename> before building Exim.
8685 </para>
8686 <literallayout class="monospaced">
8687 userforward:
8688   driver = redirect
8689   check_local_user
8690 # local_part_suffix = +* : -*
8691 # local_part_suffix_optional
8692   file = $home/.forward
8693 # allow_filter
8694   no_verify
8695   no_expn
8696   check_ancestor
8697   file_transport = address_file
8698   pipe_transport = address_pipe
8699   reply_transport = address_reply
8700 </literallayout>
8701 <para>
8702 This is the most complicated router in the default configuration. It is another
8703 redirection router, but this time it is looking for forwarding data set up by
8704 individual users. The <option>check_local_user</option> setting specifies a check that the
8705 local part of the address is the login name of a local user. If it is not, the
8706 router is skipped. The two commented options that follow <option>check_local_user</option>,
8707 namely:
8708 </para>
8709 <literallayout class="monospaced">
8710 # local_part_suffix = +* : -*
8711 # local_part_suffix_optional
8712 </literallayout>
8713 <para>
8714 <indexterm role="variable">
8715 <primary><varname>$local_part_suffix</varname></primary>
8716 </indexterm>
8717 show how you can specify the recognition of local part suffixes. If the first
8718 is uncommented, a suffix beginning with either a plus or a minus sign, followed
8719 by any sequence of characters, is removed from the local part and placed in the
8720 variable <varname>$local_part_suffix</varname>. The second suffix option specifies that the
8721 presence of a suffix in the local part is optional. When a suffix is present,
8722 the check for a local login uses the local part with the suffix removed.
8723 </para>
8724 <para>
8725 When a local user account is found, the file called <filename>.forward</filename> in the user&#x2019;s
8726 home directory is consulted. If it does not exist, or is empty, the router
8727 declines. Otherwise, the contents of <filename>.forward</filename> are interpreted as
8728 redirection data (see chapter <xref linkend="CHAPredirect"/> for more details).
8729 </para>
8730 <para>
8731 <indexterm role="concept">
8732 <primary>Sieve filter</primary>
8733 <secondary>enabling in default router</secondary>
8734 </indexterm>
8735 Traditional <filename>.forward</filename> files contain just a list of addresses, pipes, or
8736 files. Exim supports this by default. However, if <option>allow_filter</option> is set (it
8737 is commented out by default), the contents of the file are interpreted as a set
8738 of Exim or Sieve filtering instructions, provided the file begins with <quote>#Exim
8739 filter</quote> or <quote>#Sieve filter</quote>, respectively. User filtering is discussed in the
8740 separate document entitled <emphasis>Exim&#x2019;s interfaces to mail filtering</emphasis>.
8741 </para>
8742 <para>
8743 The <option>no_verify</option> and <option>no_expn</option> options mean that this router is skipped when
8744 verifying addresses, or when running as a consequence of an SMTP EXPN command.
8745 There are two reasons for doing this:
8746 </para>
8747 <orderedlist numeration="arabic">
8748 <listitem>
8749 <para>
8750 Whether or not a local user has a <filename>.forward</filename> file is not really relevant when
8751 checking an address for validity; it makes sense not to waste resources doing
8752 unnecessary work.
8753 </para>
8754 </listitem>
8755 <listitem>
8756 <para>
8757 More importantly, when Exim is verifying addresses or handling an EXPN
8758 command during an SMTP session, it is running as the Exim user, not as root.
8759 The group is the Exim group, and no additional groups are set up.
8760 It may therefore not be possible for Exim to read users&#x2019; <filename>.forward</filename> files at
8761 this time.
8762 </para>
8763 </listitem>
8764 </orderedlist>
8765 <para>
8766 The setting of <option>check_ancestor</option> prevents the router from generating a new
8767 address that is the same as any previous address that was redirected. (This
8768 works round a problem concerning a bad interaction between aliasing and
8769 forwarding &ndash; see section <xref linkend="SECTredlocmai"/>).
8770 </para>
8771 <para>
8772 The final three option settings specify the transports that are to be used when
8773 forwarding generates a direct delivery to a file, or to a pipe, or sets up an
8774 auto-reply, respectively. For example, if a <filename>.forward</filename> file contains
8775 </para>
8776 <literallayout class="monospaced">
8777 a.nother@elsewhere.example, /home/spqr/archive
8778 </literallayout>
8779 <para>
8780 the delivery to <filename>/home/spqr/archive</filename> is done by running the <option>address_file</option>
8781 transport.
8782 </para>
8783 <literallayout class="monospaced">
8784 localuser:
8785   driver = accept
8786   check_local_user
8787 # local_part_suffix = +* : -*
8788 # local_part_suffix_optional
8789   transport = local_delivery
8790 </literallayout>
8791 <para>
8792 The final router sets up delivery into local mailboxes, provided that the local
8793 part is the name of a local login, by accepting the address and assigning it to
8794 the <command>local_delivery</command> transport. Otherwise, we have reached the end of the
8795 routers, so the address is bounced. The commented suffix settings fulfil the
8796 same purpose as they do for the <command>userforward</command> router.
8797 </para>
8798 </section>
8799 <section id="SECID56">
8800 <title>Transport configuration</title>
8801 <para>
8802 <indexterm role="concept">
8803 <primary>default</primary>
8804 <secondary>transports</secondary>
8805 </indexterm>
8806 <indexterm role="concept">
8807 <primary>transports</primary>
8808 <secondary>default</secondary>
8809 </indexterm>
8810 Transports define mechanisms for actually delivering messages. They operate
8811 only when referenced from routers, so the order in which they are defined does
8812 not matter. The transports section of the configuration starts with
8813 </para>
8814 <literallayout class="monospaced">
8815 begin transports
8816 </literallayout>
8817 <para>
8818 One remote transport and four local transports are defined.
8819 </para>
8820 <literallayout class="monospaced">
8821 remote_smtp:
8822   driver = smtp
8823 </literallayout>
8824 <para>
8825 This transport is used for delivering messages over SMTP connections. All its
8826 options are defaulted. The list of remote hosts comes from the router.
8827 </para>
8828 <literallayout class="monospaced">
8829 local_delivery:
8830   driver = appendfile
8831   file = /var/mail/$local_part
8832   delivery_date_add
8833   envelope_to_add
8834   return_path_add
8835 # group = mail
8836 # mode = 0660
8837 </literallayout>
8838 <para>
8839 This <command>appendfile</command> transport is used for local delivery to user mailboxes in
8840 traditional BSD mailbox format. By default it runs under the uid and gid of the
8841 local user, which requires the sticky bit to be set on the <filename>/var/mail</filename>
8842 directory. Some systems use the alternative approach of running mail deliveries
8843 under a particular group instead of using the sticky bit. The commented options
8844 show how this can be done.
8845 </para>
8846 <para>
8847 Exim adds three headers to the message as it delivers it: <emphasis>Delivery-date:</emphasis>,
8848 <emphasis>Envelope-to:</emphasis> and <emphasis>Return-path:</emphasis>. This action is requested by the three
8849 similarly-named options above.
8850 </para>
8851 <literallayout class="monospaced">
8852 address_pipe:
8853   driver = pipe
8854   return_output
8855 </literallayout>
8856 <para>
8857 This transport is used for handling deliveries to pipes that are generated by
8858 redirection (aliasing or users&#x2019; <filename>.forward</filename> files). The <option>return_output</option>
8859 option specifies that any output generated by the pipe is to be returned to the
8860 sender.
8861 </para>
8862 <literallayout class="monospaced">
8863 address_file:
8864   driver = appendfile
8865   delivery_date_add
8866   envelope_to_add
8867   return_path_add
8868 </literallayout>
8869 <para>
8870 This transport is used for handling deliveries to files that are generated by
8871 redirection. The name of the file is not specified in this instance of
8872 <command>appendfile</command>, because it comes from the <command>redirect</command> router.
8873 </para>
8874 <literallayout class="monospaced">
8875 address_reply:
8876   driver = autoreply
8877 </literallayout>
8878 <para>
8879 This transport is used for handling automatic replies generated by users&#x2019;
8880 filter files.
8881 </para>
8882 </section>
8883 <section id="SECID57">
8884 <title>Default retry rule</title>
8885 <para>
8886 <indexterm role="concept">
8887 <primary>retry</primary>
8888 <secondary>default rule</secondary>
8889 </indexterm>
8890 <indexterm role="concept">
8891 <primary>default</primary>
8892 <secondary>retry rule</secondary>
8893 </indexterm>
8894 The retry section of the configuration file contains rules which affect the way
8895 Exim retries deliveries that cannot be completed at the first attempt. It is
8896 introduced by the line
8897 </para>
8898 <literallayout class="monospaced">
8899 begin retry
8900 </literallayout>
8901 <para>
8902 In the default configuration, there is just one rule, which applies to all
8903 errors:
8904 </para>
8905 <literallayout class="monospaced">
8906 *   *   F,2h,15m; G,16h,1h,1.5; F,4d,6h
8907 </literallayout>
8908 <para>
8909 This causes any temporarily failing address to be retried every 15 minutes for
8910 2 hours, then at intervals starting at one hour and increasing by a factor of
8911 1.5 until 16 hours have passed, then every 6 hours up to 4 days. If an address
8912 is not delivered after 4 days of temporary failure, it is bounced.
8913 </para>
8914 <para>
8915 If the retry section is removed from the configuration, or is empty (that is,
8916 if no retry rules are defined), Exim will not retry deliveries. This turns
8917 temporary errors into permanent errors.
8918 </para>
8919 </section>
8920 <section id="SECID58">
8921 <title>Rewriting configuration</title>
8922 <para>
8923 The rewriting section of the configuration, introduced by
8924 </para>
8925 <literallayout class="monospaced">
8926 begin rewrite
8927 </literallayout>
8928 <para>
8929 contains rules for rewriting addresses in messages as they arrive. There are no
8930 rewriting rules in the default configuration file.
8931 </para>
8932 </section>
8933 <section id="SECTdefconfauth">
8934 <title>Authenticators configuration</title>
8935 <para>
8936 <indexterm role="concept">
8937 <primary>AUTH</primary>
8938 <secondary>configuration</secondary>
8939 </indexterm>
8940 The authenticators section of the configuration, introduced by
8941 </para>
8942 <literallayout class="monospaced">
8943 begin authenticators
8944 </literallayout>
8945 <para>
8946 defines mechanisms for the use of the SMTP AUTH command. The default
8947 configuration file contains two commented-out example authenticators
8948 which support plaintext username/password authentication using the
8949 standard PLAIN mechanism and the traditional but non-standard LOGIN
8950 mechanism, with Exim acting as the server. PLAIN and LOGIN are enough
8951 to support most MUA software.
8952 </para>
8953 <para>
8954 The example PLAIN authenticator looks like this:
8955 </para>
8956 <literallayout class="monospaced">
8957 #PLAIN:
8958 #  driver                  = plaintext
8959 #  server_set_id           = $auth2
8960 #  server_prompts          = :
8961 #  server_condition        = Authentication is not yet configured
8962 #  server_advertise_condition = ${if def:tls_cipher }
8963 </literallayout>
8964 <para>
8965 And the example LOGIN authenticator looks like this:
8966 </para>
8967 <literallayout class="monospaced">
8968 #LOGIN:
8969 #  driver                  = plaintext
8970 #  server_set_id           = $auth1
8971 #  server_prompts          = &lt;| Username: | Password:
8972 #  server_condition        = Authentication is not yet configured
8973 #  server_advertise_condition = ${if def:tls_cipher }
8974 </literallayout>
8975 <para>
8976 The <option>server_set_id</option> option makes Exim remember the authenticated username
8977 in <varname>$authenticated_id</varname>, which can be used later in ACLs or routers. The
8978 <option>server_prompts</option> option configures the <command>plaintext</command> authenticator so
8979 that it implements the details of the specific authentication mechanism,
8980 i.e. PLAIN or LOGIN. The <option>server_advertise_condition</option> setting controls
8981 when Exim offers authentication to clients; in the examples, this is only
8982 when TLS or SSL has been started, so to enable the authenticators you also
8983 need to add support for TLS as described in <xref linkend="SECTdefconfmain"/>.
8984 </para>
8985 <para>
8986 The <option>server_condition</option> setting defines how to verify that the username and
8987 password are correct. In the examples it just produces an error message.
8988 To make the authenticators work, you can use a string expansion
8989 expression like one of the examples in <xref linkend="CHAPplaintext"/>.
8990 </para>
8991 <para>
8992 Beware that the sequence of the parameters to PLAIN and LOGIN differ; the
8993 usercode and password are in different positions.  <xref linkend="CHAPplaintext"/>
8994 covers both.
8995 </para>
8996 <para>
8997 <indexterm role="concept" startref="IIDconfiwal" class="endofrange"/>
8998 </para>
8999 </section>
9000 </chapter>
9001
9002 <chapter id="CHAPregexp">
9003 <title>Regular expressions</title>
9004 <para>
9005 <indexterm role="concept">
9006 <primary>regular expressions</primary>
9007 <secondary>library</secondary>
9008 </indexterm>
9009 <indexterm role="concept">
9010 <primary>PCRE</primary>
9011 </indexterm>
9012 Exim supports the use of regular expressions in many of its options. It
9013 uses the PCRE regular expression library; this provides regular expression
9014 matching that is compatible with Perl 5. The syntax and semantics of
9015 regular expressions is discussed in many Perl reference books, and also in
9016 Jeffrey Friedl&#x2019;s <emphasis>Mastering Regular Expressions</emphasis>, which is published by
9017 O&#x2019;Reilly (see <emphasis role="bold"><ulink url="http://www.oreilly.com/catalog/regex2/">http://www.oreilly.com/catalog/regex2/</ulink></emphasis>).
9018 </para>
9019 <para>
9020 The documentation for the syntax and semantics of the regular expressions that
9021 are supported by PCRE is included in the PCRE distribution, and no further
9022 description is included here. The PCRE functions are called from Exim using
9023 the default option settings (that is, with no PCRE options set), except that
9024 the PCRE_CASELESS option is set when the matching is required to be
9025 case-insensitive.
9026 </para>
9027 <para>
9028 In most cases, when a regular expression is required in an Exim configuration,
9029 it has to start with a circumflex, in order to distinguish it from plain text
9030 or an <quote>ends with</quote> wildcard. In this example of a configuration setting, the
9031 second item in the colon-separated list is a regular expression.
9032 </para>
9033 <literallayout class="monospaced">
9034 domains = a.b.c : ^\\d{3} : *.y.z : ...
9035 </literallayout>
9036 <para>
9037 The doubling of the backslash is required because of string expansion that
9038 precedes interpretation &ndash; see section <xref linkend="SECTlittext"/> for more discussion
9039 of this issue, and a way of avoiding the need for doubling backslashes. The
9040 regular expression that is eventually used in this example contains just one
9041 backslash. The circumflex is included in the regular expression, and has the
9042 normal effect of <quote>anchoring</quote> it to the start of the string that is being
9043 matched.
9044 </para>
9045 <para>
9046 There are, however, two cases where a circumflex is not required for the
9047 recognition of a regular expression: these are the <option>match</option> condition in a
9048 string expansion, and the <option>matches</option> condition in an Exim filter file. In
9049 these cases, the relevant string is always treated as a regular expression; if
9050 it does not start with a circumflex, the expression is not anchored, and can
9051 match anywhere in the subject string.
9052 </para>
9053 <para>
9054 In all cases, if you want a regular expression to match at the end of a string,
9055 you must code the $ metacharacter to indicate this. For example:
9056 </para>
9057 <literallayout class="monospaced">
9058 domains = ^\\d{3}\\.example
9059 </literallayout>
9060 <para>
9061 matches the domain <emphasis>123.example</emphasis>, but it also matches <emphasis>123.example.com</emphasis>.
9062 You need to use:
9063 </para>
9064 <literallayout class="monospaced">
9065 domains = ^\\d{3}\\.example\$
9066 </literallayout>
9067 <para>
9068 if you want <emphasis>example</emphasis> to be the top-level domain. The backslash before the
9069 $ is needed because string expansion also interprets dollar characters.
9070 </para>
9071 </chapter>
9072
9073 <chapter id="CHAPfdlookup">
9074 <title>File and database lookups</title>
9075 <para>
9076 <indexterm role="concept" id="IIDfidalo1" class="startofrange">
9077 <primary>file</primary>
9078 <secondary>lookups</secondary>
9079 </indexterm>
9080 <indexterm role="concept" id="IIDfidalo2" class="startofrange">
9081 <primary>database</primary>
9082 <secondary>lookups</secondary>
9083 </indexterm>
9084 <indexterm role="concept">
9085 <primary>lookup</primary>
9086 <secondary>description of</secondary>
9087 </indexterm>
9088 Exim can be configured to look up data in files or databases as it processes
9089 messages. Two different kinds of syntax are used:
9090 </para>
9091 <orderedlist numeration="arabic">
9092 <listitem>
9093 <para>
9094 A string that is to be expanded may contain explicit lookup requests. These
9095 cause parts of the string to be replaced by data that is obtained from the
9096 lookup. Lookups of this type are conditional expansion items. Different results
9097 can be defined for the cases of lookup success and failure. See chapter
9098 <xref linkend="CHAPexpand"/>, where string expansions are described in detail.
9099 </para>
9100 </listitem>
9101 <listitem>
9102 <para>
9103 Lists of domains, hosts, and email addresses can contain lookup requests as a
9104 way of avoiding excessively long linear lists. In this case, the data that is
9105 returned by the lookup is often (but not always) discarded; whether the lookup
9106 succeeds or fails is what really counts. These kinds of list are described in
9107 chapter <xref linkend="CHAPdomhosaddlists"/>.
9108 </para>
9109 </listitem>
9110 </orderedlist>
9111 <para>
9112 String expansions, lists, and lookups interact with each other in such a way
9113 that there is no order in which to describe any one of them that does not
9114 involve references to the others. Each of these three chapters makes more sense
9115 if you have read the other two first. If you are reading this for the first
9116 time, be aware that some of it will make a lot more sense after you have read
9117 chapters <xref linkend="CHAPdomhosaddlists"/> and <xref linkend="CHAPexpand"/>.
9118 </para>
9119 <section id="SECID60">
9120 <title>Examples of different lookup syntax</title>
9121 <para>
9122 It is easy to confuse the two different kinds of lookup, especially as the
9123 lists that may contain the second kind are always expanded before being
9124 processed as lists. Therefore, they may also contain lookups of the first kind.
9125 Be careful to distinguish between the following two examples:
9126 </para>
9127 <literallayout class="monospaced">
9128 domains = ${lookup{$sender_host_address}lsearch{/some/file}}
9129 domains = lsearch;/some/file
9130 </literallayout>
9131 <para>
9132 The first uses a string expansion, the result of which must be a domain list.
9133 No strings have been specified for a successful or a failing lookup; the
9134 defaults in this case are the looked-up data and an empty string, respectively.
9135 The expansion takes place before the string is processed as a list, and the
9136 file that is searched could contain lines like this:
9137 </para>
9138 <literallayout class="monospaced">
9139 192.168.3.4: domain1:domain2:...
9140 192.168.1.9: domain3:domain4:...
9141 </literallayout>
9142 <para>
9143 When the lookup succeeds, the result of the expansion is a list of domains (and
9144 possibly other types of item that are allowed in domain lists).
9145 </para>
9146 <para>
9147 In the second example, the lookup is a single item in a domain list. It causes
9148 Exim to use a lookup to see if the domain that is being processed can be found
9149 in the file. The file could contains lines like this:
9150 </para>
9151 <literallayout class="monospaced">
9152 domain1:
9153 domain2:
9154 </literallayout>
9155 <para>
9156 Any data that follows the keys is not relevant when checking that the domain
9157 matches the list item.
9158 </para>
9159 <para>
9160 It is possible, though no doubt confusing, to use both kinds of lookup at once.
9161 Consider a file containing lines like this:
9162 </para>
9163 <literallayout class="monospaced">
9164 192.168.5.6: lsearch;/another/file
9165 </literallayout>
9166 <para>
9167 If the value of <varname>$sender_host_address</varname> is 192.168.5.6, expansion of the
9168 first <option>domains</option> setting above generates the second setting, which therefore
9169 causes a second lookup to occur.
9170 </para>
9171 <para>
9172 The rest of this chapter describes the different lookup types that are
9173 available. Any of them can be used in any part of the configuration where a
9174 lookup is permitted.
9175 </para>
9176 </section>
9177 <section id="SECID61">
9178 <title>Lookup types</title>
9179 <para>
9180 <indexterm role="concept">
9181 <primary>lookup</primary>
9182 <secondary>types of</secondary>
9183 </indexterm>
9184 <indexterm role="concept">
9185 <primary>single-key lookup</primary>
9186 <secondary>definition of</secondary>
9187 </indexterm>
9188 Two different types of data lookup are implemented:
9189 </para>
9190 <itemizedlist>
9191 <listitem>
9192 <para>
9193 The <emphasis>single-key</emphasis> type requires the specification of a file in which to look,
9194 and a single key to search for. The key must be a non-empty string for the
9195 lookup to succeed. The lookup type determines how the file is searched.
9196 </para>
9197 </listitem>
9198 <listitem>
9199 <para>
9200 <indexterm role="concept">
9201 <primary>query-style lookup</primary>
9202 <secondary>definition of</secondary>
9203 </indexterm>
9204 The <emphasis>query-style</emphasis> type accepts a generalized database query. No particular
9205 key value is assumed by Exim for query-style lookups. You can use whichever
9206 Exim variables you need to construct the database query.
9207 </para>
9208 </listitem>
9209 </itemizedlist>
9210 <para>
9211 The code for each lookup type is in a separate source file that is included in
9212 the binary of Exim only if the corresponding compile-time option is set. The
9213 default settings in <filename>src/EDITME</filename> are:
9214 </para>
9215 <literallayout class="monospaced">
9216 LOOKUP_DBM=yes
9217 LOOKUP_LSEARCH=yes
9218 </literallayout>
9219 <para>
9220 which means that only linear searching and DBM lookups are included by default.
9221 For some types of lookup (e.g. SQL databases), you need to install appropriate
9222 libraries and header files before building Exim.
9223 </para>
9224 </section>
9225 <section id="SECTsinglekeylookups">
9226 <title>Single-key lookup types</title>
9227 <para>
9228 <indexterm role="concept">
9229 <primary>lookup</primary>
9230 <secondary>single-key types</secondary>
9231 </indexterm>
9232 <indexterm role="concept">
9233 <primary>single-key lookup</primary>
9234 <secondary>list of types</secondary>
9235 </indexterm>
9236 The following single-key lookup types are implemented:
9237 </para>
9238 <itemizedlist>
9239 <listitem>
9240 <para>
9241 <indexterm role="concept">
9242 <primary>cdb</primary>
9243 <secondary>description of</secondary>
9244 </indexterm>
9245 <indexterm role="concept">
9246 <primary>lookup</primary>
9247 <secondary>cdb</secondary>
9248 </indexterm>
9249 <indexterm role="concept">
9250 <primary>binary zero</primary>
9251 <secondary>in lookup key</secondary>
9252 </indexterm>
9253 <command>cdb</command>: The given file is searched as a Constant DataBase file, using the key
9254 string without a terminating binary zero. The cdb format is designed for
9255 indexed files that are read frequently and never updated, except by total
9256 re-creation. As such, it is particularly suitable for large files containing
9257 aliases or other indexed data referenced by an MTA. Information about cdb can
9258 be found in several places:
9259 </para>
9260 <literallayout>
9261 <emphasis role="bold"><ulink url="http://www.pobox.com/~djb/cdb.html">http://www.pobox.com/~djb/cdb.html</ulink></emphasis>
9262 <emphasis role="bold"><ulink url="ftp://ftp.corpit.ru/pub/tinycdb/">ftp://ftp.corpit.ru/pub/tinycdb/</ulink></emphasis>
9263 <emphasis role="bold"><ulink url="http://packages.debian.org/stable/utils/freecdb.html">http://packages.debian.org/stable/utils/freecdb.html</ulink></emphasis>
9264 </literallayout>
9265 <para>
9266 A cdb distribution is not needed in order to build Exim with cdb support,
9267 because the code for reading cdb files is included directly in Exim itself.
9268 However, no means of building or testing cdb files is provided with Exim, so
9269 you need to obtain a cdb distribution in order to do this.
9270 </para>
9271 </listitem>
9272 <listitem>
9273 <para>
9274 <indexterm role="concept">
9275 <primary>DBM</primary>
9276 <secondary>lookup type</secondary>
9277 </indexterm>
9278 <indexterm role="concept">
9279 <primary>lookup</primary>
9280 <secondary>dbm</secondary>
9281 </indexterm>
9282 <indexterm role="concept">
9283 <primary>binary zero</primary>
9284 <secondary>in lookup key</secondary>
9285 </indexterm>
9286 <command>dbm</command>: Calls to DBM library functions are used to extract data from the given
9287 DBM file by looking up the record with the given key. A terminating binary
9288 zero is included in the key that is passed to the DBM library. See section
9289 <xref linkend="SECTdb"/> for a discussion of DBM libraries.
9290 </para>
9291 <para>
9292 <indexterm role="concept">
9293 <primary>Berkeley DB library</primary>
9294 <secondary>file format</secondary>
9295 </indexterm>
9296 For all versions of Berkeley DB, Exim uses the DB_HASH style of database
9297 when building DBM files using the <option>exim_dbmbuild</option> utility. However, when
9298 using Berkeley DB versions 3 or 4, it opens existing databases for reading with
9299 the DB_UNKNOWN option. This enables it to handle any of the types of database
9300 that the library supports, and can be useful for accessing DBM files created by
9301 other applications. (For earlier DB versions, DB_HASH is always used.)
9302 </para>
9303 </listitem>
9304 <listitem>
9305 <para>
9306 <indexterm role="concept">
9307 <primary>lookup</primary>
9308 <secondary>dbmnz</secondary>
9309 </indexterm>
9310 <indexterm role="concept">
9311 <primary>lookup</primary>
9312 <secondary>dbm &ndash; terminating zero</secondary>
9313 </indexterm>
9314 <indexterm role="concept">
9315 <primary>binary zero</primary>
9316 <secondary>in lookup key</secondary>
9317 </indexterm>
9318 <indexterm role="concept">
9319 <primary>Courier</primary>
9320 </indexterm>
9321 <indexterm role="concept">
9322 <primary><filename>/etc/userdbshadow.dat</filename></primary>
9323 </indexterm>
9324 <indexterm role="concept">
9325 <primary>dmbnz lookup type</primary>
9326 </indexterm>
9327 <command>dbmnz</command>: This is the same as <command>dbm</command>, except that a terminating binary zero
9328 is not included in the key that is passed to the DBM library. You may need this
9329 if you want to look up data in files that are created by or shared with some
9330 other application that does not use terminating zeros. For example, you need to
9331 use <command>dbmnz</command> rather than <command>dbm</command> if you want to authenticate incoming SMTP
9332 calls using the passwords from Courier&#x2019;s <filename>/etc/userdbshadow.dat</filename> file. Exim&#x2019;s
9333 utility program for creating DBM files (<emphasis>exim_dbmbuild</emphasis>) includes the zeros
9334 by default, but has an option to omit them (see section <xref linkend="SECTdbmbuild"/>).
9335 </para>
9336 </listitem>
9337 <listitem>
9338 <para>
9339 <indexterm role="concept">
9340 <primary>lookup</primary>
9341 <secondary>dsearch</secondary>
9342 </indexterm>
9343 <indexterm role="concept">
9344 <primary>dsearch lookup type</primary>
9345 </indexterm>
9346 <command>dsearch</command>: The given file must be a directory; this is searched for an entry
9347 whose name is the key by calling the <function>lstat()</function> function. The key may not
9348 contain any forward slash characters. If <function>lstat()</function> succeeds, the result of
9349 the lookup is the name of the entry, which may be a file, directory,
9350 symbolic link, or any other kind of directory entry. An example of how this
9351 lookup can be used to support virtual domains is given in section
9352 <xref linkend="SECTvirtualdomains"/>.
9353 </para>
9354 </listitem>
9355 <listitem>
9356 <para>
9357 <indexterm role="concept">
9358 <primary>lookup</primary>
9359 <secondary>iplsearch</secondary>
9360 </indexterm>
9361 <indexterm role="concept">
9362 <primary>iplsearch lookup type</primary>
9363 </indexterm>
9364 <command>iplsearch</command>: The given file is a text file containing keys and data. A key is
9365 terminated by a colon or white space or the end of the line. The keys in the
9366 file must be IP addresses, or IP addresses with CIDR masks. Keys that involve
9367 IPv6 addresses must be enclosed in quotes to prevent the first internal colon
9368 being interpreted as a key terminator. For example:
9369 </para>
9370 <literallayout class="monospaced">
9371 1.2.3.4:           data for 1.2.3.4
9372 192.168.0.0/16:    data for 192.168.0.0/16
9373 "abcd::cdab":      data for abcd::cdab
9374 "abcd:abcd::/32"   data for abcd:abcd::/32
9375 </literallayout>
9376 <para>
9377 The key for an <command>iplsearch</command> lookup must be an IP address (without a mask). The
9378 file is searched linearly, using the CIDR masks where present, until a matching
9379 key is found. The first key that matches is used; there is no attempt to find a
9380 <quote>best</quote> match. Apart from the way the keys are matched, the processing for
9381 <command>iplsearch</command> is the same as for <command>lsearch</command>.
9382 </para>
9383 <para>
9384 <emphasis role="bold">Warning 1</emphasis>: Unlike most other single-key lookup types, a file of data for
9385 <command>iplsearch</command> can <emphasis>not</emphasis> be turned into a DBM or cdb file, because those
9386 lookup types support only literal keys.
9387 </para>
9388 <para>
9389 <emphasis role="bold">Warning 2</emphasis>: In a host list, you must always use <command>net-iplsearch</command> so that
9390 the implicit key is the host&#x2019;s IP address rather than its name (see section
9391 <xref linkend="SECThoslispatsikey"/>).
9392 </para>
9393 </listitem>
9394 <listitem>
9395 <para>
9396 <indexterm role="concept">
9397 <primary>linear search</primary>
9398 </indexterm>
9399 <indexterm role="concept">
9400 <primary>lookup</primary>
9401 <secondary>lsearch</secondary>
9402 </indexterm>
9403 <indexterm role="concept">
9404 <primary>lsearch lookup type</primary>
9405 </indexterm>
9406 <indexterm role="concept">
9407 <primary>case sensitivity</primary>
9408 <secondary>in lsearch lookup</secondary>
9409 </indexterm>
9410 <command>lsearch</command>: The given file is a text file that is searched linearly for a
9411 line beginning with the search key, terminated by a colon or white space or the
9412 end of the line. The search is case-insensitive; that is, upper and lower case
9413 letters are treated as the same. The first occurrence of the key that is found
9414 in the file is used.
9415 </para>
9416 <para>
9417 White space between the key and the colon is permitted. The remainder of the
9418 line, with leading and trailing white space removed, is the data. This can be
9419 continued onto subsequent lines by starting them with any amount of white
9420 space, but only a single space character is included in the data at such a
9421 junction. If the data begins with a colon, the key must be terminated by a
9422 colon, for example:
9423 </para>
9424 <literallayout class="monospaced">
9425 baduser:  :fail:
9426 </literallayout>
9427 <para>
9428 Empty lines and lines beginning with # are ignored, even if they occur in the
9429 middle of an item. This is the traditional textual format of alias files. Note
9430 that the keys in an <command>lsearch</command> file are literal strings. There is no
9431 wildcarding of any kind.
9432 </para>
9433 <para>
9434 <indexterm role="concept">
9435 <primary>lookup</primary>
9436 <secondary>lsearch &ndash; colons in keys</secondary>
9437 </indexterm>
9438 <indexterm role="concept">
9439 <primary>white space</primary>
9440 <secondary>in lsearch key</secondary>
9441 </indexterm>
9442 In most <command>lsearch</command> files, keys are not required to contain colons or #
9443 characters, or white space. However, if you need this feature, it is available.
9444 If a key begins with a doublequote character, it is terminated only by a
9445 matching quote (or end of line), and the normal escaping rules apply to its
9446 contents (see section <xref linkend="SECTstrings"/>). An optional colon is permitted after
9447 quoted keys (exactly as for unquoted keys). There is no special handling of
9448 quotes for the data part of an <command>lsearch</command> line.
9449 </para>
9450 </listitem>
9451 <listitem>
9452 <para>
9453 <indexterm role="concept">
9454 <primary>NIS lookup type</primary>
9455 </indexterm>
9456 <indexterm role="concept">
9457 <primary>lookup</primary>
9458 <secondary>NIS</secondary>
9459 </indexterm>
9460 <indexterm role="concept">
9461 <primary>binary zero</primary>
9462 <secondary>in lookup key</secondary>
9463 </indexterm>
9464 <command>nis</command>: The given file is the name of a NIS map, and a NIS lookup is done with
9465 the given key, without a terminating binary zero. There is a variant called
9466 <command>nis0</command> which does include the terminating binary zero in the key. This is
9467 reportedly needed for Sun-style alias files. Exim does not recognize NIS
9468 aliases; the full map names must be used.
9469 </para>
9470 </listitem>
9471 <listitem>
9472 <para>
9473 <indexterm role="concept">
9474 <primary>wildlsearch lookup type</primary>
9475 </indexterm>
9476 <indexterm role="concept">
9477 <primary>lookup</primary>
9478 <secondary>wildlsearch</secondary>
9479 </indexterm>
9480 <indexterm role="concept">
9481 <primary>nwildlsearch lookup type</primary>
9482 </indexterm>
9483 <indexterm role="concept">
9484 <primary>lookup</primary>
9485 <secondary>nwildlsearch</secondary>
9486 </indexterm>
9487 <command>wildlsearch</command> or <command>nwildlsearch</command>: These search a file linearly, like
9488 <command>lsearch</command>, but instead of being interpreted as a literal string, each key in
9489 the file may be wildcarded. The difference between these two lookup types is
9490 that for <command>wildlsearch</command>, each key in the file is string-expanded before being
9491 used, whereas for <command>nwildlsearch</command>, no expansion takes place.
9492 </para>
9493 <para>
9494 <indexterm role="concept">
9495 <primary>case sensitivity</primary>
9496 <secondary>in (n)wildlsearch lookup</secondary>
9497 </indexterm>
9498 Like <command>lsearch</command>, the testing is done case-insensitively. However, keys in the
9499 file that are regular expressions can be made case-sensitive by the use of
9500 <literal>(-i)</literal> within the pattern. The following forms of wildcard are recognized:
9501 </para>
9502 <orderedlist numeration="arabic">
9503 <listitem>
9504 <para>
9505 The string may begin with an asterisk to mean <quote>ends with</quote>. For example:
9506 </para>
9507 <literallayout class="monospaced">
9508     *.a.b.c       data for anything.a.b.c
9509     *fish         data for anythingfish
9510 </literallayout>
9511 </listitem>
9512 <listitem>
9513 <para>
9514 The string may begin with a circumflex to indicate a regular expression. For
9515 example, for <command>wildlsearch</command>:
9516 </para>
9517 <literallayout class="monospaced">
9518     ^\N\d+\.a\.b\N    data for &lt;digits&gt;.a.b
9519 </literallayout>
9520 <para>
9521 Note the use of <literal>\N</literal> to disable expansion of the contents of the regular
9522 expression. If you are using <command>nwildlsearch</command>, where the keys are not
9523 string-expanded, the equivalent entry is:
9524 </para>
9525 <literallayout class="monospaced">
9526     ^\d+\.a\.b        data for &lt;digits&gt;.a.b
9527 </literallayout>
9528 <para>
9529 The case-insensitive flag is set at the start of compiling the regular
9530 expression, but it can be turned off by using <literal>(-i)</literal> at an appropriate point.
9531 For example, to make the entire pattern case-sensitive:
9532 </para>
9533 <literallayout class="monospaced">
9534     ^(?-i)\d+\.a\.b        data for &lt;digits&gt;.a.b
9535 </literallayout>
9536 <para>
9537 If the regular expression contains white space or colon characters, you must
9538 either quote it (see <command>lsearch</command> above), or represent these characters in other
9539 ways. For example, <literal>\s</literal> can be used for white space and <literal>\x3A</literal> for a
9540 colon. This may be easier than quoting, because if you quote, you have to
9541 escape all the backslashes inside the quotes.
9542 </para>
9543 <para>
9544 <emphasis role="bold">Note</emphasis>: It is not possible to capture substrings in a regular expression
9545 match for later use, because the results of all lookups are cached. If a lookup
9546 is repeated, the result is taken from the cache, and no actual pattern matching
9547 takes place. The values of all the numeric variables are unset after a
9548 <command>(n)wildlsearch</command> match.
9549 </para>
9550 </listitem>
9551 <listitem>
9552 <para>
9553 Although I cannot see it being of much use, the general matching function that
9554 is used to implement <command>(n)wildlsearch</command> means that the string may begin with a
9555 lookup name terminated by a semicolon, and followed by lookup data. For
9556 example:
9557 </para>
9558 <literallayout class="monospaced">
9559     cdb;/some/file  data for keys that match the file
9560 </literallayout>
9561 <para>
9562 The data that is obtained from the nested lookup is discarded.
9563 </para>
9564 </listitem>
9565 </orderedlist>
9566 <para>
9567 Keys that do not match any of these patterns are interpreted literally. The
9568 continuation rules for the data are the same as for <command>lsearch</command>, and keys may
9569 be followed by optional colons.
9570 </para>
9571 <para>
9572 <emphasis role="bold">Warning</emphasis>: Unlike most other single-key lookup types, a file of data for
9573 <command>(n)wildlsearch</command> can <emphasis>not</emphasis> be turned into a DBM or cdb file, because those
9574 lookup types support only literal keys.
9575 </para>
9576 </listitem>
9577 </itemizedlist>
9578 </section>
9579 <section id="SECID62">
9580 <title>Query-style lookup types</title>
9581 <para>
9582 <indexterm role="concept">
9583 <primary>lookup</primary>
9584 <secondary>query-style types</secondary>
9585 </indexterm>
9586 <indexterm role="concept">
9587 <primary>query-style lookup</primary>
9588 <secondary>list of types</secondary>
9589 </indexterm>
9590 The supported query-style lookup types are listed below. Further details about
9591 many of them are given in later sections.
9592 </para>
9593 <itemizedlist>
9594 <listitem>
9595 <para>
9596 <indexterm role="concept">
9597 <primary>DNS</primary>
9598 <secondary>as a lookup type</secondary>
9599 </indexterm>
9600 <indexterm role="concept">
9601 <primary>lookup</primary>
9602 <secondary>DNS</secondary>
9603 </indexterm>
9604 <command>dnsdb</command>: This does a DNS search for one or more records whose domain names
9605 are given in the supplied query. The resulting data is the contents of the
9606 records. See section <xref linkend="SECTdnsdb"/>.
9607 </para>
9608 </listitem>
9609 <listitem>
9610 <para>
9611 <indexterm role="concept">
9612 <primary>InterBase lookup type</primary>
9613 </indexterm>
9614 <indexterm role="concept">
9615 <primary>lookup</primary>
9616 <secondary>InterBase</secondary>
9617 </indexterm>
9618 <command>ibase</command>: This does a lookup in an InterBase database.
9619 </para>
9620 </listitem>
9621 <listitem>
9622 <para>
9623 <indexterm role="concept">
9624 <primary>LDAP</primary>
9625 <secondary>lookup type</secondary>
9626 </indexterm>
9627 <indexterm role="concept">
9628 <primary>lookup</primary>
9629 <secondary>LDAP</secondary>
9630 </indexterm>
9631 <command>ldap</command>: This does an LDAP lookup using a query in the form of a URL, and
9632 returns attributes from a single entry. There is a variant called <command>ldapm</command>
9633 that permits values from multiple entries to be returned. A third variant
9634 called <command>ldapdn</command> returns the Distinguished Name of a single entry instead of
9635 any attribute values. See section <xref linkend="SECTldap"/>.
9636 </para>
9637 </listitem>
9638 <listitem>
9639 <para>
9640 <indexterm role="concept">
9641 <primary>MySQL</primary>
9642 <secondary>lookup type</secondary>
9643 </indexterm>
9644 <indexterm role="concept">
9645 <primary>lookup</primary>
9646 <secondary>MySQL</secondary>
9647 </indexterm>
9648 <command>mysql</command>: The format of the query is an SQL statement that is passed to a
9649 MySQL database. See section <xref linkend="SECTsql"/>.
9650 </para>
9651 </listitem>
9652 <listitem>
9653 <para>
9654 <indexterm role="concept">
9655 <primary>NIS+ lookup type</primary>
9656 </indexterm>
9657 <indexterm role="concept">
9658 <primary>lookup</primary>
9659 <secondary>NIS+</secondary>
9660 </indexterm>
9661 <command>nisplus</command>: This does a NIS+ lookup using a query that can specify the name of
9662 the field to be returned. See section <xref linkend="SECTnisplus"/>.
9663 </para>
9664 </listitem>
9665 <listitem>
9666 <para>
9667 <indexterm role="concept">
9668 <primary>Oracle</primary>
9669 <secondary>lookup type</secondary>
9670 </indexterm>
9671 <indexterm role="concept">
9672 <primary>lookup</primary>
9673 <secondary>Oracle</secondary>
9674 </indexterm>
9675 <command>oracle</command>: The format of the query is an SQL statement that is passed to an
9676 Oracle database. See section <xref linkend="SECTsql"/>.
9677 </para>
9678 </listitem>
9679 <listitem>
9680 <para>
9681 <indexterm role="concept">
9682 <primary>lookup</primary>
9683 <secondary>passwd</secondary>
9684 </indexterm>
9685 <indexterm role="concept">
9686 <primary>passwd lookup type</primary>
9687 </indexterm>
9688 <indexterm role="concept">
9689 <primary><filename>/etc/passwd</filename></primary>
9690 </indexterm>
9691 <command>passwd</command> is a query-style lookup with queries that are just user names. The
9692 lookup calls <function>getpwnam()</function> to interrogate the system password data, and on
9693 success, the result string is the same as you would get from an <command>lsearch</command>
9694 lookup on a traditional <filename>/etc/passwd file</filename>, though with <literal>*</literal> for the
9695 password value. For example:
9696 </para>
9697 <literallayout class="monospaced">
9698 *:42:42:King Rat:/home/kr:/bin/bash
9699 </literallayout>
9700 </listitem>
9701 <listitem>
9702 <para>
9703 <indexterm role="concept">
9704 <primary>PostgreSQL lookup type</primary>
9705 </indexterm>
9706 <indexterm role="concept">
9707 <primary>lookup</primary>
9708 <secondary>PostgreSQL</secondary>
9709 </indexterm>
9710 <command>pgsql</command>: The format of the query is an SQL statement that is passed to a
9711 PostgreSQL database. See section <xref linkend="SECTsql"/>.
9712 </para>
9713 </listitem>
9714 <listitem>
9715 <para>
9716 <indexterm role="concept">
9717 <primary>sqlite lookup type</primary>
9718 </indexterm>
9719 <indexterm role="concept">
9720 <primary>lookup</primary>
9721 <secondary>sqlite</secondary>
9722 </indexterm>
9723 <command>sqlite</command>: The format of the query is a file name followed by an SQL statement
9724 that is passed to an SQLite database. See section <xref linkend="SECTsqlite"/>.
9725 </para>
9726 </listitem>
9727 <listitem>
9728 <para>
9729 <command>testdb</command>: This is a lookup type that is used for testing Exim. It is
9730 not likely to be useful in normal operation.
9731 </para>
9732 </listitem>
9733 <listitem>
9734 <para>
9735 <indexterm role="concept">
9736 <primary>whoson lookup type</primary>
9737 </indexterm>
9738 <indexterm role="concept">
9739 <primary>lookup</primary>
9740 <secondary>whoson</secondary>
9741 </indexterm>
9742 <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
9743 allows a server to check whether a particular (dynamically allocated) IP
9744 address is currently allocated to a known (trusted) user and, optionally, to
9745 obtain the identity of the said user. For SMTP servers, <emphasis>Whoson</emphasis> was popular
9746 at one time for <quote>POP before SMTP</quote> authentication, but that approach has been
9747 superseded by SMTP authentication. In Exim, <emphasis>Whoson</emphasis> can be used to implement
9748 <quote>POP before SMTP</quote> checking using ACL statements such as
9749 </para>
9750 <literallayout class="monospaced">
9751 require condition = \
9752   ${lookup whoson {$sender_host_address}{yes}{no}}
9753 </literallayout>
9754 <para>
9755 The query consists of a single IP address. The value returned is the name of
9756 the authenticated user, which is stored in the variable <varname>$value</varname>. However, in
9757 this example, the data in <varname>$value</varname> is not used; the result of the lookup is
9758 one of the fixed strings <quote>yes</quote> or <quote>no</quote>.
9759 </para>
9760 </listitem>
9761 </itemizedlist>
9762 </section>
9763 <section id="SECID63">
9764 <title>Temporary errors in lookups</title>
9765 <para>
9766 <indexterm role="concept">
9767 <primary>lookup</primary>
9768 <secondary>temporary error in</secondary>
9769 </indexterm>
9770 Lookup functions can return temporary error codes if the lookup cannot be
9771 completed. For example, an SQL or LDAP database might be unavailable. For this
9772 reason, it is not advisable to use a lookup that might do this for critical
9773 options such as a list of local domains.
9774 </para>
9775 <para>
9776 When a lookup cannot be completed in a router or transport, delivery
9777 of the message (to the relevant address) is deferred, as for any other
9778 temporary error. In other circumstances Exim may assume the lookup has failed,
9779 or may give up altogether.
9780 </para>
9781 </section>
9782 <section id="SECTdefaultvaluelookups">
9783 <title>Default values in single-key lookups</title>
9784 <para>
9785 <indexterm role="concept">
9786 <primary>wildcard lookups</primary>
9787 </indexterm>
9788 <indexterm role="concept">
9789 <primary>lookup</primary>
9790 <secondary>default values</secondary>
9791 </indexterm>
9792 <indexterm role="concept">
9793 <primary>lookup</primary>
9794 <secondary>wildcard</secondary>
9795 </indexterm>
9796 <indexterm role="concept">
9797 <primary>lookup</primary>
9798 <secondary>* added to type</secondary>
9799 </indexterm>
9800 <indexterm role="concept">
9801 <primary>default</primary>
9802 <secondary>in single-key lookups</secondary>
9803 </indexterm>
9804 In this context, a <quote>default value</quote> is a value specified by the administrator
9805 that is to be used if a lookup fails.
9806 </para>
9807 <para>
9808 <emphasis role="bold">Note:</emphasis> This section applies only to single-key lookups. For query-style
9809 lookups, the facilities of the query language must be used. An attempt to
9810 specify a default for a query-style lookup provokes an error.
9811 </para>
9812 <para>
9813 If <quote>*</quote> is added to a single-key lookup type (for example, <option>lsearch*</option>)
9814 and the initial lookup fails, the key <quote>*</quote> is looked up in the file to
9815 provide a default value. See also the section on partial matching below.
9816 </para>
9817 <para>
9818 <indexterm role="concept">
9819 <primary>*@ with single-key lookup</primary>
9820 </indexterm>
9821 <indexterm role="concept">
9822 <primary>lookup</primary>
9823 <secondary>*@ added to type</secondary>
9824 </indexterm>
9825 <indexterm role="concept">
9826 <primary>alias file</primary>
9827 <secondary>per-domain default</secondary>
9828 </indexterm>
9829 Alternatively, if <quote>*@</quote> is added to a single-key lookup type (for example
9830 <option>dbm*@</option>) then, if the initial lookup fails and the key contains an @
9831 character, a second lookup is done with everything before the last @ replaced
9832 by *. This makes it possible to provide per-domain defaults in alias files
9833 that include the domains in the keys. If the second lookup fails (or doesn&#x2019;t
9834 take place because there is no @ in the key), <quote>*</quote> is looked up.
9835 For example, a <command>redirect</command> router might contain:
9836 </para>
9837 <literallayout class="monospaced">
9838 data = ${lookup{$local_part@$domain}lsearch*@{/etc/mix-aliases}}
9839 </literallayout>
9840 <para>
9841 Suppose the address that is being processed is <emphasis>jane@eyre.example</emphasis>. Exim
9842 looks up these keys, in this order:
9843 </para>
9844 <literallayout class="monospaced">
9845 jane@eyre.example
9846 *@eyre.example
9847 *
9848 </literallayout>
9849 <para>
9850 The data is taken from whichever key it finds first. <emphasis role="bold">Note</emphasis>: In an
9851 <command>lsearch</command> file, this does not mean the first of these keys in the file. A
9852 complete scan is done for each key, and only if it is not found at all does
9853 Exim move on to try the next key.
9854 </para>
9855 </section>
9856 <section id="SECTpartiallookup">
9857 <title>Partial matching in single-key lookups</title>
9858 <para>
9859 <indexterm role="concept">
9860 <primary>partial matching</primary>
9861 </indexterm>
9862 <indexterm role="concept">
9863 <primary>wildcard lookups</primary>
9864 </indexterm>
9865 <indexterm role="concept">
9866 <primary>lookup</primary>
9867 <secondary>partial matching</secondary>
9868 </indexterm>
9869 <indexterm role="concept">
9870 <primary>lookup</primary>
9871 <secondary>wildcard</secondary>
9872 </indexterm>
9873 <indexterm role="concept">
9874 <primary>asterisk</primary>
9875 <secondary>in search type</secondary>
9876 </indexterm>
9877 The normal operation of a single-key lookup is to search the file for an exact
9878 match with the given key. However, in a number of situations where domains are
9879 being looked up, it is useful to be able to do partial matching. In this case,
9880 information in the file that has a key starting with <quote>*.</quote> is matched by any
9881 domain that ends with the components that follow the full stop. For example, if
9882 a key in a DBM file is
9883 </para>
9884 <literallayout class="monospaced">
9885 *.dates.fict.example
9886 </literallayout>
9887 <para>
9888 then when partial matching is enabled this is matched by (amongst others)
9889 <emphasis>2001.dates.fict.example</emphasis> and <emphasis>1984.dates.fict.example</emphasis>. It is also matched
9890 by <emphasis>dates.fict.example</emphasis>, if that does not appear as a separate key in the
9891 file.
9892 </para>
9893 <para>
9894 <emphasis role="bold">Note</emphasis>: Partial matching is not available for query-style lookups. It is
9895 also not available for any lookup items in address lists (see section
9896 <xref linkend="SECTaddresslist"/>).
9897 </para>
9898 <para>
9899 Partial matching is implemented by doing a series of separate lookups using
9900 keys constructed by modifying the original subject key. This means that it can
9901 be used with any of the single-key lookup types, provided that
9902 partial matching keys
9903 beginning with a special prefix (default <quote>*.</quote>) are included in the data file.
9904 Keys in the file that do not begin with the prefix are matched only by
9905 unmodified subject keys when partial matching is in use.
9906 </para>
9907 <para>
9908 Partial matching is requested by adding the string <quote>partial-</quote> to the front of
9909 the name of a single-key lookup type, for example, <option>partial-dbm</option>. When this
9910 is done, the subject key is first looked up unmodified; if that fails, <quote>*.</quote>
9911 is added at the start of the subject key, and it is looked up again. If that
9912 fails, further lookups are tried with dot-separated components removed from the
9913 start of the subject key, one-by-one, and <quote>*.</quote> added on the front of what
9914 remains.
9915 </para>
9916 <para>
9917 A minimum number of two non-* components are required. This can be adjusted
9918 by including a number before the hyphen in the search type. For example,
9919 <option>partial3-lsearch</option> specifies a minimum of three non-* components in the
9920 modified keys. Omitting the number is equivalent to <quote>partial2-</quote>. If the
9921 subject key is <emphasis>2250.dates.fict.example</emphasis> then the following keys are looked
9922 up when the minimum number of non-* components is two:
9923 </para>
9924 <literallayout class="monospaced">
9925 2250.dates.fict.example
9926 *.2250.dates.fict.example
9927 *.dates.fict.example
9928 *.fict.example
9929 </literallayout>
9930 <para>
9931 As soon as one key in the sequence is successfully looked up, the lookup
9932 finishes.
9933 </para>
9934 <para>
9935 <indexterm role="concept">
9936 <primary>lookup</primary>
9937 <secondary>partial matching &ndash; changing prefix</secondary>
9938 </indexterm>
9939 <indexterm role="concept">
9940 <primary>prefix</primary>
9941 <secondary>for partial matching</secondary>
9942 </indexterm>
9943 The use of <quote>*.</quote> as the partial matching prefix is a default that can be
9944 changed. The motivation for this feature is to allow Exim to operate with file
9945 formats that are used by other MTAs. A different prefix can be supplied in
9946 parentheses instead of the hyphen after <quote>partial</quote>. For example:
9947 </para>
9948 <literallayout class="monospaced">
9949 domains = partial(.)lsearch;/some/file
9950 </literallayout>
9951 <para>
9952 In this example, if the domain is <emphasis>a.b.c</emphasis>, the sequence of lookups is
9953 <literal>a.b.c</literal>, <literal>.a.b.c</literal>, and <literal>.b.c</literal> (the default minimum of 2 non-wild
9954 components is unchanged). The prefix may consist of any punctuation characters
9955 other than a closing parenthesis. It may be empty, for example:
9956 </para>
9957 <literallayout class="monospaced">
9958 domains = partial1()cdb;/some/file
9959 </literallayout>
9960 <para>
9961 For this example, if the domain is <emphasis>a.b.c</emphasis>, the sequence of lookups is
9962 <literal>a.b.c</literal>, <literal>b.c</literal>, and <literal>c</literal>.
9963 </para>
9964 <para>
9965 If <quote>partial0</quote> is specified, what happens at the end (when the lookup with
9966 just one non-wild component has failed, and the original key is shortened right
9967 down to the null string) depends on the prefix:
9968 </para>
9969 <itemizedlist>
9970 <listitem>
9971 <para>
9972 If the prefix has zero length, the whole lookup fails.
9973 </para>
9974 </listitem>
9975 <listitem>
9976 <para>
9977 If the prefix has length 1, a lookup for just the prefix is done. For
9978 example, the final lookup for <quote>partial0(.)</quote> is for <literal>.</literal> alone.
9979 </para>
9980 </listitem>
9981 <listitem>
9982 <para>
9983 Otherwise, if the prefix ends in a dot, the dot is removed, and the
9984 remainder is looked up. With the default prefix, therefore, the final lookup is
9985 for <quote>*</quote> on its own.
9986 </para>
9987 </listitem>
9988 <listitem>
9989 <para>
9990 Otherwise, the whole prefix is looked up.
9991 </para>
9992 </listitem>
9993 </itemizedlist>
9994 <para>
9995 If the search type ends in <quote>*</quote> or <quote>*@</quote> (see section
9996 <xref linkend="SECTdefaultvaluelookups"/> above), the search for an ultimate default that
9997 this implies happens after all partial lookups have failed. If <quote>partial0</quote> is
9998 specified, adding <quote>*</quote> to the search type has no effect with the default
9999 prefix, because the <quote>*</quote> key is already included in the sequence of partial
10000 lookups. However, there might be a use for lookup types such as
10001 <quote>partial0(.)lsearch*</quote>.
10002 </para>
10003 <para>
10004 The use of <quote>*</quote> in lookup partial matching differs from its use as a wildcard
10005 in domain lists and the like. Partial matching works only in terms of
10006 dot-separated components; a key such as <literal>*fict.example</literal>
10007 in a database file is useless, because the asterisk in a partial matching
10008 subject key is always followed by a dot.
10009 </para>
10010 </section>
10011 <section id="SECID64">
10012 <title>Lookup caching</title>
10013 <para>
10014 <indexterm role="concept">
10015 <primary>lookup</primary>
10016 <secondary>caching</secondary>
10017 </indexterm>
10018 <indexterm role="concept">
10019 <primary>caching</primary>
10020 <secondary>lookup data</secondary>
10021 </indexterm>
10022 Exim caches all lookup results in order to avoid needless repetition of
10023 lookups. However, because (apart from the daemon) Exim operates as a collection
10024 of independent, short-lived processes, this caching applies only within a
10025 single Exim process. There is no inter-process lookup caching facility.
10026 </para>
10027 <para>
10028 For single-key lookups, Exim keeps the relevant files open in case there is
10029 another lookup that needs them. In some types of configuration this can lead to
10030 many files being kept open for messages with many recipients. To avoid hitting
10031 the operating system limit on the number of simultaneously open files, Exim
10032 closes the least recently used file when it needs to open more files than its
10033 own internal limit, which can be changed via the <option>lookup_open_max</option> option.
10034 </para>
10035 <para>
10036 The single-key lookup files are closed and the lookup caches are flushed at
10037 strategic points during delivery &ndash; for example, after all routing is
10038 complete.
10039 </para>
10040 </section>
10041 <section id="SECID65">
10042 <title>Quoting lookup data</title>
10043 <para>
10044 <indexterm role="concept">
10045 <primary>lookup</primary>
10046 <secondary>quoting</secondary>
10047 </indexterm>
10048 <indexterm role="concept">
10049 <primary>quoting</primary>
10050 <secondary>in lookups</secondary>
10051 </indexterm>
10052 When data from an incoming message is included in a query-style lookup, there
10053 is the possibility of special characters in the data messing up the syntax of
10054 the query. For example, a NIS+ query that contains
10055 </para>
10056 <literallayout class="monospaced">
10057 [name=$local_part]
10058 </literallayout>
10059 <para>
10060 will be broken if the local part happens to contain a closing square bracket.
10061 For NIS+, data can be enclosed in double quotes like this:
10062 </para>
10063 <literallayout class="monospaced">
10064 [name="$local_part"]
10065 </literallayout>
10066 <para>
10067 but this still leaves the problem of a double quote in the data. The rule for
10068 NIS+ is that double quotes must be doubled. Other lookup types have different
10069 rules, and to cope with the differing requirements, an expansion operator
10070 of the following form is provided:
10071 </para>
10072 <literallayout class="monospaced">
10073 ${quote_&lt;lookup-type&gt;:&lt;string&gt;}
10074 </literallayout>
10075 <para>
10076 For example, the safest way to write the NIS+ query is
10077 </para>
10078 <literallayout class="monospaced">
10079 [name="${quote_nisplus:$local_part}"]
10080 </literallayout>
10081 <para>
10082 See chapter <xref linkend="CHAPexpand"/> for full coverage of string expansions. The quote
10083 operator can be used for all lookup types, but has no effect for single-key
10084 lookups, since no quoting is ever needed in their key strings.
10085 </para>
10086 </section>
10087 <section id="SECTdnsdb">
10088 <title>More about dnsdb</title>
10089 <para>
10090 <indexterm role="concept">
10091 <primary>dnsdb lookup</primary>
10092 </indexterm>
10093 <indexterm role="concept">
10094 <primary>lookup</primary>
10095 <secondary>dnsdb</secondary>
10096 </indexterm>
10097 <indexterm role="concept">
10098 <primary>DNS</primary>
10099 <secondary>as a lookup type</secondary>
10100 </indexterm>
10101 The <command>dnsdb</command> lookup type uses the DNS as its database. A simple query consists
10102 of a record type and a domain name, separated by an equals sign. For example,
10103 an expansion string could contain:
10104 </para>
10105 <literallayout class="monospaced">
10106 ${lookup dnsdb{mx=a.b.example}{$value}fail}
10107 </literallayout>
10108 <para>
10109 If the lookup succeeds, the result is placed in <varname>$value</varname>, which in this case
10110 is used on its own as the result. If the lookup does not succeed, the
10111 <literal>fail</literal> keyword causes a <emphasis>forced expansion failure</emphasis> &ndash; see section
10112 <xref linkend="SECTforexpfai"/> for an explanation of what this means.
10113 </para>
10114 <para>
10115 The supported DNS record types are A, CNAME, MX, NS, PTR, SRV, and TXT, and,
10116 when Exim is compiled with IPv6 support, AAAA (and A6 if that is also
10117 configured). If no type is given, TXT is assumed. When the type is PTR,
10118 the data can be an IP address, written as normal; inversion and the addition of
10119 <option>in-addr.arpa</option> or <option>ip6.arpa</option> happens automatically. For example:
10120 </para>
10121 <literallayout class="monospaced">
10122 ${lookup dnsdb{ptr=192.168.4.5}{$value}fail}
10123 </literallayout>
10124 <para>
10125 If the data for a PTR record is not a syntactically valid IP address, it is not
10126 altered and nothing is added.
10127 </para>
10128 <para>
10129 <indexterm role="concept">
10130 <primary>MX record</primary>
10131 <secondary>in <command>dnsdb</command> lookup</secondary>
10132 </indexterm>
10133 <indexterm role="concept">
10134 <primary>SRV record</primary>
10135 <secondary>in <command>dnsdb</command> lookup</secondary>
10136 </indexterm>
10137 For an MX lookup, both the preference value and the host name are returned for
10138 each record, separated by a space. For an SRV lookup, the priority, weight,
10139 port, and host name are returned for each record, separated by spaces.
10140 </para>
10141 <para>
10142 For any record type, if multiple records are found (or, for A6 lookups, if a
10143 single record leads to multiple addresses), the data is returned as a
10144 concatenation, with newline as the default separator. The order, of course,
10145 depends on the DNS resolver. You can specify a different separator character
10146 between multiple records by putting a right angle-bracket followed immediately
10147 by the new separator at the start of the query. For example:
10148 </para>
10149 <literallayout class="monospaced">
10150 ${lookup dnsdb{&gt;: a=host1.example}}
10151 </literallayout>
10152 <para>
10153 It is permitted to specify a space as the separator character. Further
10154 white space is ignored.
10155 </para>
10156 <para>
10157 <indexterm role="concept">
10158 <primary>TXT record</primary>
10159 <secondary>in <command>dnsdb</command> lookup</secondary>
10160 </indexterm>
10161 For TXT records with multiple items of data, only the first item is returned,
10162 unless a separator for them is specified using a comma after the separator
10163 character followed immediately by the TXT record item separator. To concatenate
10164 items without a separator, use a semicolon instead.
10165 </para>
10166 <literallayout class="monospaced">
10167 ${lookup dnsdb{&gt;\n,: txt=a.b.example}}
10168 ${lookup dnsdb{&gt;\n; txt=a.b.example}}
10169 </literallayout>
10170 <para>
10171 It is permitted to specify a space as the separator character. Further
10172 white space is ignored.
10173 </para>
10174 </section>
10175 <section id="SECID66">
10176 <title>Pseudo dnsdb record types</title>
10177 <para>
10178 <indexterm role="concept">
10179 <primary>MX record</primary>
10180 <secondary>in <command>dnsdb</command> lookup</secondary>
10181 </indexterm>
10182 By default, both the preference value and the host name are returned for
10183 each MX record, separated by a space. If you want only host names, you can use
10184 the pseudo-type MXH:
10185 </para>
10186 <literallayout class="monospaced">
10187 ${lookup dnsdb{mxh=a.b.example}}
10188 </literallayout>
10189 <para>
10190 In this case, the preference values are omitted, and just the host names are
10191 returned.
10192 </para>
10193 <para>
10194 <indexterm role="concept">
10195 <primary>name server for enclosing domain</primary>
10196 </indexterm>
10197 Another pseudo-type is ZNS (for <quote>zone NS</quote>). It performs a lookup for NS
10198 records on the given domain, but if none are found, it removes the first
10199 component of the domain name, and tries again. This process continues until NS
10200 records are found or there are no more components left (or there is a DNS
10201 error). In other words, it may return the name servers for a top-level domain,
10202 but it never returns the root name servers. If there are no NS records for the
10203 top-level domain, the lookup fails. Consider these examples:
10204 </para>
10205 <literallayout class="monospaced">
10206 ${lookup dnsdb{zns=xxx.quercite.com}}
10207 ${lookup dnsdb{zns=xxx.edu}}
10208 </literallayout>
10209 <para>
10210 Assuming that in each case there are no NS records for the full domain name,
10211 the first returns the name servers for <option>quercite.com</option>, and the second returns
10212 the name servers for <option>edu</option>.
10213 </para>
10214 <para>
10215 You should be careful about how you use this lookup because, unless the
10216 top-level domain does not exist, the lookup always returns some host names. The
10217 sort of use to which this might be put is for seeing if the name servers for a
10218 given domain are on a blacklist. You can probably assume that the name servers
10219 for the high-level domains such as <option>com</option> or <option>co.uk</option> are not going to be on
10220 such a list.
10221 </para>
10222 <para>
10223 <indexterm role="concept">
10224 <primary>CSA</primary>
10225 <secondary>in <command>dnsdb</command> lookup</secondary>
10226 </indexterm>
10227 A third pseudo-type is CSA (Client SMTP Authorization). This looks up SRV
10228 records according to the CSA rules, which are described in section
10229 <xref linkend="SECTverifyCSA"/>. Although <command>dnsdb</command> supports SRV lookups directly, this is
10230 not sufficient because of the extra parent domain search behaviour of CSA. The
10231 result of a successful lookup such as:
10232 </para>
10233 <literallayout class="monospaced">
10234 ${lookup dnsdb {csa=$sender_helo_name}}
10235 </literallayout>
10236 <para>
10237 has two space-separated fields: an authorization code and a target host name.
10238 The authorization code can be <quote>Y</quote> for yes, <quote>N</quote> for no, <quote>X</quote> for explicit
10239 authorization required but absent, or <quote>?</quote> for unknown.
10240 </para>
10241 </section>
10242 <section id="SECID67">
10243 <title>Multiple dnsdb lookups</title>
10244 <para>
10245 In the previous sections, <command>dnsdb</command> lookups for a single domain are described.
10246 However, you can specify a list of domains or IP addresses in a single
10247 <command>dnsdb</command> lookup. The list is specified in the normal Exim way, with colon as
10248 the default separator, but with the ability to change this. For example:
10249 </para>
10250 <literallayout class="monospaced">
10251 ${lookup dnsdb{one.domain.com:two.domain.com}}
10252 ${lookup dnsdb{a=one.host.com:two.host.com}}
10253 ${lookup dnsdb{ptr = &lt;; 1.2.3.4 ; 4.5.6.8}}
10254 </literallayout>
10255 <para>
10256 In order to retain backwards compatibility, there is one special case: if
10257 the lookup type is PTR and no change of separator is specified, Exim looks
10258 to see if the rest of the string is precisely one IPv6 address. In this
10259 case, it does not treat it as a list.
10260 </para>
10261 <para>
10262 The data from each lookup is concatenated, with newline separators by default,
10263 in the same way that multiple DNS records for a single item are handled. A
10264 different separator can be specified, as described above.
10265 </para>
10266 <para>
10267 The <command>dnsdb</command> lookup fails only if all the DNS lookups fail. If there is a
10268 temporary DNS error for any of them, the behaviour is controlled by
10269 an optional keyword followed by a comma that may appear before the record
10270 type. The possible keywords are <quote>defer_strict</quote>, <quote>defer_never</quote>, and
10271 <quote>defer_lax</quote>. With <quote>strict</quote> behaviour, any temporary DNS error causes the
10272 whole lookup to defer. With <quote>never</quote> behaviour, a temporary DNS error is
10273 ignored, and the behaviour is as if the DNS lookup failed to find anything.
10274 With <quote>lax</quote> behaviour, all the queries are attempted, but a temporary DNS
10275 error causes the whole lookup to defer only if none of the other lookups
10276 succeed. The default is <quote>lax</quote>, so the following lookups are equivalent:
10277 </para>
10278 <literallayout class="monospaced">
10279 ${lookup dnsdb{defer_lax,a=one.host.com:two.host.com}}
10280 ${lookup dnsdb{a=one.host.com:two.host.com}}
10281 </literallayout>
10282 <para>
10283 Thus, in the default case, as long as at least one of the DNS lookups
10284 yields some data, the lookup succeeds.
10285 </para>
10286 </section>
10287 <section id="SECTldap">
10288 <title>More about LDAP</title>
10289 <para>
10290 <indexterm role="concept">
10291 <primary>LDAP</primary>
10292 <secondary>lookup, more about</secondary>
10293 </indexterm>
10294 <indexterm role="concept">
10295 <primary>lookup</primary>
10296 <secondary>LDAP</secondary>
10297 </indexterm>
10298 <indexterm role="concept">
10299 <primary>Solaris</primary>
10300 <secondary>LDAP</secondary>
10301 </indexterm>
10302 The original LDAP implementation came from the University of Michigan; this has
10303 become <quote>Open LDAP</quote>, and there are now two different releases. Another
10304 implementation comes from Netscape, and Solaris 7 and subsequent releases
10305 contain inbuilt LDAP support. Unfortunately, though these are all compatible at
10306 the lookup function level, their error handling is different. For this reason
10307 it is necessary to set a compile-time variable when building Exim with LDAP, to
10308 indicate which LDAP library is in use. One of the following should appear in
10309 your <filename>Local/Makefile</filename>:
10310 </para>
10311 <literallayout class="monospaced">
10312 LDAP_LIB_TYPE=UMICHIGAN
10313 LDAP_LIB_TYPE=OPENLDAP1
10314 LDAP_LIB_TYPE=OPENLDAP2
10315 LDAP_LIB_TYPE=NETSCAPE
10316 LDAP_LIB_TYPE=SOLARIS
10317 </literallayout>
10318 <para>
10319 If LDAP_LIB_TYPE is not set, Exim assumes <literal>OPENLDAP1</literal>, which has the
10320 same interface as the University of Michigan version.
10321 </para>
10322 <para>
10323 There are three LDAP lookup types in Exim. These behave slightly differently in
10324 the way they handle the results of a query:
10325 </para>
10326 <itemizedlist>
10327 <listitem>
10328 <para>
10329 <command>ldap</command> requires the result to contain just one entry; if there are more, it
10330 gives an error.
10331 </para>
10332 </listitem>
10333 <listitem>
10334 <para>
10335 <command>ldapdn</command> also requires the result to contain just one entry, but it is the
10336 Distinguished Name that is returned rather than any attribute values.
10337 </para>
10338 </listitem>
10339 <listitem>
10340 <para>
10341 <command>ldapm</command> permits the result to contain more than one entry; the attributes
10342 from all of them are returned.
10343 </para>
10344 </listitem>
10345 </itemizedlist>
10346 <para>
10347 For <command>ldap</command> and <command>ldapm</command>, if a query finds only entries with no attributes,
10348 Exim behaves as if the entry did not exist, and the lookup fails. The format of
10349 the data returned by a successful lookup is described in the next section.
10350 First we explain how LDAP queries are coded.
10351 </para>
10352 </section>
10353 <section id="SECTforldaque">
10354 <title>Format of LDAP queries</title>
10355 <para>
10356 <indexterm role="concept">
10357 <primary>LDAP</primary>
10358 <secondary>query format</secondary>
10359 </indexterm>
10360 An LDAP query takes the form of a URL as defined in RFC 2255. For example, in
10361 the configuration of a <command>redirect</command> router one might have this setting:
10362 </para>
10363 <literallayout class="monospaced">
10364 data = ${lookup ldap \
10365   {ldap:///cn=$local_part,o=University%20of%20Cambridge,\
10366   c=UK?mailbox?base?}}
10367 </literallayout>
10368 <para>
10369 <indexterm role="concept">
10370 <primary>LDAP</primary>
10371 <secondary>with TLS</secondary>
10372 </indexterm>
10373 The URL may begin with <literal>ldap</literal> or <literal>ldaps</literal> if your LDAP library supports
10374 secure (encrypted) LDAP connections. The second of these ensures that an
10375 encrypted TLS connection is used.
10376 </para>
10377 </section>
10378 <section id="SECID68">
10379 <title>LDAP quoting</title>
10380 <para>
10381 <indexterm role="concept">
10382 <primary>LDAP</primary>
10383 <secondary>quoting</secondary>
10384 </indexterm>
10385 Two levels of quoting are required in LDAP queries, the first for LDAP itself
10386 and the second because the LDAP query is represented as a URL. Furthermore,
10387 within an LDAP query, two different kinds of quoting are required. For this
10388 reason, there are two different LDAP-specific quoting operators.
10389 </para>
10390 <para>
10391 The <option>quote_ldap</option> operator is designed for use on strings that are part of
10392 filter specifications. Conceptually, it first does the following conversions on
10393 the string:
10394 </para>
10395 <literallayout class="monospaced">
10396 *   =&gt;   \2A
10397 (   =&gt;   \28
10398 )   =&gt;   \29
10399 \   =&gt;   \5C
10400 </literallayout>
10401 <para>
10402 in accordance with RFC 2254. The resulting string is then quoted according
10403 to the rules for URLs, that is, all non-alphanumeric characters except
10404 </para>
10405 <literallayout class="monospaced">
10406 ! $ ' - . _ ( ) * +
10407 </literallayout>
10408 <para>
10409 are converted to their hex values, preceded by a percent sign. For example:
10410 </para>
10411 <literallayout class="monospaced">
10412 ${quote_ldap: a(bc)*, a&lt;yz&gt;; }
10413 </literallayout>
10414 <para>
10415 yields
10416 </para>
10417 <literallayout class="monospaced">
10418 %20a%5C28bc%5C29%5C2A%2C%20a%3Cyz%3E%3B%20
10419 </literallayout>
10420 <para>
10421 Removing the URL quoting, this is (with a leading and a trailing space):
10422 </para>
10423 <literallayout class="monospaced">
10424 a\28bc\29\2A, a&lt;yz&gt;;
10425 </literallayout>
10426 <para>
10427 The <option>quote_ldap_dn</option> operator is designed for use on strings that are part of
10428 base DN specifications in queries. Conceptually, it first converts the string
10429 by inserting a backslash in front of any of the following characters:
10430 </para>
10431 <literallayout class="monospaced">
10432 , + " \ &lt; &gt; ;
10433 </literallayout>
10434 <para>
10435 It also inserts a backslash before any leading spaces or # characters, and
10436 before any trailing spaces. (These rules are in RFC 2253.) The resulting string
10437 is then quoted according to the rules for URLs. For example:
10438 </para>
10439 <literallayout class="monospaced">
10440 ${quote_ldap_dn: a(bc)*, a&lt;yz&gt;; }
10441 </literallayout>
10442 <para>
10443 yields
10444 </para>
10445 <literallayout class="monospaced">
10446 %5C%20a(bc)*%5C%2C%20a%5C%3Cyz%5C%3E%5C%3B%5C%20
10447 </literallayout>
10448 <para>
10449 Removing the URL quoting, this is (with a trailing space):
10450 </para>
10451 <literallayout class="monospaced">
10452 \ a(bc)*\, a\&lt;yz\&gt;\;\
10453 </literallayout>
10454 <para>
10455 There are some further comments about quoting in the section on LDAP
10456 authentication below.
10457 </para>
10458 </section>
10459 <section id="SECID69">
10460 <title>LDAP connections</title>
10461 <para>
10462 <indexterm role="concept">
10463 <primary>LDAP</primary>
10464 <secondary>connections</secondary>
10465 </indexterm>
10466 The connection to an LDAP server may either be over TCP/IP, or, when OpenLDAP
10467 is in use, via a Unix domain socket. The example given above does not specify
10468 an LDAP server. A server that is reached by TCP/IP can be specified in a query
10469 by starting it with
10470 </para>
10471 <literallayout class="monospaced">
10472 ldap://&lt;hostname&gt;:&lt;port&gt;/...
10473 </literallayout>
10474 <para>
10475 If the port (and preceding colon) are omitted, the standard LDAP port (389) is
10476 used. When no server is specified in a query, a list of default servers is
10477 taken from the <option>ldap_default_servers</option> configuration option. This supplies a
10478 colon-separated list of servers which are tried in turn until one successfully
10479 handles a query, or there is a serious error. Successful handling either
10480 returns the requested data, or indicates that it does not exist. Serious errors
10481 are syntactical, or multiple values when only a single value is expected.
10482 Errors which cause the next server to be tried are connection failures, bind
10483 failures, and timeouts.
10484 </para>
10485 <para>
10486 For each server name in the list, a port number can be given. The standard way
10487 of specifying a host and port is to use a colon separator (RFC 1738). Because
10488 <option>ldap_default_servers</option> is a colon-separated list, such colons have to be
10489 doubled. For example
10490 </para>
10491 <literallayout class="monospaced">
10492 ldap_default_servers = ldap1.example.com::145:ldap2.example.com
10493 </literallayout>
10494 <para>
10495 If <option>ldap_default_servers</option> is unset, a URL with no server name is passed
10496 to the LDAP library with no server name, and the library&#x2019;s default (normally
10497 the local host) is used.
10498 </para>
10499 <para>
10500 If you are using the OpenLDAP library, you can connect to an LDAP server using
10501 a Unix domain socket instead of a TCP/IP connection. This is specified by using
10502 <literal>ldapi</literal> instead of <literal>ldap</literal> in LDAP queries. What follows here applies only
10503 to OpenLDAP. If Exim is compiled with a different LDAP library, this feature is
10504 not available.
10505 </para>
10506 <para>
10507 For this type of connection, instead of a host name for the server, a pathname
10508 for the socket is required, and the port number is not relevant. The pathname
10509 can be specified either as an item in <option>ldap_default_servers</option>, or inline in
10510 the query. In the former case, you can have settings such as
10511 </para>
10512 <literallayout class="monospaced">
10513 ldap_default_servers = /tmp/ldap.sock : backup.ldap.your.domain
10514 </literallayout>
10515 <para>
10516 When the pathname is given in the query, you have to escape the slashes as
10517 <literal>%2F</literal> to fit in with the LDAP URL syntax. For example:
10518 </para>
10519 <literallayout class="monospaced">
10520 ${lookup ldap {ldapi://%2Ftmp%2Fldap.sock/o=...
10521 </literallayout>
10522 <para>
10523 When Exim processes an LDAP lookup and finds that the <quote>hostname</quote> is really
10524 a pathname, it uses the Unix domain socket code, even if the query actually
10525 specifies <literal>ldap</literal> or <literal>ldaps</literal>. In particular, no encryption is used for a
10526 socket connection. This behaviour means that you can use a setting of
10527 <option>ldap_default_servers</option> such as in the example above with traditional <literal>ldap</literal>
10528 or <literal>ldaps</literal> queries, and it will work. First, Exim tries a connection via
10529 the Unix domain socket; if that fails, it tries a TCP/IP connection to the
10530 backup host.
10531 </para>
10532 <para>
10533 If an explicit <literal>ldapi</literal> type is given in a query when a host name is
10534 specified, an error is diagnosed. However, if there are more items in
10535 <option>ldap_default_servers</option>, they are tried. In other words:
10536 </para>
10537 <itemizedlist>
10538 <listitem>
10539 <para>
10540 Using a pathname with <literal>ldap</literal> or <literal>ldaps</literal> forces the use of the Unix domain
10541 interface.
10542 </para>
10543 </listitem>
10544 <listitem>
10545 <para>
10546 Using <literal>ldapi</literal> with a host name causes an error.
10547 </para>
10548 </listitem>
10549 </itemizedlist>
10550 <para>
10551 Using <literal>ldapi</literal> with no host or path in the query, and no setting of
10552 <option>ldap_default_servers</option>, does whatever the library does by default.
10553 </para>
10554 </section>
10555 <section id="SECID70">
10556 <title>LDAP authentication and control information</title>
10557 <para>
10558 <indexterm role="concept">
10559 <primary>LDAP</primary>
10560 <secondary>authentication</secondary>
10561 </indexterm>
10562 The LDAP URL syntax provides no way of passing authentication and other control
10563 information to the server. To make this possible, the URL in an LDAP query may
10564 be preceded by any number of &lt;<emphasis>name</emphasis>&gt;=&lt;<emphasis>value</emphasis>&gt; settings, separated by
10565 spaces. If a value contains spaces it must be enclosed in double quotes, and
10566 when double quotes are used, backslash is interpreted in the usual way inside
10567 them. The following names are recognized:
10568 </para>
10569 <literallayout>
10570 <literal>DEREFERENCE</literal>  set the dereferencing parameter
10571 <literal>NETTIME    </literal>  set a timeout for a network operation
10572 <literal>USER       </literal>  set the DN, for authenticating the LDAP bind
10573 <literal>PASS       </literal>  set the password, likewise
10574 <literal>REFERRALS  </literal>  set the referrals parameter
10575 <literal>SIZE       </literal>  set the limit for the number of entries returned
10576 <literal>TIME       </literal>  set the maximum waiting time for a query
10577 </literallayout>
10578 <para>
10579 The value of the DEREFERENCE parameter must be one of the words <quote>never</quote>,
10580 <quote>searching</quote>, <quote>finding</quote>, or <quote>always</quote>. The value of the REFERRALS parameter
10581 must be <quote>follow</quote> (the default) or <quote>nofollow</quote>. The latter stops the LDAP
10582 library from trying to follow referrals issued by the LDAP server.
10583 </para>
10584 <para>
10585 The name CONNECT is an obsolete name for NETTIME, retained for
10586 backwards compatibility. This timeout (specified as a number of seconds) is
10587 enforced from the client end for operations that can be carried out over a
10588 network. Specifically, it applies to network connections and calls to the
10589 <emphasis>ldap_result()</emphasis> function. If the value is greater than zero, it is used if
10590 LDAP_OPT_NETWORK_TIMEOUT is defined in the LDAP headers (OpenLDAP), or
10591 if LDAP_X_OPT_CONNECT_TIMEOUT is defined in the LDAP headers (Netscape
10592 SDK 4.1). A value of zero forces an explicit setting of <quote>no timeout</quote> for
10593 Netscape SDK; for OpenLDAP no action is taken.
10594 </para>
10595 <para>
10596 The TIME parameter (also a number of seconds) is passed to the server to
10597 set a server-side limit on the time taken to complete a search.
10598 </para>
10599 <para>
10600 Here is an example of an LDAP query in an Exim lookup that uses some of these
10601 values. This is a single line, folded to fit on the page:
10602 </para>
10603 <literallayout class="monospaced">
10604 ${lookup ldap
10605   {user="cn=manager,o=University of Cambridge,c=UK" pass=secret
10606   ldap:///o=University%20of%20Cambridge,c=UK?sn?sub?(cn=foo)}
10607   {$value}fail}
10608 </literallayout>
10609 <para>
10610 The encoding of spaces as <literal>%20</literal> is a URL thing which should not be done for
10611 any of the auxiliary data. Exim configuration settings that include lookups
10612 which contain password information should be preceded by <quote>hide</quote> to prevent
10613 non-admin users from using the <option>-bP</option> option to see their values.
10614 </para>
10615 <para>
10616 The auxiliary data items may be given in any order. The default is no
10617 connection timeout (the system timeout is used), no user or password, no limit
10618 on the number of entries returned, and no time limit on queries.
10619 </para>
10620 <para>
10621 When a DN is quoted in the USER= setting for LDAP authentication, Exim
10622 removes any URL quoting that it may contain before passing it LDAP. Apparently
10623 some libraries do this for themselves, but some do not. Removing the URL
10624 quoting has two advantages:
10625 </para>
10626 <itemizedlist>
10627 <listitem>
10628 <para>
10629 It makes it possible to use the same <option>quote_ldap_dn</option> expansion for USER=
10630 DNs as with DNs inside actual queries.
10631 </para>
10632 </listitem>
10633 <listitem>
10634 <para>
10635 It permits spaces inside USER= DNs.
10636 </para>
10637 </listitem>
10638 </itemizedlist>
10639 <para>
10640 For example, a setting such as
10641 </para>
10642 <literallayout class="monospaced">
10643 USER=cn=${quote_ldap_dn:$1}
10644 </literallayout>
10645 <para>
10646 should work even if <varname>$1</varname> contains spaces.
10647 </para>
10648 <para>
10649 Expanded data for the PASS= value should be quoted using the <option>quote</option>
10650 expansion operator, rather than the LDAP quote operators. The only reason this
10651 field needs quoting is to ensure that it conforms to the Exim syntax, which
10652 does not allow unquoted spaces. For example:
10653 </para>
10654 <literallayout class="monospaced">
10655 PASS=${quote:$3}
10656 </literallayout>
10657 <para>
10658 The LDAP authentication mechanism can be used to check passwords as part of
10659 SMTP authentication. See the <option>ldapauth</option> expansion string condition in chapter
10660 <xref linkend="CHAPexpand"/>.
10661 </para>
10662 </section>
10663 <section id="SECID71">
10664 <title>Format of data returned by LDAP</title>
10665 <para>
10666 <indexterm role="concept">
10667 <primary>LDAP</primary>
10668 <secondary>returned data formats</secondary>
10669 </indexterm>
10670 The <command>ldapdn</command> lookup type returns the Distinguished Name from a single entry
10671 as a sequence of values, for example
10672 </para>
10673 <literallayout class="monospaced">
10674 cn=manager, o=University of Cambridge, c=UK
10675 </literallayout>
10676 <para>
10677 The <command>ldap</command> lookup type generates an error if more than one entry matches the
10678 search filter, whereas <command>ldapm</command> permits this case, and inserts a newline in
10679 the result between the data from different entries. It is possible for multiple
10680 values to be returned for both <command>ldap</command> and <command>ldapm</command>, but in the former case
10681 you know that whatever values are returned all came from a single entry in the
10682 directory.
10683 </para>
10684 <para>
10685 In the common case where you specify a single attribute in your LDAP query, the
10686 result is not quoted, and does not contain the attribute name. If the attribute
10687 has multiple values, they are separated by commas.
10688 </para>
10689 <para>
10690 If you specify multiple attributes, the result contains space-separated, quoted
10691 strings, each preceded by the attribute name and an equals sign. Within the
10692 quotes, the quote character, backslash, and newline are escaped with
10693 backslashes, and commas are used to separate multiple values for the attribute.
10694 Apart from the escaping, the string within quotes takes the same form as the
10695 output when a single attribute is requested. Specifying no attributes is the
10696 same as specifying all of an entry&#x2019;s attributes.
10697 </para>
10698 <para>
10699 Here are some examples of the output format. The first line of each pair is an
10700 LDAP query, and the second is the data that is returned. The attribute called
10701 <option>attr1</option> has two values, whereas <option>attr2</option> has only one value:
10702 </para>
10703 <literallayout class="monospaced">
10704 ldap:///o=base?attr1?sub?(uid=fred)
10705 value1.1, value1.2
10706
10707 ldap:///o=base?attr2?sub?(uid=fred)
10708 value two
10709
10710 ldap:///o=base?attr1,attr2?sub?(uid=fred)
10711 attr1="value1.1, value1.2" attr2="value two"
10712
10713 ldap:///o=base??sub?(uid=fred)
10714 objectClass="top" attr1="value1.1, value1.2" attr2="value two"
10715 </literallayout>
10716 <para>
10717 The <option>extract</option> operator in string expansions can be used to pick out
10718 individual fields from data that consists of <emphasis>key</emphasis>=<emphasis>value</emphasis> pairs. You can
10719 make use of Exim&#x2019;s <option>-be</option> option to run expansion tests and thereby check the
10720 results of LDAP lookups.
10721 </para>
10722 </section>
10723 <section id="SECTnisplus">
10724 <title>More about NIS+</title>
10725 <para>
10726 <indexterm role="concept">
10727 <primary>NIS+ lookup type</primary>
10728 </indexterm>
10729 <indexterm role="concept">
10730 <primary>lookup</primary>
10731 <secondary>NIS+</secondary>
10732 </indexterm>
10733 NIS+ queries consist of a NIS+ <emphasis>indexed name</emphasis> followed by an optional colon
10734 and field name. If this is given, the result of a successful query is the
10735 contents of the named field; otherwise the result consists of a concatenation
10736 of <emphasis>field-name=field-value</emphasis> pairs, separated by spaces. Empty values and
10737 values containing spaces are quoted. For example, the query
10738 </para>
10739 <literallayout class="monospaced">
10740 [name=mg1456],passwd.org_dir
10741 </literallayout>
10742 <para>
10743 might return the string
10744 </para>
10745 <literallayout class="monospaced">
10746 name=mg1456 passwd="" uid=999 gid=999 gcos="Martin Guerre"
10747 home=/home/mg1456 shell=/bin/bash shadow=""
10748 </literallayout>
10749 <para>
10750 (split over two lines here to fit on the page), whereas
10751 </para>
10752 <literallayout class="monospaced">
10753 [name=mg1456],passwd.org_dir:gcos
10754 </literallayout>
10755 <para>
10756 would just return
10757 </para>
10758 <literallayout class="monospaced">
10759 Martin Guerre
10760 </literallayout>
10761 <para>
10762 with no quotes. A NIS+ lookup fails if NIS+ returns more than one table entry
10763 for the given indexed key. The effect of the <option>quote_nisplus</option> expansion
10764 operator is to double any quote characters within the text.
10765 </para>
10766 </section>
10767 <section id="SECTsql">
10768 <title>SQL lookups</title>
10769 <para>
10770 <indexterm role="concept">
10771 <primary>SQL lookup types</primary>
10772 </indexterm>
10773 <indexterm role="concept">
10774 <primary>MySQL</primary>
10775 <secondary>lookup type</secondary>
10776 </indexterm>
10777 <indexterm role="concept">
10778 <primary>PostgreSQL lookup type</primary>
10779 </indexterm>
10780 <indexterm role="concept">
10781 <primary>lookup</primary>
10782 <secondary>MySQL</secondary>
10783 </indexterm>
10784 <indexterm role="concept">
10785 <primary>lookup</primary>
10786 <secondary>PostgreSQL</secondary>
10787 </indexterm>
10788 <indexterm role="concept">
10789 <primary>Oracle</primary>
10790 <secondary>lookup type</secondary>
10791 </indexterm>
10792 <indexterm role="concept">
10793 <primary>lookup</primary>
10794 <secondary>Oracle</secondary>
10795 </indexterm>
10796 <indexterm role="concept">
10797 <primary>InterBase lookup type</primary>
10798 </indexterm>
10799 <indexterm role="concept">
10800 <primary>lookup</primary>
10801 <secondary>InterBase</secondary>
10802 </indexterm>
10803 Exim can support lookups in InterBase, MySQL, Oracle, PostgreSQL, and SQLite
10804 databases. Queries for these databases contain SQL statements, so an example
10805 might be
10806 </para>
10807 <literallayout class="monospaced">
10808 ${lookup mysql{select mailbox from users where id='userx'}\
10809   {$value}fail}
10810 </literallayout>
10811 <para>
10812 If the result of the query contains more than one field, the data for each
10813 field in the row is returned, preceded by its name, so the result of
10814 </para>
10815 <literallayout class="monospaced">
10816 ${lookup pgsql{select home,name from users where id='userx'}\
10817   {$value}}
10818 </literallayout>
10819 <para>
10820 might be
10821 </para>
10822 <literallayout class="monospaced">
10823 home=/home/userx name="Mister X"
10824 </literallayout>
10825 <para>
10826 Empty values and values containing spaces are double quoted, with embedded
10827 quotes escaped by a backslash. If the result of the query contains just one
10828 field, the value is passed back verbatim, without a field name, for example:
10829 </para>
10830 <literallayout class="monospaced">
10831 Mister X
10832 </literallayout>
10833 <para>
10834 If the result of the query yields more than one row, it is all concatenated,
10835 with a newline between the data for each row.
10836 </para>
10837 </section>
10838 <section id="SECID72">
10839 <title>More about MySQL, PostgreSQL, Oracle, and InterBase</title>
10840 <para>
10841 <indexterm role="concept">
10842 <primary>MySQL</primary>
10843 <secondary>lookup type</secondary>
10844 </indexterm>
10845 <indexterm role="concept">
10846 <primary>PostgreSQL lookup type</primary>
10847 </indexterm>
10848 <indexterm role="concept">
10849 <primary>lookup</primary>
10850 <secondary>MySQL</secondary>
10851 </indexterm>
10852 <indexterm role="concept">
10853 <primary>lookup</primary>
10854 <secondary>PostgreSQL</secondary>
10855 </indexterm>
10856 <indexterm role="concept">
10857 <primary>Oracle</primary>
10858 <secondary>lookup type</secondary>
10859 </indexterm>
10860 <indexterm role="concept">
10861 <primary>lookup</primary>
10862 <secondary>Oracle</secondary>
10863 </indexterm>
10864 <indexterm role="concept">
10865 <primary>InterBase lookup type</primary>
10866 </indexterm>
10867 <indexterm role="concept">
10868 <primary>lookup</primary>
10869 <secondary>InterBase</secondary>
10870 </indexterm>
10871 If any MySQL, PostgreSQL, Oracle, or InterBase lookups are used, the
10872 <option>mysql_servers</option>, <option>pgsql_servers</option>, <option>oracle_servers</option>, or <option>ibase_servers</option>
10873 option (as appropriate) must be set to a colon-separated list of server
10874 information.
10875 (For MySQL and PostgreSQL only, the global option need not be set if all
10876 queries contain their own server information &ndash; see section
10877 <xref linkend="SECTspeserque"/>.) Each item in the list is a slash-separated list of four
10878 items: host name, database name, user name, and password. In the case of
10879 Oracle, the host name field is used for the <quote>service name</quote>, and the database
10880 name field is not used and should be empty. For example:
10881 </para>
10882 <literallayout class="monospaced">
10883 hide oracle_servers = oracle.plc.example//userx/abcdwxyz
10884 </literallayout>
10885 <para>
10886 Because password data is sensitive, you should always precede the setting with
10887 <quote>hide</quote>, to prevent non-admin users from obtaining the setting via the <option>-bP</option>
10888 option. Here is an example where two MySQL servers are listed:
10889 </para>
10890 <literallayout class="monospaced">
10891 hide mysql_servers = localhost/users/root/secret:\
10892                      otherhost/users/root/othersecret
10893 </literallayout>
10894 <para>
10895 For MySQL and PostgreSQL, a host may be specified as &lt;<emphasis>name</emphasis>&gt;:&lt;<emphasis>port</emphasis>&gt; but
10896 because this is a colon-separated list, the colon has to be doubled. For each
10897 query, these parameter groups are tried in order until a connection is made and
10898 a query is successfully processed. The result of a query may be that no data is
10899 found, but that is still a successful query. In other words, the list of
10900 servers provides a backup facility, not a list of different places to look.
10901 </para>
10902 <para>
10903 The <option>quote_mysql</option>, <option>quote_pgsql</option>, and <option>quote_oracle</option> expansion operators
10904 convert newline, tab, carriage return, and backspace to \n, \t, \r, and \b
10905 respectively, and the characters single-quote, double-quote, and backslash
10906 itself are escaped with backslashes. The <option>quote_pgsql</option> expansion operator, in
10907 addition, escapes the percent and underscore characters. This cannot be done
10908 for MySQL because these escapes are not recognized in contexts where these
10909 characters are not special.
10910 </para>
10911 </section>
10912 <section id="SECTspeserque">
10913 <title>Specifying the server in the query</title>
10914 <para>
10915 For MySQL and PostgreSQL lookups (but not currently for Oracle and InterBase),
10916 it is possible to specify a list of servers with an individual query. This is
10917 done by starting the query with
10918 </para>
10919 <literallayout>
10920 <literal>servers=</literal><emphasis>server1:server2:server3:...</emphasis><literal>;</literal>
10921 </literallayout>
10922 <para>
10923 Each item in the list may take one of two forms:
10924 </para>
10925 <orderedlist numeration="arabic">
10926 <listitem>
10927 <para>
10928 If it contains no slashes it is assumed to be just a host name. The appropriate
10929 global option (<option>mysql_servers</option> or <option>pgsql_servers</option>) is searched for a host
10930 of the same name, and the remaining parameters (database, user, password) are
10931 taken from there.
10932 </para>
10933 </listitem>
10934 <listitem>
10935 <para>
10936 If it contains any slashes, it is taken as a complete parameter set.
10937 </para>
10938 </listitem>
10939 </orderedlist>
10940 <para>
10941 The list of servers is used in exactly the same way as the global list.
10942 Once a connection to a server has happened and a query has been
10943 successfully executed, processing of the lookup ceases.
10944 </para>
10945 <para>
10946 This feature is intended for use in master/slave situations where updates
10947 are occurring and you want to update the master rather than a slave. If the
10948 master is in the list as a backup for reading, you might have a global setting
10949 like this:
10950 </para>
10951 <literallayout class="monospaced">
10952 mysql_servers = slave1/db/name/pw:\
10953                 slave2/db/name/pw:\
10954                 master/db/name/pw
10955 </literallayout>
10956 <para>
10957 In an updating lookup, you could then write:
10958 </para>
10959 <literallayout class="monospaced">
10960 ${lookup mysql{servers=master; UPDATE ...} }
10961 </literallayout>
10962 <para>
10963 That query would then be sent only to the master server. If, on the other hand,
10964 the master is not to be used for reading, and so is not present in the global
10965 option, you can still update it by a query of this form:
10966 </para>
10967 <literallayout class="monospaced">
10968 ${lookup pgsql{servers=master/db/name/pw; UPDATE ...} }
10969 </literallayout>
10970 </section>
10971 <section id="SECID73">
10972 <title>Special MySQL features</title>
10973 <para>
10974 For MySQL, an empty host name or the use of <quote>localhost</quote> in <option>mysql_servers</option>
10975 causes a connection to the server on the local host by means of a Unix domain
10976 socket. An alternate socket can be specified in parentheses. The full syntax of
10977 each item in <option>mysql_servers</option> is:
10978 </para>
10979 <literallayout>
10980 &lt;<emphasis>hostname</emphasis>&gt;::&lt;<emphasis>port</emphasis>&gt;(&lt;<emphasis>socket name</emphasis>&gt;)/&lt;<emphasis>database</emphasis>&gt;/&lt;<emphasis>user</emphasis>&gt;/&lt;<emphasis>password</emphasis>&gt;
10981 </literallayout>
10982 <para>
10983 Any of the three sub-parts of the first field can be omitted. For normal use on
10984 the local host it can be left blank or set to just <quote>localhost</quote>.
10985 </para>
10986 <para>
10987 No database need be supplied &ndash; but if it is absent here, it must be given in
10988 the queries.
10989 </para>
10990 <para>
10991 If a MySQL query is issued that does not request any data (an insert, update,
10992 or delete command), the result of the lookup is the number of rows affected.
10993 </para>
10994 <para>
10995 <emphasis role="bold">Warning</emphasis>: This can be misleading. If an update does not actually change
10996 anything (for example, setting a field to the value it already has), the result
10997 is zero because no rows are affected.
10998 </para>
10999 </section>
11000 <section id="SECID74">
11001 <title>Special PostgreSQL features</title>
11002 <para>
11003 PostgreSQL lookups can also use Unix domain socket connections to the database.
11004 This is usually faster and costs less CPU time than a TCP/IP connection.
11005 However it can be used only if the mail server runs on the same machine as the
11006 database server. A configuration line for PostgreSQL via Unix domain sockets
11007 looks like this:
11008 </para>
11009 <literallayout class="monospaced">
11010 hide pgsql_servers = (/tmp/.s.PGSQL.5432)/db/user/password : ...
11011 </literallayout>
11012 <para>
11013 In other words, instead of supplying a host name, a path to the socket is
11014 given. The path name is enclosed in parentheses so that its slashes aren&#x2019;t
11015 visually confused with the delimiters for the other server parameters.
11016 </para>
11017 <para>
11018 If a PostgreSQL query is issued that does not request any data (an insert,
11019 update, or delete command), the result of the lookup is the number of rows
11020 affected.
11021 </para>
11022 </section>
11023 <section id="SECTsqlite">
11024 <title>More about SQLite</title>
11025 <para>
11026 <indexterm role="concept">
11027 <primary>lookup</primary>
11028 <secondary>SQLite</secondary>
11029 </indexterm>
11030 <indexterm role="concept">
11031 <primary>sqlite lookup type</primary>
11032 </indexterm>
11033 SQLite is different to the other SQL lookups because a file name is required in
11034 addition to the SQL query. An SQLite database is a single file, and there is no
11035 daemon as in the other SQL databases. The interface to Exim requires the name
11036 of the file, as an absolute path, to be given at the start of the query. It is
11037 separated from the query by white space. This means that the path name cannot
11038 contain white space. Here is a lookup expansion example:
11039 </para>
11040 <literallayout class="monospaced">
11041 ${lookup sqlite {/some/thing/sqlitedb \
11042   select name from aliases where id='userx';}}
11043 </literallayout>
11044 <para>
11045 In a list, the syntax is similar. For example:
11046 </para>
11047 <literallayout class="monospaced">
11048 domainlist relay_domains = sqlite;/some/thing/sqlitedb \
11049    select * from relays where ip='$sender_host_address';
11050 </literallayout>
11051 <para>
11052 The only character affected by the <option>quote_sqlite</option> operator is a single
11053 quote, which it doubles.
11054 </para>
11055 <para>
11056 The SQLite library handles multiple simultaneous accesses to the database
11057 internally. Multiple readers are permitted, but only one process can
11058 update at once. Attempts to access the database while it is being updated
11059 are rejected after a timeout period, during which the SQLite library
11060 waits for the lock to be released. In Exim, the default timeout is set
11061 to 5 seconds, but it can be changed by means of the <option>sqlite_lock_timeout</option>
11062 option.
11063 <indexterm role="concept" startref="IIDfidalo1" class="endofrange"/>
11064 <indexterm role="concept" startref="IIDfidalo2" class="endofrange"/>
11065 </para>
11066 </section>
11067 </chapter>
11068
11069 <chapter id="CHAPdomhosaddlists">
11070 <title>Domain, host, address, and local part lists</title>
11071 <titleabbrev>Domain, host, and address lists</titleabbrev>
11072 <para>
11073 <indexterm role="concept" id="IIDdohoadli" class="startofrange">
11074 <primary>lists of domains; hosts; etc.</primary>
11075 </indexterm>
11076 A number of Exim configuration options contain lists of domains, hosts,
11077 email addresses, or local parts. For example, the <option>hold_domains</option> option
11078 contains a list of domains whose delivery is currently suspended. These lists
11079 are also used as data in ACL statements (see chapter <xref linkend="CHAPACL"/>), and as
11080 arguments to expansion conditions such as <option>match_domain</option>.
11081 </para>
11082 <para>
11083 Each item in one of these lists is a pattern to be matched against a domain,
11084 host, email address, or local part, respectively. In the sections below, the
11085 different types of pattern for each case are described, but first we cover some
11086 general facilities that apply to all four kinds of list.
11087 </para>
11088 <section id="SECID75">
11089 <title>Expansion of lists</title>
11090 <para>
11091 <indexterm role="concept">
11092 <primary>expansion</primary>
11093 <secondary>of lists</secondary>
11094 </indexterm>
11095 Each list is expanded as a single string before it is used. The result of
11096 expansion must be a list, possibly containing empty items, which is split up
11097 into separate items for matching. By default, colon is the separator character,
11098 but this can be varied if necessary. See sections <xref linkend="SECTlistconstruct"/> and
11099 <xref linkend="SECTempitelis"/> for details of the list syntax; the second of these
11100 discusses the way to specify empty list items.
11101 </para>
11102 <para>
11103 If the string expansion is forced to fail, Exim behaves as if the item it is
11104 testing (domain, host, address, or local part) is not in the list. Other
11105 expansion failures cause temporary errors.
11106 </para>
11107 <para>
11108 If an item in a list is a regular expression, backslashes, dollars and possibly
11109 other special characters in the expression must be protected against
11110 misinterpretation by the string expander. The easiest way to do this is to use
11111 the <literal>\N</literal> expansion feature to indicate that the contents of the regular
11112 expression should not be expanded. For example, in an ACL you might have:
11113 </para>
11114 <literallayout class="monospaced">
11115 deny senders = \N^\d{8}\w@.*\.baddomain\.example$\N : \
11116                ${lookup{$domain}lsearch{/badsenders/bydomain}}
11117 </literallayout>
11118 <para>
11119 The first item is a regular expression that is protected from expansion by
11120 <literal>\N</literal>, whereas the second uses the expansion to obtain a list of unwanted
11121 senders based on the receiving domain.
11122 </para>
11123 </section>
11124 <section id="SECID76">
11125 <title>Negated items in lists</title>
11126 <para>
11127 <indexterm role="concept">
11128 <primary>list</primary>
11129 <secondary>negation</secondary>
11130 </indexterm>
11131 <indexterm role="concept">
11132 <primary>negation</primary>
11133 <secondary>in lists</secondary>
11134 </indexterm>
11135 Items in a list may be positive or negative. Negative items are indicated by a
11136 leading exclamation mark, which may be followed by optional white space. A list
11137 defines a set of items (domains, etc). When Exim processes one of these lists,
11138 it is trying to find out whether a domain, host, address, or local part
11139 (respectively) is in the set that is defined by the list. It works like this:
11140 </para>
11141 <para>
11142 The list is scanned from left to right. If a positive item is matched, the
11143 subject that is being checked is in the set; if a negative item is matched, the
11144 subject is not in the set. If the end of the list is reached without the
11145 subject having matched any of the patterns, it is in the set if the last item
11146 was a negative one, but not if it was a positive one. For example, the list in
11147 </para>
11148 <literallayout class="monospaced">
11149 domainlist relay_domains = !a.b.c : *.b.c
11150 </literallayout>
11151 <para>
11152 matches any domain ending in <emphasis>.b.c</emphasis> except for <emphasis>a.b.c</emphasis>. Domains that match
11153 neither <emphasis>a.b.c</emphasis> nor <emphasis>*.b.c</emphasis> do not match, because the last item in the
11154 list is positive. However, if the setting were
11155 </para>
11156 <literallayout class="monospaced">
11157 domainlist relay_domains = !a.b.c
11158 </literallayout>
11159 <para>
11160 then all domains other than <emphasis>a.b.c</emphasis> would match because the last item in the
11161 list is negative. In other words, a list that ends with a negative item behaves
11162 as if it had an extra item <literal>:*</literal> on the end.
11163 </para>
11164 <para>
11165 Another way of thinking about positive and negative items in lists is to read
11166 the connector as <quote>or</quote> after a positive item and as <quote>and</quote> after a negative
11167 item.
11168 </para>
11169 </section>
11170 <section id="SECTfilnamlis">
11171 <title>File names in lists</title>
11172 <para>
11173 <indexterm role="concept">
11174 <primary>list</primary>
11175 <secondary>file name in</secondary>
11176 </indexterm>
11177 If an item in a domain, host, address, or local part list is an absolute file
11178 name (beginning with a slash character), each line of the file is read and
11179 processed as if it were an independent item in the list, except that further
11180 file names are not allowed,
11181 and no expansion of the data from the file takes place.
11182 Empty lines in the file are ignored, and the file may also contain comment
11183 lines:
11184 </para>
11185 <itemizedlist>
11186 <listitem>
11187 <para>
11188 For domain and host lists, if a # character appears anywhere in a line of the
11189 file, it and all following characters are ignored.
11190 </para>
11191 </listitem>
11192 <listitem>
11193 <para>
11194 Because local parts may legitimately contain # characters, a comment in an
11195 address list or local part list file is recognized only if # is preceded by
11196 white space or the start of the line. For example:
11197 </para>
11198 <literallayout class="monospaced">
11199 not#comment@x.y.z   # but this is a comment
11200 </literallayout>
11201 </listitem>
11202 </itemizedlist>
11203 <para>
11204 Putting a file name in a list has the same effect as inserting each line of the
11205 file as an item in the list (blank lines and comments excepted). However, there
11206 is one important difference: the file is read each time the list is processed,
11207 so if its contents vary over time, Exim&#x2019;s behaviour changes.
11208 </para>
11209 <para>
11210 If a file name is preceded by an exclamation mark, the sense of any match
11211 within the file is inverted. For example, if
11212 </para>
11213 <literallayout class="monospaced">
11214 hold_domains = !/etc/nohold-domains
11215 </literallayout>
11216 <para>
11217 and the file contains the lines
11218 </para>
11219 <literallayout class="monospaced">
11220 !a.b.c
11221 *.b.c
11222 </literallayout>
11223 <para>
11224 then <emphasis>a.b.c</emphasis> is in the set of domains defined by <option>hold_domains</option>, whereas
11225 any domain matching <literal>*.b.c</literal> is not.
11226 </para>
11227 </section>
11228 <section id="SECID77">
11229 <title>An lsearch file is not an out-of-line list</title>
11230 <para>
11231 As will be described in the sections that follow, lookups can be used in lists
11232 to provide indexed methods of checking list membership. There has been some
11233 confusion about the way <command>lsearch</command> lookups work in lists. Because
11234 an <command>lsearch</command> file contains plain text and is scanned sequentially, it is
11235 sometimes thought that it is allowed to contain wild cards and other kinds of
11236 non-constant pattern. This is not the case. The keys in an <command>lsearch</command> file are
11237 always fixed strings, just as for any other single-key lookup type.
11238 </para>
11239 <para>
11240 If you want to use a file to contain wild-card patterns that form part of a
11241 list, just give the file name on its own, without a search type, as described
11242 in the previous section. You could also use the <command>wildlsearch</command> or
11243 <command>nwildlsearch</command>, but there is no advantage in doing this.
11244 </para>
11245 </section>
11246 <section id="SECTnamedlists">
11247 <title>Named lists</title>
11248 <para>
11249 <indexterm role="concept">
11250 <primary>named lists</primary>
11251 </indexterm>
11252 <indexterm role="concept">
11253 <primary>list</primary>
11254 <secondary>named</secondary>
11255 </indexterm>
11256 A list of domains, hosts, email addresses, or local parts can be given a name
11257 which is then used to refer to the list elsewhere in the configuration. This is
11258 particularly convenient if the same list is required in several different
11259 places. It also allows lists to be given meaningful names, which can improve
11260 the readability of the configuration. For example, it is conventional to define
11261 a domain list called <emphasis>local_domains</emphasis> for all the domains that are handled
11262 locally on a host, using a configuration line such as
11263 </para>
11264 <literallayout class="monospaced">
11265 domainlist local_domains = localhost:my.dom.example
11266 </literallayout>
11267 <para>
11268 Named lists are referenced by giving their name preceded by a plus sign, so,
11269 for example, a router that is intended to handle local domains would be
11270 configured with the line
11271 </para>
11272 <literallayout class="monospaced">
11273 domains = +local_domains
11274 </literallayout>
11275 <para>
11276 The first router in a configuration is often one that handles all domains
11277 except the local ones, using a configuration with a negated item like this:
11278 </para>
11279 <literallayout class="monospaced">
11280 dnslookup:
11281   driver = dnslookup
11282   domains = ! +local_domains
11283   transport = remote_smtp
11284   no_more
11285 </literallayout>
11286 <para>
11287 The four kinds of named list are created by configuration lines starting with
11288 the words <option>domainlist</option>, <option>hostlist</option>, <option>addresslist</option>, or <option>localpartlist</option>,
11289 respectively. Then there follows the name that you are defining, followed by an
11290 equals sign and the list itself. For example:
11291 </para>
11292 <literallayout class="monospaced">
11293 hostlist    relay_hosts = 192.168.23.0/24 : my.friend.example
11294 addresslist bad_senders = cdb;/etc/badsenders
11295 </literallayout>
11296 <para>
11297 A named list may refer to other named lists:
11298 </para>
11299 <literallayout class="monospaced">
11300 domainlist  dom1 = first.example : second.example
11301 domainlist  dom2 = +dom1 : third.example
11302 domainlist  dom3 = fourth.example : +dom2 : fifth.example
11303 </literallayout>
11304 <para>
11305 <emphasis role="bold">Warning</emphasis>: If the last item in a referenced list is a negative one, the
11306 effect may not be what you intended, because the negation does not propagate
11307 out to the higher level. For example, consider:
11308 </para>
11309 <literallayout class="monospaced">
11310 domainlist  dom1 = !a.b
11311 domainlist  dom2 = +dom1 : *.b
11312 </literallayout>
11313 <para>
11314 The second list specifies <quote>either in the <option>dom1</option> list or <emphasis>*.b</emphasis></quote>. The first
11315 list specifies just <quote>not <emphasis>a.b</emphasis></quote>, so the domain <emphasis>x.y</emphasis> matches it. That
11316 means it matches the second list as well. The effect is not the same as
11317 </para>
11318 <literallayout class="monospaced">
11319 domainlist  dom2 = !a.b : *.b
11320 </literallayout>
11321 <para>
11322 where <emphasis>x.y</emphasis> does not match. It&#x2019;s best to avoid negation altogether in
11323 referenced lists if you can.
11324 </para>
11325 <para>
11326 Named lists may have a performance advantage. When Exim is routing an
11327 address or checking an incoming message, it caches the result of tests on named
11328 lists. So, if you have a setting such as
11329 </para>
11330 <literallayout class="monospaced">
11331 domains = +local_domains
11332 </literallayout>
11333 <para>
11334 on several of your routers
11335 or in several ACL statements,
11336 the actual test is done only for the first one. However, the caching works only
11337 if there are no expansions within the list itself or any sublists that it
11338 references. In other words, caching happens only for lists that are known to be
11339 the same each time they are referenced.
11340 </para>
11341 <para>
11342 By default, there may be up to 16 named lists of each type. This limit can be
11343 extended by changing a compile-time variable. The use of domain and host lists
11344 is recommended for concepts such as local domains, relay domains, and relay
11345 hosts. The default configuration is set up like this.
11346 </para>
11347 </section>
11348 <section id="SECID78">
11349 <title>Named lists compared with macros</title>
11350 <para>
11351 <indexterm role="concept">
11352 <primary>list</primary>
11353 <secondary>named compared with macro</secondary>
11354 </indexterm>
11355 <indexterm role="concept">
11356 <primary>macro</primary>
11357 <secondary>compared with named list</secondary>
11358 </indexterm>
11359 At first sight, named lists might seem to be no different from macros in the
11360 configuration file. However, macros are just textual substitutions. If you
11361 write
11362 </para>
11363 <literallayout class="monospaced">
11364 ALIST = host1 : host2
11365 auth_advertise_hosts = !ALIST
11366 </literallayout>
11367 <para>
11368 it probably won&#x2019;t do what you want, because that is exactly the same as
11369 </para>
11370 <literallayout class="monospaced">
11371 auth_advertise_hosts = !host1 : host2
11372 </literallayout>
11373 <para>
11374 Notice that the second host name is not negated. However, if you use a host
11375 list, and write
11376 </para>
11377 <literallayout class="monospaced">
11378 hostlist alist = host1 : host2
11379 auth_advertise_hosts = ! +alist
11380 </literallayout>
11381 <para>
11382 the negation applies to the whole list, and so that is equivalent to
11383 </para>
11384 <literallayout class="monospaced">
11385 auth_advertise_hosts = !host1 : !host2
11386 </literallayout>
11387 </section>
11388 <section id="SECID79">
11389 <title>Named list caching</title>
11390 <para>
11391 <indexterm role="concept">
11392 <primary>list</primary>
11393 <secondary>caching of named</secondary>
11394 </indexterm>
11395 <indexterm role="concept">
11396 <primary>caching</primary>
11397 <secondary>named lists</secondary>
11398 </indexterm>
11399 While processing a message, Exim caches the result of checking a named list if
11400 it is sure that the list is the same each time. In practice, this means that
11401 the cache operates only if the list contains no $ characters, which guarantees
11402 that it will not change when it is expanded. Sometimes, however, you may have
11403 an expanded list that you know will be the same each time within a given
11404 message. For example:
11405 </para>
11406 <literallayout class="monospaced">
11407 domainlist special_domains = \
11408            ${lookup{$sender_host_address}cdb{/some/file}}
11409 </literallayout>
11410 <para>
11411 This provides a list of domains that depends only on the sending host&#x2019;s IP
11412 address. If this domain list is referenced a number of times (for example,
11413 in several ACL lines, or in several routers) the result of the check is not
11414 cached by default, because Exim does not know that it is going to be the
11415 same list each time.
11416 </para>
11417 <para>
11418 By appending <literal>_cache</literal> to <literal>domainlist</literal> you can tell Exim to go ahead and
11419 cache the result anyway. For example:
11420 </para>
11421 <literallayout class="monospaced">
11422 domainlist_cache special_domains = ${lookup{...
11423 </literallayout>
11424 <para>
11425 If you do this, you should be absolutely sure that caching is going to do
11426 the right thing in all cases. When in doubt, leave it out.
11427 </para>
11428 </section>
11429 <section id="SECTdomainlist">
11430 <title>Domain lists</title>
11431 <para>
11432 <indexterm role="concept">
11433 <primary>domain list</primary>
11434 <secondary>patterns for</secondary>
11435 </indexterm>
11436 <indexterm role="concept">
11437 <primary>list</primary>
11438 <secondary>domain list</secondary>
11439 </indexterm>
11440 Domain lists contain patterns that are to be matched against a mail domain.
11441 The following types of item may appear in domain lists:
11442 </para>
11443 <itemizedlist>
11444 <listitem>
11445 <para>
11446 <indexterm role="concept">
11447 <primary>primary host name</primary>
11448 </indexterm>
11449 <indexterm role="concept">
11450 <primary>host name</primary>
11451 <secondary>matched in domain list</secondary>
11452 </indexterm>
11453 <indexterm role="option">
11454 <primary><option>primary_hostname</option></primary>
11455 </indexterm>
11456 <indexterm role="concept">
11457 <primary>domain list</primary>
11458 <secondary>matching primary host name</secondary>
11459 </indexterm>
11460 <indexterm role="concept">
11461 <primary>@ in a domain list</primary>
11462 </indexterm>
11463 If a pattern consists of a single @ character, it matches the local host name,
11464 as set by the <option>primary_hostname</option> option (or defaulted). This makes it
11465 possible to use the same configuration file on several different hosts that
11466 differ only in their names.
11467 </para>
11468 </listitem>
11469 <listitem>
11470 <para>
11471 <indexterm role="concept">
11472 <primary>@[] in a domain list</primary>
11473 </indexterm>
11474 <indexterm role="concept">
11475 <primary>domain list</primary>
11476 <secondary>matching local IP interfaces</secondary>
11477 </indexterm>
11478 <indexterm role="concept">
11479 <primary>domain literal</primary>
11480 </indexterm>
11481 If a pattern consists of the string <literal>@[]</literal> it matches an IP address enclosed
11482 in square brackets (as in an email address that contains a domain literal), but
11483 only if that IP address is recognized as local for email routing purposes. The
11484 <option>local_interfaces</option> and <option>extra_local_interfaces</option> options can be used to
11485 control which of a host&#x2019;s several IP addresses are treated as local.
11486 In today&#x2019;s Internet, the use of domain literals is controversial.
11487 </para>
11488 </listitem>
11489 <listitem>
11490 <para>
11491 <indexterm role="concept">
11492 <primary>@mx_any</primary>
11493 </indexterm>
11494 <indexterm role="concept">
11495 <primary>@mx_primary</primary>
11496 </indexterm>
11497 <indexterm role="concept">
11498 <primary>@mx_secondary</primary>
11499 </indexterm>
11500 <indexterm role="concept">
11501 <primary>domain list</primary>
11502 <secondary>matching MX pointers to local host</secondary>
11503 </indexterm>
11504 If a pattern consists of the string <literal>@mx_any</literal> it matches any domain that
11505 has an MX record pointing to the local host or to any host that is listed in
11506 <indexterm role="option">
11507 <primary><option>hosts_treat_as_local</option></primary>
11508 </indexterm>
11509 <option>hosts_treat_as_local</option>. The items <literal>@mx_primary</literal> and <literal>@mx_secondary</literal>
11510 are similar, except that the first matches only when a primary MX target is the
11511 local host, and the second only when no primary MX target is the local host,
11512 but a secondary MX target is. <quote>Primary</quote> means an MX record with the lowest
11513 preference value &ndash; there may of course be more than one of them.
11514 </para>
11515 <para>
11516 The MX lookup that takes place when matching a pattern of this type is
11517 performed with the resolver options for widening names turned off. Thus, for
11518 example, a single-component domain will <emphasis>not</emphasis> be expanded by adding the
11519 resolver&#x2019;s default domain. See the <option>qualify_single</option> and <option>search_parents</option>
11520 options of the <command>dnslookup</command> router for a discussion of domain widening.
11521 </para>
11522 <para>
11523 Sometimes you may want to ignore certain IP addresses when using one of these
11524 patterns. You can specify this by following the pattern with <literal>/ignore=</literal>&lt;<emphasis>ip
11525 list</emphasis>&gt;, where &lt;<emphasis>ip list</emphasis>&gt; is a list of IP addresses. These addresses are
11526 ignored when processing the pattern (compare the <option>ignore_target_hosts</option> option
11527 on a router). For example:
11528 </para>
11529 <literallayout class="monospaced">
11530 domains = @mx_any/ignore=127.0.0.1
11531 </literallayout>
11532 <para>
11533 This example matches any domain that has an MX record pointing to one of
11534 the local host&#x2019;s IP addresses other than 127.0.0.1.
11535 </para>
11536 <para>
11537 The list of IP addresses is in fact processed by the same code that processes
11538 host lists, so it may contain CIDR-coded network specifications and it may also
11539 contain negative items.
11540 </para>
11541 <para>
11542 Because the list of IP addresses is a sublist within a domain list, you have to
11543 be careful about delimiters if there is more than one address. Like any other
11544 list, the default delimiter can be changed. Thus, you might have:
11545 </para>
11546 <literallayout class="monospaced">
11547 domains = @mx_any/ignore=&lt;;127.0.0.1;0.0.0.0 : \
11548           an.other.domain : ...
11549 </literallayout>
11550 <para>
11551 so that the sublist uses semicolons for delimiters. When IPv6 addresses are
11552 involved, it is easiest to change the delimiter for the main list as well:
11553 </para>
11554 <literallayout class="monospaced">
11555 domains = &lt;? @mx_any/ignore=&lt;;127.0.0.1;::1 ? \
11556           an.other.domain ? ...
11557 </literallayout>
11558 </listitem>
11559 <listitem>
11560 <para>
11561 <indexterm role="concept">
11562 <primary>asterisk</primary>
11563 <secondary>in domain list</secondary>
11564 </indexterm>
11565 <indexterm role="concept">
11566 <primary>domain list</primary>
11567 <secondary>asterisk in</secondary>
11568 </indexterm>
11569 <indexterm role="concept">
11570 <primary>domain list</primary>
11571 <secondary>matching <quote>ends with</quote></secondary>
11572 </indexterm>
11573 If a pattern starts with an asterisk, the remaining characters of the pattern
11574 are compared with the terminating characters of the domain. The use of <quote>*</quote> in
11575 domain lists differs from its use in partial matching lookups. In a domain
11576 list, the character following the asterisk need not be a dot, whereas partial
11577 matching works only in terms of dot-separated components. For example, a domain
11578 list item such as <literal>*key.ex</literal> matches <emphasis>donkey.ex</emphasis> as well as
11579 <emphasis>cipher.key.ex</emphasis>.
11580 </para>
11581 </listitem>
11582 <listitem>
11583 <para>
11584 <indexterm role="concept">
11585 <primary>regular expressions</primary>
11586 <secondary>in domain list</secondary>
11587 </indexterm>
11588 <indexterm role="concept">
11589 <primary>domain list</primary>
11590 <secondary>matching regular expression</secondary>
11591 </indexterm>
11592 If a pattern starts with a circumflex character, it is treated as a regular
11593 expression, and matched against the domain using a regular expression matching
11594 function. The circumflex is treated as part of the regular expression.
11595 Email domains are case-independent, so this regular expression match is by
11596 default case-independent, but you can make it case-dependent by starting it
11597 with <literal>(?-i)</literal>. References to descriptions of the syntax of regular expressions
11598 are given in chapter <xref linkend="CHAPregexp"/>.
11599 </para>
11600 <para>
11601 <emphasis role="bold">Warning</emphasis>: Because domain lists are expanded before being processed, you
11602 must escape any backslash and dollar characters in the regular expression, or
11603 use the special <literal>\N</literal> sequence (see chapter <xref linkend="CHAPexpand"/>) to specify that
11604 it is not to be expanded (unless you really do want to build a regular
11605 expression by expansion, of course).
11606 </para>
11607 </listitem>
11608 <listitem>
11609 <para>
11610 <indexterm role="concept">
11611 <primary>lookup</primary>
11612 <secondary>in domain list</secondary>
11613 </indexterm>
11614 <indexterm role="concept">
11615 <primary>domain list</primary>
11616 <secondary>matching by lookup</secondary>
11617 </indexterm>
11618 If a pattern starts with the name of a single-key lookup type followed by a
11619 semicolon (for example, <quote>dbm;</quote> or <quote>lsearch;</quote>), the remainder of the pattern
11620 must be a file name in a suitable format for the lookup type. For example, for
11621 <quote>cdb;</quote> it must be an absolute path:
11622 </para>
11623 <literallayout class="monospaced">
11624 domains = cdb;/etc/mail/local_domains.cdb
11625 </literallayout>
11626 <para>
11627 The appropriate type of lookup is done on the file using the domain name as the
11628 key. In most cases, the data that is looked up is not used; Exim is interested
11629 only in whether or not the key is present in the file. However, when a lookup
11630 is used for the <option>domains</option> option on a router
11631 or a <option>domains</option> condition in an ACL statement, the data is preserved in the
11632 <varname>$domain_data</varname> variable and can be referred to in other router options or
11633 other statements in the same ACL.
11634 </para>
11635 </listitem>
11636 <listitem>
11637 <para>
11638 Any of the single-key lookup type names may be preceded by
11639 <literal>partial</literal>&lt;<emphasis>n</emphasis>&gt;<literal>-</literal>, where the &lt;<emphasis>n</emphasis>&gt; is optional, for example,
11640 </para>
11641 <literallayout class="monospaced">
11642 domains = partial-dbm;/partial/domains
11643 </literallayout>
11644 <para>
11645 This causes partial matching logic to be invoked; a description of how this
11646 works is given in section <xref linkend="SECTpartiallookup"/>.
11647 </para>
11648 </listitem>
11649 <listitem>
11650 <para>
11651 <indexterm role="concept">
11652 <primary>asterisk</primary>
11653 <secondary>in lookup type</secondary>
11654 </indexterm>
11655 Any of the single-key lookup types may be followed by an asterisk. This causes
11656 a default lookup for a key consisting of a single asterisk to be done if the
11657 original lookup fails. This is not a useful feature when using a domain list to
11658 select particular domains (because any domain would match), but it might have
11659 value if the result of the lookup is being used via the <varname>$domain_data</varname>
11660 expansion variable.
11661 </para>
11662 </listitem>
11663 <listitem>
11664 <para>
11665 If the pattern starts with the name of a query-style lookup type followed by a
11666 semicolon (for example, <quote>nisplus;</quote> or <quote>ldap;</quote>), the remainder of the
11667 pattern must be an appropriate query for the lookup type, as described in
11668 chapter <xref linkend="CHAPfdlookup"/>. For example:
11669 </para>
11670 <literallayout class="monospaced">
11671 hold_domains = mysql;select domain from holdlist \
11672   where domain = '$domain';
11673 </literallayout>
11674 <para>
11675 In most cases, the data that is looked up is not used (so for an SQL query, for
11676 example, it doesn&#x2019;t matter what field you select). Exim is interested only in
11677 whether or not the query succeeds. However, when a lookup is used for the
11678 <option>domains</option> option on a router, the data is preserved in the <varname>$domain_data</varname>
11679 variable and can be referred to in other options.
11680 </para>
11681 </listitem>
11682 <listitem>
11683 <para>
11684 <indexterm role="concept">
11685 <primary>domain list</primary>
11686 <secondary>matching literal domain name</secondary>
11687 </indexterm>
11688 If none of the above cases apply, a caseless textual comparison is made
11689 between the pattern and the domain.
11690 </para>
11691 </listitem>
11692 </itemizedlist>
11693 <para>
11694 Here is an example that uses several different kinds of pattern:
11695 </para>
11696 <literallayout class="monospaced">
11697 domainlist funny_domains = \
11698   @ : \
11699   lib.unseen.edu : \
11700   *.foundation.fict.example : \
11701   \N^[1-2]\d{3}\.fict\.example$\N : \
11702   partial-dbm;/opt/data/penguin/book : \
11703   nis;domains.byname : \
11704   nisplus;[name=$domain,status=local],domains.org_dir
11705 </literallayout>
11706 <para>
11707 There are obvious processing trade-offs among the various matching modes. Using
11708 an asterisk is faster than a regular expression, and listing a few names
11709 explicitly probably is too. The use of a file or database lookup is expensive,
11710 but may be the only option if hundreds of names are required. Because the
11711 patterns are tested in order, it makes sense to put the most commonly matched
11712 patterns earlier.
11713 </para>
11714 </section>
11715 <section id="SECThostlist">
11716 <title>Host lists</title>
11717 <para>
11718 <indexterm role="concept">
11719 <primary>host list</primary>
11720 <secondary>patterns in</secondary>
11721 </indexterm>
11722 <indexterm role="concept">
11723 <primary>list</primary>
11724 <secondary>host list</secondary>
11725 </indexterm>
11726 Host lists are used to control what remote hosts are allowed to do. For
11727 example, some hosts may be allowed to use the local host as a relay, and some
11728 may be permitted to use the SMTP ETRN command. Hosts can be identified in
11729 two different ways, by name or by IP address. In a host list, some types of
11730 pattern are matched to a host name, and some are matched to an IP address.
11731 You need to be particularly careful with this when single-key lookups are
11732 involved, to ensure that the right value is being used as the key.
11733 </para>
11734 </section>
11735 <section id="SECID80">
11736 <title>Special host list patterns</title>
11737 <para>
11738 <indexterm role="concept">
11739 <primary>empty item in hosts list</primary>
11740 </indexterm>
11741 <indexterm role="concept">
11742 <primary>host list</primary>
11743 <secondary>empty string in</secondary>
11744 </indexterm>
11745 If a host list item is the empty string, it matches only when no remote host is
11746 involved. This is the case when a message is being received from a local
11747 process using SMTP on the standard input, that is, when a TCP/IP connection is
11748 not used.
11749 </para>
11750 <para>
11751 <indexterm role="concept">
11752 <primary>asterisk</primary>
11753 <secondary>in host list</secondary>
11754 </indexterm>
11755 The special pattern <quote>*</quote> in a host list matches any host or no host. Neither
11756 the IP address nor the name is actually inspected.
11757 </para>
11758 </section>
11759 <section id="SECThoslispatip">
11760 <title>Host list patterns that match by IP address</title>
11761 <para>
11762 <indexterm role="concept">
11763 <primary>host list</primary>
11764 <secondary>matching IP addresses</secondary>
11765 </indexterm>
11766 If an IPv4 host calls an IPv6 host and the call is accepted on an IPv6 socket,
11767 the incoming address actually appears in the IPv6 host as
11768 <literal>::ffff:</literal>&lt;<emphasis>v4address</emphasis>&gt;. When such an address is tested against a host
11769 list, it is converted into a traditional IPv4 address first. (Not all operating
11770 systems accept IPv4 calls on IPv6 sockets, as there have been some security
11771 concerns.)
11772 </para>
11773 <para>
11774 The following types of pattern in a host list check the remote host by
11775 inspecting its IP address:
11776 </para>
11777 <itemizedlist>
11778 <listitem>
11779 <para>
11780 If the pattern is a plain domain name (not a regular expression, not starting
11781 with *, not a lookup of any kind), Exim calls the operating system function
11782 to find the associated IP address(es). Exim uses the newer
11783 <function>getipnodebyname()</function> function when available, otherwise <function>gethostbyname()</function>.
11784 This typically causes a forward DNS lookup of the name. The result is compared
11785 with the IP address of the subject host.
11786 </para>
11787 <para>
11788 If there is a temporary problem (such as a DNS timeout) with the host name
11789 lookup, a temporary error occurs. For example, if the list is being used in an
11790 ACL condition, the ACL gives a <quote>defer</quote> response, usually leading to a
11791 temporary SMTP error code. If no IP address can be found for the host name,
11792 what happens is described in section <xref linkend="SECTbehipnot"/> below.
11793 </para>
11794 </listitem>
11795 <listitem>
11796 <para>
11797 <indexterm role="concept">
11798 <primary>@ in a host list</primary>
11799 </indexterm>
11800 If the pattern is <quote>@</quote>, the primary host name is substituted and used as a
11801 domain name, as just described.
11802 </para>
11803 </listitem>
11804 <listitem>
11805 <para>
11806 If the pattern is an IP address, it is matched against the IP address of the
11807 subject host. IPv4 addresses are given in the normal <quote>dotted-quad</quote> notation.
11808 IPv6 addresses can be given in colon-separated format, but the colons have to
11809 be doubled so as not to be taken as item separators when the default list
11810 separator is used. IPv6 addresses are recognized even when Exim is compiled
11811 without IPv6 support. This means that if they appear in a host list on an
11812 IPv4-only host, Exim will not treat them as host names. They are just addresses
11813 that can never match a client host.
11814 </para>
11815 </listitem>
11816 <listitem>
11817 <para>
11818 <indexterm role="concept">
11819 <primary>@[] in a host list</primary>
11820 </indexterm>
11821 If the pattern is <quote>@[]</quote>, it matches the IP address of any IP interface on
11822 the local host. For example, if the local host is an IPv4 host with one
11823 interface address 10.45.23.56, these two ACL statements have the same effect:
11824 </para>
11825 <literallayout class="monospaced">
11826 accept hosts = 127.0.0.1 : 10.45.23.56
11827 accept hosts = @[]
11828 </literallayout>
11829 </listitem>
11830 <listitem>
11831 <para>
11832 <indexterm role="concept">
11833 <primary>CIDR notation</primary>
11834 </indexterm>
11835 If the pattern is an IP address followed by a slash and a mask length (for
11836 example 10.11.42.0/24), it is matched against the IP address of the subject
11837 host under the given mask. This allows, an entire network of hosts to be
11838 included (or excluded) by a single item. The mask uses CIDR notation; it
11839 specifies the number of address bits that must match, starting from the most
11840 significant end of the address.
11841 </para>
11842 <para>
11843 <emphasis role="bold">Note</emphasis>: The mask is <emphasis>not</emphasis> a count of addresses, nor is it the high number
11844 of a range of addresses. It is the number of bits in the network portion of the
11845 address. The above example specifies a 24-bit netmask, so it matches all 256
11846 addresses in the 10.11.42.0 network. An item such as
11847 </para>
11848 <literallayout class="monospaced">
11849 192.168.23.236/31
11850 </literallayout>
11851 <para>
11852 matches just two addresses, 192.168.23.236 and 192.168.23.237. A mask value of
11853 32 for an IPv4 address is the same as no mask at all; just a single address
11854 matches.
11855 </para>
11856 <para>
11857 Here is another example which shows an IPv4 and an IPv6 network:
11858 </para>
11859 <literallayout class="monospaced">
11860 recipient_unqualified_hosts = 192.168.0.0/16: \
11861                               3ffe::ffff::836f::::/48
11862 </literallayout>
11863 <para>
11864 The doubling of list separator characters applies only when these items
11865 appear inline in a host list. It is not required when indirecting via a file.
11866 For example:
11867 </para>
11868 <literallayout class="monospaced">
11869 recipient_unqualified_hosts = /opt/exim/unqualnets
11870 </literallayout>
11871 <para>
11872 could make use of a file containing
11873 </para>
11874 <literallayout class="monospaced">
11875 172.16.0.0/12
11876 3ffe:ffff:836f::/48
11877 </literallayout>
11878 <para>
11879 to have exactly the same effect as the previous example. When listing IPv6
11880 addresses inline, it is usually more convenient to use the facility for
11881 changing separator characters. This list contains the same two networks:
11882 </para>
11883 <literallayout class="monospaced">
11884 recipient_unqualified_hosts = &lt;; 172.16.0.0/12; \
11885                                  3ffe:ffff:836f::/48
11886 </literallayout>
11887 <para>
11888 The separator is changed to semicolon by the leading <quote>&lt;;</quote> at the start of the
11889 list.
11890 </para>
11891 </listitem>
11892 </itemizedlist>
11893 </section>
11894 <section id="SECThoslispatsikey">
11895 <title>Host list patterns for single-key lookups by host address</title>
11896 <para>
11897 <indexterm role="concept">
11898 <primary>host list</primary>
11899 <secondary>lookup of IP address</secondary>
11900 </indexterm>
11901 When a host is to be identified by a single-key lookup of its complete IP
11902 address, the pattern takes this form:
11903 </para>
11904 <literallayout>
11905 <literal>net-&lt;</literal><emphasis>single-key-search-type</emphasis><literal>&gt;;&lt;</literal><emphasis>search-data</emphasis><literal>&gt;</literal>
11906 </literallayout>
11907 <para>
11908 For example:
11909 </para>
11910 <literallayout class="monospaced">
11911 hosts_lookup = net-cdb;/hosts-by-ip.db
11912 </literallayout>
11913 <para>
11914 The text form of the IP address of the subject host is used as the lookup key.
11915 IPv6 addresses are converted to an unabbreviated form, using lower case
11916 letters, with dots as separators because colon is the key terminator in
11917 <command>lsearch</command> files. [Colons can in fact be used in keys in <command>lsearch</command> files by
11918 quoting the keys, but this is a facility that was added later.] The data
11919 returned by the lookup is not used.
11920 </para>
11921 <para>
11922 <indexterm role="concept">
11923 <primary>IP address</primary>
11924 <secondary>masking</secondary>
11925 </indexterm>
11926 <indexterm role="concept">
11927 <primary>host list</primary>
11928 <secondary>masked IP address</secondary>
11929 </indexterm>
11930 Single-key lookups can also be performed using masked IP addresses, using
11931 patterns of this form:
11932 </para>
11933 <literallayout>
11934 <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>
11935 </literallayout>
11936 <para>
11937 For example:
11938 </para>
11939 <literallayout class="monospaced">
11940 net24-dbm;/networks.db
11941 </literallayout>
11942 <para>
11943 The IP address of the subject host is masked using &lt;<emphasis>number</emphasis>&gt; as the mask
11944 length. A textual string is constructed from the masked value, followed by the
11945 mask, and this is used as the lookup key. For example, if the host&#x2019;s IP address
11946 is 192.168.34.6, the key that is looked up for the above example is
11947 <quote>192.168.34.0/24</quote>.
11948 </para>
11949 <para>
11950 When an IPv6 address is converted to a string, dots are normally used instead
11951 of colons, so that keys in <command>lsearch</command> files need not contain colons (which
11952 terminate <command>lsearch</command> keys). This was implemented some time before the ability
11953 to quote keys was made available in <command>lsearch</command> files. However, the more
11954 recently implemented <command>iplsearch</command> files do require colons in IPv6 keys
11955 (notated using the quoting facility) so as to distinguish them from IPv4 keys.
11956 For this reason, when the lookup type is <command>iplsearch</command>, IPv6 addresses are
11957 converted using colons and not dots. In all cases, full, unabbreviated IPv6
11958 addresses are always used.
11959 </para>
11960 <para>
11961 Ideally, it would be nice to tidy up this anomalous situation by changing to
11962 colons in all cases, given that quoting is now available for <command>lsearch</command>.
11963 However, this would be an incompatible change that might break some existing
11964 configurations.
11965 </para>
11966 <para>
11967 <emphasis role="bold">Warning</emphasis>: Specifying <option>net32-</option> (for an IPv4 address) or <option>net128-</option> (for an
11968 IPv6 address) is not the same as specifying just <option>net-</option> without a number. In
11969 the former case the key strings include the mask value, whereas in the latter
11970 case the IP address is used on its own.
11971 </para>
11972 </section>
11973 <section id="SECThoslispatnam">
11974 <title>Host list patterns that match by host name</title>
11975 <para>
11976 <indexterm role="concept">
11977 <primary>host</primary>
11978 <secondary>lookup failures</secondary>
11979 </indexterm>
11980 <indexterm role="concept">
11981 <primary>unknown host name</primary>
11982 </indexterm>
11983 <indexterm role="concept">
11984 <primary>host list</primary>
11985 <secondary>matching host name</secondary>
11986 </indexterm>
11987 There are several types of pattern that require Exim to know the name of the
11988 remote host. These are either wildcard patterns or lookups by name. (If a
11989 complete hostname is given without any wildcarding, it is used to find an IP
11990 address to match against, as described in the section <xref linkend="SECThoslispatip"/>
11991 above.)
11992 </para>
11993 <para>
11994 If the remote host name is not already known when Exim encounters one of these
11995 patterns, it has to be found from the IP address.
11996 Although many sites on the Internet are conscientious about maintaining reverse
11997 DNS data for their hosts, there are also many that do not do this.
11998 Consequently, a name cannot always be found, and this may lead to unwanted
11999 effects. Take care when configuring host lists with wildcarded name patterns.
12000 Consider what will happen if a name cannot be found.
12001 </para>
12002 <para>
12003 Because of the problems of determining host names from IP addresses, matching
12004 against host names is not as common as matching against IP addresses.
12005 </para>
12006 <para>
12007 By default, in order to find a host name, Exim first does a reverse DNS lookup;
12008 if no name is found in the DNS, the system function (<function>gethostbyaddr()</function> or
12009 <function>getipnodebyaddr()</function> if available) is tried. The order in which these lookups
12010 are done can be changed by setting the <option>host_lookup_order</option> option. For
12011 security, once Exim has found one or more names, it looks up the IP addresses
12012 for these names and compares them with the IP address that it started with.
12013 Only those names whose IP addresses match are accepted. Any other names are
12014 discarded. If no names are left, Exim behaves as if the host name cannot be
12015 found. In the most common case there is only one name and one IP address.
12016 </para>
12017 <para>
12018 There are some options that control what happens if a host name cannot be
12019 found. These are described in section <xref linkend="SECTbehipnot"/> below.
12020 </para>
12021 <para>
12022 <indexterm role="concept">
12023 <primary>host</primary>
12024 <secondary>alias for</secondary>
12025 </indexterm>
12026 <indexterm role="concept">
12027 <primary>alias for host</primary>
12028 </indexterm>
12029 As a result of aliasing, hosts may have more than one name. When processing any
12030 of the following types of pattern, all the host&#x2019;s names are checked:
12031 </para>
12032 <itemizedlist>
12033 <listitem>
12034 <para>
12035 <indexterm role="concept">
12036 <primary>asterisk</primary>
12037 <secondary>in host list</secondary>
12038 </indexterm>
12039 If a pattern starts with <quote>*</quote> the remainder of the item must match the end of
12040 the host name. For example, <literal>*.b.c</literal> matches all hosts whose names end in
12041 <emphasis>.b.c</emphasis>. This special simple form is provided because this is a very common
12042 requirement. Other kinds of wildcarding require the use of a regular
12043 expression.
12044 </para>
12045 </listitem>
12046 <listitem>
12047 <para>
12048 <indexterm role="concept">
12049 <primary>regular expressions</primary>
12050 <secondary>in host list</secondary>
12051 </indexterm>
12052 <indexterm role="concept">
12053 <primary>host list</primary>
12054 <secondary>regular expression in</secondary>
12055 </indexterm>
12056 If the item starts with <quote>^</quote> it is taken to be a regular expression which is
12057 matched against the host name. Host names are case-independent, so this regular
12058 expression match is by default case-independent, but you can make it
12059 case-dependent by starting it with <literal>(?-i)</literal>. References to descriptions of the
12060 syntax of regular expressions are given in chapter <xref linkend="CHAPregexp"/>. For
12061 example,
12062 </para>
12063 <literallayout class="monospaced">
12064 ^(a|b)\.c\.d$
12065 </literallayout>
12066 <para>
12067 is a regular expression that matches either of the two hosts <emphasis>a.c.d</emphasis> or
12068 <emphasis>b.c.d</emphasis>. When a regular expression is used in a host list, you must take care
12069 that backslash and dollar characters are not misinterpreted as part of the
12070 string expansion. The simplest way to do this is to use <literal>\N</literal> to mark that
12071 part of the string as non-expandable. For example:
12072 </para>
12073 <literallayout class="monospaced">
12074 sender_unqualified_hosts = \N^(a|b)\.c\.d$\N : ....
12075 </literallayout>
12076 <para>
12077 <emphasis role="bold">Warning</emphasis>: If you want to match a complete host name, you must include the
12078 <literal>$</literal> terminating metacharacter in the regular expression, as in the above
12079 example. Without it, a match at the start of the host name is all that is
12080 required.
12081 </para>
12082 </listitem>
12083 </itemizedlist>
12084 </section>
12085 <section id="SECTbehipnot">
12086 <title>Behaviour when an IP address or name cannot be found</title>
12087 <para>
12088 <indexterm role="concept">
12089 <primary>host</primary>
12090 <secondary>lookup failures, permanent</secondary>
12091 </indexterm>
12092 While processing a host list, Exim may need to look up an IP address from a
12093 name (see section <xref linkend="SECThoslispatip"/>), or it may need to look up a host name
12094 from an IP address (see section <xref linkend="SECThoslispatnam"/>). In either case, the
12095 behaviour when it fails to find the information it is seeking is the same.
12096 </para>
12097 <para>
12098 <emphasis role="bold">Note</emphasis>: This section applies to permanent lookup failures. It does <emphasis>not</emphasis>
12099 apply to temporary DNS errors, whose handling is described in the next section.
12100 </para>
12101 <para>
12102 <indexterm role="concept">
12103 <primary><literal>+include_unknown</literal></primary>
12104 </indexterm>
12105 <indexterm role="concept">
12106 <primary><literal>+ignore_unknown</literal></primary>
12107 </indexterm>
12108 By default, Exim behaves as if the host does not match the list. This may not
12109 always be what you want to happen. To change Exim&#x2019;s behaviour, the special
12110 items <literal>+include_unknown</literal> or <literal>+ignore_unknown</literal> may appear in the list (at
12111 top level &ndash; they are not recognized in an indirected file).
12112 </para>
12113 <itemizedlist>
12114 <listitem>
12115 <para>
12116 If any item that follows <literal>+include_unknown</literal> requires information that
12117 cannot found, Exim behaves as if the host does match the list. For example,
12118 </para>
12119 <literallayout class="monospaced">
12120 host_reject_connection = +include_unknown:*.enemy.ex
12121 </literallayout>
12122 <para>
12123 rejects connections from any host whose name matches <literal>*.enemy.ex</literal>, and also
12124 any hosts whose name it cannot find.
12125 </para>
12126 </listitem>
12127 <listitem>
12128 <para>
12129 If any item that follows <literal>+ignore_unknown</literal> requires information that cannot
12130 be found, Exim ignores that item and proceeds to the rest of the list. For
12131 example:
12132 </para>
12133 <literallayout class="monospaced">
12134 accept hosts = +ignore_unknown : friend.example : \
12135                192.168.4.5
12136 </literallayout>
12137 <para>
12138 accepts from any host whose name is <emphasis>friend.example</emphasis> and from 192.168.4.5,
12139 whether or not its host name can be found. Without <literal>+ignore_unknown</literal>, if no
12140 name can be found for 192.168.4.5, it is rejected.
12141 </para>
12142 </listitem>
12143 </itemizedlist>
12144 <para>
12145 Both <literal>+include_unknown</literal> and <literal>+ignore_unknown</literal> may appear in the same
12146 list. The effect of each one lasts until the next, or until the end of the
12147 list.
12148 </para>
12149 </section>
12150 <section id="SECTtemdnserr">
12151 <title>Temporary DNS errors when looking up host information</title>
12152 <para>
12153 <indexterm role="concept">
12154 <primary>host</primary>
12155 <secondary>lookup failures, temporary</secondary>
12156 </indexterm>
12157 <indexterm role="concept">
12158 <primary><literal>+include_defer</literal></primary>
12159 </indexterm>
12160 <indexterm role="concept">
12161 <primary><literal>+ignore_defer</literal></primary>
12162 </indexterm>
12163 A temporary DNS lookup failure normally causes a defer action (except when
12164 <option>dns_again_means_nonexist</option> converts it into a permanent error). However,
12165 host lists can include <literal>+ignore_defer</literal> and <literal>+include_defer</literal>, analagous to
12166 <literal>+ignore_unknown</literal> and <literal>+include_unknown</literal>, as described in the previous
12167 section. These options should be used with care, probably only in non-critical
12168 host lists such as whitelists.
12169 </para>
12170 </section>
12171 <section id="SECThoslispatnamsk">
12172 <title>Host list patterns for single-key lookups by host name</title>
12173 <para>
12174 <indexterm role="concept">
12175 <primary>unknown host name</primary>
12176 </indexterm>
12177 <indexterm role="concept">
12178 <primary>host list</primary>
12179 <secondary>matching host name</secondary>
12180 </indexterm>
12181 If a pattern is of the form
12182 </para>
12183 <literallayout>
12184 &lt;<emphasis>single-key-search-type</emphasis>&gt;;&lt;<emphasis>search-data</emphasis>&gt;
12185 </literallayout>
12186 <para>
12187 for example
12188 </para>
12189 <literallayout class="monospaced">
12190 dbm;/host/accept/list
12191 </literallayout>
12192 <para>
12193 a single-key lookup is performed, using the host name as its key. If the
12194 lookup succeeds, the host matches the item. The actual data that is looked up
12195 is not used.
12196 </para>
12197 <para>
12198 <emphasis role="bold">Reminder</emphasis>: With this kind of pattern, you must have host <emphasis>names</emphasis> as
12199 keys in the file, not IP addresses. If you want to do lookups based on IP
12200 addresses, you must precede the search type with <quote>net-</quote> (see section
12201 <xref linkend="SECThoslispatsikey"/>). There is, however, no reason why you could not use
12202 two items in the same list, one doing an address lookup and one doing a name
12203 lookup, both using the same file.
12204 </para>
12205 </section>
12206 <section id="SECID81">
12207 <title>Host list patterns for query-style lookups</title>
12208 <para>
12209 If a pattern is of the form
12210 </para>
12211 <literallayout>
12212 &lt;<emphasis>query-style-search-type</emphasis>&gt;;&lt;<emphasis>query</emphasis>&gt;
12213 </literallayout>
12214 <para>
12215 the query is obeyed, and if it succeeds, the host matches the item. The actual
12216 data that is looked up is not used. The variables <varname>$sender_host_address</varname> and
12217 <varname>$sender_host_name</varname> can be used in the query. For example:
12218 </para>
12219 <literallayout class="monospaced">
12220 hosts_lookup = pgsql;\
12221   select ip from hostlist where ip='$sender_host_address'
12222 </literallayout>
12223 <para>
12224 The value of <varname>$sender_host_address</varname> for an IPv6 address contains colons. You
12225 can use the <option>sg</option> expansion item to change this if you need to. If you want to
12226 use masked IP addresses in database queries, you can use the <option>mask</option> expansion
12227 operator.
12228 </para>
12229 <para>
12230 If the query contains a reference to <varname>$sender_host_name</varname>, Exim automatically
12231 looks up the host name if has not already done so. (See section
12232 <xref linkend="SECThoslispatnam"/> for comments on finding host names.)
12233 </para>
12234 <para>
12235 Historical note: prior to release 4.30, Exim would always attempt to find a
12236 host name before running the query, unless the search type was preceded by
12237 <literal>net-</literal>. This is no longer the case. For backwards compatibility, <literal>net-</literal> is
12238 still recognized for query-style lookups, but its presence or absence has no
12239 effect. (Of course, for single-key lookups, <literal>net-</literal> <emphasis>is</emphasis> important.
12240 See section <xref linkend="SECThoslispatsikey"/>.)
12241 </para>
12242 </section>
12243 <section id="SECTmixwilhos">
12244 <title>Mixing wildcarded host names and addresses in host lists</title>
12245 <para>
12246 <indexterm role="concept">
12247 <primary>host list</primary>
12248 <secondary>mixing names and addresses in</secondary>
12249 </indexterm>
12250 If you have name lookups or wildcarded host names and IP addresses in the same
12251 host list, you should normally put the IP addresses first. For example, in an
12252 ACL you could have:
12253 </para>
12254 <literallayout class="monospaced">
12255 accept hosts = 10.9.8.7 : *.friend.example
12256 </literallayout>
12257 <para>
12258 The reason for this lies in the left-to-right way that Exim processes lists.
12259 It can test IP addresses without doing any DNS lookups, but when it reaches an
12260 item that requires a host name, it fails if it cannot find a host name to
12261 compare with the pattern. If the above list is given in the opposite order, the
12262 <option>accept</option> statement fails for a host whose name cannot be found, even if its
12263 IP address is 10.9.8.7.
12264 </para>
12265 <para>
12266 If you really do want to do the name check first, and still recognize the IP
12267 address, you can rewrite the ACL like this:
12268 </para>
12269 <literallayout class="monospaced">
12270 accept hosts = *.friend.example
12271 accept hosts = 10.9.8.7
12272 </literallayout>
12273 <para>
12274 If the first <option>accept</option> fails, Exim goes on to try the second one. See chapter
12275 <xref linkend="CHAPACL"/> for details of ACLs.
12276 </para>
12277 </section>
12278 <section id="SECTaddresslist">
12279 <title>Address lists</title>
12280 <para>
12281 <indexterm role="concept">
12282 <primary>list</primary>
12283 <secondary>address list</secondary>
12284 </indexterm>
12285 <indexterm role="concept">
12286 <primary>address list</primary>
12287 <secondary>empty item</secondary>
12288 </indexterm>
12289 <indexterm role="concept">
12290 <primary>address list</primary>
12291 <secondary>patterns</secondary>
12292 </indexterm>
12293 Address lists contain patterns that are matched against mail addresses. There
12294 is one special case to be considered: the sender address of a bounce message is
12295 always empty. You can test for this by providing an empty item in an address
12296 list. For example, you can set up a router to process bounce messages by
12297 using this option setting:
12298 </para>
12299 <literallayout class="monospaced">
12300 senders = :
12301 </literallayout>
12302 <para>
12303 The presence of the colon creates an empty item. If you do not provide any
12304 data, the list is empty and matches nothing. The empty sender can also be
12305 detected by a regular expression that matches an empty string,
12306 and by a query-style lookup that succeeds when <varname>$sender_address</varname> is empty.
12307 </para>
12308 <para>
12309 Non-empty items in an address list can be straightforward email addresses. For
12310 example:
12311 </para>
12312 <literallayout class="monospaced">
12313 senders = jbc@askone.example : hs@anacreon.example
12314 </literallayout>
12315 <para>
12316 A certain amount of wildcarding is permitted. If a pattern contains an @
12317 character, but is not a regular expression and does not begin with a
12318 semicolon-terminated lookup type (described below), the local part of the
12319 subject address is compared with the local part of the pattern, which may start
12320 with an asterisk. If the local parts match, the domain is checked in exactly
12321 the same way as for a pattern in a domain list. For example, the domain can be
12322 wildcarded, refer to a named list, or be a lookup:
12323 </para>
12324 <literallayout class="monospaced">
12325 deny senders = *@*.spamming.site:\
12326                *@+hostile_domains:\
12327                bozo@partial-lsearch;/list/of/dodgy/sites:\
12328                *@dbm;/bad/domains.db
12329 </literallayout>
12330 <para>
12331 <indexterm role="concept">
12332 <primary>local part</primary>
12333 <secondary>starting with !</secondary>
12334 </indexterm>
12335 <indexterm role="concept">
12336 <primary>address list</primary>
12337 <secondary>local part starting with !</secondary>
12338 </indexterm>
12339 If a local part that begins with an exclamation mark is required, it has to be
12340 specified using a regular expression, because otherwise the exclamation mark is
12341 treated as a sign of negation, as is standard in lists.
12342 </para>
12343 <para>
12344 If a non-empty pattern that is not a regular expression or a lookup does not
12345 contain an @ character, it is matched against the domain part of the subject
12346 address. The only two formats that are recognized this way are a literal
12347 domain, or a domain pattern that starts with *. In both these cases, the effect
12348 is the same as if <literal>*@</literal> preceded the pattern. For example:
12349 </para>
12350 <literallayout class="monospaced">
12351 deny senders = enemy.domain : *.enemy.domain
12352 </literallayout>
12353 <para>
12354 The following kinds of more complicated address list pattern can match any
12355 address, including the empty address that is characteristic of bounce message
12356 senders:
12357 </para>
12358 <itemizedlist>
12359 <listitem>
12360 <para>
12361 <indexterm role="concept">
12362 <primary>regular expressions</primary>
12363 <secondary>in address list</secondary>
12364 </indexterm>
12365 <indexterm role="concept">
12366 <primary>address list</primary>
12367 <secondary>regular expression in</secondary>
12368 </indexterm>
12369 If (after expansion) a pattern starts with <quote>^</quote>, a regular expression match is
12370 done against the complete address, with the pattern as the regular expression.
12371 You must take care that backslash and dollar characters are not misinterpreted
12372 as part of the string expansion. The simplest way to do this is to use <literal>\N</literal>
12373 to mark that part of the string as non-expandable. For example:
12374 </para>
12375 <literallayout class="monospaced">
12376 deny senders = \N^.*this.*@example\.com$\N : \
12377                \N^\d{8}.+@spamhaus.example$\N : ...
12378 </literallayout>
12379 <para>
12380 The <literal>\N</literal> sequences are removed by the expansion, so these items do indeed
12381 start with <quote>^</quote> by the time they are being interpreted as address patterns.
12382 </para>
12383 </listitem>
12384 <listitem>
12385 <para>
12386 <indexterm role="concept">
12387 <primary>address list</primary>
12388 <secondary>lookup for complete address</secondary>
12389 </indexterm>
12390 Complete addresses can be looked up by using a pattern that starts with a
12391 lookup type terminated by a semicolon, followed by the data for the lookup. For
12392 example:
12393 </para>
12394 <literallayout class="monospaced">
12395 deny senders = cdb;/etc/blocked.senders : \
12396   mysql;select address from blocked where \
12397   address='${quote_mysql:$sender_address}'
12398 </literallayout>
12399 <para>
12400 Both query-style and single-key lookup types can be used. For a single-key
12401 lookup type, Exim uses the complete address as the key. However, empty keys are
12402 not supported for single-key lookups, so a match against the empty address
12403 always fails. This restriction does not apply to query-style lookups.
12404 </para>
12405 <para>
12406 Partial matching for single-key lookups (section <xref linkend="SECTpartiallookup"/>)
12407 cannot be used, and is ignored if specified, with an entry being written to the
12408 panic log.
12409 <indexterm role="concept">
12410 <primary>*@ with single-key lookup</primary>
12411 </indexterm>
12412 However, you can configure lookup defaults, as described in section
12413 <xref linkend="SECTdefaultvaluelookups"/>, but this is useful only for the <quote>*@</quote> type of
12414 default. For example, with this lookup:
12415 </para>
12416 <literallayout class="monospaced">
12417 accept senders = lsearch*@;/some/file
12418 </literallayout>
12419 <para>
12420 the file could contains lines like this:
12421 </para>
12422 <literallayout class="monospaced">
12423 user1@domain1.example
12424 *@domain2.example
12425 </literallayout>
12426 <para>
12427 and for the sender address <emphasis>nimrod@jaeger.example</emphasis>, the sequence of keys
12428 that are tried is:
12429 </para>
12430 <literallayout class="monospaced">
12431 nimrod@jaeger.example
12432 *@jaeger.example
12433 *
12434 </literallayout>
12435 <para>
12436 <emphasis role="bold">Warning 1</emphasis>: Do not include a line keyed by <quote>*</quote> in the file, because that
12437 would mean that every address matches, thus rendering the test useless.
12438 </para>
12439 <para>
12440 <emphasis role="bold">Warning 2</emphasis>: Do not confuse these two kinds of item:
12441 </para>
12442 <literallayout class="monospaced">
12443 deny recipients = dbm*@;/some/file
12444 deny recipients = *@dbm;/some/file
12445 </literallayout>
12446 <para>
12447 The first does a whole address lookup, with defaulting, as just described,
12448 because it starts with a lookup type. The second matches the local part and
12449 domain independently, as described in a bullet point below.
12450 </para>
12451 </listitem>
12452 </itemizedlist>
12453 <para>
12454 The following kinds of address list pattern can match only non-empty addresses.
12455 If the subject address is empty, a match against any of these pattern types
12456 always fails.
12457 </para>
12458 <itemizedlist>
12459 <listitem>
12460 <para>
12461 <indexterm role="concept">
12462 <primary>@@ with single-key lookup</primary>
12463 </indexterm>
12464 <indexterm role="concept">
12465 <primary>address list</primary>
12466 <secondary>@@ lookup type</secondary>
12467 </indexterm>
12468 <indexterm role="concept">
12469 <primary>address list</primary>
12470 <secondary>split local part and domain</secondary>
12471 </indexterm>
12472 If a pattern starts with <quote>@@</quote> followed by a single-key lookup item
12473 (for example, <literal>@@lsearch;/some/file</literal>), the address that is being checked is
12474 split into a local part and a domain. The domain is looked up in the file. If
12475 it is not found, there is no match. If it is found, the data that is looked up
12476 from the file is treated as a colon-separated list of local part patterns, each
12477 of which is matched against the subject local part in turn.
12478 </para>
12479 <para>
12480 <indexterm role="concept">
12481 <primary>asterisk</primary>
12482 <secondary>in address list</secondary>
12483 </indexterm>
12484 The lookup may be a partial one, and/or one involving a search for a default
12485 keyed by <quote>*</quote> (see section <xref linkend="SECTdefaultvaluelookups"/>). The local part
12486 patterns that are looked up can be regular expressions or begin with <quote>*</quote>, or
12487 even be further lookups. They may also be independently negated. For example,
12488 with
12489 </para>
12490 <literallayout class="monospaced">
12491 deny senders = @@dbm;/etc/reject-by-domain
12492 </literallayout>
12493 <para>
12494 the data from which the DBM file is built could contain lines like
12495 </para>
12496 <literallayout class="monospaced">
12497 baddomain.com:  !postmaster : *
12498 </literallayout>
12499 <para>
12500 to reject all senders except <option>postmaster</option> from that domain.
12501 </para>
12502 <para>
12503 <indexterm role="concept">
12504 <primary>local part</primary>
12505 <secondary>starting with !</secondary>
12506 </indexterm>
12507 If a local part that actually begins with an exclamation mark is required, it
12508 has to be specified using a regular expression. In <command>lsearch</command> files, an entry
12509 may be split over several lines by indenting the second and subsequent lines,
12510 but the separating colon must still be included at line breaks. White space
12511 surrounding the colons is ignored. For example:
12512 </para>
12513 <literallayout class="monospaced">
12514 aol.com:  spammer1 : spammer2 : ^[0-9]+$ :
12515 spammer3 : spammer4
12516 </literallayout>
12517 <para>
12518 As in all colon-separated lists in Exim, a colon can be included in an item by
12519 doubling.
12520 </para>
12521 <para>
12522 If the last item in the list starts with a right angle-bracket, the remainder
12523 of the item is taken as a new key to look up in order to obtain a continuation
12524 list of local parts. The new key can be any sequence of characters. Thus one
12525 might have entries like
12526 </para>
12527 <literallayout class="monospaced">
12528 aol.com: spammer1 : spammer 2 : &gt;*
12529 xyz.com: spammer3 : &gt;*
12530 *:       ^\d{8}$
12531 </literallayout>
12532 <para>
12533 in a file that was searched with <option>@@dbm*</option>, to specify a match for 8-digit
12534 local parts for all domains, in addition to the specific local parts listed for
12535 each domain. Of course, using this feature costs another lookup each time a
12536 chain is followed, but the effort needed to maintain the data is reduced.
12537 </para>
12538 <para>
12539 <indexterm role="concept">
12540 <primary>loop</primary>
12541 <secondary>in lookups</secondary>
12542 </indexterm>
12543 It is possible to construct loops using this facility, and in order to catch
12544 them, the chains may be no more than fifty items long.
12545 </para>
12546 </listitem>
12547 <listitem>
12548 <para>
12549 The @@&lt;<emphasis>lookup</emphasis>&gt; style of item can also be used with a query-style
12550 lookup, but in this case, the chaining facility is not available. The lookup
12551 can only return a single list of local parts.
12552 </para>
12553 </listitem>
12554 </itemizedlist>
12555 <para>
12556 <emphasis role="bold">Warning</emphasis>: There is an important difference between the address list items
12557 in these two examples:
12558 </para>
12559 <literallayout class="monospaced">
12560 senders = +my_list
12561 senders = *@+my_list
12562 </literallayout>
12563 <para>
12564 In the first one, <literal>my_list</literal> is a named address list, whereas in the second
12565 example it is a named domain list.
12566 </para>
12567 </section>
12568 <section id="SECTcasletadd">
12569 <title>Case of letters in address lists</title>
12570 <para>
12571 <indexterm role="concept">
12572 <primary>case of local parts</primary>
12573 </indexterm>
12574 <indexterm role="concept">
12575 <primary>address list</primary>
12576 <secondary>case forcing</secondary>
12577 </indexterm>
12578 <indexterm role="concept">
12579 <primary>case forcing in address lists</primary>
12580 </indexterm>
12581 Domains in email addresses are always handled caselessly, but for local parts
12582 case may be significant on some systems (see <option>caseful_local_part</option> for how
12583 Exim deals with this when routing addresses). However, RFC 2505 (<emphasis>Anti-Spam
12584 Recommendations for SMTP MTAs</emphasis>) suggests that matching of addresses to
12585 blocking lists should be done in a case-independent manner. Since most address
12586 lists in Exim are used for this kind of control, Exim attempts to do this by
12587 default.
12588 </para>
12589 <para>
12590 The domain portion of an address is always lowercased before matching it to an
12591 address list. The local part is lowercased by default, and any string
12592 comparisons that take place are done caselessly. This means that the data in
12593 the address list itself, in files included as plain file names, and in any file
12594 that is looked up using the <quote>@@</quote> mechanism, can be in any case. However, the
12595 keys in files that are looked up by a search type other than <command>lsearch</command> (which
12596 works caselessly) must be in lower case, because these lookups are not
12597 case-independent.
12598 </para>
12599 <para>
12600 <indexterm role="concept">
12601 <primary><literal>+caseful</literal></primary>
12602 </indexterm>
12603 To allow for the possibility of caseful address list matching, if an item in
12604 an address list is the string <quote>+caseful</quote>, the original case of the local
12605 part is restored for any comparisons that follow, and string comparisons are no
12606 longer case-independent. This does not affect the domain, which remains in
12607 lower case. However, although independent matches on the domain alone are still
12608 performed caselessly, regular expressions that match against an entire address
12609 become case-sensitive after <quote>+caseful</quote> has been seen.
12610 </para>
12611 </section>
12612 <section id="SECTlocparlis">
12613 <title>Local part lists</title>
12614 <para>
12615 <indexterm role="concept">
12616 <primary>list</primary>
12617 <secondary>local part list</secondary>
12618 </indexterm>
12619 <indexterm role="concept">
12620 <primary>local part</primary>
12621 <secondary>list</secondary>
12622 </indexterm>
12623 Case-sensitivity in local part lists is handled in the same way as for address
12624 lists, as just described. The <quote>+caseful</quote> item can be used if required. In a
12625 setting of the <option>local_parts</option> option in a router with <option>caseful_local_part</option>
12626 set false, the subject is lowercased and the matching is initially
12627 case-insensitive. In this case, <quote>+caseful</quote> will restore case-sensitive
12628 matching in the local part list, but not elsewhere in the router. If
12629 <option>caseful_local_part</option> is set true in a router, matching in the <option>local_parts</option>
12630 option is case-sensitive from the start.
12631 </para>
12632 <para>
12633 If a local part list is indirected to a file (see section <xref linkend="SECTfilnamlis"/>),
12634 comments are handled in the same way as address lists &ndash; they are recognized
12635 only if the # is preceded by white space or the start of the line.
12636 Otherwise, local part lists are matched in the same way as domain lists, except
12637 that the special items that refer to the local host (<literal>@</literal>, <literal>@[]</literal>,
12638 <literal>@mx_any</literal>, <literal>@mx_primary</literal>, and <literal>@mx_secondary</literal>) are not recognized.
12639 Refer to section <xref linkend="SECTdomainlist"/> for details of the other available item
12640 types.
12641 <indexterm role="concept" startref="IIDdohoadli" class="endofrange"/>
12642 </para>
12643 </section>
12644 </chapter>
12645
12646 <chapter id="CHAPexpand">
12647 <title>String expansions</title>
12648 <para>
12649 <indexterm role="concept" id="IIDstrexp" class="startofrange">
12650 <primary>expansion</primary>
12651 <secondary>of strings</secondary>
12652 </indexterm>
12653 Many strings in Exim&#x2019;s run time configuration are expanded before use. Some of
12654 them are expanded every time they are used; others are expanded only once.
12655 </para>
12656 <para>
12657 When a string is being expanded it is copied verbatim from left to right except
12658 when a dollar or backslash character is encountered. A dollar specifies the
12659 start of a portion of the string that is interpreted and replaced as described
12660 below in section <xref linkend="SECTexpansionitems"/> onwards. Backslash is used as an
12661 escape character, as described in the following section.
12662 </para>
12663 <section id="SECTlittext">
12664 <title>Literal text in expanded strings</title>
12665 <para>
12666 <indexterm role="concept">
12667 <primary>expansion</primary>
12668 <secondary>including literal text</secondary>
12669 </indexterm>
12670 An uninterpreted dollar can be included in an expanded string by putting a
12671 backslash in front of it. A backslash can be used to prevent any special
12672 character being treated specially in an expansion, including backslash itself.
12673 If the string appears in quotes in the configuration file, two backslashes are
12674 required because the quotes themselves cause interpretation of backslashes when
12675 the string is read in (see section <xref linkend="SECTstrings"/>).
12676 </para>
12677 <para>
12678 <indexterm role="concept">
12679 <primary>expansion</primary>
12680 <secondary>non-expandable substrings</secondary>
12681 </indexterm>
12682 A portion of the string can specified as non-expandable by placing it between
12683 two occurrences of <literal>\N</literal>. This is particularly useful for protecting regular
12684 expressions, which often contain backslashes and dollar signs. For example:
12685 </para>
12686 <literallayout class="monospaced">
12687 deny senders = \N^\d{8}[a-z]@some\.site\.example$\N
12688 </literallayout>
12689 <para>
12690 On encountering the first <literal>\N</literal>, the expander copies subsequent characters
12691 without interpretation until it reaches the next <literal>\N</literal> or the end of the
12692 string.
12693 </para>
12694 </section>
12695 <section id="SECID82">
12696 <title>Character escape sequences in expanded strings</title>
12697 <para>
12698 <indexterm role="concept">
12699 <primary>expansion</primary>
12700 <secondary>escape sequences</secondary>
12701 </indexterm>
12702 A backslash followed by one of the letters <quote>n</quote>, <quote>r</quote>, or <quote>t</quote> in an
12703 expanded string is recognized as an escape sequence for the character newline,
12704 carriage return, or tab, respectively. A backslash followed by up to three
12705 octal digits is recognized as an octal encoding for a single character, and a
12706 backslash followed by <quote>x</quote> and up to two hexadecimal digits is a hexadecimal
12707 encoding.
12708 </para>
12709 <para>
12710 These escape sequences are also recognized in quoted strings when they are read
12711 in. Their interpretation in expansions as well is useful for unquoted strings,
12712 and for other cases such as looked-up strings that are then expanded.
12713 </para>
12714 </section>
12715 <section id="SECID83">
12716 <title>Testing string expansions</title>
12717 <para>
12718 <indexterm role="concept">
12719 <primary>expansion</primary>
12720 <secondary>testing</secondary>
12721 </indexterm>
12722 <indexterm role="concept">
12723 <primary>testing</primary>
12724 <secondary>string expansion</secondary>
12725 </indexterm>
12726 <indexterm role="option">
12727 <primary><option>-be</option></primary>
12728 </indexterm>
12729 Many expansions can be tested by calling Exim with the <option>-be</option> option. This
12730 takes the command arguments, or lines from the standard input if there are no
12731 arguments, runs them through the string expansion code, and writes the results
12732 to the standard output. Variables based on configuration values are set up, but
12733 since no message is being processed, variables such as <varname>$local_part</varname> have no
12734 value. Nevertheless the <option>-be</option> option can be useful for checking out file and
12735 database lookups, and the use of expansion operators such as <option>sg</option>, <option>substr</option>
12736 and <option>nhash</option>.
12737 </para>
12738 <para>
12739 Exim gives up its root privilege when it is called with the <option>-be</option> option, and
12740 instead runs under the uid and gid it was called with, to prevent users from
12741 using <option>-be</option> for reading files to which they do not have access.
12742 </para>
12743 <para>
12744 <indexterm role="option">
12745 <primary><option>-bem</option></primary>
12746 </indexterm>
12747 If you want to test expansions that include variables whose values are taken
12748 from a message, there are two other options that can be used. The <option>-bem</option>
12749 option is like <option>-be</option> except that it is followed by a file name. The file is
12750 read as a message before doing the test expansions. For example:
12751 </para>
12752 <literallayout class="monospaced">
12753 exim -bem /tmp/test.message '$h_subject:'
12754 </literallayout>
12755 <para>
12756 The <option>-Mset</option> option is used in conjunction with <option>-be</option> and is followed by an
12757 Exim message identifier. For example:
12758 </para>
12759 <literallayout class="monospaced">
12760 exim -be -Mset 1GrA8W-0004WS-LQ '$recipients'
12761 </literallayout>
12762 <para>
12763 This loads the message from Exim&#x2019;s spool before doing the test expansions, and
12764 is therefore restricted to admin users.
12765 </para>
12766 </section>
12767 <section id="SECTforexpfai">
12768 <title>Forced expansion failure</title>
12769 <para>
12770 <indexterm role="concept">
12771 <primary>expansion</primary>
12772 <secondary>forced failure</secondary>
12773 </indexterm>
12774 A number of expansions that are described in the following section have
12775 alternative <quote>true</quote> and <quote>false</quote> substrings, enclosed in brace characters
12776 (which are sometimes called <quote>curly brackets</quote>). Which of the two strings is
12777 used depends on some condition that is evaluated as part of the expansion. If,
12778 instead of a <quote>false</quote> substring, the word <quote>fail</quote> is used (not in braces),
12779 the entire string expansion fails in a way that can be detected by the code
12780 that requested the expansion. This is called <quote>forced expansion failure</quote>, and
12781 its consequences depend on the circumstances. In some cases it is no different
12782 from any other expansion failure, but in others a different action may be
12783 taken. Such variations are mentioned in the documentation of the option that is
12784 being expanded.
12785 </para>
12786 </section>
12787 <section id="SECTexpansionitems">
12788 <title>Expansion items</title>
12789 <para>
12790 The following items are recognized in expanded strings. White space may be used
12791 between sub-items that are keywords or substrings enclosed in braces inside an
12792 outer set of braces, to improve readability. <emphasis role="bold">Warning</emphasis>: Within braces,
12793 white space is significant.
12794 </para>
12795 <variablelist>
12796 <varlistentry>
12797 <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>
12798 <listitem>
12799 <para>
12800 <indexterm role="concept">
12801 <primary>expansion</primary>
12802 <secondary>variables</secondary>
12803 </indexterm>
12804 Substitute the contents of the named variable, for example:
12805 </para>
12806 <literallayout class="monospaced">
12807 $local_part
12808 ${domain}
12809 </literallayout>
12810 <para>
12811 The second form can be used to separate the name from subsequent alphanumeric
12812 characters. This form (using braces) is available only for variables; it does
12813 <emphasis>not</emphasis> apply to message headers. The names of the variables are given in
12814 section <xref linkend="SECTexpvar"/> below. If the name of a non-existent variable is
12815 given, the expansion fails.
12816 </para>
12817 </listitem></varlistentry>
12818 <varlistentry>
12819 <term><emphasis role="bold">${</emphasis>&lt;<emphasis>op</emphasis>&gt;<emphasis role="bold">:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
12820 <listitem>
12821 <para>
12822 <indexterm role="concept">
12823 <primary>expansion</primary>
12824 <secondary>operators</secondary>
12825 </indexterm>
12826 The string is first itself expanded, and then the operation specified by
12827 &lt;<emphasis>op</emphasis>&gt; is applied to it. For example:
12828 </para>
12829 <literallayout class="monospaced">
12830 ${lc:$local_part}
12831 </literallayout>
12832 <para>
12833 The string starts with the first character after the colon, which may be
12834 leading white space. A list of operators is given in section <xref linkend="SECTexpop"/>
12835 below. The operator notation is used for simple expansion items that have just
12836 one argument, because it reduces the number of braces and therefore makes the
12837 string easier to understand.
12838 </para>
12839 </listitem></varlistentry>
12840 <varlistentry>
12841 <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>
12842 <listitem>
12843 <para>
12844 This item inserts <quote>basic</quote> header lines. It is described with the <option>header</option>
12845 expansion item below.
12846 </para>
12847 </listitem></varlistentry>
12848 <varlistentry>
12849 <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>
12850 <listitem>
12851 <para>
12852 <indexterm role="concept">
12853 <primary><option>dlfunc</option></primary>
12854 </indexterm>
12855 This expansion dynamically loads and then calls a locally-written C function.
12856 This functionality is available only if Exim is compiled with
12857 </para>
12858 <literallayout class="monospaced">
12859 EXPAND_DLFUNC=yes
12860 </literallayout>
12861 <para>
12862 set in <filename>Local/Makefile</filename>. Once loaded, Exim remembers the dynamically loaded
12863 object so that it doesn&#x2019;t reload the same object file in the same Exim process
12864 (but of course Exim does start new processes frequently).
12865 </para>
12866 <para>
12867 There may be from zero to eight arguments to the function. When compiling
12868 a local function that is to be called in this way, <filename>local_scan.h</filename> should be
12869 included. The Exim variables and functions that are defined by that API
12870 are also available for dynamically loaded functions. The function itself
12871 must have the following type:
12872 </para>
12873 <literallayout class="monospaced">
12874 int dlfunction(uschar **yield, int argc, uschar *argv[])
12875 </literallayout>
12876 <para>
12877 Where <literal>uschar</literal> is a typedef for <literal>unsigned char</literal> in <filename>local_scan.h</filename>. The
12878 function should return one of the following values:
12879 </para>
12880 <para>
12881 <literal>OK</literal>: Success. The string that is placed in the variable <emphasis>yield</emphasis> is put
12882 into the expanded string that is being built.
12883 </para>
12884 <para>
12885 <literal>FAIL</literal>: A non-forced expansion failure occurs, with the error message taken
12886 from <emphasis>yield</emphasis>, if it is set.
12887 </para>
12888 <para>
12889 <literal>FAIL_FORCED</literal>: A forced expansion failure occurs, with the error message
12890 taken from <emphasis>yield</emphasis> if it is set.
12891 </para>
12892 <para>
12893 <literal>ERROR</literal>: Same as <literal>FAIL</literal>, except that a panic log entry is written.
12894 </para>
12895 <para>
12896 When compiling a function that is to be used in this way with gcc,
12897 you need to add <option>-shared</option> to the gcc command. Also, in the Exim build-time
12898 configuration, you must add <option>-export-dynamic</option> to EXTRALIBS.
12899 </para>
12900 </listitem></varlistentry>
12901 <varlistentry>
12902 <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>
12903 <listitem>
12904 <para>
12905 <indexterm role="concept">
12906 <primary>expansion</primary>
12907 <secondary>extracting substrings by key</secondary>
12908 </indexterm>
12909 <indexterm role="concept">
12910 <primary><option>extract</option></primary>
12911 <secondary>substrings by key</secondary>
12912 </indexterm>
12913 The key and &lt;<emphasis>string1</emphasis>&gt; are first expanded separately. Leading and trailing
12914 white space is removed from the key (but not from any of the strings). The key
12915 must not consist entirely of digits. The expanded &lt;<emphasis>string1</emphasis>&gt; must be of the
12916 form:
12917 </para>
12918 <literallayout>
12919 &lt;<emphasis>key1</emphasis>&gt; = &lt;<emphasis>value1</emphasis>&gt;  &lt;<emphasis>key2</emphasis>&gt; = &lt;<emphasis>value2</emphasis>&gt; ...
12920 </literallayout>
12921 <para>
12922 <indexterm role="variable">
12923 <primary><varname>$value</varname></primary>
12924 </indexterm>
12925 where the equals signs and spaces (but not both) are optional. If any of the
12926 values contain white space, they must be enclosed in double quotes, and any
12927 values that are enclosed in double quotes are subject to escape processing as
12928 described in section <xref linkend="SECTstrings"/>. The expanded &lt;<emphasis>string1</emphasis>&gt; is searched
12929 for the value that corresponds to the key. The search is case-insensitive. If
12930 the key is found, &lt;<emphasis>string2</emphasis>&gt; is expanded, and replaces the whole item;
12931 otherwise &lt;<emphasis>string3</emphasis>&gt; is used. During the expansion of &lt;<emphasis>string2</emphasis>&gt; the
12932 variable <varname>$value</varname> contains the value that has been extracted. Afterwards, it
12933 is restored to any previous value it might have had.
12934 </para>
12935 <para>
12936 If {&lt;<emphasis>string3</emphasis>&gt;} is omitted, the item is replaced by an empty string if the
12937 key is not found. If {&lt;<emphasis>string2</emphasis>&gt;} is also omitted, the value that was
12938 extracted is used. Thus, for example, these two expansions are identical, and
12939 yield <quote>2001</quote>:
12940 </para>
12941 <literallayout class="monospaced">
12942 ${extract{gid}{uid=1984 gid=2001}}
12943 ${extract{gid}{uid=1984 gid=2001}{$value}}
12944 </literallayout>
12945 <para>
12946 Instead of {&lt;<emphasis>string3</emphasis>&gt;} the word <quote>fail</quote> (not in curly brackets) can
12947 appear, for example:
12948 </para>
12949 <literallayout class="monospaced">
12950 ${extract{Z}{A=... B=...}{$value} fail }
12951 </literallayout>
12952 <para>
12953 This forces an expansion failure (see section <xref linkend="SECTforexpfai"/>);
12954 {&lt;<emphasis>string2</emphasis>&gt;} must be present for <quote>fail</quote> to be recognized.
12955 </para>
12956 </listitem></varlistentry>
12957 <varlistentry>
12958 <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>
12959 <listitem>
12960 <para>
12961 <indexterm role="concept">
12962 <primary>expansion</primary>
12963 <secondary>extracting substrings by number</secondary>
12964 </indexterm>
12965 <indexterm role="concept">
12966 <primary><option>extract</option></primary>
12967 <secondary>substrings by number</secondary>
12968 </indexterm>
12969 The &lt;<emphasis>number</emphasis>&gt; argument must consist entirely of decimal digits,
12970 apart from leading and trailing white space, which is ignored.
12971 This is what distinguishes this form of <option>extract</option> from the previous kind. It
12972 behaves in the same way, except that, instead of extracting a named field, it
12973 extracts from &lt;<emphasis>string1</emphasis>&gt; the field whose number is given as the first
12974 argument. You can use <varname>$value</varname> in &lt;<emphasis>string2</emphasis>&gt; or <literal>fail</literal> instead of
12975 &lt;<emphasis>string3</emphasis>&gt; as before.
12976 </para>
12977 <para>
12978 The fields in the string are separated by any one of the characters in the
12979 separator string. These may include space or tab characters.
12980 The first field is numbered one. If the number is negative, the fields are
12981 counted from the end of the string, with the rightmost one numbered -1. If the
12982 number given is zero, the entire string is returned. If the modulus of the
12983 number is greater than the number of fields in the string, the result is the
12984 expansion of &lt;<emphasis>string3</emphasis>&gt;, or the empty string if &lt;<emphasis>string3</emphasis>&gt; is not
12985 provided. For example:
12986 </para>
12987 <literallayout class="monospaced">
12988 ${extract{2}{:}{x:42:99:&amp; Mailer::/bin/bash}}
12989 </literallayout>
12990 <para>
12991 yields <quote>42</quote>, and
12992 </para>
12993 <literallayout class="monospaced">
12994 ${extract{-4}{:}{x:42:99:&amp; Mailer::/bin/bash}}
12995 </literallayout>
12996 <para>
12997 yields <quote>99</quote>. Two successive separators mean that the field between them is
12998 empty (for example, the fifth field above).
12999 </para>
13000 </listitem></varlistentry>
13001 <varlistentry>
13002 <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>
13003 <listitem>
13004 <para>
13005 <indexterm role="concept">
13006 <primary>list</primary>
13007 <secondary>selecting by condition</secondary>
13008 </indexterm>
13009 <indexterm role="concept">
13010 <primary>expansion</primary>
13011 <secondary>selecting from list by condition</secondary>
13012 </indexterm>
13013 <indexterm role="variable">
13014 <primary><varname>$item</varname></primary>
13015 </indexterm>
13016 After expansion, &lt;<emphasis>string</emphasis>&gt; is interpreted as a list, colon-separated by
13017 default, but the separator can be changed in the usual way. For each item
13018 in this list, its value is place in <varname>$item</varname>, and then the condition is
13019 evaluated. If the condition is true, <varname>$item</varname> is added to the output as an
13020 item in a new list; if the condition is false, the item is discarded. The
13021 separator used for the output list is the same as the one used for the
13022 input, but a separator setting is not included in the output. For example:
13023 </para>
13024 <literallayout class="monospaced">
13025 ${filter{a:b:c}{!eq{$item}{b}}
13026 </literallayout>
13027 <para>
13028 yields <literal>a:c</literal>. At the end of the expansion, the value of <varname>$item</varname> is restored
13029 to what it was before. See also the <emphasis role="bold">map</emphasis> and <emphasis role="bold">reduce</emphasis> expansion items.
13030 </para>
13031 </listitem></varlistentry>
13032 <varlistentry>
13033 <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>
13034 <listitem>
13035 <para>
13036 <indexterm role="concept">
13037 <primary>hash function</primary>
13038 <secondary>textual</secondary>
13039 </indexterm>
13040 <indexterm role="concept">
13041 <primary>expansion</primary>
13042 <secondary>textual hash</secondary>
13043 </indexterm>
13044 This is a textual hashing function, and was the first to be implemented in
13045 early versions of Exim. In current releases, there are other hashing functions
13046 (numeric, MD5, and SHA-1), which are described below.
13047 </para>
13048 <para>
13049 The first two strings, after expansion, must be numbers. Call them &lt;<emphasis>m</emphasis>&gt; and
13050 &lt;<emphasis>n</emphasis>&gt;. If you are using fixed values for these numbers, that is, if
13051 &lt;<emphasis>string1</emphasis>&gt; and &lt;<emphasis>string2</emphasis>&gt; do not change when they are expanded, you can
13052 use the simpler operator notation that avoids some of the braces:
13053 </para>
13054 <literallayout class="monospaced">
13055 ${hash_&lt;n&gt;_&lt;m&gt;:&lt;string&gt;}
13056 </literallayout>
13057 <para>
13058 The second number is optional (in both notations). If &lt;<emphasis>n</emphasis>&gt; is greater than
13059 or equal to the length of the string, the expansion item returns the string.
13060 Otherwise it computes a new string of length &lt;<emphasis>n</emphasis>&gt; by applying a hashing
13061 function to the string. The new string consists of characters taken from the
13062 first &lt;<emphasis>m</emphasis>&gt; characters of the string
13063 </para>
13064 <literallayout class="monospaced">
13065 abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQWRSTUVWXYZ0123456789
13066 </literallayout>
13067 <para>
13068 If &lt;<emphasis>m</emphasis>&gt; is not present the value 26 is used, so that only lower case
13069 letters appear. For example:
13070 </para>
13071 <literallayout>
13072 <literal>$hash{3}{monty}}           </literal>   yields  <literal>jmg</literal>
13073 <literal>$hash{5}{monty}}           </literal>   yields  <literal>monty</literal>
13074 <literal>$hash{4}{62}{monty python}}</literal>   yields  <literal>fbWx</literal>
13075 </literallayout>
13076 </listitem></varlistentry>
13077 <varlistentry>
13078 <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>
13079 <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>
13080 <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>
13081 <listitem>
13082 <para>
13083 <indexterm role="concept">
13084 <primary>expansion</primary>
13085 <secondary>header insertion</secondary>
13086 </indexterm>
13087 <indexterm role="variable">
13088 <primary><varname>$header_</varname></primary>
13089 </indexterm>
13090 <indexterm role="variable">
13091 <primary><varname>$bheader_</varname></primary>
13092 </indexterm>
13093 <indexterm role="variable">
13094 <primary><varname>$rheader_</varname></primary>
13095 </indexterm>
13096 <indexterm role="concept">
13097 <primary>header lines</primary>
13098 <secondary>in expansion strings</secondary>
13099 </indexterm>
13100 <indexterm role="concept">
13101 <primary>header lines</primary>
13102 <secondary>character sets</secondary>
13103 </indexterm>
13104 <indexterm role="concept">
13105 <primary>header lines</primary>
13106 <secondary>decoding</secondary>
13107 </indexterm>
13108 Substitute the contents of the named message header line, for example
13109 </para>
13110 <literallayout class="monospaced">
13111 $header_reply-to:
13112 </literallayout>
13113 <para>
13114 The newline that terminates a header line is not included in the expansion, but
13115 internal newlines (caused by splitting the header line over several physical
13116 lines) may be present.
13117 </para>
13118 <para>
13119 The difference between <option>rheader</option>, <option>bheader</option>, and <option>header</option> is in the way
13120 the data in the header line is interpreted.
13121 </para>
13122 <itemizedlist>
13123 <listitem>
13124 <para>
13125 <indexterm role="concept">
13126 <primary>white space</primary>
13127 <secondary>in header lines</secondary>
13128 </indexterm>
13129 <option>rheader</option> gives the original <quote>raw</quote> content of the header line, with no
13130 processing at all, and without the removal of leading and trailing white space.
13131 </para>
13132 </listitem>
13133 <listitem>
13134 <para>
13135 <indexterm role="concept">
13136 <primary>base64 encoding</primary>
13137 <secondary>in header lines</secondary>
13138 </indexterm>
13139 <option>bheader</option> removes leading and trailing white space, and then decodes base64
13140 or quoted-printable MIME <quote>words</quote> within the header text, but does no
13141 character set translation. If decoding of what looks superficially like a MIME
13142 <quote>word</quote> fails, the raw string is returned. If decoding
13143 <indexterm role="concept">
13144 <primary>binary zero</primary>
13145 <secondary>in header line</secondary>
13146 </indexterm>
13147 produces a binary zero character, it is replaced by a question mark &ndash; this is
13148 what Exim does for binary zeros that are actually received in header lines.
13149 </para>
13150 </listitem>
13151 <listitem>
13152 <para>
13153 <option>header</option> tries to translate the string as decoded by <option>bheader</option> to a
13154 standard character set. This is an attempt to produce the same string as would
13155 be displayed on a user&#x2019;s MUA. If translation fails, the <option>bheader</option> string is
13156 returned. Translation is attempted only on operating systems that support the
13157 <function>iconv()</function> function. This is indicated by the compile-time macro HAVE_ICONV in
13158 a system Makefile or in <filename>Local/Makefile</filename>.
13159 </para>
13160 </listitem>
13161 </itemizedlist>
13162 <para>
13163 In a filter file, the target character set for <option>header</option> can be specified by a
13164 command of the following form:
13165 </para>
13166 <literallayout class="monospaced">
13167 headers charset "UTF-8"
13168 </literallayout>
13169 <para>
13170 This command affects all references to <varname>$h_</varname> (or <varname>$header_</varname>) expansions in
13171 subsequently obeyed filter commands. In the absence of this command, the target
13172 character set in a filter is taken from the setting of the <option>headers_charset</option>
13173 option in the runtime configuration. The value of this option defaults to the
13174 value of HEADERS_CHARSET in <filename>Local/Makefile</filename>. The ultimate default is
13175 ISO-8859-1.
13176 </para>
13177 <para>
13178 Header names follow the syntax of RFC 2822, which states that they may contain
13179 any printing characters except space and colon. Consequently, curly brackets
13180 <emphasis>do not</emphasis> terminate header names, and should not be used to enclose them as
13181 if they were variables. Attempting to do so causes a syntax error.
13182 </para>
13183 <para>
13184 Only header lines that are common to all copies of a message are visible to
13185 this mechanism. These are the original header lines that are received with the
13186 message, and any that are added by an ACL statement or by a system
13187 filter. Header lines that are added to a particular copy of a message by a
13188 router or transport are not accessible.
13189 </para>
13190 <para>
13191 For incoming SMTP messages, no header lines are visible in ACLs that are obeyed
13192 before the DATA ACL, because the header structure is not set up until the
13193 message is received. Header lines that are added in a RCPT ACL (for example)
13194 are saved until the message&#x2019;s incoming header lines are available, at which
13195 point they are added. When a DATA ACL is running, however, header lines added
13196 by earlier ACLs are visible.
13197 </para>
13198 <para>
13199 Upper case and lower case letters are synonymous in header names. If the
13200 following character is white space, the terminating colon may be omitted, but
13201 this is not recommended, because you may then forget it when it is needed. When
13202 white space terminates the header name, it is included in the expanded string.
13203 If the message does not contain the given header, the expansion item is
13204 replaced by an empty string. (See the <option>def</option> condition in section
13205 <xref linkend="SECTexpcond"/> for a means of testing for the existence of a header.)
13206 </para>
13207 <para>
13208 If there is more than one header with the same name, they are all concatenated
13209 to form the substitution string, up to a maximum length of 64K. Unless
13210 <option>rheader</option> is being used, leading and trailing white space is removed from
13211 each header before concatenation, and a completely empty header is ignored. A
13212 newline character is then inserted between non-empty headers, but there is no
13213 newline at the very end. For the <option>header</option> and <option>bheader</option> expansion, for
13214 those headers that contain lists of addresses, a comma is also inserted at the
13215 junctions between headers. This does not happen for the <option>rheader</option> expansion.
13216 </para>
13217 </listitem></varlistentry>
13218 <varlistentry>
13219 <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>
13220 <listitem>
13221 <para>
13222 <indexterm role="concept">
13223 <primary>expansion</primary>
13224 <secondary>hmac hashing</secondary>
13225 </indexterm>
13226 <indexterm role="concept">
13227 <primary><option>hmac</option></primary>
13228 </indexterm>
13229 This function uses cryptographic hashing (either MD5 or SHA-1) to convert a
13230 shared secret and some text into a message authentication code, as specified in
13231 RFC 2104. This differs from <literal>${md5:secret_text...}</literal> or
13232 <literal>${sha1:secret_text...}</literal> in that the hmac step adds a signature to the
13233 cryptographic hash, allowing for authentication that is not possible with MD5
13234 or SHA-1 alone. The hash name must expand to either <literal>md5</literal> or <literal>sha1</literal> at
13235 present. For example:
13236 </para>
13237 <literallayout class="monospaced">
13238 ${hmac{md5}{somesecret}{$primary_hostname $tod_log}}
13239 </literallayout>
13240 <para>
13241 For the hostname <emphasis>mail.example.com</emphasis> and time 2002-10-17 11:30:59, this
13242 produces:
13243 </para>
13244 <literallayout class="monospaced">
13245 dd97e3ba5d1a61b5006108f8c8252953
13246 </literallayout>
13247 <para>
13248 As an example of how this might be used, you might put in the main part of
13249 an Exim configuration:
13250 </para>
13251 <literallayout class="monospaced">
13252 SPAMSCAN_SECRET=cohgheeLei2thahw
13253 </literallayout>
13254 <para>
13255 In a router or a transport you could then have:
13256 </para>
13257 <literallayout class="monospaced">
13258 headers_add = \
13259   X-Spam-Scanned: ${primary_hostname} ${message_exim_id} \
13260   ${hmac{md5}{SPAMSCAN_SECRET}\
13261   {${primary_hostname},${message_exim_id},$h_message-id:}}
13262 </literallayout>
13263 <para>
13264 Then given a message, you can check where it was scanned by looking at the
13265 <emphasis>X-Spam-Scanned:</emphasis> header line. If you know the secret, you can check that
13266 this header line is authentic by recomputing the authentication code from the
13267 host name, message ID and the <emphasis>Message-id:</emphasis> header line. This can be done
13268 using Exim&#x2019;s <option>-be</option> option, or by other means, for example by using the
13269 <emphasis>hmac_md5_hex()</emphasis> function in Perl.
13270 </para>
13271 </listitem></varlistentry>
13272 <varlistentry>
13273 <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>
13274 <listitem>
13275 <para>
13276 <indexterm role="concept">
13277 <primary>expansion</primary>
13278 <secondary>conditional</secondary>
13279 </indexterm>
13280 <indexterm role="concept">
13281 <primary><option>if</option>, expansion item</primary>
13282 </indexterm>
13283 If &lt;<emphasis>condition</emphasis>&gt; is true, &lt;<emphasis>string1</emphasis>&gt; is expanded and replaces the whole
13284 item; otherwise &lt;<emphasis>string2</emphasis>&gt; is used. The available conditions are described
13285 in section <xref linkend="SECTexpcond"/> below. For example:
13286 </para>
13287 <literallayout class="monospaced">
13288 ${if eq {$local_part}{postmaster} {yes}{no} }
13289 </literallayout>
13290 <para>
13291 The second string need not be present; if it is not and the condition is not
13292 true, the item is replaced with nothing. Alternatively, the word <quote>fail</quote> may
13293 be present instead of the second string (without any curly brackets). In this
13294 case, the expansion is forced to fail if the condition is not true (see section
13295 <xref linkend="SECTforexpfai"/>).
13296 </para>
13297 <para>
13298 If both strings are omitted, the result is the string <literal>true</literal> if the condition
13299 is true, and the empty string if the condition is false. This makes it less
13300 cumbersome to write custom ACL and router conditions. For example, instead of
13301 </para>
13302 <literallayout class="monospaced">
13303 condition = ${if &gt;{$acl_m4}{3}{true}{false}}
13304 </literallayout>
13305 <para>
13306 you can use
13307 </para>
13308 <literallayout class="monospaced">
13309 condition = ${if &gt;{$acl_m4}{3}}
13310 </literallayout>
13311 </listitem></varlistentry>
13312 <varlistentry>
13313 <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>
13314 <listitem>
13315 <para>
13316 <indexterm role="concept">
13317 <primary>expansion</primary>
13318 <secondary>string truncation</secondary>
13319 </indexterm>
13320 <indexterm role="concept">
13321 <primary><option>length</option> expansion item</primary>
13322 </indexterm>
13323 The <option>length</option> item is used to extract the initial portion of a string. Both
13324 strings are expanded, and the first one must yield a number, &lt;<emphasis>n</emphasis>&gt;, say. If
13325 you are using a fixed value for the number, that is, if &lt;<emphasis>string1</emphasis>&gt; does not
13326 change when expanded, you can use the simpler operator notation that avoids
13327 some of the braces:
13328 </para>
13329 <literallayout class="monospaced">
13330 ${length_&lt;n&gt;:&lt;string&gt;}
13331 </literallayout>
13332 <para>
13333 The result of this item is either the first &lt;<emphasis>n</emphasis>&gt; characters or the whole
13334 of &lt;<emphasis>string2</emphasis>&gt;, whichever is the shorter. Do not confuse <option>length</option> with
13335 <option>strlen</option>, which gives the length of a string.
13336 </para>
13337 </listitem></varlistentry>
13338 <varlistentry>
13339 <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>
13340 <listitem>
13341 <para>
13342 This is the first of one of two different types of lookup item, which are both
13343 described in the next item.
13344 </para>
13345 </listitem></varlistentry>
13346 <varlistentry>
13347 <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>
13348 <listitem>
13349 <para>
13350 <indexterm role="concept">
13351 <primary>expansion</primary>
13352 <secondary>lookup in</secondary>
13353 </indexterm>
13354 <indexterm role="concept">
13355 <primary>file</primary>
13356 <secondary>lookups</secondary>
13357 </indexterm>
13358 <indexterm role="concept">
13359 <primary>lookup</primary>
13360 <secondary>in expanded string</secondary>
13361 </indexterm>
13362 The two forms of lookup item specify data lookups in files and databases, as
13363 discussed in chapter <xref linkend="CHAPfdlookup"/>. The first form is used for single-key
13364 lookups, and the second is used for query-style lookups. The &lt;<emphasis>key</emphasis>&gt;,
13365 &lt;<emphasis>file</emphasis>&gt;, and &lt;<emphasis>query</emphasis>&gt; strings are expanded before use.
13366 </para>
13367 <para>
13368 If there is any white space in a lookup item which is part of a filter command,
13369 a retry or rewrite rule, a routing rule for the <command>manualroute</command> router, or any
13370 other place where white space is significant, the lookup item must be enclosed
13371 in double quotes. The use of data lookups in users&#x2019; filter files may be locked
13372 out by the system administrator.
13373 </para>
13374 <para>
13375 <indexterm role="variable">
13376 <primary><varname>$value</varname></primary>
13377 </indexterm>
13378 If the lookup succeeds, &lt;<emphasis>string1</emphasis>&gt; is expanded and replaces the entire item.
13379 During its expansion, the variable <varname>$value</varname> contains the data returned by the
13380 lookup. Afterwards it reverts to the value it had previously (at the outer
13381 level it is empty). If the lookup fails, &lt;<emphasis>string2</emphasis>&gt; is expanded and replaces
13382 the entire item. If {&lt;<emphasis>string2</emphasis>&gt;} is omitted, the replacement is the empty
13383 string on failure. If &lt;<emphasis>string2</emphasis>&gt; is provided, it can itself be a nested
13384 lookup, thus providing a mechanism for looking up a default value when the
13385 original lookup fails.
13386 </para>
13387 <para>
13388 If a nested lookup is used as part of &lt;<emphasis>string1</emphasis>&gt;, <varname>$value</varname> contains the
13389 data for the outer lookup while the parameters of the second lookup are
13390 expanded, and also while &lt;<emphasis>string2</emphasis>&gt; of the second lookup is expanded, should
13391 the second lookup fail. Instead of {&lt;<emphasis>string2</emphasis>&gt;} the word <quote>fail</quote> can
13392 appear, and in this case, if the lookup fails, the entire expansion is forced
13393 to fail (see section <xref linkend="SECTforexpfai"/>). If both {&lt;<emphasis>string1</emphasis>&gt;} and
13394 {&lt;<emphasis>string2</emphasis>&gt;} are omitted, the result is the looked up value in the case of a
13395 successful lookup, and nothing in the case of failure.
13396 </para>
13397 <para>
13398 For single-key lookups, the string <quote>partial</quote> is permitted to precede the
13399 search type in order to do partial matching, and * or *@ may follow a search
13400 type to request default lookups if the key does not match (see sections
13401 <xref linkend="SECTdefaultvaluelookups"/> and <xref linkend="SECTpartiallookup"/> for details).
13402 </para>
13403 <para>
13404 <indexterm role="concept">
13405 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
13406 <secondary>in lookup expansion</secondary>
13407 </indexterm>
13408 If a partial search is used, the variables <varname>$1</varname> and <varname>$2</varname> contain the wild
13409 and non-wild parts of the key during the expansion of the replacement text.
13410 They return to their previous values at the end of the lookup item.
13411 </para>
13412 <para>
13413 This example looks up the postmaster alias in the conventional alias file:
13414 </para>
13415 <literallayout class="monospaced">
13416 ${lookup {postmaster} lsearch {/etc/aliases} {$value}}
13417 </literallayout>
13418 <para>
13419 This example uses NIS+ to look up the full name of the user corresponding to
13420 the local part of an address, forcing the expansion to fail if it is not found:
13421 </para>
13422 <literallayout class="monospaced">
13423 ${lookup nisplus {[name=$local_part],passwd.org_dir:gcos} \
13424   {$value}fail}
13425 </literallayout>
13426 </listitem></varlistentry>
13427 <varlistentry>
13428 <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>
13429 <listitem>
13430 <para>
13431 <indexterm role="concept">
13432 <primary>expansion</primary>
13433 <secondary>list creation</secondary>
13434 </indexterm>
13435 <indexterm role="variable">
13436 <primary><varname>$item</varname></primary>
13437 </indexterm>
13438 After expansion, &lt;<emphasis>string1</emphasis>&gt; is interpreted as a list, colon-separated by
13439 default, but the separator can be changed in the usual way. For each item
13440 in this list, its value is place in <varname>$item</varname>, and then &lt;<emphasis>string2</emphasis>&gt; is
13441 expanded and added to the output as an item in a new list. The separator used
13442 for the output list is the same as the one used for the input, but a separator
13443 setting is not included in the output. For example:
13444 </para>
13445 <literallayout class="monospaced">
13446 ${map{a:b:c}{[$item]}} ${map{&lt;- x-y-z}{($item)}}
13447 </literallayout>
13448 <para>
13449 expands to <literal>[a]:[b]:[c] (x)-(y)-(z)</literal>. At the end of the expansion, the
13450 value of <varname>$item</varname> is restored to what it was before. See also the <emphasis role="bold">filter</emphasis>
13451 and <emphasis role="bold">reduce</emphasis> expansion items.
13452 </para>
13453 </listitem></varlistentry>
13454 <varlistentry>
13455 <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>
13456 <listitem>
13457 <para>
13458 <indexterm role="concept">
13459 <primary>expansion</primary>
13460 <secondary>numeric hash</secondary>
13461 </indexterm>
13462 <indexterm role="concept">
13463 <primary>hash function</primary>
13464 <secondary>numeric</secondary>
13465 </indexterm>
13466 The three strings are expanded; the first two must yield numbers. Call them
13467 &lt;<emphasis>n</emphasis>&gt; and &lt;<emphasis>m</emphasis>&gt;. If you are using fixed values for these numbers, that is,
13468 if &lt;<emphasis>string1</emphasis>&gt; and &lt;<emphasis>string2</emphasis>&gt; do not change when they are expanded, you
13469 can use the simpler operator notation that avoids some of the braces:
13470 </para>
13471 <literallayout class="monospaced">
13472 ${nhash_&lt;n&gt;_&lt;m&gt;:&lt;string&gt;}
13473 </literallayout>
13474 <para>
13475 The second number is optional (in both notations). If there is only one number,
13476 the result is a number in the range 0&ndash;&lt;<emphasis>n</emphasis>&gt;-1. Otherwise, the string is
13477 processed by a div/mod hash function that returns two numbers, separated by a
13478 slash, in the ranges 0 to &lt;<emphasis>n</emphasis>&gt;-1 and 0 to &lt;<emphasis>m</emphasis>&gt;-1, respectively. For
13479 example,
13480 </para>
13481 <literallayout class="monospaced">
13482 ${nhash{8}{64}{supercalifragilisticexpialidocious}}
13483 </literallayout>
13484 <para>
13485 returns the string <quote>6/33</quote>.
13486 </para>
13487 </listitem></varlistentry>
13488 <varlistentry>
13489 <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>
13490 <listitem>
13491 <para>
13492 <indexterm role="concept">
13493 <primary>Perl</primary>
13494 <secondary>use in expanded string</secondary>
13495 </indexterm>
13496 <indexterm role="concept">
13497 <primary>expansion</primary>
13498 <secondary>calling Perl from</secondary>
13499 </indexterm>
13500 This item is available only if Exim has been built to include an embedded Perl
13501 interpreter. The subroutine name and the arguments are first separately
13502 expanded, and then the Perl subroutine is called with those arguments. No
13503 additional arguments need be given; the maximum number permitted, including the
13504 name of the subroutine, is nine.
13505 </para>
13506 <para>
13507 The return value of the subroutine is inserted into the expanded string, unless
13508 the return value is <option>undef</option>. In that case, the expansion fails in the same
13509 way as an explicit <quote>fail</quote> on a lookup item. The return value is a scalar.
13510 Whatever you return is evaluated in a scalar context. For example, if you
13511 return the name of a Perl vector, the return value is the size of the vector,
13512 not its contents.
13513 </para>
13514 <para>
13515 If the subroutine exits by calling Perl&#x2019;s <option>die</option> function, the expansion fails
13516 with the error message that was passed to <option>die</option>. More details of the embedded
13517 Perl facility are given in chapter <xref linkend="CHAPperl"/>.
13518 </para>
13519 <para>
13520 The <command>redirect</command> router has an option called <option>forbid_filter_perl</option> which locks
13521 out the use of this expansion item in filter files.
13522 </para>
13523 </listitem></varlistentry>
13524 <varlistentry>
13525 <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>
13526 <listitem>
13527 <para>
13528 <indexterm role="concept">
13529 <primary><option>prvs</option> expansion item</primary>
13530 </indexterm>
13531 The first argument is a complete email address and the second is secret
13532 keystring. The third argument, specifying a key number, is optional. If absent,
13533 it defaults to 0. The result of the expansion is a prvs-signed email address,
13534 to be typically used with the <option>return_path</option> option on an <command>smtp</command> transport
13535 as part of a bounce address tag validation (BATV) scheme. For more discussion
13536 and an example, see section <xref linkend="SECTverifyPRVS"/>.
13537 </para>
13538 </listitem></varlistentry>
13539 <varlistentry>
13540 <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>
13541 <listitem>
13542 <para>
13543 <indexterm role="concept">
13544 <primary><option>prvscheck</option> expansion item</primary>
13545 </indexterm>
13546 This expansion item is the complement of the <option>prvs</option> item. It is used for
13547 checking prvs-signed addresses. If the expansion of the first argument does not
13548 yield a syntactically valid prvs-signed address, the whole item expands to the
13549 empty string. When the first argument does expand to a syntactically valid
13550 prvs-signed address, the second argument is expanded, with the prvs-decoded
13551 version of the address and the key number extracted from the address in the
13552 variables <varname>$prvscheck_address</varname> and <varname>$prvscheck_keynum</varname>, respectively.
13553 </para>
13554 <para>
13555 These two variables can be used in the expansion of the second argument to
13556 retrieve the secret. The validity of the prvs-signed address is then checked
13557 against the secret. The result is stored in the variable <varname>$prvscheck_result</varname>,
13558 which is empty for failure or <quote>1</quote> for success.
13559 </para>
13560 <para>
13561 The third argument is optional; if it is missing, it defaults to an empty
13562 string. This argument is now expanded. If the result is an empty string, the
13563 result of the expansion is the decoded version of the address. This is the case
13564 whether or not the signature was valid. Otherwise, the result of the expansion
13565 is the expansion of the third argument.
13566 </para>
13567 <para>
13568 All three variables can be used in the expansion of the third argument.
13569 However, once the expansion is complete, only <varname>$prvscheck_result</varname> remains set.
13570 For more discussion and an example, see section <xref linkend="SECTverifyPRVS"/>.
13571 </para>
13572 </listitem></varlistentry>
13573 <varlistentry>
13574 <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>
13575 <listitem>
13576 <para>
13577 <indexterm role="concept">
13578 <primary>expansion</primary>
13579 <secondary>inserting an entire file</secondary>
13580 </indexterm>
13581 <indexterm role="concept">
13582 <primary>file</primary>
13583 <secondary>inserting into expansion</secondary>
13584 </indexterm>
13585 <indexterm role="concept">
13586 <primary><option>readfile</option> expansion item</primary>
13587 </indexterm>
13588 The file name and end-of-line string are first expanded separately. The file is
13589 then read, and its contents replace the entire item. All newline characters in
13590 the file are replaced by the end-of-line string if it is present. Otherwise,
13591 newlines are left in the string.
13592 String expansion is not applied to the contents of the file. If you want this,
13593 you must wrap the item in an <option>expand</option> operator. If the file cannot be read,
13594 the string expansion fails.
13595 </para>
13596 <para>
13597 The <command>redirect</command> router has an option called <option>forbid_filter_readfile</option> which
13598 locks out the use of this expansion item in filter files.
13599 </para>
13600 </listitem></varlistentry>
13601 <varlistentry>
13602 <term><emphasis role="bold">${readsocket{</emphasis>&lt;<emphasis>name</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>request</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>timeout</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>eol&nbsp;string</emphasis>&gt;<emphasis role="bold">}{</emphasis>&lt;<emphasis>fail&nbsp;string</emphasis>&gt;<emphasis role="bold">}}</emphasis></term>
13603 <listitem>
13604 <para>
13605 <indexterm role="concept">
13606 <primary>expansion</primary>
13607 <secondary>inserting from a socket</secondary>
13608 </indexterm>
13609 <indexterm role="concept">
13610 <primary>socket, use of in expansion</primary>
13611 </indexterm>
13612 <indexterm role="concept">
13613 <primary><option>readsocket</option> expansion item</primary>
13614 </indexterm>
13615 This item inserts data from a Unix domain or Internet socket into the expanded
13616 string. The minimal way of using it uses just two arguments, as in these
13617 examples:
13618 </para>
13619 <literallayout class="monospaced">
13620 ${readsocket{/socket/name}{request string}}
13621 ${readsocket{inet:some.host:1234}{request string}}
13622 </literallayout>
13623 <para>
13624 For a Unix domain socket, the first substring must be the path to the socket.
13625 For an Internet socket, the first substring must contain <literal>inet:</literal> followed by
13626 a host name or IP address, followed by a colon and a port, which can be a
13627 number or the name of a TCP port in <filename>/etc/services</filename>. An IP address may
13628 optionally be enclosed in square brackets. This is best for IPv6 addresses. For
13629 example:
13630 </para>
13631 <literallayout class="monospaced">
13632 ${readsocket{inet:[::1]:1234}{request string}}
13633 </literallayout>
13634 <para>
13635 Only a single host name may be given, but if looking it up yields more than
13636 one IP address, they are each tried in turn until a connection is made. For
13637 both kinds of socket, Exim makes a connection, writes the request string
13638 (unless it is an empty string) and reads from the socket until an end-of-file
13639 is read. A timeout of 5 seconds is applied. Additional, optional arguments
13640 extend what can be done. Firstly, you can vary the timeout. For example:
13641 </para>
13642 <literallayout class="monospaced">
13643 ${readsocket{/socket/name}{request string}{3s}}
13644 </literallayout>
13645 <para>
13646 A fourth argument allows you to change any newlines that are in the data
13647 that is read, in the same way as for <option>readfile</option> (see above). This example
13648 turns them into spaces:
13649 </para>
13650 <literallayout class="monospaced">
13651 ${readsocket{inet:127.0.0.1:3294}{request string}{3s}{ }}
13652 </literallayout>
13653 <para>
13654 As with all expansions, the substrings are expanded before the processing
13655 happens. Errors in these sub-expansions cause the expansion to fail. In
13656 addition, the following errors can occur:
13657 </para>
13658 <itemizedlist>
13659 <listitem>
13660 <para>
13661 Failure to create a socket file descriptor;
13662 </para>
13663 </listitem>
13664 <listitem>
13665 <para>
13666 Failure to connect the socket;
13667 </para>
13668 </listitem>
13669 <listitem>
13670 <para>
13671 Failure to write the request string;
13672 </para>
13673 </listitem>
13674 <listitem>
13675 <para>
13676 Timeout on reading from the socket.
13677 </para>
13678 </listitem>
13679 </itemizedlist>
13680 <para>
13681 By default, any of these errors causes the expansion to fail. However, if
13682 you supply a fifth substring, it is expanded and used when any of the above
13683 errors occurs. For example:
13684 </para>
13685 <literallayout class="monospaced">
13686 ${readsocket{/socket/name}{request string}{3s}{\n}\
13687   {socket failure}}
13688 </literallayout>
13689 <para>
13690 You can test for the existence of a Unix domain socket by wrapping this
13691 expansion in <literal>${if exists</literal>, but there is a race condition between that test
13692 and the actual opening of the socket, so it is safer to use the fifth argument
13693 if you want to be absolutely sure of avoiding an expansion error for a
13694 non-existent Unix domain socket, or a failure to connect to an Internet socket.
13695 </para>
13696 <para>
13697 The <command>redirect</command> router has an option called <option>forbid_filter_readsocket</option> which
13698 locks out the use of this expansion item in filter files.
13699 </para>
13700 </listitem></varlistentry>
13701 <varlistentry>
13702 <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>
13703 <listitem>
13704 <para>
13705 <indexterm role="concept">
13706 <primary>expansion</primary>
13707 <secondary>reducing a list to a scalar</secondary>
13708 </indexterm>
13709 <indexterm role="concept">
13710 <primary>list</primary>
13711 <secondary>reducing to a scalar</secondary>
13712 </indexterm>
13713 <indexterm role="variable">
13714 <primary><varname>$value</varname></primary>
13715 </indexterm>
13716 <indexterm role="variable">
13717 <primary><varname>$item</varname></primary>
13718 </indexterm>
13719 This operation reduces a list to a single, scalar string. After expansion,
13720 &lt;<emphasis>string1</emphasis>&gt; is interpreted as a list, colon-separated by default, but the
13721 separator can be changed in the usual way. Then &lt;<emphasis>string2</emphasis>&gt; is expanded and
13722 assigned to the <varname>$value</varname> variable. After this, each item in the &lt;<emphasis>string1</emphasis>&gt;
13723 list is assigned to <varname>$item</varname> in turn, and &lt;<emphasis>string3</emphasis>&gt; is expanded for each of
13724 them. The result of that expansion is assigned to <varname>$value</varname> before the next
13725 iteration. When the end of the list is reached, the final value of <varname>$value</varname> is
13726 added to the expansion output. The <emphasis role="bold">reduce</emphasis> expansion item can be used in a
13727 number of ways. For example, to add up a list of numbers:
13728 </para>
13729 <literallayout class="monospaced">
13730 ${reduce {&lt;, 1,2,3}{0}{${eval:$value+$item}}}
13731 </literallayout>
13732 <para>
13733 The result of that expansion would be <literal>6</literal>. The maximum of a list of numbers
13734 can be found:
13735 </para>
13736 <literallayout class="monospaced">
13737 ${reduce {3:0:9:4:6}{0}{${if &gt;{$item}{$value}{$item}{$value}}}}
13738 </literallayout>
13739 <para>
13740 At the end of a <emphasis role="bold">reduce</emphasis> expansion, the values of <varname>$item</varname> and <varname>$value</varname> are
13741 restored to what they were before. See also the <emphasis role="bold">filter</emphasis> and <emphasis role="bold">map</emphasis>
13742 expansion items.
13743 </para>
13744 </listitem></varlistentry>
13745 <varlistentry>
13746 <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>
13747 <listitem>
13748 <para>
13749 This item inserts <quote>raw</quote> header lines. It is described with the <option>header</option>
13750 expansion item above.
13751 </para>
13752 </listitem></varlistentry>
13753 <varlistentry>
13754 <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>
13755 <listitem>
13756 <para>
13757 <indexterm role="concept">
13758 <primary>expansion</primary>
13759 <secondary>running a command</secondary>
13760 </indexterm>
13761 <indexterm role="concept">
13762 <primary><option>run</option> expansion item</primary>
13763 </indexterm>
13764 The command and its arguments are first expanded separately, and then the
13765 command is run in a separate process, but under the same uid and gid. As in
13766 other command executions from Exim, a shell is not used by default. If you want
13767 a shell, you must explicitly code it.
13768 </para>
13769 <para>
13770 The standard input for the command exists, but is empty. The standard output
13771 and standard error are set to the same file descriptor.
13772 <indexterm role="concept">
13773 <primary>return code</primary>
13774 <secondary>from <option>run</option> expansion</secondary>
13775 </indexterm>
13776 <indexterm role="variable">
13777 <primary><varname>$value</varname></primary>
13778 </indexterm>
13779 If the command succeeds (gives a zero return code) &lt;<emphasis>string1</emphasis>&gt; is expanded
13780 and replaces the entire item; during this expansion, the standard output/error
13781 from the command is in the variable <varname>$value</varname>. If the command fails,
13782 &lt;<emphasis>string2</emphasis>&gt;, if present, is expanded and used. Once again, during the
13783 expansion, the standard output/error from the command is in the variable
13784 <varname>$value</varname>.
13785 </para>
13786 <para>
13787 If &lt;<emphasis>string2</emphasis>&gt; is absent, the result is empty. Alternatively, &lt;<emphasis>string2</emphasis>&gt;
13788 can be the word <quote>fail</quote> (not in braces) to force expansion failure if the
13789 command does not succeed. If both strings are omitted, the result is contents
13790 of the standard output/error on success, and nothing on failure.
13791 </para>
13792 <para>
13793 <indexterm role="variable">
13794 <primary><varname>$runrc</varname></primary>
13795 </indexterm>
13796 The return code from the command is put in the variable <varname>$runrc</varname>, and this
13797 remains set afterwards, so in a filter file you can do things like this:
13798 </para>
13799 <literallayout class="monospaced">
13800 if "${run{x y z}{}}$runrc" is 1 then ...
13801   elif $runrc is 2 then ...
13802   ...
13803 endif
13804 </literallayout>
13805 <para>
13806 If execution of the command fails (for example, the command does not exist),
13807 the return code is 127 &ndash; the same code that shells use for non-existent
13808 commands.
13809 </para>
13810 <para>
13811 <emphasis role="bold">Warning</emphasis>: In a router or transport, you cannot assume the order in which
13812 option values are expanded, except for those preconditions whose order of
13813 testing is documented. Therefore, you cannot reliably expect to set <varname>$runrc</varname>
13814 by the expansion of one option, and use it in another.
13815 </para>
13816 <para>
13817 The <command>redirect</command> router has an option called <option>forbid_filter_run</option> which locks
13818 out the use of this expansion item in filter files.
13819 </para>
13820 </listitem></varlistentry>
13821 <varlistentry>
13822 <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>
13823 <listitem>
13824 <para>
13825 <indexterm role="concept">
13826 <primary>expansion</primary>
13827 <secondary>string substitution</secondary>
13828 </indexterm>
13829 <indexterm role="concept">
13830 <primary><option>sg</option> expansion item</primary>
13831 </indexterm>
13832 This item works like Perl&#x2019;s substitution operator (s) with the global (/g)
13833 option; hence its name. However, unlike the Perl equivalent, Exim does not
13834 modify the subject string; instead it returns the modified string for insertion
13835 into the overall expansion. The item takes three arguments: the subject string,
13836 a regular expression, and a substitution string. For example:
13837 </para>
13838 <literallayout class="monospaced">
13839 ${sg{abcdefabcdef}{abc}{xyz}}
13840 </literallayout>
13841 <para>
13842 yields <quote>xyzdefxyzdef</quote>. Because all three arguments are expanded before use,
13843 if any $ or \ characters are required in the regular expression or in the
13844 substitution string, they have to be escaped. For example:
13845 </para>
13846 <literallayout class="monospaced">
13847 ${sg{abcdef}{^(...)(...)\$}{\$2\$1}}
13848 </literallayout>
13849 <para>
13850 yields <quote>defabc</quote>, and
13851 </para>
13852 <literallayout class="monospaced">
13853 ${sg{1=A 4=D 3=C}{\N(\d+)=\N}{K\$1=}}
13854 </literallayout>
13855 <para>
13856 yields <quote>K1=A K4=D K3=C</quote>. Note the use of <literal>\N</literal> to protect the contents of
13857 the regular expression from string expansion.
13858 </para>
13859 </listitem></varlistentry>
13860 <varlistentry>
13861 <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>
13862 <listitem>
13863 <para>
13864 <indexterm role="concept">
13865 <primary><option>substr</option> expansion item</primary>
13866 </indexterm>
13867 <indexterm role="concept">
13868 <primary>substring extraction</primary>
13869 </indexterm>
13870 <indexterm role="concept">
13871 <primary>expansion</primary>
13872 <secondary>substring extraction</secondary>
13873 </indexterm>
13874 The three strings are expanded; the first two must yield numbers. Call them
13875 &lt;<emphasis>n</emphasis>&gt; and &lt;<emphasis>m</emphasis>&gt;. If you are using fixed values for these numbers, that is,
13876 if &lt;<emphasis>string1</emphasis>&gt; and &lt;<emphasis>string2</emphasis>&gt; do not change when they are expanded, you
13877 can use the simpler operator notation that avoids some of the braces:
13878 </para>
13879 <literallayout class="monospaced">
13880 ${substr_&lt;n&gt;_&lt;m&gt;:&lt;string&gt;}
13881 </literallayout>
13882 <para>
13883 The second number is optional (in both notations).
13884 If it is absent in the simpler format, the preceding underscore must also be
13885 omitted.
13886 </para>
13887 <para>
13888 The <option>substr</option> item can be used to extract more general substrings than
13889 <option>length</option>. The first number, &lt;<emphasis>n</emphasis>&gt;, is a starting offset, and &lt;<emphasis>m</emphasis>&gt; is the
13890 length required. For example
13891 </para>
13892 <literallayout class="monospaced">
13893 ${substr{3}{2}{$local_part}}
13894 </literallayout>
13895 <para>
13896 If the starting offset is greater than the string length the result is the
13897 null string; if the length plus starting offset is greater than the string
13898 length, the result is the right-hand part of the string, starting from the
13899 given offset. The first character in the string has offset zero.
13900 </para>
13901 <para>
13902 The <option>substr</option> expansion item can take negative offset values to count
13903 from the right-hand end of its operand. The last character is offset -1, the
13904 second-last is offset -2, and so on. Thus, for example,
13905 </para>
13906 <literallayout class="monospaced">
13907 ${substr{-5}{2}{1234567}}
13908 </literallayout>
13909 <para>
13910 yields <quote>34</quote>. If the absolute value of a negative offset is greater than the
13911 length of the string, the substring starts at the beginning of the string, and
13912 the length is reduced by the amount of overshoot. Thus, for example,
13913 </para>
13914 <literallayout class="monospaced">
13915 ${substr{-5}{2}{12}}
13916 </literallayout>
13917 <para>
13918 yields an empty string, but
13919 </para>
13920 <literallayout class="monospaced">
13921 ${substr{-3}{2}{12}}
13922 </literallayout>
13923 <para>
13924 yields <quote>1</quote>.
13925 </para>
13926 <para>
13927 When the second number is omitted from <option>substr</option>, the remainder of the string
13928 is taken if the offset is positive. If it is negative, all characters in the
13929 string preceding the offset point are taken. For example, an offset of -1 and
13930 no length, as in these semantically identical examples:
13931 </para>
13932 <literallayout class="monospaced">
13933 ${substr_-1:abcde}
13934 ${substr{-1}{abcde}}
13935 </literallayout>
13936 <para>
13937 yields all but the last character of the string, that is, <quote>abcd</quote>.
13938 </para>
13939 </listitem></varlistentry>
13940 <varlistentry>
13941 <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>
13942 <listitem>
13943 <para>
13944 <indexterm role="concept">
13945 <primary>expansion</primary>
13946 <secondary>character translation</secondary>
13947 </indexterm>
13948 <indexterm role="concept">
13949 <primary><option>tr</option> expansion item</primary>
13950 </indexterm>
13951 This item does single-character translation on its subject string. The second
13952 argument is a list of characters to be translated in the subject string. Each
13953 matching character is replaced by the corresponding character from the
13954 replacement list. For example
13955 </para>
13956 <literallayout class="monospaced">
13957 ${tr{abcdea}{ac}{13}}
13958 </literallayout>
13959 <para>
13960 yields <literal>1b3de1</literal>. If there are duplicates in the second character string, the
13961 last occurrence is used. If the third string is shorter than the second, its
13962 last character is replicated. However, if it is empty, no translation takes
13963 place.
13964 </para>
13965 </listitem></varlistentry>
13966 </variablelist>
13967 </section>
13968 <section id="SECTexpop">
13969 <title>Expansion operators</title>
13970 <para>
13971 <indexterm role="concept">
13972 <primary>expansion</primary>
13973 <secondary>operators</secondary>
13974 </indexterm>
13975 For expansion items that perform transformations on a single argument string,
13976 the <quote>operator</quote> notation is used because it is simpler and uses fewer braces.
13977 The substring is first expanded before the operation is applied to it. The
13978 following operations can be performed:
13979 </para>
13980 <variablelist>
13981 <varlistentry>
13982 <term><emphasis role="bold">${address:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
13983 <listitem>
13984 <para>
13985 <indexterm role="concept">
13986 <primary>expansion</primary>
13987 <secondary>RFC 2822 address handling</secondary>
13988 </indexterm>
13989 <indexterm role="concept">
13990 <primary><option>address</option> expansion item</primary>
13991 </indexterm>
13992 The string is interpreted as an RFC 2822 address, as it might appear in a
13993 header line, and the effective address is extracted from it. If the string does
13994 not parse successfully, the result is empty.
13995 </para>
13996 </listitem></varlistentry>
13997 <varlistentry>
13998 <term><emphasis role="bold">${addresses:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
13999 <listitem>
14000 <para>
14001 <indexterm role="concept">
14002 <primary>expansion</primary>
14003 <secondary>RFC 2822 address handling</secondary>
14004 </indexterm>
14005 <indexterm role="concept">
14006 <primary><option>addresses</option> expansion item</primary>
14007 </indexterm>
14008 The string (after expansion) is interpreted as a list of addresses in RFC
14009 2822 format, such as can be found in a <emphasis>To:</emphasis> or <emphasis>Cc:</emphasis> header line. The
14010 operative address (<emphasis>local-part@domain</emphasis>) is extracted from each item, and the
14011 result of the expansion is a colon-separated list, with appropriate
14012 doubling of colons should any happen to be present in the email addresses.
14013 Syntactically invalid RFC2822 address items are omitted from the output.
14014 </para>
14015 <para>
14016 It is possible to specify a character other than colon for the output
14017 separator by starting the string with &gt; followed by the new separator
14018 character. For example:
14019 </para>
14020 <literallayout class="monospaced">
14021 ${addresses:&gt;&amp; Chief &lt;ceo@up.stairs&gt;, sec@base.ment (dogsbody)}
14022 </literallayout>
14023 <para>
14024 expands to <literal>ceo@up.stairs&amp;sec@base.ment</literal>. Compare the <emphasis role="bold">address</emphasis> (singular)
14025 expansion item, which extracts the working address from a single RFC2822
14026 address. See the <emphasis role="bold">filter</emphasis>, <emphasis role="bold">map</emphasis>, and <emphasis role="bold">reduce</emphasis> items for ways of
14027 processing lists.
14028 </para>
14029 </listitem></varlistentry>
14030 <varlistentry>
14031 <term><emphasis role="bold">${base62:</emphasis>&lt;<emphasis>digits</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14032 <listitem>
14033 <para>
14034 <indexterm role="concept">
14035 <primary><option>base62</option> expansion item</primary>
14036 </indexterm>
14037 <indexterm role="concept">
14038 <primary>expansion</primary>
14039 <secondary>conversion to base 62</secondary>
14040 </indexterm>
14041 The string must consist entirely of decimal digits. The number is converted to
14042 base 62 and output as a string of six characters, including leading zeros. In
14043 the few operating environments where Exim uses base 36 instead of base 62 for
14044 its message identifiers (because those systems do not have case-sensitive file
14045 names), base 36 is used by this operator, despite its name. <emphasis role="bold">Note</emphasis>: Just to
14046 be absolutely clear: this is <emphasis>not</emphasis> base64 encoding.
14047 </para>
14048 </listitem></varlistentry>
14049 <varlistentry>
14050 <term><emphasis role="bold">${base62d:</emphasis>&lt;<emphasis>base-62&nbsp;digits</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14051 <listitem>
14052 <para>
14053 <indexterm role="concept">
14054 <primary><option>base62d</option> expansion item</primary>
14055 </indexterm>
14056 <indexterm role="concept">
14057 <primary>expansion</primary>
14058 <secondary>conversion to base 62</secondary>
14059 </indexterm>
14060 The string must consist entirely of base-62 digits, or, in operating
14061 environments where Exim uses base 36 instead of base 62 for its message
14062 identifiers, base-36 digits. The number is converted to decimal and output as a
14063 string.
14064 </para>
14065 </listitem></varlistentry>
14066 <varlistentry>
14067 <term><emphasis role="bold">${domain:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14068 <listitem>
14069 <para>
14070 <indexterm role="concept">
14071 <primary>domain</primary>
14072 <secondary>extraction</secondary>
14073 </indexterm>
14074 <indexterm role="concept">
14075 <primary>expansion</primary>
14076 <secondary>domain extraction</secondary>
14077 </indexterm>
14078 The string is interpreted as an RFC 2822 address and the domain is extracted
14079 from it. If the string does not parse successfully, the result is empty.
14080 </para>
14081 </listitem></varlistentry>
14082 <varlistentry>
14083 <term><emphasis role="bold">${escape:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14084 <listitem>
14085 <para>
14086 <indexterm role="concept">
14087 <primary>expansion</primary>
14088 <secondary>escaping non-printing characters</secondary>
14089 </indexterm>
14090 <indexterm role="concept">
14091 <primary><option>escape</option> expansion item</primary>
14092 </indexterm>
14093 If the string contains any non-printing characters, they are converted to
14094 escape sequences starting with a backslash. Whether characters with the most
14095 significant bit set (so-called <quote>8-bit characters</quote>) count as printing or not
14096 is controlled by the <option>print_topbitchars</option> option.
14097 </para>
14098 </listitem></varlistentry>
14099 <varlistentry>
14100 <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>
14101 <listitem>
14102 <para>
14103 <indexterm role="concept">
14104 <primary>expansion</primary>
14105 <secondary>expression evaluation</secondary>
14106 </indexterm>
14107 <indexterm role="concept">
14108 <primary>expansion</primary>
14109 <secondary>arithmetic expression</secondary>
14110 </indexterm>
14111 <indexterm role="concept">
14112 <primary><option>eval</option> expansion item</primary>
14113 </indexterm>
14114 These items supports simple arithmetic and bitwise logical operations in
14115 expansion strings. The string (after expansion) must be a conventional
14116 arithmetic expression, but it is limited to basic arithmetic operators, bitwise
14117 logical operators, and parentheses. All operations are carried out using
14118 integer arithmetic. The operator priorities are as follows (the same as in the
14119 C programming language):
14120 </para>
14121 <informaltable frame="none">
14122 <tgroup cols="2" colsep="0" rowsep="0">
14123 <colspec colwidth="70pt" align="left"/>
14124 <colspec colwidth="300pt" align="left"/>
14125 <tbody>
14126 <row>
14127 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<emphasis>highest:</emphasis></entry>
14128 <entry>not (~), negate (-)</entry>
14129 </row>
14130 <row>
14131 <entry>&nbsp;&nbsp;&nbsp;&nbsp;</entry>
14132 <entry>multiply (*), divide (/), remainder (%)</entry>
14133 </row>
14134 <row>
14135 <entry>&nbsp;&nbsp;&nbsp;&nbsp;</entry>
14136 <entry>plus (+), minus (-)</entry>
14137 </row>
14138 <row>
14139 <entry>&nbsp;&nbsp;&nbsp;&nbsp;</entry>
14140 <entry>shift-left (&lt;&lt;), shift-right (&gt;&gt;)</entry>
14141 </row>
14142 <row>
14143 <entry>&nbsp;&nbsp;&nbsp;&nbsp;</entry>
14144 <entry>and (&amp;)</entry>
14145 </row>
14146 <row>
14147 <entry>&nbsp;&nbsp;&nbsp;&nbsp;</entry>
14148 <entry>xor (^)</entry>
14149 </row>
14150 <row>
14151 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<emphasis>lowest:</emphasis></entry>
14152 <entry>or (|)</entry>
14153 </row>
14154 </tbody>
14155 </tgroup>
14156 </informaltable>
14157 <para>
14158 Binary operators with the same priority are evaluated from left to right. White
14159 space is permitted before or after operators.
14160 </para>
14161 <para>
14162 For <option>eval</option>, numbers may be decimal, octal (starting with <quote>0</quote>) or
14163 hexadecimal (starting with <quote>0x</quote>). For <option>eval10</option>, all numbers are taken as
14164 decimal, even if they start with a leading zero; hexadecimal numbers are not
14165 permitted. This can be useful when processing numbers extracted from dates or
14166 times, which often do have leading zeros.
14167 </para>
14168 <para>
14169 A number may be followed by <quote>K</quote> or <quote>M</quote> to multiply it by 1024 or 1024*1024,
14170 respectively. Negative numbers are supported. The result of the computation is
14171 a decimal representation of the answer (without <quote>K</quote> or <quote>M</quote>). For example:
14172 </para>
14173 <literallayout>
14174 <literal>${eval:1+1}            </literal>  yields 2
14175 <literal>${eval:1+2*3}          </literal>  yields 7
14176 <literal>${eval:(1+2)*3}        </literal>  yields 9
14177 <literal>${eval:2+42%5}         </literal>  yields 4
14178 <literal>${eval:0xc&amp;5}          </literal>  yields 4
14179 <literal>${eval:0xc|5}          </literal>  yields 13
14180 <literal>${eval:0xc^5}          </literal>  yields 9
14181 <literal>${eval:0xc&gt;&gt;1}         </literal>  yields 6
14182 <literal>${eval:0xc&lt;&lt;1}         </literal>  yields 24
14183 <literal>${eval:~255&amp;0x1234}    </literal>  yields 4608
14184 <literal>${eval:-(~255&amp;0x1234)} </literal>  yields -4608
14185 </literallayout>
14186 <para>
14187 As a more realistic example, in an ACL you might have
14188 </para>
14189 <literallayout class="monospaced">
14190 deny   message = Too many bad recipients
14191        condition =                    \
14192          ${if and {                   \
14193            {&gt;{$rcpt_count}{10}}       \
14194            {                          \
14195            &lt;                          \
14196              {$recipients_count}      \
14197              {${eval:$rcpt_count/2}}  \
14198            }                          \
14199          }{yes}{no}}
14200 </literallayout>
14201 <para>
14202 The condition is true if there have been more than 10 RCPT commands and
14203 fewer than half of them have resulted in a valid recipient.
14204 </para>
14205 </listitem></varlistentry>
14206 <varlistentry>
14207 <term><emphasis role="bold">${expand:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14208 <listitem>
14209 <para>
14210 <indexterm role="concept">
14211 <primary>expansion</primary>
14212 <secondary>re-expansion of substring</secondary>
14213 </indexterm>
14214 The <option>expand</option> operator causes a string to be expanded for a second time. For
14215 example,
14216 </para>
14217 <literallayout class="monospaced">
14218 ${expand:${lookup{$domain}dbm{/some/file}{$value}}}
14219 </literallayout>
14220 <para>
14221 first looks up a string in a file while expanding the operand for <option>expand</option>,
14222 and then re-expands what it has found.
14223 </para>
14224 </listitem></varlistentry>
14225 <varlistentry>
14226 <term><emphasis role="bold">${from_utf8:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14227 <listitem>
14228 <para>
14229 <indexterm role="concept">
14230 <primary>Unicode</primary>
14231 </indexterm>
14232 <indexterm role="concept">
14233 <primary>UTF-8</primary>
14234 <secondary>conversion from</secondary>
14235 </indexterm>
14236 <indexterm role="concept">
14237 <primary>expansion</primary>
14238 <secondary>UTF-8 conversion</secondary>
14239 </indexterm>
14240 <indexterm role="concept">
14241 <primary><option>from_utf8</option> expansion item</primary>
14242 </indexterm>
14243 The world is slowly moving towards Unicode, although there are no standards for
14244 email yet. However, other applications (including some databases) are starting
14245 to store data in Unicode, using UTF-8 encoding. This operator converts from a
14246 UTF-8 string to an ISO-8859-1 string. UTF-8 code values greater than 255 are
14247 converted to underscores. The input must be a valid UTF-8 string. If it is not,
14248 the result is an undefined sequence of bytes.
14249 </para>
14250 <para>
14251 Unicode code points with values less than 256 are compatible with ASCII and
14252 ISO-8859-1 (also known as Latin-1).
14253 For example, character 169 is the copyright symbol in both cases, though the
14254 way it is encoded is different. In UTF-8, more than one byte is needed for
14255 characters with code values greater than 127, whereas ISO-8859-1 is a
14256 single-byte encoding (but thereby limited to 256 characters). This makes
14257 translation from UTF-8 to ISO-8859-1 straightforward.
14258 </para>
14259 </listitem></varlistentry>
14260 <varlistentry>
14261 <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>
14262 <listitem>
14263 <para>
14264 <indexterm role="concept">
14265 <primary>hash function</primary>
14266 <secondary>textual</secondary>
14267 </indexterm>
14268 <indexterm role="concept">
14269 <primary>expansion</primary>
14270 <secondary>textual hash</secondary>
14271 </indexterm>
14272 The <option>hash</option> operator is a simpler interface to the hashing function that can
14273 be used when the two parameters are fixed numbers (as opposed to strings that
14274 change when expanded). The effect is the same as
14275 </para>
14276 <literallayout class="monospaced">
14277 ${hash{&lt;n&gt;}{&lt;m&gt;}{&lt;string&gt;}}
14278 </literallayout>
14279 <para>
14280 See the description of the general <option>hash</option> item above for details. The
14281 abbreviation <option>h</option> can be used when <option>hash</option> is used as an operator.
14282 </para>
14283 </listitem></varlistentry>
14284 <varlistentry>
14285 <term><emphasis role="bold">${hex2b64:</emphasis>&lt;<emphasis>hexstring</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14286 <listitem>
14287 <para>
14288 <indexterm role="concept">
14289 <primary>base64 encoding</primary>
14290 <secondary>conversion from hex</secondary>
14291 </indexterm>
14292 <indexterm role="concept">
14293 <primary>expansion</primary>
14294 <secondary>hex to base64</secondary>
14295 </indexterm>
14296 <indexterm role="concept">
14297 <primary><option>hex2b64</option> expansion item</primary>
14298 </indexterm>
14299 This operator converts a hex string into one that is base64 encoded. This can
14300 be useful for processing the output of the MD5 and SHA-1 hashing functions.
14301 </para>
14302 </listitem></varlistentry>
14303 <varlistentry>
14304 <term><emphasis role="bold">${lc:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14305 <listitem>
14306 <para>
14307 <indexterm role="concept">
14308 <primary>case forcing in strings</primary>
14309 </indexterm>
14310 <indexterm role="concept">
14311 <primary>string</primary>
14312 <secondary>case forcing</secondary>
14313 </indexterm>
14314 <indexterm role="concept">
14315 <primary>lower casing</primary>
14316 </indexterm>
14317 <indexterm role="concept">
14318 <primary>expansion</primary>
14319 <secondary>case forcing</secondary>
14320 </indexterm>
14321 <indexterm role="concept">
14322 <primary><option>lc</option> expansion item</primary>
14323 </indexterm>
14324 This forces the letters in the string into lower-case, for example:
14325 </para>
14326 <literallayout class="monospaced">
14327 ${lc:$local_part}
14328 </literallayout>
14329 </listitem></varlistentry>
14330 <varlistentry>
14331 <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>
14332 <listitem>
14333 <para>
14334 <indexterm role="concept">
14335 <primary>expansion</primary>
14336 <secondary>string truncation</secondary>
14337 </indexterm>
14338 <indexterm role="concept">
14339 <primary><option>length</option> expansion item</primary>
14340 </indexterm>
14341 The <option>length</option> operator is a simpler interface to the <option>length</option> function that
14342 can be used when the parameter is a fixed number (as opposed to a string that
14343 changes when expanded). The effect is the same as
14344 </para>
14345 <literallayout class="monospaced">
14346 ${length{&lt;number&gt;}{&lt;string&gt;}}
14347 </literallayout>
14348 <para>
14349 See the description of the general <option>length</option> item above for details. Note that
14350 <option>length</option> is not the same as <option>strlen</option>. The abbreviation <option>l</option> can be used
14351 when <option>length</option> is used as an operator.
14352 </para>
14353 </listitem></varlistentry>
14354 <varlistentry>
14355 <term><emphasis role="bold">${local_part:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14356 <listitem>
14357 <para>
14358 <indexterm role="concept">
14359 <primary>expansion</primary>
14360 <secondary>local part extraction</secondary>
14361 </indexterm>
14362 <indexterm role="concept">
14363 <primary><option>local_part</option> expansion item</primary>
14364 </indexterm>
14365 The string is interpreted as an RFC 2822 address and the local part is
14366 extracted from it. If the string does not parse successfully, the result is
14367 empty.
14368 </para>
14369 </listitem></varlistentry>
14370 <varlistentry>
14371 <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>
14372 <listitem>
14373 <para>
14374 <indexterm role="concept">
14375 <primary>masked IP address</primary>
14376 </indexterm>
14377 <indexterm role="concept">
14378 <primary>IP address</primary>
14379 <secondary>masking</secondary>
14380 </indexterm>
14381 <indexterm role="concept">
14382 <primary>CIDR notation</primary>
14383 </indexterm>
14384 <indexterm role="concept">
14385 <primary>expansion</primary>
14386 <secondary>IP address masking</secondary>
14387 </indexterm>
14388 <indexterm role="concept">
14389 <primary><option>mask</option> expansion item</primary>
14390 </indexterm>
14391 If the form of the string to be operated on is not an IP address followed by a
14392 slash and an integer (that is, a network address in CIDR notation), the
14393 expansion fails. Otherwise, this operator converts the IP address to binary,
14394 masks off the least significant bits according to the bit count, and converts
14395 the result back to text, with mask appended. For example,
14396 </para>
14397 <literallayout class="monospaced">
14398 ${mask:10.111.131.206/28}
14399 </literallayout>
14400 <para>
14401 returns the string <quote>10.111.131.192/28</quote>. Since this operation is expected to
14402 be mostly used for looking up masked addresses in files, the result for an IPv6
14403 address uses dots to separate components instead of colons, because colon
14404 terminates a key string in lsearch files. So, for example,
14405 </para>
14406 <literallayout class="monospaced">
14407 ${mask:3ffe:ffff:836f:0a00:000a:0800:200a:c031/99}
14408 </literallayout>
14409 <para>
14410 returns the string
14411 </para>
14412 <literallayout class="monospaced">
14413 3ffe.ffff.836f.0a00.000a.0800.2000.0000/99
14414 </literallayout>
14415 <para>
14416 Letters in IPv6 addresses are always output in lower case.
14417 </para>
14418 </listitem></varlistentry>
14419 <varlistentry>
14420 <term><emphasis role="bold">${md5:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14421 <listitem>
14422 <para>
14423 <indexterm role="concept">
14424 <primary>MD5 hash</primary>
14425 </indexterm>
14426 <indexterm role="concept">
14427 <primary>expansion</primary>
14428 <secondary>MD5 hash</secondary>
14429 </indexterm>
14430 <indexterm role="concept">
14431 <primary><option>md5</option> expansion item</primary>
14432 </indexterm>
14433 The <option>md5</option> operator computes the MD5 hash value of the string, and returns it
14434 as a 32-digit hexadecimal number, in which any letters are in lower case.
14435 </para>
14436 </listitem></varlistentry>
14437 <varlistentry>
14438 <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>
14439 <listitem>
14440 <para>
14441 <indexterm role="concept">
14442 <primary>expansion</primary>
14443 <secondary>numeric hash</secondary>
14444 </indexterm>
14445 <indexterm role="concept">
14446 <primary>hash function</primary>
14447 <secondary>numeric</secondary>
14448 </indexterm>
14449 The <option>nhash</option> operator is a simpler interface to the numeric hashing function
14450 that can be used when the two parameters are fixed numbers (as opposed to
14451 strings that change when expanded). The effect is the same as
14452 </para>
14453 <literallayout class="monospaced">
14454 ${nhash{&lt;n&gt;}{&lt;m&gt;}{&lt;string&gt;}}
14455 </literallayout>
14456 <para>
14457 See the description of the general <option>nhash</option> item above for details.
14458 </para>
14459 </listitem></varlistentry>
14460 <varlistentry>
14461 <term><emphasis role="bold">${quote:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14462 <listitem>
14463 <para>
14464 <indexterm role="concept">
14465 <primary>quoting</primary>
14466 <secondary>in string expansions</secondary>
14467 </indexterm>
14468 <indexterm role="concept">
14469 <primary>expansion</primary>
14470 <secondary>quoting</secondary>
14471 </indexterm>
14472 <indexterm role="concept">
14473 <primary><option>quote</option> expansion item</primary>
14474 </indexterm>
14475 The <option>quote</option> operator puts its argument into double quotes if it
14476 is an empty string or
14477 contains anything other than letters, digits, underscores, dots, and hyphens.
14478 Any occurrences of double quotes and backslashes are escaped with a backslash.
14479 Newlines and carriage returns are converted to <literal>\n</literal> and <literal>\r</literal>,
14480 respectively For example,
14481 </para>
14482 <literallayout class="monospaced">
14483 ${quote:ab"*"cd}
14484 </literallayout>
14485 <para>
14486 becomes
14487 </para>
14488 <literallayout class="monospaced">
14489 "ab\"*\"cd"
14490 </literallayout>
14491 <para>
14492 The place where this is useful is when the argument is a substitution from a
14493 variable or a message header.
14494 </para>
14495 </listitem></varlistentry>
14496 <varlistentry>
14497 <term><emphasis role="bold">${quote_local_part:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14498 <listitem>
14499 <para>
14500 <indexterm role="concept">
14501 <primary><option>quote_local_part</option> expansion item</primary>
14502 </indexterm>
14503 This operator is like <option>quote</option>, except that it quotes the string only if
14504 required to do so by the rules of RFC 2822 for quoting local parts. For
14505 example, a plus sign would not cause quoting (but it would for <option>quote</option>).
14506 If you are creating a new email address from the contents of <varname>$local_part</varname>
14507 (or any other unknown data), you should always use this operator.
14508 </para>
14509 </listitem></varlistentry>
14510 <varlistentry>
14511 <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>
14512 <listitem>
14513 <para>
14514 <indexterm role="concept">
14515 <primary>quoting</primary>
14516 <secondary>lookup-specific</secondary>
14517 </indexterm>
14518 This operator applies lookup-specific quoting rules to the string. Each
14519 query-style lookup type has its own quoting rules which are described with
14520 the lookups in chapter <xref linkend="CHAPfdlookup"/>. For example,
14521 </para>
14522 <literallayout class="monospaced">
14523 ${quote_ldap:two * two}
14524 </literallayout>
14525 <para>
14526 returns
14527 </para>
14528 <literallayout class="monospaced">
14529 two%20%5C2A%20two
14530 </literallayout>
14531 <para>
14532 For single-key lookup types, no quoting is ever necessary and this operator
14533 yields an unchanged string.
14534 </para>
14535 </listitem></varlistentry>
14536 <varlistentry>
14537 <term><emphasis role="bold">${randint:</emphasis>&lt;<emphasis>n</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14538 <listitem>
14539 <para>
14540 <indexterm role="concept">
14541 <primary>random number</primary>
14542 </indexterm>
14543 This operator returns a somewhat random number which is less than the
14544 supplied number and is at least 0.  The quality of this randomness depends
14545 on how Exim was built; the values are not suitable for keying material.
14546 If Exim is linked against OpenSSL then RAND_pseudo_bytes() is used.
14547 Otherwise, the implementation may be arc4random(), random() seeded by
14548 srandomdev() or srandom(), or a custom implementation even weaker than
14549 random().
14550 </para>
14551 </listitem></varlistentry>
14552 <varlistentry revisionflag="changed">
14553 <term><emphasis role="bold">${reverse_ip:</emphasis>&lt;<emphasis>ipaddr</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14554 <listitem>
14555 <para revisionflag="changed">
14556 <indexterm role="concept">
14557 <primary>expansion</primary>
14558 <secondary>IP address</secondary>
14559 </indexterm>
14560 This operator reverses an IP address; for IPv4 addresses, the result is in
14561 dotted-quad decimal form, while for IPv6 addreses the result is in
14562 dotted-nibble hexadecimal form.  In both cases, this is the "natural" form
14563 for DNS.  For example,
14564 </para>
14565 <literallayout class="monospaced" revisionflag="changed">
14566 ${reverse_ip:192.0.2.4} and ${reverse_ip:2001:0db8:c42:9:1:abcd:192.0.2.3}
14567 </literallayout>
14568 <para revisionflag="changed">
14569 returns
14570 </para>
14571 <literallayout class="monospaced" revisionflag="changed">
14572 4.2.0.192 and 3.0.2.0.0.0.0.c.d.c.b.a.1.0.0.0.9.0.0.0.2.4.c.0.8.b.d.0.1.0.0.2
14573 </literallayout>
14574 </listitem></varlistentry>
14575 <varlistentry>
14576 <term><emphasis role="bold">${rfc2047:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14577 <listitem>
14578 <para>
14579 <indexterm role="concept">
14580 <primary>expansion</primary>
14581 <secondary>RFC 2047</secondary>
14582 </indexterm>
14583 <indexterm role="concept">
14584 <primary>RFC 2047</primary>
14585 <secondary>expansion operator</secondary>
14586 </indexterm>
14587 <indexterm role="concept">
14588 <primary><option>rfc2047</option> expansion item</primary>
14589 </indexterm>
14590 This operator encodes text according to the rules of RFC 2047. This is an
14591 encoding that is used in header lines to encode non-ASCII characters. It is
14592 assumed that the input string is in the encoding specified by the
14593 <option>headers_charset</option> option, which defaults to ISO-8859-1. If the string
14594 contains only characters in the range 33&ndash;126, and no instances of the
14595 characters
14596 </para>
14597 <literallayout class="monospaced">
14598 ? = ( ) &lt; &gt; @ , ; : \ " . [ ] _
14599 </literallayout>
14600 <para>
14601 it is not modified. Otherwise, the result is the RFC 2047 encoding of the
14602 string, using as many <quote>encoded words</quote> as necessary to encode all the
14603 characters.
14604 </para>
14605 </listitem></varlistentry>
14606 <varlistentry>
14607 <term><emphasis role="bold">${rfc2047d:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14608 <listitem>
14609 <para>
14610 <indexterm role="concept">
14611 <primary>expansion</primary>
14612 <secondary>RFC 2047</secondary>
14613 </indexterm>
14614 <indexterm role="concept">
14615 <primary>RFC 2047</primary>
14616 <secondary>decoding</secondary>
14617 </indexterm>
14618 <indexterm role="concept">
14619 <primary><option>rfc2047d</option> expansion item</primary>
14620 </indexterm>
14621 This operator decodes strings that are encoded as per RFC 2047. Binary zero
14622 bytes are replaced by question marks. Characters are converted into the
14623 character set defined by <option>headers_charset</option>. Overlong RFC 2047 <quote>words</quote> are
14624 not recognized unless <option>check_rfc2047_length</option> is set false.
14625 </para>
14626 <para>
14627 <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
14628 access a header line, RFC 2047 decoding is done automatically. You do not need
14629 to use this operator as well.
14630 </para>
14631 </listitem></varlistentry>
14632 <varlistentry>
14633 <term><emphasis role="bold">${rxquote:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14634 <listitem>
14635 <para>
14636 <indexterm role="concept">
14637 <primary>quoting</primary>
14638 <secondary>in regular expressions</secondary>
14639 </indexterm>
14640 <indexterm role="concept">
14641 <primary>regular expressions</primary>
14642 <secondary>quoting</secondary>
14643 </indexterm>
14644 <indexterm role="concept">
14645 <primary><option>rxquote</option> expansion item</primary>
14646 </indexterm>
14647 The <option>rxquote</option> operator inserts a backslash before any non-alphanumeric
14648 characters in its argument. This is useful when substituting the values of
14649 variables or headers inside regular expressions.
14650 </para>
14651 </listitem></varlistentry>
14652 <varlistentry>
14653 <term><emphasis role="bold">${sha1:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14654 <listitem>
14655 <para>
14656 <indexterm role="concept">
14657 <primary>SHA-1 hash</primary>
14658 </indexterm>
14659 <indexterm role="concept">
14660 <primary>expansion</primary>
14661 <secondary>SHA-1 hashing</secondary>
14662 </indexterm>
14663 <indexterm role="concept">
14664 <primary><option>sha2</option> expansion item</primary>
14665 </indexterm>
14666 The <option>sha1</option> operator computes the SHA-1 hash value of the string, and returns
14667 it as a 40-digit hexadecimal number, in which any letters are in upper case.
14668 </para>
14669 </listitem></varlistentry>
14670 <varlistentry>
14671 <term><emphasis role="bold">${stat:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14672 <listitem>
14673 <para>
14674 <indexterm role="concept">
14675 <primary>expansion</primary>
14676 <secondary>statting a file</secondary>
14677 </indexterm>
14678 <indexterm role="concept">
14679 <primary>file</primary>
14680 <secondary>extracting characteristics</secondary>
14681 </indexterm>
14682 <indexterm role="concept">
14683 <primary><option>stat</option> expansion item</primary>
14684 </indexterm>
14685 The string, after expansion, must be a file path. A call to the <function>stat()</function>
14686 function is made for this path. If <function>stat()</function> fails, an error occurs and the
14687 expansion fails. If it succeeds, the data from the stat replaces the item, as a
14688 series of &lt;<emphasis>name</emphasis>&gt;=&lt;<emphasis>value</emphasis>&gt; pairs, where the values are all numerical,
14689 except for the value of <quote>smode</quote>. The names are: <quote>mode</quote> (giving the mode as
14690 a 4-digit octal number), <quote>smode</quote> (giving the mode in symbolic format as a
14691 10-character string, as for the <emphasis>ls</emphasis> command), <quote>inode</quote>, <quote>device</quote>,
14692 <quote>links</quote>, <quote>uid</quote>, <quote>gid</quote>, <quote>size</quote>, <quote>atime</quote>, <quote>mtime</quote>, and <quote>ctime</quote>. You
14693 can extract individual fields using the <option>extract</option> expansion item.
14694 </para>
14695 <para>
14696 The use of the <option>stat</option> expansion in users&#x2019; filter files can be locked out by
14697 the system administrator. <emphasis role="bold">Warning</emphasis>: The file size may be incorrect on 32-bit
14698 systems for files larger than 2GB.
14699 </para>
14700 </listitem></varlistentry>
14701 <varlistentry>
14702 <term><emphasis role="bold">${str2b64:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14703 <listitem>
14704 <para>
14705 <indexterm role="concept">
14706 <primary>expansion</primary>
14707 <secondary>base64 encoding</secondary>
14708 </indexterm>
14709 <indexterm role="concept">
14710 <primary>base64 encoding</primary>
14711 <secondary>in string expansion</secondary>
14712 </indexterm>
14713 <indexterm role="concept">
14714 <primary><option>str2b64</option> expansion item</primary>
14715 </indexterm>
14716 This operator converts a string into one that is base64 encoded.
14717 </para>
14718 </listitem></varlistentry>
14719 <varlistentry>
14720 <term><emphasis role="bold">${strlen:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14721 <listitem>
14722 <para>
14723 <indexterm role="concept">
14724 <primary>expansion</primary>
14725 <secondary>string length</secondary>
14726 </indexterm>
14727 <indexterm role="concept">
14728 <primary>string</primary>
14729 <secondary>length in expansion</secondary>
14730 </indexterm>
14731 <indexterm role="concept">
14732 <primary><option>strlen</option> expansion item</primary>
14733 </indexterm>
14734 The item is replace by the length of the expanded string, expressed as a
14735 decimal number. <emphasis role="bold">Note</emphasis>: Do not confuse <option>strlen</option> with <option>length</option>.
14736 </para>
14737 </listitem></varlistentry>
14738 <varlistentry>
14739 <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>
14740 <listitem>
14741 <para>
14742 <indexterm role="concept">
14743 <primary><option>substr</option> expansion item</primary>
14744 </indexterm>
14745 <indexterm role="concept">
14746 <primary>substring extraction</primary>
14747 </indexterm>
14748 <indexterm role="concept">
14749 <primary>expansion</primary>
14750 <secondary>substring expansion</secondary>
14751 </indexterm>
14752 The <option>substr</option> operator is a simpler interface to the <option>substr</option> function that
14753 can be used when the two parameters are fixed numbers (as opposed to strings
14754 that change when expanded). The effect is the same as
14755 </para>
14756 <literallayout class="monospaced">
14757 ${substr{&lt;start&gt;}{&lt;length&gt;}{&lt;string&gt;}}
14758 </literallayout>
14759 <para>
14760 See the description of the general <option>substr</option> item above for details. The
14761 abbreviation <option>s</option> can be used when <option>substr</option> is used as an operator.
14762 </para>
14763 </listitem></varlistentry>
14764 <varlistentry>
14765 <term><emphasis role="bold">${time_eval:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14766 <listitem>
14767 <para>
14768 <indexterm role="concept">
14769 <primary><option>time_eval</option> expansion item</primary>
14770 </indexterm>
14771 <indexterm role="concept">
14772 <primary>time interval</primary>
14773 <secondary>decoding</secondary>
14774 </indexterm>
14775 This item converts an Exim time interval such as <literal>2d4h5m</literal> into a number of
14776 seconds.
14777 </para>
14778 </listitem></varlistentry>
14779 <varlistentry>
14780 <term><emphasis role="bold">${time_interval:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14781 <listitem>
14782 <para>
14783 <indexterm role="concept">
14784 <primary><option>time_interval</option> expansion item</primary>
14785 </indexterm>
14786 <indexterm role="concept">
14787 <primary>time interval</primary>
14788 <secondary>formatting</secondary>
14789 </indexterm>
14790 The argument (after sub-expansion) must be a sequence of decimal digits that
14791 represents an interval of time as a number of seconds. It is converted into a
14792 number of larger units and output in Exim&#x2019;s normal time format, for example,
14793 <literal>1w3d4h2m6s</literal>.
14794 </para>
14795 </listitem></varlistentry>
14796 <varlistentry>
14797 <term><emphasis role="bold">${uc:</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14798 <listitem>
14799 <para>
14800 <indexterm role="concept">
14801 <primary>case forcing in strings</primary>
14802 </indexterm>
14803 <indexterm role="concept">
14804 <primary>string</primary>
14805 <secondary>case forcing</secondary>
14806 </indexterm>
14807 <indexterm role="concept">
14808 <primary>upper casing</primary>
14809 </indexterm>
14810 <indexterm role="concept">
14811 <primary>expansion</primary>
14812 <secondary>case forcing</secondary>
14813 </indexterm>
14814 <indexterm role="concept">
14815 <primary><option>uc</option> expansion item</primary>
14816 </indexterm>
14817 This forces the letters in the string into upper-case.
14818 </para>
14819 </listitem></varlistentry>
14820 </variablelist>
14821 </section>
14822 <section id="SECTexpcond">
14823 <title>Expansion conditions</title>
14824 <para>
14825 <indexterm role="concept" id="IIDexpcond" class="startofrange">
14826 <primary>expansion</primary>
14827 <secondary>conditions</secondary>
14828 </indexterm>
14829 The following conditions are available for testing by the <option>${if</option> construct
14830 while expanding strings:
14831 </para>
14832 <variablelist>
14833 <varlistentry>
14834 <term><emphasis role="bold">!</emphasis>&lt;<emphasis>condition</emphasis>&gt;</term>
14835 <listitem>
14836 <para>
14837 <indexterm role="concept">
14838 <primary>expansion</primary>
14839 <secondary>negating a condition</secondary>
14840 </indexterm>
14841 <indexterm role="concept">
14842 <primary>negation</primary>
14843 <secondary>in expansion condition</secondary>
14844 </indexterm>
14845 Preceding any condition with an exclamation mark negates the result of the
14846 condition.
14847 </para>
14848 </listitem></varlistentry>
14849 <varlistentry>
14850 <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>
14851 <listitem>
14852 <para>
14853 <indexterm role="concept">
14854 <primary>numeric comparison</primary>
14855 </indexterm>
14856 <indexterm role="concept">
14857 <primary>expansion</primary>
14858 <secondary>numeric comparison</secondary>
14859 </indexterm>
14860 There are a number of symbolic operators for doing numeric comparisons. They
14861 are:
14862 </para>
14863 <literallayout>
14864 <literal>=   </literal>   equal
14865 <literal>==  </literal>   equal
14866 <literal>&gt;   </literal>   greater
14867 <literal>&gt;=  </literal>   greater or equal
14868 <literal>&lt;   </literal>   less
14869 <literal>&lt;=  </literal>   less or equal
14870 </literallayout>
14871 <para>
14872 For example:
14873 </para>
14874 <literallayout class="monospaced">
14875 ${if &gt;{$message_size}{10M} ...
14876 </literallayout>
14877 <para>
14878 Note that the general negation operator provides for inequality testing. The
14879 two strings must take the form of optionally signed decimal integers,
14880 optionally followed by one of the letters <quote>K</quote> or <quote>M</quote> (in either upper or
14881 lower case), signifying multiplication by 1024 or 1024*1024, respectively.
14882 As a special case, the numerical value of an empty string is taken as
14883 zero.
14884 </para>
14885 </listitem></varlistentry>
14886 <varlistentry revisionflag="changed">
14887 <term><emphasis role="bold">bool&nbsp;{</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14888 <listitem>
14889 <para revisionflag="changed">
14890 <indexterm role="concept">
14891 <primary>expansion</primary>
14892 <secondary>boolean parsing</secondary>
14893 </indexterm>
14894 <indexterm role="concept">
14895 <primary><option>bool</option> expansion condition</primary>
14896 </indexterm>
14897 This condition turns a string holding a true or false representation into
14898 a boolean state.  It parses <quote>true</quote>, <quote>false</quote>, <quote>yes</quote> and <quote>no</quote>
14899 (case-insensitively); also positive integer numbers map to true if non-zero,
14900 false if zero.  Leading and trailing whitespace is ignored.
14901 All other string values will result in expansion failure.
14902 </para>
14903 <para revisionflag="changed">
14904 When combined with ACL variables, this expansion condition will let you
14905 make decisions in one place and act on those decisions in another place.
14906 For example:
14907 </para>
14908 <literallayout class="monospaced" revisionflag="changed">
14909 ${if bool{$acl_m_privileged_sender} ...
14910 </literallayout>
14911 </listitem></varlistentry>
14912 <varlistentry revisionflag="changed">
14913 <term><emphasis role="bold">bool_lax&nbsp;{</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
14914 <listitem>
14915 <para revisionflag="changed">
14916 <indexterm role="concept">
14917 <primary>expansion</primary>
14918 <secondary>boolean parsing</secondary>
14919 </indexterm>
14920 <indexterm role="concept">
14921 <primary><option>bool_lax</option> expansion condition</primary>
14922 </indexterm>
14923 Like <option>bool</option>, this condition turns a string into a boolean state.  But
14924 where <option>bool</option> accepts a strict set of strings, <option>bool_lax</option> uses the same
14925 loose definition that the Router <option>condition</option> option uses.  The empty string
14926 and the values <quote>false</quote>, <quote>no</quote> and <quote>0</quote> map to false, all others map to
14927 true.  Leading and trailing whitespace is ignored.
14928 </para>
14929 <para revisionflag="changed">
14930 Note that where <quote>bool{00}</quote> is false, <quote>bool_lax{00}</quote> is true.
14931 </para>
14932 </listitem></varlistentry>
14933 <varlistentry>
14934 <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>
14935 <listitem>
14936 <para>
14937 <indexterm role="concept">
14938 <primary>expansion</primary>
14939 <secondary>encrypted comparison</secondary>
14940 </indexterm>
14941 <indexterm role="concept">
14942 <primary>encrypted strings, comparing</primary>
14943 </indexterm>
14944 <indexterm role="concept">
14945 <primary><option>crypteq</option> expansion condition</primary>
14946 </indexterm>
14947 This condition is included in the Exim binary if it is built to support any
14948 authentication mechanisms (see chapter <xref linkend="CHAPSMTPAUTH"/>). Otherwise, it is
14949 necessary to define SUPPORT_CRYPTEQ in <filename>Local/Makefile</filename> to get <option>crypteq</option>
14950 included in the binary.
14951 </para>
14952 <para>
14953 The <option>crypteq</option> condition has two arguments. The first is encrypted and
14954 compared against the second, which is already encrypted. The second string may
14955 be in the LDAP form for storing encrypted strings, which starts with the
14956 encryption type in curly brackets, followed by the data. If the second string
14957 does not begin with <quote>{</quote> it is assumed to be encrypted with <function>crypt()</function> or
14958 <function>crypt16()</function> (see below), since such strings cannot begin with <quote>{</quote>.
14959 Typically this will be a field from a password file. An example of an encrypted
14960 string in LDAP form is:
14961 </para>
14962 <literallayout class="monospaced">
14963 {md5}CY9rzUYh03PK3k6DJie09g==
14964 </literallayout>
14965 <para>
14966 If such a string appears directly in an expansion, the curly brackets have to
14967 be quoted, because they are part of the expansion syntax. For example:
14968 </para>
14969 <literallayout class="monospaced">
14970 ${if crypteq {test}{\{md5\}CY9rzUYh03PK3k6DJie09g==}{yes}{no}}
14971 </literallayout>
14972 <para>
14973 The following encryption types (whose names are matched case-independently) are
14974 supported:
14975 </para>
14976 <itemizedlist>
14977 <listitem>
14978 <para>
14979 <indexterm role="concept">
14980 <primary>MD5 hash</primary>
14981 </indexterm>
14982 <indexterm role="concept">
14983 <primary>base64 encoding</primary>
14984 <secondary>in encrypted password</secondary>
14985 </indexterm>
14986 <option>{md5}</option> computes the MD5 digest of the first string, and expresses this as
14987 printable characters to compare with the remainder of the second string. If the
14988 length of the comparison string is 24, Exim assumes that it is base64 encoded
14989 (as in the above example). If the length is 32, Exim assumes that it is a
14990 hexadecimal encoding of the MD5 digest. If the length not 24 or 32, the
14991 comparison fails.
14992 </para>
14993 </listitem>
14994 <listitem>
14995 <para>
14996 <indexterm role="concept">
14997 <primary>SHA-1 hash</primary>
14998 </indexterm>
14999 <option>{sha1}</option> computes the SHA-1 digest of the first string, and expresses this as
15000 printable characters to compare with the remainder of the second string. If the
15001 length of the comparison string is 28, Exim assumes that it is base64 encoded.
15002 If the length is 40, Exim assumes that it is a hexadecimal encoding of the
15003 SHA-1 digest. If the length is not 28 or 40, the comparison fails.
15004 </para>
15005 </listitem>
15006 <listitem>
15007 <para>
15008 <indexterm role="concept">
15009 <primary><function>crypt()</function></primary>
15010 </indexterm>
15011 <option>{crypt}</option> calls the <function>crypt()</function> function, which traditionally used to use
15012 only the first eight characters of the password. However, in modern operating
15013 systems this is no longer true, and in many cases the entire password is used,
15014 whatever its length.
15015 </para>
15016 </listitem>
15017 <listitem>
15018 <para>
15019 <indexterm role="concept">
15020 <primary><function>crypt16()</function></primary>
15021 </indexterm>
15022 <option>{crypt16}</option> calls the <function>crypt16()</function> function, which was originally created to
15023 use up to 16 characters of the password in some operating systems. Again, in
15024 modern operating systems, more characters may be used.
15025 </para>
15026 </listitem>
15027 </itemizedlist>
15028 <para>
15029 Exim has its own version of <function>crypt16()</function>, which is just a double call to
15030 <function>crypt()</function>. For operating systems that have their own version, setting
15031 HAVE_CRYPT16 in <filename>Local/Makefile</filename> when building Exim causes it to use the
15032 operating system version instead of its own. This option is set by default in
15033 the OS-dependent <filename>Makefile</filename> for those operating systems that are known to
15034 support <function>crypt16()</function>.
15035 </para>
15036 <para>
15037 Some years after Exim&#x2019;s <function>crypt16()</function> was implemented, a user discovered that
15038 it was not using the same algorithm as some operating systems&#x2019; versions. It
15039 turns out that as well as <function>crypt16()</function> there is a function called
15040 <function>bigcrypt()</function> in some operating systems. This may or may not use the same
15041 algorithm, and both of them may be different to Exim&#x2019;s built-in <function>crypt16()</function>.
15042 </para>
15043 <para>
15044 However, since there is now a move away from the traditional <function>crypt()</function>
15045 functions towards using SHA1 and other algorithms, tidying up this area of
15046 Exim is seen as very low priority.
15047 </para>
15048 <para>
15049 If you do not put a encryption type (in curly brackets) in a <option>crypteq</option>
15050 comparison, the default is usually either <literal>{crypt}</literal> or <literal>{crypt16}</literal>, as
15051 determined by the setting of DEFAULT_CRYPT in <filename>Local/Makefile</filename>. The default
15052 default is <literal>{crypt}</literal>. Whatever the default, you can always use either
15053 function by specifying it explicitly in curly brackets.
15054 </para>
15055 </listitem></varlistentry>
15056 <varlistentry>
15057 <term><emphasis role="bold">def:</emphasis>&lt;<emphasis>variable&nbsp;name</emphasis>&gt;</term>
15058 <listitem>
15059 <para>
15060 <indexterm role="concept">
15061 <primary>expansion</primary>
15062 <secondary>checking for empty variable</secondary>
15063 </indexterm>
15064 <indexterm role="concept">
15065 <primary><option>def</option> expansion condition</primary>
15066 </indexterm>
15067 The <option>def</option> condition must be followed by the name of one of the expansion
15068 variables defined in section <xref linkend="SECTexpvar"/>. The condition is true if the
15069 variable does not contain the empty string. For example:
15070 </para>
15071 <literallayout class="monospaced">
15072 ${if def:sender_ident {from $sender_ident}}
15073 </literallayout>
15074 <para>
15075 Note that the variable name is given without a leading <option>$</option> character. If the
15076 variable does not exist, the expansion fails.
15077 </para>
15078 </listitem></varlistentry>
15079 <varlistentry>
15080 <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>
15081 <listitem>
15082 <para>
15083 <indexterm role="concept">
15084 <primary>expansion</primary>
15085 <secondary>checking header line existence</secondary>
15086 </indexterm>
15087 This condition is true if a message is being processed and the named header
15088 exists in the message. For example,
15089 </para>
15090 <literallayout class="monospaced">
15091 ${if def:header_reply-to:{$h_reply-to:}{$h_from:}}
15092 </literallayout>
15093 <para>
15094 <emphasis role="bold">Note</emphasis>: No <option>$</option> appears before <option>header_</option> or <option>h_</option> in the condition, and
15095 the header name must be terminated by a colon if white space does not follow.
15096 </para>
15097 </listitem></varlistentry>
15098 <varlistentry>
15099 <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>
15100 <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>
15101 <listitem>
15102 <para>
15103 <indexterm role="concept">
15104 <primary>string</primary>
15105 <secondary>comparison</secondary>
15106 </indexterm>
15107 <indexterm role="concept">
15108 <primary>expansion</primary>
15109 <secondary>string comparison</secondary>
15110 </indexterm>
15111 <indexterm role="concept">
15112 <primary><option>eq</option> expansion condition</primary>
15113 </indexterm>
15114 <indexterm role="concept">
15115 <primary><option>eqi</option> expansion condition</primary>
15116 </indexterm>
15117 The two substrings are first expanded. The condition is true if the two
15118 resulting strings are identical. For <option>eq</option> the comparison includes the case of
15119 letters, whereas for <option>eqi</option> the comparison is case-independent.
15120 </para>
15121 </listitem></varlistentry>
15122 <varlistentry>
15123 <term><emphasis role="bold">exists&nbsp;{</emphasis>&lt;<emphasis>file&nbsp;name</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
15124 <listitem>
15125 <para>
15126 <indexterm role="concept">
15127 <primary>expansion</primary>
15128 <secondary>file existence test</secondary>
15129 </indexterm>
15130 <indexterm role="concept">
15131 <primary>file</primary>
15132 <secondary>existence test</secondary>
15133 </indexterm>
15134 <indexterm role="concept">
15135 <primary><option>exists</option>, expansion condition</primary>
15136 </indexterm>
15137 The substring is first expanded and then interpreted as an absolute path. The
15138 condition is true if the named file (or directory) exists. The existence test
15139 is done by calling the <function>stat()</function> function. The use of the <option>exists</option> test in
15140 users&#x2019; filter files may be locked out by the system administrator.
15141 </para>
15142 </listitem></varlistentry>
15143 <varlistentry>
15144 <term><emphasis role="bold">first_delivery</emphasis></term>
15145 <listitem>
15146 <para>
15147 <indexterm role="concept">
15148 <primary>delivery</primary>
15149 <secondary>first</secondary>
15150 </indexterm>
15151 <indexterm role="concept">
15152 <primary>first delivery</primary>
15153 </indexterm>
15154 <indexterm role="concept">
15155 <primary>expansion</primary>
15156 <secondary>first delivery test</secondary>
15157 </indexterm>
15158 <indexterm role="concept">
15159 <primary><option>first_delivery</option> expansion condition</primary>
15160 </indexterm>
15161 This condition, which has no data, is true during a message&#x2019;s first delivery
15162 attempt. It is false during any subsequent delivery attempts.
15163 </para>
15164 </listitem></varlistentry>
15165 <varlistentry>
15166 <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>
15167 <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>
15168 <listitem>
15169 <para>
15170 <indexterm role="concept">
15171 <primary>list</primary>
15172 <secondary>iterative conditions</secondary>
15173 </indexterm>
15174 <indexterm role="concept">
15175 <primary>expansion</primary>
15176 <secondary><emphasis role="bold">forall</emphasis> condition</secondary>
15177 </indexterm>
15178 <indexterm role="concept">
15179 <primary>expansion</primary>
15180 <secondary><emphasis role="bold">forany</emphasis> condition</secondary>
15181 </indexterm>
15182 <indexterm role="variable">
15183 <primary><varname>$item</varname></primary>
15184 </indexterm>
15185 These conditions iterate over a list. The first argument is expanded to form
15186 the list. By default, the list separator is a colon, but it can be changed by
15187 the normal method. The second argument is interpreted as a condition that is to
15188 be applied to each item in the list in turn. During the interpretation of the
15189 condition, the current list item is placed in a variable called <varname>$item</varname>.
15190 </para>
15191 <itemizedlist>
15192 <listitem>
15193 <para>
15194 For <emphasis role="bold">forany</emphasis>, interpretation stops if the condition is true for any item, and
15195 the result of the whole condition is true. If the condition is false for all
15196 items in the list, the overall condition is false.
15197 </para>
15198 </listitem>
15199 <listitem>
15200 <para>
15201 For <emphasis role="bold">forall</emphasis>, interpretation stops if the condition is false for any item,
15202 and the result of the whole condition is false. If the condition is true for
15203 all items in the list, the overall condition is true.
15204 </para>
15205 </listitem>
15206 </itemizedlist>
15207 <para>
15208 Note that negation of <emphasis role="bold">forany</emphasis> means that the condition must be false for all
15209 items for the overall condition to succeed, and negation of <emphasis role="bold">forall</emphasis> means
15210 that the condition must be false for at least one item. In this example, the
15211 list separator is changed to a comma:
15212 </para>
15213 <literallayout class="monospaced">
15214 ${if forany{&lt;, $recipients}{match{$item}{^user3@}}{yes}{no}}
15215 </literallayout>
15216 <para>
15217 The value of <varname>$item</varname> is saved and restored while <emphasis role="bold">forany</emphasis> or <emphasis role="bold">forall</emphasis> is
15218 being processed, to enable these expansion items to be nested.
15219 </para>
15220 </listitem></varlistentry>
15221 <varlistentry>
15222 <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>
15223 <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>
15224 <listitem>
15225 <para>
15226 <indexterm role="concept">
15227 <primary>string</primary>
15228 <secondary>comparison</secondary>
15229 </indexterm>
15230 <indexterm role="concept">
15231 <primary>expansion</primary>
15232 <secondary>string comparison</secondary>
15233 </indexterm>
15234 <indexterm role="concept">
15235 <primary><option>ge</option> expansion condition</primary>
15236 </indexterm>
15237 <indexterm role="concept">
15238 <primary><option>gei</option> expansion condition</primary>
15239 </indexterm>
15240 The two substrings are first expanded. The condition is true if the first
15241 string is lexically greater than or equal to the second string. For <option>ge</option> the
15242 comparison includes the case of letters, whereas for <option>gei</option> the comparison is
15243 case-independent.
15244 </para>
15245 </listitem></varlistentry>
15246 <varlistentry>
15247 <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>
15248 <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>
15249 <listitem>
15250 <para>
15251 <indexterm role="concept">
15252 <primary>string</primary>
15253 <secondary>comparison</secondary>
15254 </indexterm>
15255 <indexterm role="concept">
15256 <primary>expansion</primary>
15257 <secondary>string comparison</secondary>
15258 </indexterm>
15259 <indexterm role="concept">
15260 <primary><option>gt</option> expansion condition</primary>
15261 </indexterm>
15262 <indexterm role="concept">
15263 <primary><option>gti</option> expansion condition</primary>
15264 </indexterm>
15265 The two substrings are first expanded. The condition is true if the first
15266 string is lexically greater than the second string. For <option>gt</option> the comparison
15267 includes the case of letters, whereas for <option>gti</option> the comparison is
15268 case-independent.
15269 </para>
15270 </listitem></varlistentry>
15271 <varlistentry>
15272 <term><emphasis role="bold">isip&nbsp;{</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
15273 <term><emphasis role="bold">isip4&nbsp;{</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
15274 <term><emphasis role="bold">isip6&nbsp;{</emphasis>&lt;<emphasis>string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
15275 <listitem>
15276 <para>
15277 <indexterm role="concept">
15278 <primary>IP address</primary>
15279 <secondary>testing string format</secondary>
15280 </indexterm>
15281 <indexterm role="concept">
15282 <primary>string</primary>
15283 <secondary>testing for IP address</secondary>
15284 </indexterm>
15285 <indexterm role="concept">
15286 <primary><option>isip</option> expansion condition</primary>
15287 </indexterm>
15288 <indexterm role="concept">
15289 <primary><option>isip4</option> expansion condition</primary>
15290 </indexterm>
15291 <indexterm role="concept">
15292 <primary><option>isip6</option> expansion condition</primary>
15293 </indexterm>
15294 The substring is first expanded, and then tested to see if it has the form of
15295 an IP address. Both IPv4 and IPv6 addresses are valid for <option>isip</option>, whereas
15296 <option>isip4</option> and <option>isip6</option> test specifically for IPv4 or IPv6 addresses.
15297 </para>
15298 <para>
15299 For an IPv4 address, the test is for four dot-separated components, each of
15300 which consists of from one to three digits. For an IPv6 address, up to eight
15301 colon-separated components are permitted, each containing from one to four
15302 hexadecimal digits. There may be fewer than eight components if an empty
15303 component (adjacent colons) is present. Only one empty component is permitted.
15304 </para>
15305 <para>
15306 <emphasis role="bold">Note</emphasis>: The checks are just on the form of the address; actual numerical
15307 values are not considered. Thus, for example, 999.999.999.999 passes the IPv4
15308 check. The main use of these tests is to distinguish between IP addresses and
15309 host names, or between IPv4 and IPv6 addresses. For example, you could use
15310 </para>
15311 <literallayout class="monospaced">
15312 ${if isip4{$sender_host_address}...
15313 </literallayout>
15314 <para>
15315 to test which IP version an incoming SMTP connection is using.
15316 </para>
15317 </listitem></varlistentry>
15318 <varlistentry>
15319 <term><emphasis role="bold">ldapauth&nbsp;{</emphasis>&lt;<emphasis>ldap&nbsp;query</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
15320 <listitem>
15321 <para>
15322 <indexterm role="concept">
15323 <primary>LDAP</primary>
15324 <secondary>use for authentication</secondary>
15325 </indexterm>
15326 <indexterm role="concept">
15327 <primary>expansion</primary>
15328 <secondary>LDAP authentication test</secondary>
15329 </indexterm>
15330 <indexterm role="concept">
15331 <primary><option>ldapauth</option> expansion condition</primary>
15332 </indexterm>
15333 This condition supports user authentication using LDAP. See section
15334 <xref linkend="SECTldap"/> for details of how to use LDAP in lookups and the syntax of
15335 queries. For this use, the query must contain a user name and password. The
15336 query itself is not used, and can be empty. The condition is true if the
15337 password is not empty, and the user name and password are accepted by the LDAP
15338 server. An empty password is rejected without calling LDAP because LDAP binds
15339 with an empty password are considered anonymous regardless of the username, and
15340 will succeed in most configurations. See chapter <xref linkend="CHAPSMTPAUTH"/> for details
15341 of SMTP authentication, and chapter <xref linkend="CHAPplaintext"/> for an example of how
15342 this can be used.
15343 </para>
15344 </listitem></varlistentry>
15345 <varlistentry>
15346 <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>
15347 <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>
15348 <listitem>
15349 <para>
15350 <indexterm role="concept">
15351 <primary>string</primary>
15352 <secondary>comparison</secondary>
15353 </indexterm>
15354 <indexterm role="concept">
15355 <primary>expansion</primary>
15356 <secondary>string comparison</secondary>
15357 </indexterm>
15358 <indexterm role="concept">
15359 <primary><option>le</option> expansion condition</primary>
15360 </indexterm>
15361 <indexterm role="concept">
15362 <primary><option>lei</option> expansion condition</primary>
15363 </indexterm>
15364 The two substrings are first expanded. The condition is true if the first
15365 string is lexically less than or equal to the second string. For <option>le</option> the
15366 comparison includes the case of letters, whereas for <option>lei</option> the comparison is
15367 case-independent.
15368 </para>
15369 </listitem></varlistentry>
15370 <varlistentry>
15371 <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>
15372 <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>
15373 <listitem>
15374 <para>
15375 <indexterm role="concept">
15376 <primary>string</primary>
15377 <secondary>comparison</secondary>
15378 </indexterm>
15379 <indexterm role="concept">
15380 <primary>expansion</primary>
15381 <secondary>string comparison</secondary>
15382 </indexterm>
15383 <indexterm role="concept">
15384 <primary><option>lt</option> expansion condition</primary>
15385 </indexterm>
15386 <indexterm role="concept">
15387 <primary><option>lti</option> expansion condition</primary>
15388 </indexterm>
15389 The two substrings are first expanded. The condition is true if the first
15390 string is lexically less than the second string. For <option>lt</option> the comparison
15391 includes the case of letters, whereas for <option>lti</option> the comparison is
15392 case-independent.
15393 </para>
15394 </listitem></varlistentry>
15395 <varlistentry>
15396 <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>
15397 <listitem>
15398 <para>
15399 <indexterm role="concept">
15400 <primary>expansion</primary>
15401 <secondary>regular expression comparison</secondary>
15402 </indexterm>
15403 <indexterm role="concept">
15404 <primary>regular expressions</primary>
15405 <secondary>match in expanded string</secondary>
15406 </indexterm>
15407 <indexterm role="concept">
15408 <primary><option>match</option> expansion condition</primary>
15409 </indexterm>
15410 The two substrings are first expanded. The second is then treated as a regular
15411 expression and applied to the first. Because of the pre-expansion, if the
15412 regular expression contains dollar, or backslash characters, they must be
15413 escaped. Care must also be taken if the regular expression contains braces
15414 (curly brackets). A closing brace must be escaped so that it is not taken as a
15415 premature termination of &lt;<emphasis>string2</emphasis>&gt;. The easiest approach is to use the
15416 <literal>\N</literal> feature to disable expansion of the regular expression.
15417 For example,
15418 </para>
15419 <literallayout class="monospaced">
15420 ${if match {$local_part}{\N^\d{3}\N} ...
15421 </literallayout>
15422 <para>
15423 If the whole expansion string is in double quotes, further escaping of
15424 backslashes is also required.
15425 </para>
15426 <para>
15427 The condition is true if the regular expression match succeeds.
15428 The regular expression is not required to begin with a circumflex
15429 metacharacter, but if there is no circumflex, the expression is not anchored,
15430 and it may match anywhere in the subject, not just at the start. If you want
15431 the pattern to match at the end of the subject, you must include the <literal>$</literal>
15432 metacharacter at an appropriate point.
15433 </para>
15434 <para>
15435 <indexterm role="concept">
15436 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
15437 <secondary>in <option>if</option> expansion</secondary>
15438 </indexterm>
15439 At the start of an <option>if</option> expansion the values of the numeric variable
15440 substitutions <varname>$1</varname> etc. are remembered. Obeying a <option>match</option> condition that
15441 succeeds causes them to be reset to the substrings of that condition and they
15442 will have these values during the expansion of the success string. At the end
15443 of the <option>if</option> expansion, the previous values are restored. After testing a
15444 combination of conditions using <option>or</option>, the subsequent values of the numeric
15445 variables are those of the condition that succeeded.
15446 </para>
15447 </listitem></varlistentry>
15448 <varlistentry>
15449 <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>
15450 <listitem>
15451 <para>
15452 <indexterm role="concept">
15453 <primary><option>match_address</option> expansion condition</primary>
15454 </indexterm>
15455 See <emphasis role="bold">match_local_part</emphasis>.
15456 </para>
15457 </listitem></varlistentry>
15458 <varlistentry>
15459 <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>
15460 <listitem>
15461 <para>
15462 <indexterm role="concept">
15463 <primary><option>match_domain</option> expansion condition</primary>
15464 </indexterm>
15465 See <emphasis role="bold">match_local_part</emphasis>.
15466 </para>
15467 </listitem></varlistentry>
15468 <varlistentry>
15469 <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>
15470 <listitem>
15471 <para>
15472 <indexterm role="concept">
15473 <primary><option>match_ip</option> expansion condition</primary>
15474 </indexterm>
15475 This condition matches an IP address to a list of IP address patterns. It must
15476 be followed by two argument strings. The first (after expansion) must be an IP
15477 address or an empty string. The second (after expansion) is a restricted host
15478 list that can match only an IP address, not a host name. For example:
15479 </para>
15480 <literallayout class="monospaced">
15481 ${if match_ip{$sender_host_address}{1.2.3.4:5.6.7.8}{...}{...}}
15482 </literallayout>
15483 <para>
15484 The specific types of host list item that are permitted in the list are:
15485 </para>
15486 <itemizedlist>
15487 <listitem>
15488 <para>
15489 An IP address, optionally with a CIDR mask.
15490 </para>
15491 </listitem>
15492 <listitem>
15493 <para>
15494 A single asterisk, which matches any IP address.
15495 </para>
15496 </listitem>
15497 <listitem>
15498 <para>
15499 An empty item, which matches only if the IP address is empty. This could be
15500 useful for testing for a locally submitted message or one from specific hosts
15501 in a single test such as
15502 </para>
15503 <literallayout class="monospaced">
15504   ${if match_ip{$sender_host_address}{:4.3.2.1:...}{...}{...}}
15505 </literallayout>
15506 <para>
15507 where the first item in the list is the empty string.
15508 </para>
15509 </listitem>
15510 <listitem>
15511 <para>
15512 The item @[] matches any of the local host&#x2019;s interface addresses.
15513 </para>
15514 </listitem>
15515 <listitem>
15516 <para>
15517 Single-key lookups are assumed to be like <quote>net-</quote> style lookups in host lists,
15518 even if <literal>net-</literal> is not specified. There is never any attempt to turn the IP
15519 address into a host name. The most common type of linear search for
15520 <emphasis role="bold">match_ip</emphasis> is likely to be <emphasis role="bold">iplsearch</emphasis>, in which the file can contain CIDR
15521 masks. For example:
15522 </para>
15523 <literallayout class="monospaced">
15524   ${if match_ip{$sender_host_address}{iplsearch;/some/file}...
15525 </literallayout>
15526 <para>
15527 It is of course possible to use other kinds of lookup, and in such a case, you
15528 do need to specify the <literal>net-</literal> prefix if you want to specify a specific
15529 address mask, for example:
15530 </para>
15531 <literallayout class="monospaced">
15532   ${if match_ip{$sender_host_address}{net24-dbm;/some/file}...
15533 </literallayout>
15534 <para>
15535 However, unless you are combining a <option>match_ip</option> condition with others, it is
15536 just as easy to use the fact that a lookup is itself a condition, and write:
15537 </para>
15538 <literallayout class="monospaced">
15539   ${lookup{${mask:$sender_host_address/24}}dbm{/a/file}...
15540 </literallayout>
15541 </listitem>
15542 </itemizedlist>
15543 <para>
15544 Consult section <xref linkend="SECThoslispatip"/> for further details of these patterns.
15545 </para>
15546 </listitem></varlistentry>
15547 <varlistentry>
15548 <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>
15549 <listitem>
15550 <para>
15551 <indexterm role="concept">
15552 <primary>domain list</primary>
15553 <secondary>in expansion condition</secondary>
15554 </indexterm>
15555 <indexterm role="concept">
15556 <primary>address list</primary>
15557 <secondary>in expansion condition</secondary>
15558 </indexterm>
15559 <indexterm role="concept">
15560 <primary>local part</primary>
15561 <secondary>list, in expansion condition</secondary>
15562 </indexterm>
15563 <indexterm role="concept">
15564 <primary><option>match_local_part</option> expansion condition</primary>
15565 </indexterm>
15566 This condition, together with <option>match_address</option> and <option>match_domain</option>, make it
15567 possible to test domain, address, and local part lists within expansions. Each
15568 condition requires two arguments: an item and a list to match. A trivial
15569 example is:
15570 </para>
15571 <literallayout class="monospaced">
15572 ${if match_domain{a.b.c}{x.y.z:a.b.c:p.q.r}{yes}{no}}
15573 </literallayout>
15574 <para>
15575 In each case, the second argument may contain any of the allowable items for a
15576 list of the appropriate type. Also, because the second argument (after
15577 expansion) is a standard form of list, it is possible to refer to a named list.
15578 Thus, you can use conditions like this:
15579 </para>
15580 <literallayout class="monospaced">
15581 ${if match_domain{$domain}{+local_domains}{...
15582 </literallayout>
15583 <para>
15584 <indexterm role="concept">
15585 <primary><literal>+caseful</literal></primary>
15586 </indexterm>
15587 For address lists, the matching starts off caselessly, but the <literal>+caseful</literal>
15588 item can be used, as in all address lists, to cause subsequent items to
15589 have their local parts matched casefully. Domains are always matched
15590 caselessly.
15591 </para>
15592 <para>
15593 <emphasis role="bold">Note</emphasis>: Host lists are <emphasis>not</emphasis> supported in this way. This is because
15594 hosts have two identities: a name and an IP address, and it is not clear
15595 how to specify cleanly how such a test would work. However, IP addresses can be
15596 matched using <option>match_ip</option>.
15597 </para>
15598 </listitem></varlistentry>
15599 <varlistentry>
15600 <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>
15601 <listitem>
15602 <para>
15603 <indexterm role="concept">
15604 <primary>PAM authentication</primary>
15605 </indexterm>
15606 <indexterm role="concept">
15607 <primary>AUTH</primary>
15608 <secondary>with PAM</secondary>
15609 </indexterm>
15610 <indexterm role="concept">
15611 <primary>Solaris</primary>
15612 <secondary>PAM support</secondary>
15613 </indexterm>
15614 <indexterm role="concept">
15615 <primary>expansion</primary>
15616 <secondary>PAM authentication test</secondary>
15617 </indexterm>
15618 <indexterm role="concept">
15619 <primary><option>pam</option> expansion condition</primary>
15620 </indexterm>
15621 <emphasis>Pluggable Authentication Modules</emphasis>
15622 (<emphasis role="bold"><ulink url="http://www.kernel.org/pub/linux/libs/pam/">http://www.kernel.org/pub/linux/libs/pam/</ulink></emphasis>) are a facility that is
15623 available in the latest releases of Solaris and in some GNU/Linux
15624 distributions. The Exim support, which is intended for use in conjunction with
15625 the SMTP AUTH command, is available only if Exim is compiled with
15626 </para>
15627 <literallayout class="monospaced">
15628 SUPPORT_PAM=yes
15629 </literallayout>
15630 <para>
15631 in <filename>Local/Makefile</filename>. You probably need to add <option>-lpam</option> to EXTRALIBS, and
15632 in some releases of GNU/Linux <option>-ldl</option> is also needed.
15633 </para>
15634 <para>
15635 The argument string is first expanded, and the result must be a
15636 colon-separated list of strings. Leading and trailing white space is ignored.
15637 The PAM module is initialized with the service name <quote>exim</quote> and the user name
15638 taken from the first item in the colon-separated data string (&lt;<emphasis>string1</emphasis>&gt;).
15639 The remaining items in the data string are passed over in response to requests
15640 from the authentication function. In the simple case there will only be one
15641 request, for a password, so the data consists of just two strings.
15642 </para>
15643 <para>
15644 There can be problems if any of the strings are permitted to contain colon
15645 characters. In the usual way, these have to be doubled to avoid being taken as
15646 separators. If the data is being inserted from a variable, the <option>sg</option> expansion
15647 item can be used to double any existing colons. For example, the configuration
15648 of a LOGIN authenticator might contain this setting:
15649 </para>
15650 <literallayout class="monospaced">
15651 server_condition = ${if pam{$auth1:${sg{$auth2}{:}{::}}}}
15652 </literallayout>
15653 <para>
15654 For a PLAIN authenticator you could use:
15655 </para>
15656 <literallayout class="monospaced">
15657 server_condition = ${if pam{$auth2:${sg{$auth3}{:}{::}}}}
15658 </literallayout>
15659 <para>
15660 In some operating systems, PAM authentication can be done only from a process
15661 running as root. Since Exim is running as the Exim user when receiving
15662 messages, this means that PAM cannot be used directly in those systems.
15663 A patched version of the <emphasis>pam_unix</emphasis> module that comes with the
15664 Linux PAM package is available from <emphasis role="bold"><ulink url="http://www.e-admin.de/pam_exim/">http://www.e-admin.de/pam_exim/</ulink></emphasis>.
15665 The patched module allows one special uid/gid combination, in addition to root,
15666 to authenticate. If you build the patched module to allow the Exim user and
15667 group, PAM can then be used from an Exim authenticator.
15668 </para>
15669 </listitem></varlistentry>
15670 <varlistentry>
15671 <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>
15672 <listitem>
15673 <para>
15674 <indexterm role="concept">
15675 <primary><emphasis>pwcheck</emphasis> daemon</primary>
15676 </indexterm>
15677 <indexterm role="concept">
15678 <primary>Cyrus</primary>
15679 </indexterm>
15680 <indexterm role="concept">
15681 <primary>expansion</primary>
15682 <secondary><emphasis>pwcheck</emphasis> authentication test</secondary>
15683 </indexterm>
15684 <indexterm role="concept">
15685 <primary><option>pwcheck</option> expansion condition</primary>
15686 </indexterm>
15687 This condition supports user authentication using the Cyrus <emphasis>pwcheck</emphasis> daemon.
15688 This is one way of making it possible for passwords to be checked by a process
15689 that is not running as root. <emphasis role="bold">Note</emphasis>: The use of <emphasis>pwcheck</emphasis> is now
15690 deprecated. Its replacement is <emphasis>saslauthd</emphasis> (see below).
15691 </para>
15692 <para>
15693 The pwcheck support is not included in Exim by default. You need to specify
15694 the location of the pwcheck daemon&#x2019;s socket in <filename>Local/Makefile</filename> before
15695 building Exim. For example:
15696 </para>
15697 <literallayout class="monospaced">
15698 CYRUS_PWCHECK_SOCKET=/var/pwcheck/pwcheck
15699 </literallayout>
15700 <para>
15701 You do not need to install the full Cyrus software suite in order to use
15702 the pwcheck daemon. You can compile and install just the daemon alone
15703 from the Cyrus SASL library. Ensure that <emphasis>exim</emphasis> is the only user that has
15704 access to the <filename>/var/pwcheck</filename> directory.
15705 </para>
15706 <para>
15707 The <option>pwcheck</option> condition takes one argument, which must be the user name and
15708 password, separated by a colon. For example, in a LOGIN authenticator
15709 configuration, you might have this:
15710 </para>
15711 <literallayout class="monospaced">
15712 server_condition = ${if pwcheck{$auth1:$auth2}}
15713 </literallayout>
15714 <para>
15715 Again, for a PLAIN authenticator configuration, this would be:
15716 </para>
15717 <literallayout class="monospaced">
15718 server_condition = ${if pwcheck{$auth2:$auth3}}
15719 </literallayout>
15720 </listitem></varlistentry>
15721 <varlistentry>
15722 <term><emphasis role="bold">queue_running</emphasis></term>
15723 <listitem>
15724 <para>
15725 <indexterm role="concept">
15726 <primary>queue runner</primary>
15727 <secondary>detecting when delivering from</secondary>
15728 </indexterm>
15729 <indexterm role="concept">
15730 <primary>expansion</primary>
15731 <secondary>queue runner test</secondary>
15732 </indexterm>
15733 <indexterm role="concept">
15734 <primary><option>queue_running</option> expansion condition</primary>
15735 </indexterm>
15736 This condition, which has no data, is true during delivery attempts that are
15737 initiated by queue runner processes, and false otherwise.
15738 </para>
15739 </listitem></varlistentry>
15740 <varlistentry>
15741 <term><emphasis role="bold">radius&nbsp;{</emphasis>&lt;<emphasis>authentication&nbsp;string</emphasis>&gt;<emphasis role="bold">}</emphasis></term>
15742 <listitem>
15743 <para>
15744 <indexterm role="concept">
15745 <primary>Radius</primary>
15746 </indexterm>
15747 <indexterm role="concept">
15748 <primary>expansion</primary>
15749 <secondary>Radius authentication</secondary>
15750 </indexterm>
15751 <indexterm role="concept">
15752 <primary><option>radius</option> expansion condition</primary>
15753 </indexterm>
15754 Radius authentication (RFC 2865) is supported in a similar way to PAM. You must
15755 set RADIUS_CONFIG_FILE in <filename>Local/Makefile</filename> to specify the location of
15756 the Radius client configuration file in order to build Exim with Radius
15757 support.
15758 </para>
15759 <para>
15760 With just that one setting, Exim expects to be linked with the <option>radiusclient</option>
15761 library, using the original API. If you are using release 0.4.0 or later of
15762 this library, you need to set
15763 </para>
15764 <literallayout class="monospaced">
15765 RADIUS_LIB_TYPE=RADIUSCLIENTNEW
15766 </literallayout>
15767 <para>
15768 in <filename>Local/Makefile</filename> when building Exim. You can also link Exim with the
15769 <option>libradius</option> library that comes with FreeBSD. To do this, set
15770 </para>
15771 <literallayout class="monospaced">
15772 RADIUS_LIB_TYPE=RADLIB
15773 </literallayout>
15774 <para>
15775 in <filename>Local/Makefile</filename>, in addition to setting RADIUS_CONFIGURE_FILE.
15776 You may also have to supply a suitable setting in EXTRALIBS so that the
15777 Radius library can be found when Exim is linked.
15778 </para>
15779 <para>
15780 The string specified by RADIUS_CONFIG_FILE is expanded and passed to the
15781 Radius client library, which calls the Radius server. The condition is true if
15782 the authentication is successful. For example:
15783 </para>
15784 <literallayout class="monospaced">
15785 server_condition = ${if radius{&lt;arguments&gt;}}
15786 </literallayout>
15787 </listitem></varlistentry>
15788 <varlistentry>
15789 <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>
15790 <listitem>
15791 <para>
15792 <indexterm role="concept">
15793 <primary><emphasis>saslauthd</emphasis> daemon</primary>
15794 </indexterm>
15795 <indexterm role="concept">
15796 <primary>Cyrus</primary>
15797 </indexterm>
15798 <indexterm role="concept">
15799 <primary>expansion</primary>
15800 <secondary><emphasis>saslauthd</emphasis> authentication test</secondary>
15801 </indexterm>
15802 <indexterm role="concept">
15803 <primary><option>saslauthd</option> expansion condition</primary>
15804 </indexterm>
15805 This condition supports user authentication using the Cyrus <emphasis>saslauthd</emphasis>
15806 daemon. This replaces the older <emphasis>pwcheck</emphasis> daemon, which is now deprecated.
15807 Using this daemon is one way of making it possible for passwords to be checked
15808 by a process that is not running as root.
15809 </para>
15810 <para>
15811 The saslauthd support is not included in Exim by default. You need to specify
15812 the location of the saslauthd daemon&#x2019;s socket in <filename>Local/Makefile</filename> before
15813 building Exim. For example:
15814 </para>
15815 <literallayout class="monospaced">
15816 CYRUS_SASLAUTHD_SOCKET=/var/state/saslauthd/mux
15817 </literallayout>
15818 <para>
15819 You do not need to install the full Cyrus software suite in order to use
15820 the saslauthd daemon. You can compile and install just the daemon alone
15821 from the Cyrus SASL library.
15822 </para>
15823 <para>
15824 Up to four arguments can be supplied to the <option>saslauthd</option> condition, but only
15825 two are mandatory. For example:
15826 </para>
15827 <literallayout class="monospaced">
15828 server_condition = ${if saslauthd{{$auth1}{$auth2}}}
15829 </literallayout>
15830 <para>
15831 The service and the realm are optional (which is why the arguments are enclosed
15832 in their own set of braces). For details of the meaning of the service and
15833 realm, and how to run the daemon, consult the Cyrus documentation.
15834 </para>
15835 </listitem></varlistentry>
15836 </variablelist>
15837 </section>
15838 <section id="SECID84">
15839 <title>Combining expansion conditions</title>
15840 <para>
15841 <indexterm role="concept">
15842 <primary>expansion</primary>
15843 <secondary>combining conditions</secondary>
15844 </indexterm>
15845 Several conditions can be tested at once by combining them using the <option>and</option>
15846 and <option>or</option> combination conditions. Note that <option>and</option> and <option>or</option> are complete
15847 conditions on their own, and precede their lists of sub-conditions. Each
15848 sub-condition must be enclosed in braces within the overall braces that contain
15849 the list. No repetition of <option>if</option> is used.
15850 </para>
15851 <variablelist>
15852 <varlistentry>
15853 <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>
15854 <listitem>
15855 <para>
15856 <indexterm role="concept">
15857 <primary><quote>or</quote> expansion condition</primary>
15858 </indexterm>
15859 <indexterm role="concept">
15860 <primary>expansion</primary>
15861 <secondary><quote>or</quote> of conditions</secondary>
15862 </indexterm>
15863 The sub-conditions are evaluated from left to right. The condition is true if
15864 any one of the sub-conditions is true.
15865 For example,
15866 </para>
15867 <literallayout class="monospaced">
15868 ${if or {{eq{$local_part}{spqr}}{eq{$domain}{testing.com}}}...
15869 </literallayout>
15870 <para>
15871 When a true sub-condition is found, the following ones are parsed but not
15872 evaluated. If there are several <quote>match</quote> sub-conditions the values of the
15873 numeric variables afterwards are taken from the first one that succeeds.
15874 </para>
15875 </listitem></varlistentry>
15876 <varlistentry>
15877 <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>
15878 <listitem>
15879 <para>
15880 <indexterm role="concept">
15881 <primary><quote>and</quote> expansion condition</primary>
15882 </indexterm>
15883 <indexterm role="concept">
15884 <primary>expansion</primary>
15885 <secondary><quote>and</quote> of conditions</secondary>
15886 </indexterm>
15887 The sub-conditions are evaluated from left to right. The condition is true if
15888 all of the sub-conditions are true. If there are several <quote>match</quote>
15889 sub-conditions, the values of the numeric variables afterwards are taken from
15890 the last one. When a false sub-condition is found, the following ones are
15891 parsed but not evaluated.
15892 </para>
15893 </listitem></varlistentry>
15894 </variablelist>
15895 <para>
15896 <indexterm role="concept" startref="IIDexpcond" class="endofrange"/>
15897 </para>
15898 </section>
15899 <section id="SECTexpvar">
15900 <title>Expansion variables</title>
15901 <para>
15902 <indexterm role="concept">
15903 <primary>expansion</primary>
15904 <secondary>variables, list of</secondary>
15905 </indexterm>
15906 This section contains an alphabetical list of all the expansion variables. Some
15907 of them are available only when Exim is compiled with specific options such as
15908 support for TLS or the content scanning extension.
15909 </para>
15910 <variablelist>
15911 <varlistentry>
15912 <term><varname>$0</varname>, <varname>$1</varname>, etc</term>
15913 <listitem>
15914 <para>
15915 <indexterm role="concept">
15916 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
15917 </indexterm>
15918 When a <option>match</option> expansion condition succeeds, these variables contain the
15919 captured substrings identified by the regular expression during subsequent
15920 processing of the success string of the containing <option>if</option> expansion item.
15921 However, they do not retain their values afterwards; in fact, their previous
15922 values are restored at the end of processing an <option>if</option> item. The numerical
15923 variables may also be set externally by some other matching process which
15924 precedes the expansion of the string. For example, the commands available in
15925 Exim filter files include an <option>if</option> command with its own regular expression
15926 matching condition.
15927 </para>
15928 </listitem></varlistentry>
15929 <varlistentry>
15930 <term><varname>$acl_c...</varname></term>
15931 <listitem>
15932 <para>
15933 Values can be placed in these variables by the <option>set</option> modifier in an ACL. They
15934 can be given any name that starts with <varname>$acl_c</varname> and is at least six characters
15935 long, but the sixth character must be either a digit or an underscore. For
15936 example: <varname>$acl_c5</varname>, <varname>$acl_c_mycount</varname>. The values of the <varname>$acl_c...</varname>
15937 variables persist throughout the lifetime of an SMTP connection. They can be
15938 used to pass information between ACLs and between different invocations of the
15939 same ACL. When a message is received, the values of these variables are saved
15940 with the message, and can be accessed by filters, routers, and transports
15941 during subsequent delivery.
15942 </para>
15943 </listitem></varlistentry>
15944 <varlistentry>
15945 <term><varname>$acl_m...</varname></term>
15946 <listitem>
15947 <para>
15948 These variables are like the <varname>$acl_c...</varname> variables, except that their values
15949 are reset after a message has been received. Thus, if several messages are
15950 received in one SMTP connection, <varname>$acl_m...</varname> values are not passed on from one
15951 message to the next, as <varname>$acl_c...</varname> values are. The <varname>$acl_m...</varname> variables are
15952 also reset by MAIL, RSET, EHLO, HELO, and after starting a TLS session. When a
15953 message is received, the values of these variables are saved with the message,
15954 and can be accessed by filters, routers, and transports during subsequent
15955 delivery.
15956 </para>
15957 </listitem></varlistentry>
15958 <varlistentry>
15959 <term><varname>$acl_verify_message</varname></term>
15960 <listitem>
15961 <para>
15962 <indexterm role="variable">
15963 <primary><varname>$acl_verify_message</varname></primary>
15964 </indexterm>
15965 After an address verification has failed, this variable contains the failure
15966 message. It retains its value for use in subsequent modifiers. The message can
15967 be preserved by coding like this:
15968 </para>
15969 <literallayout class="monospaced">
15970 warn !verify = sender
15971      set acl_m0 = $acl_verify_message
15972 </literallayout>
15973 <para>
15974 You can use <varname>$acl_verify_message</varname> during the expansion of the <option>message</option> or
15975 <option>log_message</option> modifiers, to include information about the verification
15976 failure.
15977 </para>
15978 </listitem></varlistentry>
15979 <varlistentry>
15980 <term><varname>$address_data</varname></term>
15981 <listitem>
15982 <para>
15983 <indexterm role="variable">
15984 <primary><varname>$address_data</varname></primary>
15985 </indexterm>
15986 This variable is set by means of the <option>address_data</option> option in routers. The
15987 value then remains with the address while it is processed by subsequent routers
15988 and eventually a transport. If the transport is handling multiple addresses,
15989 the value from the first address is used. See chapter <xref linkend="CHAProutergeneric"/>
15990 for more details. <emphasis role="bold">Note</emphasis>: The contents of <varname>$address_data</varname> are visible in
15991 user filter files.
15992 </para>
15993 <para>
15994 If <varname>$address_data</varname> is set when the routers are called from an ACL to verify
15995 a recipient address, the final value is still in the variable for subsequent
15996 conditions and modifiers of the ACL statement. If routing the address caused it
15997 to be redirected to just one address, the child address is also routed as part
15998 of the verification, and in this case the final value of <varname>$address_data</varname> is
15999 from the child&#x2019;s routing.
16000 </para>
16001 <para>
16002 If <varname>$address_data</varname> is set when the routers are called from an ACL to verify a
16003 sender address, the final value is also preserved, but this time in
16004 <varname>$sender_address_data</varname>, to distinguish it from data from a recipient
16005 address.
16006 </para>
16007 <para>
16008 In both cases (recipient and sender verification), the value does not persist
16009 after the end of the current ACL statement. If you want to preserve
16010 these values for longer, you can save them in ACL variables.
16011 </para>
16012 </listitem></varlistentry>
16013 <varlistentry>
16014 <term><varname>$address_file</varname></term>
16015 <listitem>
16016 <para>
16017 <indexterm role="variable">
16018 <primary><varname>$address_file</varname></primary>
16019 </indexterm>
16020 When, as a result of aliasing, forwarding, or filtering, a message is directed
16021 to a specific file, this variable holds the name of the file when the transport
16022 is running. At other times, the variable is empty. For example, using the
16023 default configuration, if user <option>r2d2</option> has a <filename>.forward</filename> file containing
16024 </para>
16025 <literallayout class="monospaced">
16026 /home/r2d2/savemail
16027 </literallayout>
16028 <para>
16029 then when the <command>address_file</command> transport is running, <varname>$address_file</varname>
16030 contains the text string <literal>/home/r2d2/savemail</literal>.
16031 <indexterm role="concept">
16032 <primary>Sieve filter</primary>
16033 <secondary>value of <varname>$address_file</varname></secondary>
16034 </indexterm>
16035 For Sieve filters, the value may be <quote>inbox</quote> or a relative folder name. It is
16036 then up to the transport configuration to generate an appropriate absolute path
16037 to the relevant file.
16038 </para>
16039 </listitem></varlistentry>
16040 <varlistentry>
16041 <term><varname>$address_pipe</varname></term>
16042 <listitem>
16043 <para>
16044 <indexterm role="variable">
16045 <primary><varname>$address_pipe</varname></primary>
16046 </indexterm>
16047 When, as a result of aliasing or forwarding, a message is directed to a pipe,
16048 this variable holds the pipe command when the transport is running.
16049 </para>
16050 </listitem></varlistentry>
16051 <varlistentry>
16052 <term><varname>$auth1</varname> &ndash; <varname>$auth3</varname></term>
16053 <listitem>
16054 <para>
16055 <indexterm role="variable">
16056 <primary><varname>$auth1</varname>, <varname>$auth2</varname>, etc</primary>
16057 </indexterm>
16058 These variables are used in SMTP authenticators (see chapters
16059 <xref linkend="CHAPplaintext"/>&ndash;<xref linkend="CHAPspa"/>). Elsewhere, they are empty.
16060 </para>
16061 </listitem></varlistentry>
16062 <varlistentry>
16063 <term><varname>$authenticated_id</varname></term>
16064 <listitem>
16065 <para>
16066 <indexterm role="concept">
16067 <primary>authentication</primary>
16068 <secondary>id</secondary>
16069 </indexterm>
16070 <indexterm role="variable">
16071 <primary><varname>$authenticated_id</varname></primary>
16072 </indexterm>
16073 When a server successfully authenticates a client it may be configured to
16074 preserve some of the authentication information in the variable
16075 <varname>$authenticated_id</varname> (see chapter <xref linkend="CHAPSMTPAUTH"/>). For example, a
16076 user/password authenticator configuration might preserve the user name for use
16077 in the routers. Note that this is not the same information that is saved in
16078 <varname>$sender_host_authenticated</varname>.
16079 When a message is submitted locally (that is, not over a TCP connection)
16080 the value of <varname>$authenticated_id</varname> is normally the login name of the calling
16081 process. However, a trusted user can override this by means of the <option>-oMai</option>
16082 command line option.
16083 </para>
16084 </listitem></varlistentry>
16085 <varlistentry>
16086 <term><varname>$authenticated_sender</varname></term>
16087 <listitem>
16088 <para>
16089 <indexterm role="concept">
16090 <primary>sender</primary>
16091 <secondary>authenticated</secondary>
16092 </indexterm>
16093 <indexterm role="concept">
16094 <primary>authentication</primary>
16095 <secondary>sender</secondary>
16096 </indexterm>
16097 <indexterm role="concept">
16098 <primary>AUTH</primary>
16099 <secondary>on MAIL command</secondary>
16100 </indexterm>
16101 <indexterm role="variable">
16102 <primary><varname>$authenticated_sender</varname></primary>
16103 </indexterm>
16104 When acting as a server, Exim takes note of the AUTH= parameter on an incoming
16105 SMTP MAIL command if it believes the sender is sufficiently trusted, as
16106 described in section <xref linkend="SECTauthparamail"/>. Unless the data is the string
16107 <quote>&lt;&gt;</quote>, it is set as the authenticated sender of the message, and the value is
16108 available during delivery in the <varname>$authenticated_sender</varname> variable. If the
16109 sender is not trusted, Exim accepts the syntax of AUTH=, but ignores the data.
16110 </para>
16111 <para>
16112 <indexterm role="variable">
16113 <primary><varname>$qualify_domain</varname></primary>
16114 </indexterm>
16115 When a message is submitted locally (that is, not over a TCP connection), the
16116 value of <varname>$authenticated_sender</varname> is an address constructed from the login
16117 name of the calling process and <varname>$qualify_domain</varname>, except that a trusted user
16118 can override this by means of the <option>-oMas</option> command line option.
16119 </para>
16120 </listitem></varlistentry>
16121 <varlistentry>
16122 <term><varname>$authentication_failed</varname></term>
16123 <listitem>
16124 <para>
16125 <indexterm role="concept">
16126 <primary>authentication</primary>
16127 <secondary>failure</secondary>
16128 </indexterm>
16129 <indexterm role="variable">
16130 <primary><varname>$authentication_failed</varname></primary>
16131 </indexterm>
16132 This variable is set to <quote>1</quote> in an Exim server if a client issues an AUTH
16133 command that does not succeed. Otherwise it is set to <quote>0</quote>. This makes it
16134 possible to distinguish between <quote>did not try to authenticate</quote>
16135 (<varname>$sender_host_authenticated</varname> is empty and <varname>$authentication_failed</varname> is set to
16136 <quote>0</quote>) and <quote>tried to authenticate but failed</quote> (<varname>$sender_host_authenticated</varname>
16137 is empty and <varname>$authentication_failed</varname> is set to <quote>1</quote>). Failure includes any
16138 negative response to an AUTH command, including (for example) an attempt to use
16139 an undefined mechanism.
16140 </para>
16141 </listitem></varlistentry>
16142 <varlistentry>
16143 <term><varname>$body_linecount</varname></term>
16144 <listitem>
16145 <para>
16146 <indexterm role="concept">
16147 <primary>message body</primary>
16148 <secondary>line count</secondary>
16149 </indexterm>
16150 <indexterm role="concept">
16151 <primary>body of message</primary>
16152 <secondary>line count</secondary>
16153 </indexterm>
16154 <indexterm role="variable">
16155 <primary><varname>$body_linecount</varname></primary>
16156 </indexterm>
16157 When a message is being received or delivered, this variable contains the
16158 number of lines in the message&#x2019;s body. See also <varname>$message_linecount</varname>.
16159 </para>
16160 </listitem></varlistentry>
16161 <varlistentry>
16162 <term><varname>$body_zerocount</varname></term>
16163 <listitem>
16164 <para>
16165 <indexterm role="concept">
16166 <primary>message body</primary>
16167 <secondary>binary zero count</secondary>
16168 </indexterm>
16169 <indexterm role="concept">
16170 <primary>body of message</primary>
16171 <secondary>binary zero count</secondary>
16172 </indexterm>
16173 <indexterm role="concept">
16174 <primary>binary zero</primary>
16175 <secondary>in message body</secondary>
16176 </indexterm>
16177 <indexterm role="variable">
16178 <primary><varname>$body_zerocount</varname></primary>
16179 </indexterm>
16180 When a message is being received or delivered, this variable contains the
16181 number of binary zero bytes in the message&#x2019;s body.
16182 </para>
16183 </listitem></varlistentry>
16184 <varlistentry>
16185 <term><varname>$bounce_recipient</varname></term>
16186 <listitem>
16187 <para>
16188 <indexterm role="variable">
16189 <primary><varname>$bounce_recipient</varname></primary>
16190 </indexterm>
16191 This is set to the recipient address of a bounce message while Exim is creating
16192 it. It is useful if a customized bounce message text file is in use (see
16193 chapter <xref linkend="CHAPemsgcust"/>).
16194 </para>
16195 </listitem></varlistentry>
16196 <varlistentry>
16197 <term><varname>$bounce_return_size_limit</varname></term>
16198 <listitem>
16199 <para>
16200 <indexterm role="variable">
16201 <primary><varname>$bounce_return_size_limit</varname></primary>
16202 </indexterm>
16203 This contains the value set in the <option>bounce_return_size_limit</option> option, rounded
16204 up to a multiple of 1000. It is useful when a customized error message text
16205 file is in use (see chapter <xref linkend="CHAPemsgcust"/>).
16206 </para>
16207 </listitem></varlistentry>
16208 <varlistentry>
16209 <term><varname>$caller_gid</varname></term>
16210 <listitem>
16211 <para>
16212 <indexterm role="concept">
16213 <primary>gid (group id)</primary>
16214 <secondary>caller</secondary>
16215 </indexterm>
16216 <indexterm role="variable">
16217 <primary><varname>$caller_gid</varname></primary>
16218 </indexterm>
16219 The real group id under which the process that called Exim was running. This is
16220 not the same as the group id of the originator of a message (see
16221 <varname>$originator_gid</varname>). If Exim re-execs itself, this variable in the new
16222 incarnation normally contains the Exim gid.
16223 </para>
16224 </listitem></varlistentry>
16225 <varlistentry>
16226 <term><varname>$caller_uid</varname></term>
16227 <listitem>
16228 <para>
16229 <indexterm role="concept">
16230 <primary>uid (user id)</primary>
16231 <secondary>caller</secondary>
16232 </indexterm>
16233 <indexterm role="variable">
16234 <primary><varname>$caller_uid</varname></primary>
16235 </indexterm>
16236 The real user id under which the process that called Exim was running. This is
16237 not the same as the user id of the originator of a message (see
16238 <varname>$originator_uid</varname>). If Exim re-execs itself, this variable in the new
16239 incarnation normally contains the Exim uid.
16240 </para>
16241 </listitem></varlistentry>
16242 <varlistentry>
16243 <term><varname>$compile_date</varname></term>
16244 <listitem>
16245 <para>
16246 <indexterm role="variable">
16247 <primary><varname>$compile_date</varname></primary>
16248 </indexterm>
16249 The date on which the Exim binary was compiled.
16250 </para>
16251 </listitem></varlistentry>
16252 <varlistentry>
16253 <term><varname>$compile_number</varname></term>
16254 <listitem>
16255 <para>
16256 <indexterm role="variable">
16257 <primary><varname>$compile_number</varname></primary>
16258 </indexterm>
16259 The building process for Exim keeps a count of the number
16260 of times it has been compiled. This serves to distinguish different
16261 compilations of the same version of the program.
16262 </para>
16263 </listitem></varlistentry>
16264 <varlistentry>
16265 <term><varname>$demime_errorlevel</varname></term>
16266 <listitem>
16267 <para>
16268 <indexterm role="variable">
16269 <primary><varname>$demime_errorlevel</varname></primary>
16270 </indexterm>
16271 This variable is available when Exim is compiled with
16272 the content-scanning extension and the obsolete <option>demime</option> condition. For
16273 details, see section <xref linkend="SECTdemimecond"/>.
16274 </para>
16275 </listitem></varlistentry>
16276 <varlistentry>
16277 <term><varname>$demime_reason</varname></term>
16278 <listitem>
16279 <para>
16280 <indexterm role="variable">
16281 <primary><varname>$demime_reason</varname></primary>
16282 </indexterm>
16283 This variable is available when Exim is compiled with the
16284 content-scanning extension and the obsolete <option>demime</option> condition. For details,
16285 see section <xref linkend="SECTdemimecond"/>.
16286 </para>
16287 </listitem></varlistentry>
16288 <varlistentry>
16289 <term><varname>$dnslist_domain</varname></term>
16290 <term><varname>$dnslist_matched</varname></term>
16291 <term><varname>$dnslist_text</varname></term>
16292 <term><varname>$dnslist_value</varname></term>
16293 <listitem>
16294 <para>
16295 <indexterm role="variable">
16296 <primary><varname>$dnslist_domain</varname></primary>
16297 </indexterm>
16298 <indexterm role="variable">
16299 <primary><varname>$dnslist_matched</varname></primary>
16300 </indexterm>
16301 <indexterm role="variable">
16302 <primary><varname>$dnslist_text</varname></primary>
16303 </indexterm>
16304 <indexterm role="variable">
16305 <primary><varname>$dnslist_value</varname></primary>
16306 </indexterm>
16307 <indexterm role="concept">
16308 <primary>black list (DNS)</primary>
16309 </indexterm>
16310 When a DNS (black) list lookup succeeds, these variables are set to contain
16311 the following data from the lookup: the list&#x2019;s domain name, the key that was
16312 looked up, the contents of any associated TXT record, and the value from the
16313 main A record. See section <xref linkend="SECID204"/> for more details.
16314 </para>
16315 </listitem></varlistentry>
16316 <varlistentry>
16317 <term><varname>$domain</varname></term>
16318 <listitem>
16319 <para>
16320 <indexterm role="variable">
16321 <primary><varname>$domain</varname></primary>
16322 </indexterm>
16323 When an address is being routed, or delivered on its own, this variable
16324 contains the domain. Uppercase letters in the domain are converted into lower
16325 case for <varname>$domain</varname>.
16326 </para>
16327 <para>
16328 Global address rewriting happens when a message is received, so the value of
16329 <varname>$domain</varname> during routing and delivery is the value after rewriting. <varname>$domain</varname>
16330 is set during user filtering, but not during system filtering, because a
16331 message may have many recipients and the system filter is called just once.
16332 </para>
16333 <para>
16334 When more than one address is being delivered at once (for example, several
16335 RCPT commands in one SMTP delivery), <varname>$domain</varname> is set only if they all
16336 have the same domain. Transports can be restricted to handling only one domain
16337 at a time if the value of <varname>$domain</varname> is required at transport time &ndash; this is
16338 the default for local transports. For further details of the environment in
16339 which local transports are run, see chapter <xref linkend="CHAPenvironment"/>.
16340 </para>
16341 <para>
16342 <indexterm role="option">
16343 <primary><option>delay_warning_condition</option></primary>
16344 </indexterm>
16345 At the end of a delivery, if all deferred addresses have the same domain, it is
16346 set in <varname>$domain</varname> during the expansion of <option>delay_warning_condition</option>.
16347 </para>
16348 <para>
16349 The <varname>$domain</varname> variable is also used in some other circumstances:
16350 </para>
16351 <itemizedlist>
16352 <listitem>
16353 <para>
16354 When an ACL is running for a RCPT command, <varname>$domain</varname> contains the domain of
16355 the recipient address. The domain of the <emphasis>sender</emphasis> address is in
16356 <varname>$sender_address_domain</varname> at both MAIL time and at RCPT time. <varname>$domain</varname> is not
16357 normally set during the running of the MAIL ACL. However, if the sender address
16358 is verified with a callout during the MAIL ACL, the sender domain is placed in
16359 <varname>$domain</varname> during the expansions of <option>hosts</option>, <option>interface</option>, and <option>port</option> in
16360 the <command>smtp</command> transport.
16361 </para>
16362 </listitem>
16363 <listitem>
16364 <para>
16365 When a rewrite item is being processed (see chapter <xref linkend="CHAPrewrite"/>),
16366 <varname>$domain</varname> contains the domain portion of the address that is being rewritten;
16367 it can be used in the expansion of the replacement address, for example, to
16368 rewrite domains by file lookup.
16369 </para>
16370 </listitem>
16371 <listitem>
16372 <para>
16373 With one important exception, whenever a domain list is being scanned,
16374 <varname>$domain</varname> contains the subject domain. <emphasis role="bold">Exception</emphasis>: When a domain list in
16375 a <option>sender_domains</option> condition in an ACL is being processed, the subject domain
16376 is in <varname>$sender_address_domain</varname> and not in <varname>$domain</varname>. It works this way so
16377 that, in a RCPT ACL, the sender domain list can be dependent on the
16378 recipient domain (which is what is in <varname>$domain</varname> at this time).
16379 </para>
16380 </listitem>
16381 <listitem>
16382 <para>
16383 <indexterm role="concept">
16384 <primary>ETRN</primary>
16385 <secondary>value of <varname>$domain</varname></secondary>
16386 </indexterm>
16387 <indexterm role="option">
16388 <primary><option>smtp_etrn_command</option></primary>
16389 </indexterm>
16390 When the <option>smtp_etrn_command</option> option is being expanded, <varname>$domain</varname> contains
16391 the complete argument of the ETRN command (see section <xref linkend="SECTETRN"/>).
16392 </para>
16393 </listitem>
16394 </itemizedlist>
16395 </listitem></varlistentry>
16396 <varlistentry>
16397 <term><varname>$domain_data</varname></term>
16398 <listitem>
16399 <para>
16400 <indexterm role="variable">
16401 <primary><varname>$domain_data</varname></primary>
16402 </indexterm>
16403 When the <option>domains</option> option on a router matches a domain by
16404 means of a lookup, the data read by the lookup is available during the running
16405 of the router as <varname>$domain_data</varname>. In addition, if the driver routes the
16406 address to a transport, the value is available in that transport. If the
16407 transport is handling multiple addresses, the value from the first address is
16408 used.
16409 </para>
16410 <para>
16411 <varname>$domain_data</varname> is also set when the <option>domains</option> condition in an ACL matches a
16412 domain by means of a lookup. The data read by the lookup is available during
16413 the rest of the ACL statement. In all other situations, this variable expands
16414 to nothing.
16415 </para>
16416 </listitem></varlistentry>
16417 <varlistentry>
16418 <term><varname>$exim_gid</varname></term>
16419 <listitem>
16420 <para>
16421 <indexterm role="variable">
16422 <primary><varname>$exim_gid</varname></primary>
16423 </indexterm>
16424 This variable contains the numerical value of the Exim group id.
16425 </para>
16426 </listitem></varlistentry>
16427 <varlistentry>
16428 <term><varname>$exim_path</varname></term>
16429 <listitem>
16430 <para>
16431 <indexterm role="variable">
16432 <primary><varname>$exim_path</varname></primary>
16433 </indexterm>
16434 This variable contains the path to the Exim binary.
16435 </para>
16436 </listitem></varlistentry>
16437 <varlistentry>
16438 <term><varname>$exim_uid</varname></term>
16439 <listitem>
16440 <para>
16441 <indexterm role="variable">
16442 <primary><varname>$exim_uid</varname></primary>
16443 </indexterm>
16444 This variable contains the numerical value of the Exim user id.
16445 </para>
16446 </listitem></varlistentry>
16447 <varlistentry>
16448 <term><varname>$found_extension</varname></term>
16449 <listitem>
16450 <para>
16451 <indexterm role="variable">
16452 <primary><varname>$found_extension</varname></primary>
16453 </indexterm>
16454 This variable is available when Exim is compiled with the
16455 content-scanning extension and the obsolete <option>demime</option> condition. For details,
16456 see section <xref linkend="SECTdemimecond"/>.
16457 </para>
16458 </listitem></varlistentry>
16459 <varlistentry>
16460 <term><varname>$header_</varname>&lt;<emphasis>name</emphasis>&gt;</term>
16461 <listitem>
16462 <para>
16463 This is not strictly an expansion variable. It is expansion syntax for
16464 inserting the message header line with the given name. Note that the name must
16465 be terminated by colon or white space, because it may contain a wide variety of
16466 characters. Note also that braces must <emphasis>not</emphasis> be used.
16467 </para>
16468 </listitem></varlistentry>
16469 <varlistentry>
16470 <term><varname>$home</varname></term>
16471 <listitem>
16472 <para>
16473 <indexterm role="variable">
16474 <primary><varname>$home</varname></primary>
16475 </indexterm>
16476 When the <option>check_local_user</option> option is set for a router, the user&#x2019;s home
16477 directory is placed in <varname>$home</varname> when the check succeeds. In particular, this
16478 means it is set during the running of users&#x2019; filter files. A router may also
16479 explicitly set a home directory for use by a transport; this can be overridden
16480 by a setting on the transport itself.
16481 </para>
16482 <para>
16483 When running a filter test via the <option>-bf</option> option, <varname>$home</varname> is set to the value
16484 of the environment variable HOME.
16485 </para>
16486 </listitem></varlistentry>
16487 <varlistentry>
16488 <term><varname>$host</varname></term>
16489 <listitem>
16490 <para>
16491 <indexterm role="variable">
16492 <primary><varname>$host</varname></primary>
16493 </indexterm>
16494 If a router assigns an address to a transport (any transport), and passes a
16495 list of hosts with the address, the value of <varname>$host</varname> when the transport starts
16496 to run is the name of the first host on the list. Note that this applies both
16497 to local and remote transports.
16498 </para>
16499 <para>
16500 <indexterm role="concept">
16501 <primary>transport</primary>
16502 <secondary>filter</secondary>
16503 </indexterm>
16504 <indexterm role="concept">
16505 <primary>filter</primary>
16506 <secondary>transport filter</secondary>
16507 </indexterm>
16508 For the <command>smtp</command> transport, if there is more than one host, the value of
16509 <varname>$host</varname> changes as the transport works its way through the list. In
16510 particular, when the <command>smtp</command> transport is expanding its options for encryption
16511 using TLS, or for specifying a transport filter (see chapter
16512 <xref linkend="CHAPtransportgeneric"/>), <varname>$host</varname> contains the name of the host to which it
16513 is connected.
16514 </para>
16515 <para>
16516 When used in the client part of an authenticator configuration (see chapter
16517 <xref linkend="CHAPSMTPAUTH"/>), <varname>$host</varname> contains the name of the server to which the
16518 client is connected.
16519 </para>
16520 </listitem></varlistentry>
16521 <varlistentry>
16522 <term><varname>$host_address</varname></term>
16523 <listitem>
16524 <para>
16525 <indexterm role="variable">
16526 <primary><varname>$host_address</varname></primary>
16527 </indexterm>
16528 This variable is set to the remote host&#x2019;s IP address whenever <varname>$host</varname> is set
16529 for a remote connection. It is also set to the IP address that is being checked
16530 when the <option>ignore_target_hosts</option> option is being processed.
16531 </para>
16532 </listitem></varlistentry>
16533 <varlistentry>
16534 <term><varname>$host_data</varname></term>
16535 <listitem>
16536 <para>
16537 <indexterm role="variable">
16538 <primary><varname>$host_data</varname></primary>
16539 </indexterm>
16540 If a <option>hosts</option> condition in an ACL is satisfied by means of a lookup, the
16541 result of the lookup is made available in the <varname>$host_data</varname> variable. This
16542 allows you, for example, to do things like this:
16543 </para>
16544 <literallayout class="monospaced">
16545 deny  hosts = net-lsearch;/some/file
16546 message = $host_data
16547 </literallayout>
16548 </listitem></varlistentry>
16549 <varlistentry>
16550 <term><varname>$host_lookup_deferred</varname></term>
16551 <listitem>
16552 <para>
16553 <indexterm role="concept">
16554 <primary>host name</primary>
16555 <secondary>lookup, failure of</secondary>
16556 </indexterm>
16557 <indexterm role="variable">
16558 <primary><varname>$host_lookup_deferred</varname></primary>
16559 </indexterm>
16560 This variable normally contains <quote>0</quote>, as does <varname>$host_lookup_failed</varname>. When a
16561 message comes from a remote host and there is an attempt to look up the host&#x2019;s
16562 name from its IP address, and the attempt is not successful, one of these
16563 variables is set to <quote>1</quote>.
16564 </para>
16565 <itemizedlist>
16566 <listitem>
16567 <para>
16568 If the lookup receives a definite negative response (for example, a DNS lookup
16569 succeeded, but no records were found), <varname>$host_lookup_failed</varname> is set to <quote>1</quote>.
16570 </para>
16571 </listitem>
16572 <listitem>
16573 <para>
16574 If there is any kind of problem during the lookup, such that Exim cannot
16575 tell whether or not the host name is defined (for example, a timeout for a DNS
16576 lookup), <varname>$host_lookup_deferred</varname> is set to <quote>1</quote>.
16577 </para>
16578 </listitem>
16579 </itemizedlist>
16580 <para>
16581 Looking up a host&#x2019;s name from its IP address consists of more than just a
16582 single reverse lookup. Exim checks that a forward lookup of at least one of the
16583 names it receives from a reverse lookup yields the original IP address. If this
16584 is not the case, Exim does not accept the looked up name(s), and
16585 <varname>$host_lookup_failed</varname> is set to <quote>1</quote>. Thus, being able to find a name from an
16586 IP address (for example, the existence of a PTR record in the DNS) is not
16587 sufficient on its own for the success of a host name lookup. If the reverse
16588 lookup succeeds, but there is a lookup problem such as a timeout when checking
16589 the result, the name is not accepted, and <varname>$host_lookup_deferred</varname> is set to
16590 <quote>1</quote>. See also <varname>$sender_host_name</varname>.
16591 </para>
16592 </listitem></varlistentry>
16593 <varlistentry>
16594 <term><varname>$host_lookup_failed</varname></term>
16595 <listitem>
16596 <para>
16597 <indexterm role="variable">
16598 <primary><varname>$host_lookup_failed</varname></primary>
16599 </indexterm>
16600 See <varname>$host_lookup_deferred</varname>.
16601 </para>
16602 </listitem></varlistentry>
16603 <varlistentry>
16604 <term><varname>$inode</varname></term>
16605 <listitem>
16606 <para>
16607 <indexterm role="variable">
16608 <primary><varname>$inode</varname></primary>
16609 </indexterm>
16610 The only time this variable is set is while expanding the <option>directory_file</option>
16611 option in the <command>appendfile</command> transport. The variable contains the inode number
16612 of the temporary file which is about to be renamed. It can be used to construct
16613 a unique name for the file.
16614 </para>
16615 </listitem></varlistentry>
16616 <varlistentry>
16617 <term><varname>$interface_address</varname></term>
16618 <listitem>
16619 <para>
16620 <indexterm role="variable">
16621 <primary><varname>$interface_address</varname></primary>
16622 </indexterm>
16623 This is an obsolete name for <varname>$received_ip_address</varname>.
16624 </para>
16625 </listitem></varlistentry>
16626 <varlistentry>
16627 <term><varname>$interface_port</varname></term>
16628 <listitem>
16629 <para>
16630 <indexterm role="variable">
16631 <primary><varname>$interface_port</varname></primary>
16632 </indexterm>
16633 This is an obsolete name for <varname>$received_port</varname>.
16634 </para>
16635 </listitem></varlistentry>
16636 <varlistentry>
16637 <term><varname>$item</varname></term>
16638 <listitem>
16639 <para>
16640 <indexterm role="variable">
16641 <primary><varname>$item</varname></primary>
16642 </indexterm>
16643 This variable is used during the expansion of <emphasis role="bold">forall</emphasis> and <emphasis role="bold">forany</emphasis>
16644 conditions (see section <xref linkend="SECTexpcond"/>), and <emphasis role="bold">filter</emphasis>, <emphasis role="bold">map</emphasis>, and
16645 <emphasis role="bold">reduce</emphasis> items (see section <xref linkend="SECTexpcond"/>). In other circumstances, it is
16646 empty.
16647 </para>
16648 </listitem></varlistentry>
16649 <varlistentry>
16650 <term><varname>$ldap_dn</varname></term>
16651 <listitem>
16652 <para>
16653 <indexterm role="variable">
16654 <primary><varname>$ldap_dn</varname></primary>
16655 </indexterm>
16656 This variable, which is available only when Exim is compiled with LDAP support,
16657 contains the DN from the last entry in the most recently successful LDAP
16658 lookup.
16659 </para>
16660 </listitem></varlistentry>
16661 <varlistentry>
16662 <term><varname>$load_average</varname></term>
16663 <listitem>
16664 <para>
16665 <indexterm role="variable">
16666 <primary><varname>$load_average</varname></primary>
16667 </indexterm>
16668 This variable contains the system load average, multiplied by 1000 so that it
16669 is an integer. For example, if the load average is 0.21, the value of the
16670 variable is 210. The value is recomputed every time the variable is referenced.
16671 </para>
16672 </listitem></varlistentry>
16673 <varlistentry>
16674 <term><varname>$local_part</varname></term>
16675 <listitem>
16676 <para>
16677 <indexterm role="variable">
16678 <primary><varname>$local_part</varname></primary>
16679 </indexterm>
16680 When an address is being routed, or delivered on its own, this
16681 variable contains the local part. When a number of addresses are being
16682 delivered together (for example, multiple RCPT commands in an SMTP
16683 session), <varname>$local_part</varname> is not set.
16684 </para>
16685 <para>
16686 Global address rewriting happens when a message is received, so the value of
16687 <varname>$local_part</varname> during routing and delivery is the value after rewriting.
16688 <varname>$local_part</varname> is set during user filtering, but not during system filtering,
16689 because a message may have many recipients and the system filter is called just
16690 once.
16691 </para>
16692 <para>
16693 <indexterm role="variable">
16694 <primary><varname>$local_part_prefix</varname></primary>
16695 </indexterm>
16696 <indexterm role="variable">
16697 <primary><varname>$local_part_suffix</varname></primary>
16698 </indexterm>
16699 If a local part prefix or suffix has been recognized, it is not included in the
16700 value of <varname>$local_part</varname> during routing and subsequent delivery. The values of
16701 any prefix or suffix are in <varname>$local_part_prefix</varname> and
16702 <varname>$local_part_suffix</varname>, respectively.
16703 </para>
16704 <para>
16705 When a message is being delivered to a file, pipe, or autoreply transport as a
16706 result of aliasing or forwarding, <varname>$local_part</varname> is set to the local part of
16707 the parent address, not to the file name or command (see <varname>$address_file</varname> and
16708 <varname>$address_pipe</varname>).
16709 </para>
16710 <para>
16711 When an ACL is running for a RCPT command, <varname>$local_part</varname> contains the
16712 local part of the recipient address.
16713 </para>
16714 <para>
16715 When a rewrite item is being processed (see chapter <xref linkend="CHAPrewrite"/>),
16716 <varname>$local_part</varname> contains the local part of the address that is being rewritten;
16717 it can be used in the expansion of the replacement address, for example.
16718 </para>
16719 <para>
16720 In all cases, all quoting is removed from the local part. For example, for both
16721 the addresses
16722 </para>
16723 <literallayout class="monospaced">
16724 "abc:xyz"@test.example
16725 abc\:xyz@test.example
16726 </literallayout>
16727 <para>
16728 the value of <varname>$local_part</varname> is
16729 </para>
16730 <literallayout class="monospaced">
16731 abc:xyz
16732 </literallayout>
16733 <para>
16734 If you use <varname>$local_part</varname> to create another address, you should always wrap it
16735 inside a quoting operator. For example, in a <command>redirect</command> router you could
16736 have:
16737 </para>
16738 <literallayout class="monospaced">
16739 data = ${quote_local_part:$local_part}@new.domain.example
16740 </literallayout>
16741 <para>
16742 <emphasis role="bold">Note</emphasis>: The value of <varname>$local_part</varname> is normally lower cased. If you want
16743 to process local parts in a case-dependent manner in a router, you can set the
16744 <option>caseful_local_part</option> option (see chapter <xref linkend="CHAProutergeneric"/>).
16745 </para>
16746 </listitem></varlistentry>
16747 <varlistentry>
16748 <term><varname>$local_part_data</varname></term>
16749 <listitem>
16750 <para>
16751 <indexterm role="variable">
16752 <primary><varname>$local_part_data</varname></primary>
16753 </indexterm>
16754 When the <option>local_parts</option> option on a router matches a local part by means of a
16755 lookup, the data read by the lookup is available during the running of the
16756 router as <varname>$local_part_data</varname>. In addition, if the driver routes the address
16757 to a transport, the value is available in that transport. If the transport is
16758 handling multiple addresses, the value from the first address is used.
16759 </para>
16760 <para>
16761 <varname>$local_part_data</varname> is also set when the <option>local_parts</option> condition in an ACL
16762 matches a local part by means of a lookup. The data read by the lookup is
16763 available during the rest of the ACL statement. In all other situations, this
16764 variable expands to nothing.
16765 </para>
16766 </listitem></varlistentry>
16767 <varlistentry>
16768 <term><varname>$local_part_prefix</varname></term>
16769 <listitem>
16770 <para>
16771 <indexterm role="variable">
16772 <primary><varname>$local_part_prefix</varname></primary>
16773 </indexterm>
16774 When an address is being routed or delivered, and a
16775 specific prefix for the local part was recognized, it is available in this
16776 variable, having been removed from <varname>$local_part</varname>.
16777 </para>
16778 </listitem></varlistentry>
16779 <varlistentry>
16780 <term><varname>$local_part_suffix</varname></term>
16781 <listitem>
16782 <para>
16783 <indexterm role="variable">
16784 <primary><varname>$local_part_suffix</varname></primary>
16785 </indexterm>
16786 When an address is being routed or delivered, and a
16787 specific suffix for the local part was recognized, it is available in this
16788 variable, having been removed from <varname>$local_part</varname>.
16789 </para>
16790 </listitem></varlistentry>
16791 <varlistentry>
16792 <term><varname>$local_scan_data</varname></term>
16793 <listitem>
16794 <para>
16795 <indexterm role="variable">
16796 <primary><varname>$local_scan_data</varname></primary>
16797 </indexterm>
16798 This variable contains the text returned by the <function>local_scan()</function> function when
16799 a message is received. See chapter <xref linkend="CHAPlocalscan"/> for more details.
16800 </para>
16801 </listitem></varlistentry>
16802 <varlistentry>
16803 <term><varname>$local_user_gid</varname></term>
16804 <listitem>
16805 <para>
16806 <indexterm role="variable">
16807 <primary><varname>$local_user_gid</varname></primary>
16808 </indexterm>
16809 See <varname>$local_user_uid</varname>.
16810 </para>
16811 </listitem></varlistentry>
16812 <varlistentry>
16813 <term><varname>$local_user_uid</varname></term>
16814 <listitem>
16815 <para>
16816 <indexterm role="variable">
16817 <primary><varname>$local_user_uid</varname></primary>
16818 </indexterm>
16819 This variable and <varname>$local_user_gid</varname> are set to the uid and gid after the
16820 <option>check_local_user</option> router precondition succeeds. This means that their values
16821 are available for the remaining preconditions (<option>senders</option>, <option>require_files</option>,
16822 and <option>condition</option>), for the <option>address_data</option> expansion, and for any
16823 router-specific expansions. At all other times, the values in these variables
16824 are <literal>(uid_t)(-1)</literal> and <literal>(gid_t)(-1)</literal>, respectively.
16825 </para>
16826 </listitem></varlistentry>
16827 <varlistentry>
16828 <term><varname>$localhost_number</varname></term>
16829 <listitem>
16830 <para>
16831 <indexterm role="variable">
16832 <primary><varname>$localhost_number</varname></primary>
16833 </indexterm>
16834 This contains the expanded value of the
16835 <option>localhost_number</option> option. The expansion happens after the main options have
16836 been read.
16837 </para>
16838 </listitem></varlistentry>
16839 <varlistentry>
16840 <term><varname>$log_inodes</varname></term>
16841 <listitem>
16842 <para>
16843 <indexterm role="variable">
16844 <primary><varname>$log_inodes</varname></primary>
16845 </indexterm>
16846 The number of free inodes in the disk partition where Exim&#x2019;s
16847 log files are being written. The value is recalculated whenever the variable is
16848 referenced. If the relevant file system does not have the concept of inodes,
16849 the value of is -1. See also the <option>check_log_inodes</option> option.
16850 </para>
16851 </listitem></varlistentry>
16852 <varlistentry>
16853 <term><varname>$log_space</varname></term>
16854 <listitem>
16855 <para>
16856 <indexterm role="variable">
16857 <primary><varname>$log_space</varname></primary>
16858 </indexterm>
16859 The amount of free space (as a number of kilobytes) in the disk
16860 partition where Exim&#x2019;s log files are being written. The value is recalculated
16861 whenever the variable is referenced. If the operating system does not have the
16862 ability to find the amount of free space (only true for experimental systems),
16863 the space value is -1. See also the <option>check_log_space</option> option.
16864 </para>
16865 </listitem></varlistentry>
16866 <varlistentry>
16867 <term><varname>$mailstore_basename</varname></term>
16868 <listitem>
16869 <para>
16870 <indexterm role="variable">
16871 <primary><varname>$mailstore_basename</varname></primary>
16872 </indexterm>
16873 This variable is set only when doing deliveries in <quote>mailstore</quote> format in the
16874 <command>appendfile</command> transport. During the expansion of the <option>mailstore_prefix</option>,
16875 <option>mailstore_suffix</option>, <option>message_prefix</option>, and <option>message_suffix</option> options, it
16876 contains the basename of the files that are being written, that is, the name
16877 without the <quote>.tmp</quote>, <quote>.env</quote>, or <quote>.msg</quote> suffix. At all other times, this
16878 variable is empty.
16879 </para>
16880 </listitem></varlistentry>
16881 <varlistentry>
16882 <term><varname>$malware_name</varname></term>
16883 <listitem>
16884 <para>
16885 <indexterm role="variable">
16886 <primary><varname>$malware_name</varname></primary>
16887 </indexterm>
16888 This variable is available when Exim is compiled with the
16889 content-scanning extension. It is set to the name of the virus that was found
16890 when the ACL <option>malware</option> condition is true (see section <xref linkend="SECTscanvirus"/>).
16891 </para>
16892 </listitem></varlistentry>
16893 <varlistentry>
16894 <term><varname>$max_received_linelength</varname></term>
16895 <listitem>
16896 <para>
16897 <indexterm role="variable">
16898 <primary><varname>$max_received_linelength</varname></primary>
16899 </indexterm>
16900 <indexterm role="concept">
16901 <primary>maximum</primary>
16902 <secondary>line length</secondary>
16903 </indexterm>
16904 <indexterm role="concept">
16905 <primary>line length</primary>
16906 <secondary>maximum</secondary>
16907 </indexterm>
16908 This variable contains the number of bytes in the longest line that was
16909 received as part of the message, not counting the line termination
16910 character(s).
16911 </para>
16912 </listitem></varlistentry>
16913 <varlistentry>
16914 <term><varname>$message_age</varname></term>
16915 <listitem>
16916 <para>
16917 <indexterm role="concept">
16918 <primary>message</primary>
16919 <secondary>age of</secondary>
16920 </indexterm>
16921 <indexterm role="variable">
16922 <primary><varname>$message_age</varname></primary>
16923 </indexterm>
16924 This variable is set at the start of a delivery attempt to contain the number
16925 of seconds since the message was received. It does not change during a single
16926 delivery attempt.
16927 </para>
16928 </listitem></varlistentry>
16929 <varlistentry>
16930 <term><varname>$message_body</varname></term>
16931 <listitem>
16932 <para>
16933 <indexterm role="concept">
16934 <primary>body of message</primary>
16935 <secondary>expansion variable</secondary>
16936 </indexterm>
16937 <indexterm role="concept">
16938 <primary>message body</primary>
16939 <secondary>in expansion</secondary>
16940 </indexterm>
16941 <indexterm role="concept">
16942 <primary>binary zero</primary>
16943 <secondary>in message body</secondary>
16944 </indexterm>
16945 <indexterm role="variable">
16946 <primary><varname>$message_body</varname></primary>
16947 </indexterm>
16948 <indexterm role="option">
16949 <primary><option>message_body_visible</option></primary>
16950 </indexterm>
16951 This variable contains the initial portion of a message&#x2019;s body while it is
16952 being delivered, and is intended mainly for use in filter files. The maximum
16953 number of characters of the body that are put into the variable is set by the
16954 <option>message_body_visible</option> configuration option; the default is 500.
16955 </para>
16956 <para>
16957 <indexterm role="option">
16958 <primary><option>message_body_newlines</option></primary>
16959 </indexterm>
16960 By default, newlines are converted into spaces in <varname>$message_body</varname>, to make it
16961 easier to search for phrases that might be split over a line break. However,
16962 this can be disabled by setting <option>message_body_newlines</option> to be true. Binary
16963 zeros are always converted into spaces.
16964 </para>
16965 </listitem></varlistentry>
16966 <varlistentry>
16967 <term><varname>$message_body_end</varname></term>
16968 <listitem>
16969 <para>
16970 <indexterm role="concept">
16971 <primary>body of message</primary>
16972 <secondary>expansion variable</secondary>
16973 </indexterm>
16974 <indexterm role="concept">
16975 <primary>message body</primary>
16976 <secondary>in expansion</secondary>
16977 </indexterm>
16978 <indexterm role="variable">
16979 <primary><varname>$message_body_end</varname></primary>
16980 </indexterm>
16981 This variable contains the final portion of a message&#x2019;s
16982 body while it is being delivered. The format and maximum size are as for
16983 <varname>$message_body</varname>.
16984 </para>
16985 </listitem></varlistentry>
16986 <varlistentry>
16987 <term><varname>$message_body_size</varname></term>
16988 <listitem>
16989 <para>
16990 <indexterm role="concept">
16991 <primary>body of message</primary>
16992 <secondary>size</secondary>
16993 </indexterm>
16994 <indexterm role="concept">
16995 <primary>message body</primary>
16996 <secondary>size</secondary>
16997 </indexterm>
16998 <indexterm role="variable">
16999 <primary><varname>$message_body_size</varname></primary>
17000 </indexterm>
17001 When a message is being delivered, this variable contains the size of the body
17002 in bytes. The count starts from the character after the blank line that
17003 separates the body from the header. Newlines are included in the count. See
17004 also <varname>$message_size</varname>, <varname>$body_linecount</varname>, and <varname>$body_zerocount</varname>.
17005 </para>
17006 </listitem></varlistentry>
17007 <varlistentry>
17008 <term><varname>$message_exim_id</varname></term>
17009 <listitem>
17010 <para>
17011 <indexterm role="variable">
17012 <primary><varname>$message_exim_id</varname></primary>
17013 </indexterm>
17014 When a message is being received or delivered, this variable contains the
17015 unique message id that is generated and used by Exim to identify the message.
17016 An id is not created for a message until after its header has been successfully
17017 received. <emphasis role="bold">Note</emphasis>: This is <emphasis>not</emphasis> the contents of the <emphasis>Message-ID:</emphasis> header
17018 line; it is the local id that Exim assigns to the message, for example:
17019 <literal>1BXTIK-0001yO-VA</literal>.
17020 </para>
17021 </listitem></varlistentry>
17022 <varlistentry>
17023 <term><varname>$message_headers</varname></term>
17024 <listitem>
17025 <para>
17026 <indexterm role="variable">
17027 <primary><varname>$message_headers</varname></primary>
17028 </indexterm>
17029 This variable contains a concatenation of all the header lines when a message
17030 is being processed, except for lines added by routers or transports. The header
17031 lines are separated by newline characters. Their contents are decoded in the
17032 same way as a header line that is inserted by <option>bheader</option>.
17033 </para>
17034 </listitem></varlistentry>
17035 <varlistentry>
17036 <term><varname>$message_headers_raw</varname></term>
17037 <listitem>
17038 <para>
17039 <indexterm role="variable">
17040 <primary><varname>$message_headers_raw</varname></primary>
17041 </indexterm>
17042 This variable is like <varname>$message_headers</varname> except that no processing of the
17043 contents of header lines is done.
17044 </para>
17045 </listitem></varlistentry>
17046 <varlistentry>
17047 <term><varname>$message_id</varname></term>
17048 <listitem>
17049 <para>
17050 This is an old name for <varname>$message_exim_id</varname>, which is now deprecated.
17051 </para>
17052 </listitem></varlistentry>
17053 <varlistentry>
17054 <term><varname>$message_linecount</varname></term>
17055 <listitem>
17056 <para>
17057 <indexterm role="variable">
17058 <primary><varname>$message_linecount</varname></primary>
17059 </indexterm>
17060 This variable contains the total number of lines in the header and body of the
17061 message. Compare <varname>$body_linecount</varname>, which is the count for the body only.
17062 During the DATA and content-scanning ACLs, <varname>$message_linecount</varname> contains the
17063 number of lines received. Before delivery happens (that is, before filters,
17064 routers, and transports run) the count is increased to include the
17065 <emphasis>Received:</emphasis> header line that Exim standardly adds, and also any other header
17066 lines that are added by ACLs. The blank line that separates the message header
17067 from the body is not counted. Here is an example of the use of this variable in
17068 a DATA ACL:
17069 </para>
17070 <literallayout class="monospaced">
17071 deny message   = Too many lines in message header
17072      condition = \
17073       ${if &lt;{250}{${eval:$message_linecount - $body_linecount}}}
17074 </literallayout>
17075 <para>
17076 In the MAIL and RCPT ACLs, the value is zero because at that stage the
17077 message has not yet been received.
17078 </para>
17079 </listitem></varlistentry>
17080 <varlistentry>
17081 <term><varname>$message_size</varname></term>
17082 <listitem>
17083 <para>
17084 <indexterm role="concept">
17085 <primary>size</primary>
17086 <secondary>of message</secondary>
17087 </indexterm>
17088 <indexterm role="concept">
17089 <primary>message</primary>
17090 <secondary>size</secondary>
17091 </indexterm>
17092 <indexterm role="variable">
17093 <primary><varname>$message_size</varname></primary>
17094 </indexterm>
17095 When a message is being processed, this variable contains its size in bytes. In
17096 most cases, the size includes those headers that were received with the
17097 message, but not those (such as <emphasis>Envelope-to:</emphasis>) that are added to individual
17098 deliveries as they are written. However, there is one special case: during the
17099 expansion of the <option>maildir_tag</option> option in the <command>appendfile</command> transport while
17100 doing a delivery in maildir format, the value of <varname>$message_size</varname> is the
17101 precise size of the file that has been written. See also
17102 <varname>$message_body_size</varname>, <varname>$body_linecount</varname>, and <varname>$body_zerocount</varname>.
17103 </para>
17104 <para>
17105 <indexterm role="concept">
17106 <primary>RCPT</primary>
17107 <secondary>value of <varname>$message_size</varname></secondary>
17108 </indexterm>
17109 While running a per message ACL (mail/rcpt/predata), <varname>$message_size</varname>
17110 contains the size supplied on the MAIL command, or -1 if no size was given. The
17111 value may not, of course, be truthful.
17112 </para>
17113 </listitem></varlistentry>
17114 <varlistentry>
17115 <term><varname>$mime_</varname><emphasis>xxx</emphasis></term>
17116 <listitem>
17117 <para>
17118 A number of variables whose names start with <varname>$mime</varname> are
17119 available when Exim is compiled with the content-scanning extension. For
17120 details, see section <xref linkend="SECTscanmimepart"/>.
17121 </para>
17122 </listitem></varlistentry>
17123 <varlistentry>
17124 <term><varname>$n0</varname> &ndash; <varname>$n9</varname></term>
17125 <listitem>
17126 <para>
17127 These variables are counters that can be incremented by means
17128 of the <option>add</option> command in filter files.
17129 </para>
17130 </listitem></varlistentry>
17131 <varlistentry>
17132 <term><varname>$original_domain</varname></term>
17133 <listitem>
17134 <para>
17135 <indexterm role="variable">
17136 <primary><varname>$domain</varname></primary>
17137 </indexterm>
17138 <indexterm role="variable">
17139 <primary><varname>$original_domain</varname></primary>
17140 </indexterm>
17141 When a top-level address is being processed for delivery, this contains the
17142 same value as <varname>$domain</varname>. However, if a <quote>child</quote> address (for example,
17143 generated by an alias, forward, or filter file) is being processed, this
17144 variable contains the domain of the original address (lower cased). This
17145 differs from <varname>$parent_domain</varname> only when there is more than one level of
17146 aliasing or forwarding. When more than one address is being delivered in a
17147 single transport run, <varname>$original_domain</varname> is not set.
17148 </para>
17149 <para>
17150 If a new address is created by means of a <option>deliver</option> command in a system
17151 filter, it is set up with an artificial <quote>parent</quote> address. This has the local
17152 part <emphasis>system-filter</emphasis> and the default qualify domain.
17153 </para>
17154 </listitem></varlistentry>
17155 <varlistentry>
17156 <term><varname>$original_local_part</varname></term>
17157 <listitem>
17158 <para>
17159 <indexterm role="variable">
17160 <primary><varname>$local_part</varname></primary>
17161 </indexterm>
17162 <indexterm role="variable">
17163 <primary><varname>$original_local_part</varname></primary>
17164 </indexterm>
17165 When a top-level address is being processed for delivery, this contains the
17166 same value as <varname>$local_part</varname>, unless a prefix or suffix was removed from the
17167 local part, because <varname>$original_local_part</varname> always contains the full local
17168 part. When a <quote>child</quote> address (for example, generated by an alias, forward, or
17169 filter file) is being processed, this variable contains the full local part of
17170 the original address.
17171 </para>
17172 <para>
17173 If the router that did the redirection processed the local part
17174 case-insensitively, the value in <varname>$original_local_part</varname> is in lower case.
17175 This variable differs from <varname>$parent_local_part</varname> only when there is more than
17176 one level of aliasing or forwarding. When more than one address is being
17177 delivered in a single transport run, <varname>$original_local_part</varname> is not set.
17178 </para>
17179 <para>
17180 If a new address is created by means of a <option>deliver</option> command in a system
17181 filter, it is set up with an artificial <quote>parent</quote> address. This has the local
17182 part <emphasis>system-filter</emphasis> and the default qualify domain.
17183 </para>
17184 </listitem></varlistentry>
17185 <varlistentry>
17186 <term><varname>$originator_gid</varname></term>
17187 <listitem>
17188 <para>
17189 <indexterm role="concept">
17190 <primary>gid (group id)</primary>
17191 <secondary>of originating user</secondary>
17192 </indexterm>
17193 <indexterm role="concept">
17194 <primary>sender</primary>
17195 <secondary>gid</secondary>
17196 </indexterm>
17197 <indexterm role="variable">
17198 <primary><varname>$caller_gid</varname></primary>
17199 </indexterm>
17200 <indexterm role="variable">
17201 <primary><varname>$originator_gid</varname></primary>
17202 </indexterm>
17203 This variable contains the value of <varname>$caller_gid</varname> that was set when the
17204 message was received. For messages received via the command line, this is the
17205 gid of the sending user. For messages received by SMTP over TCP/IP, this is
17206 normally the gid of the Exim user.
17207 </para>
17208 </listitem></varlistentry>
17209 <varlistentry>
17210 <term><varname>$originator_uid</varname></term>
17211 <listitem>
17212 <para>
17213 <indexterm role="concept">
17214 <primary>uid (user id)</primary>
17215 <secondary>of originating user</secondary>
17216 </indexterm>
17217 <indexterm role="concept">
17218 <primary>sender</primary>
17219 <secondary>uid</secondary>
17220 </indexterm>
17221 <indexterm role="variable">
17222 <primary><varname>$caller_uid</varname></primary>
17223 </indexterm>
17224 <indexterm role="variable">
17225 <primary><varname>$originaltor_uid</varname></primary>
17226 </indexterm>
17227 The value of <varname>$caller_uid</varname> that was set when the message was received. For
17228 messages received via the command line, this is the uid of the sending user.
17229 For messages received by SMTP over TCP/IP, this is normally the uid of the Exim
17230 user.
17231 </para>
17232 </listitem></varlistentry>
17233 <varlistentry>
17234 <term><varname>$parent_domain</varname></term>
17235 <listitem>
17236 <para>
17237 <indexterm role="variable">
17238 <primary><varname>$parent_domain</varname></primary>
17239 </indexterm>
17240 This variable is similar to <varname>$original_domain</varname> (see
17241 above), except that it refers to the immediately preceding parent address.
17242 </para>
17243 </listitem></varlistentry>
17244 <varlistentry>
17245 <term><varname>$parent_local_part</varname></term>
17246 <listitem>
17247 <para>
17248 <indexterm role="variable">
17249 <primary><varname>$parent_local_part</varname></primary>
17250 </indexterm>
17251 This variable is similar to <varname>$original_local_part</varname>
17252 (see above), except that it refers to the immediately preceding parent address.
17253 </para>
17254 </listitem></varlistentry>
17255 <varlistentry>
17256 <term><varname>$pid</varname></term>
17257 <listitem>
17258 <para>
17259 <indexterm role="concept">
17260 <primary>pid (process id)</primary>
17261 <secondary>of current process</secondary>
17262 </indexterm>
17263 <indexterm role="variable">
17264 <primary><varname>$pid</varname></primary>
17265 </indexterm>
17266 This variable contains the current process id.
17267 </para>
17268 </listitem></varlistentry>
17269 <varlistentry>
17270 <term><varname>$pipe_addresses</varname></term>
17271 <listitem>
17272 <para>
17273 <indexterm role="concept">
17274 <primary>filter</primary>
17275 <secondary>transport filter</secondary>
17276 </indexterm>
17277 <indexterm role="concept">
17278 <primary>transport</primary>
17279 <secondary>filter</secondary>
17280 </indexterm>
17281 <indexterm role="variable">
17282 <primary><varname>$pipe_addresses</varname></primary>
17283 </indexterm>
17284 This is not an expansion variable, but is mentioned here because the string
17285 <literal>$pipe_addresses</literal> is handled specially in the command specification for the
17286 <command>pipe</command> transport (chapter <xref linkend="CHAPpipetransport"/>) and in transport filters
17287 (described under <option>transport_filter</option> in chapter <xref linkend="CHAPtransportgeneric"/>).
17288 It cannot be used in general expansion strings, and provokes an <quote>unknown
17289 variable</quote> error if encountered.
17290 </para>
17291 </listitem></varlistentry>
17292 <varlistentry>
17293 <term><varname>$primary_hostname</varname></term>
17294 <listitem>
17295 <para>
17296 <indexterm role="variable">
17297 <primary><varname>$primary_hostname</varname></primary>
17298 </indexterm>
17299 This variable contains the value set by <option>primary_hostname</option> in the
17300 configuration file, or read by the <function>uname()</function> function. If <function>uname()</function> returns
17301 a single-component name, Exim calls <function>gethostbyname()</function> (or
17302 <function>getipnodebyname()</function> where available) in an attempt to acquire a fully
17303 qualified host name. See also <varname>$smtp_active_hostname</varname>.
17304 </para>
17305 </listitem></varlistentry>
17306 <varlistentry>
17307 <term><varname>$prvscheck_address</varname></term>
17308 <listitem>
17309 <para>
17310 This variable is used in conjunction with the <option>prvscheck</option> expansion item,
17311 which is described in sections <xref linkend="SECTexpansionitems"/> and
17312 <xref linkend="SECTverifyPRVS"/>.
17313 </para>
17314 </listitem></varlistentry>
17315 <varlistentry>
17316 <term><varname>$prvscheck_keynum</varname></term>
17317 <listitem>
17318 <para>
17319 This variable is used in conjunction with the <option>prvscheck</option> expansion item,
17320 which is described in sections <xref linkend="SECTexpansionitems"/> and
17321 <xref linkend="SECTverifyPRVS"/>.
17322 </para>
17323 </listitem></varlistentry>
17324 <varlistentry>
17325 <term><varname>$prvscheck_result</varname></term>
17326 <listitem>
17327 <para>
17328 This variable is used in conjunction with the <option>prvscheck</option> expansion item,
17329 which is described in sections <xref linkend="SECTexpansionitems"/> and
17330 <xref linkend="SECTverifyPRVS"/>.
17331 </para>
17332 </listitem></varlistentry>
17333 <varlistentry>
17334 <term><varname>$qualify_domain</varname></term>
17335 <listitem>
17336 <para>
17337 <indexterm role="variable">
17338 <primary><varname>$qualify_domain</varname></primary>
17339 </indexterm>
17340 The value set for the <option>qualify_domain</option> option in the configuration file.
17341 </para>
17342 </listitem></varlistentry>
17343 <varlistentry>
17344 <term><varname>$qualify_recipient</varname></term>
17345 <listitem>
17346 <para>
17347 <indexterm role="variable">
17348 <primary><varname>$qualify_recipient</varname></primary>
17349 </indexterm>
17350 The value set for the <option>qualify_recipient</option> option in the configuration file,
17351 or if not set, the value of <varname>$qualify_domain</varname>.
17352 </para>
17353 </listitem></varlistentry>
17354 <varlistentry>
17355 <term><varname>$rcpt_count</varname></term>
17356 <listitem>
17357 <para>
17358 <indexterm role="variable">
17359 <primary><varname>$rcpt_count</varname></primary>
17360 </indexterm>
17361 When a message is being received by SMTP, this variable contains the number of
17362 RCPT commands received for the current message. If this variable is used in a
17363 RCPT ACL, its value includes the current command.
17364 </para>
17365 </listitem></varlistentry>
17366 <varlistentry>
17367 <term><varname>$rcpt_defer_count</varname></term>
17368 <listitem>
17369 <para>
17370 <indexterm role="variable">
17371 <primary><varname>$rcpt_defer_count</varname></primary>
17372 </indexterm>
17373 <indexterm role="concept">
17374 <primary>4<emphasis>xx</emphasis> responses</primary>
17375 <secondary>count of</secondary>
17376 </indexterm>
17377 When a message is being received by SMTP, this variable contains the number of
17378 RCPT commands in the current message that have previously been rejected with a
17379 temporary (4<emphasis>xx</emphasis>) response.
17380 </para>
17381 </listitem></varlistentry>
17382 <varlistentry>
17383 <term><varname>$rcpt_fail_count</varname></term>
17384 <listitem>
17385 <para>
17386 <indexterm role="variable">
17387 <primary><varname>$rcpt_fail_count</varname></primary>
17388 </indexterm>
17389 When a message is being received by SMTP, this variable contains the number of
17390 RCPT commands in the current message that have previously been rejected with a
17391 permanent (5<emphasis>xx</emphasis>) response.
17392 </para>
17393 </listitem></varlistentry>
17394 <varlistentry>
17395 <term><varname>$received_count</varname></term>
17396 <listitem>
17397 <para>
17398 <indexterm role="variable">
17399 <primary><varname>$received_count</varname></primary>
17400 </indexterm>
17401 This variable contains the number of <emphasis>Received:</emphasis> header lines in the message,
17402 including the one added by Exim (so its value is always greater than zero). It
17403 is available in the DATA ACL, the non-SMTP ACL, and while routing and
17404 delivering.
17405 </para>
17406 </listitem></varlistentry>
17407 <varlistentry>
17408 <term><varname>$received_for</varname></term>
17409 <listitem>
17410 <para>
17411 <indexterm role="variable">
17412 <primary><varname>$received_for</varname></primary>
17413 </indexterm>
17414 If there is only a single recipient address in an incoming message, this
17415 variable contains that address when the <emphasis>Received:</emphasis> header line is being
17416 built. The value is copied after recipient rewriting has happened, but before
17417 the <function>local_scan()</function> function is run.
17418 </para>
17419 </listitem></varlistentry>
17420 <varlistentry>
17421 <term><varname>$received_ip_address</varname></term>
17422 <listitem>
17423 <para>
17424 <indexterm role="variable">
17425 <primary><varname>$received_ip_address</varname></primary>
17426 </indexterm>
17427 As soon as an Exim server starts processing an incoming TCP/IP connection, this
17428 variable is set to the address of the local IP interface, and <varname>$received_port</varname>
17429 is set to the local port number. (The remote IP address and port are in
17430 <varname>$sender_host_address</varname> and <varname>$sender_host_port</varname>.) When testing with <option>-bh</option>,
17431 the port value is -1 unless it has been set using the <option>-oMi</option> command line
17432 option.
17433 </para>
17434 <para>
17435 As well as being useful in ACLs (including the <quote>connect</quote> ACL), these variable
17436 could be used, for example, to make the file name for a TLS certificate depend
17437 on which interface and/or port is being used for the incoming connection. The
17438 values of <varname>$received_ip_address</varname> and <varname>$received_port</varname> are saved with any
17439 messages that are received, thus making these variables available at delivery
17440 time.
17441 </para>
17442 <para>
17443 <emphasis role="bold">Note:</emphasis> There are no equivalent variables for outgoing connections, because
17444 the values are unknown (unless they are explicitly set by options of the
17445 <command>smtp</command> transport).
17446 </para>
17447 </listitem></varlistentry>
17448 <varlistentry>
17449 <term><varname>$received_port</varname></term>
17450 <listitem>
17451 <para>
17452 <indexterm role="variable">
17453 <primary><varname>$received_port</varname></primary>
17454 </indexterm>
17455 See <varname>$received_ip_address</varname>.
17456 </para>
17457 </listitem></varlistentry>
17458 <varlistentry>
17459 <term><varname>$received_protocol</varname></term>
17460 <listitem>
17461 <para>
17462 <indexterm role="variable">
17463 <primary><varname>$received_protocol</varname></primary>
17464 </indexterm>
17465 When a message is being processed, this variable contains the name of the
17466 protocol by which it was received. Most of the names used by Exim are defined
17467 by RFCs 821, 2821, and 3848. They start with <quote>smtp</quote> (the client used HELO) or
17468 <quote>esmtp</quote> (the client used EHLO). This can be followed by <quote>s</quote> for secure
17469 (encrypted) and/or <quote>a</quote> for authenticated. Thus, for example, if the protocol
17470 is set to <quote>esmtpsa</quote>, the message was received over an encrypted SMTP
17471 connection and the client was successfully authenticated.
17472 </para>
17473 <para>
17474 Exim uses the protocol name <quote>smtps</quote> for the case when encryption is
17475 automatically set up on connection without the use of STARTTLS (see
17476 <option>tls_on_connect_ports</option>), and the client uses HELO to initiate the
17477 encrypted SMTP session. The name <quote>smtps</quote> is also used for the rare situation
17478 where the client initially uses EHLO, sets up an encrypted connection using
17479 STARTTLS, and then uses HELO afterwards.
17480 </para>
17481 <para>
17482 The <option>-oMr</option> option provides a way of specifying a custom protocol name for
17483 messages that are injected locally by trusted callers. This is commonly used to
17484 identify messages that are being re-injected after some kind of scanning.
17485 </para>
17486 </listitem></varlistentry>
17487 <varlistentry>
17488 <term><varname>$received_time</varname></term>
17489 <listitem>
17490 <para>
17491 <indexterm role="variable">
17492 <primary><varname>$received_time</varname></primary>
17493 </indexterm>
17494 This variable contains the date and time when the current message was received,
17495 as a number of seconds since the start of the Unix epoch.
17496 </para>
17497 </listitem></varlistentry>
17498 <varlistentry>
17499 <term><varname>$recipient_data</varname></term>
17500 <listitem>
17501 <para>
17502 <indexterm role="variable">
17503 <primary><varname>$recipient_data</varname></primary>
17504 </indexterm>
17505 This variable is set after an indexing lookup success in an ACL <option>recipients</option>
17506 condition. It contains the data from the lookup, and the value remains set
17507 until the next <option>recipients</option> test. Thus, you can do things like this:
17508 </para>
17509 <literallayout>
17510 <literal>require recipients  = cdb*@;/some/file</literal>
17511 <literal>deny    </literal><emphasis>some further test involving</emphasis> <literal>$recipient_data</literal>
17512 </literallayout>
17513 <para>
17514 <emphasis role="bold">Warning</emphasis>: This variable is set only when a lookup is used as an indexing
17515 method in the address list, using the semicolon syntax as in the example above.
17516 The variable is not set for a lookup that is used as part of the string
17517 expansion that all such lists undergo before being interpreted.
17518 </para>
17519 </listitem></varlistentry>
17520 <varlistentry>
17521 <term><varname>$recipient_verify_failure</varname></term>
17522 <listitem>
17523 <para>
17524 <indexterm role="variable">
17525 <primary><varname>$recipient_verify_failure</varname></primary>
17526 </indexterm>
17527 In an ACL, when a recipient verification fails, this variable contains
17528 information about the failure. It is set to one of the following words:
17529 </para>
17530 <itemizedlist>
17531 <listitem>
17532 <para>
17533 <quote>qualify</quote>: The address was unqualified (no domain), and the message
17534 was neither local nor came from an exempted host.
17535 </para>
17536 </listitem>
17537 <listitem>
17538 <para>
17539 <quote>route</quote>: Routing failed.
17540 </para>
17541 </listitem>
17542 <listitem>
17543 <para>
17544 <quote>mail</quote>: Routing succeeded, and a callout was attempted; rejection occurred at
17545 or before the MAIL command (that is, on initial connection, HELO, or
17546 MAIL).
17547 </para>
17548 </listitem>
17549 <listitem>
17550 <para>
17551 <quote>recipient</quote>: The RCPT command in a callout was rejected.
17552 </para>
17553 </listitem>
17554 <listitem>
17555 <para>
17556 <quote>postmaster</quote>: The postmaster check in a callout was rejected.
17557 </para>
17558 </listitem>
17559 </itemizedlist>
17560 <para>
17561 The main use of this variable is expected to be to distinguish between
17562 rejections of MAIL and rejections of RCPT.
17563 </para>
17564 </listitem></varlistentry>
17565 <varlistentry>
17566 <term><varname>$recipients</varname></term>
17567 <listitem>
17568 <para>
17569 <indexterm role="variable">
17570 <primary><varname>$recipients</varname></primary>
17571 </indexterm>
17572 This variable contains a list of envelope recipients for a message. A comma and
17573 a space separate the addresses in the replacement text. However, the variable
17574 is not generally available, to prevent exposure of Bcc recipients in
17575 unprivileged users&#x2019; filter files. You can use <varname>$recipients</varname> only in these
17576 cases:
17577 </para>
17578 <orderedlist numeration="arabic">
17579 <listitem>
17580 <para>
17581 In a system filter file.
17582 </para>
17583 </listitem>
17584 <listitem>
17585 <para>
17586 In the ACLs associated with the DATA command and with non-SMTP messages, that
17587 is, the ACLs defined by <option>acl_smtp_predata</option>, <option>acl_smtp_data</option>,
17588 <option>acl_smtp_mime</option>, <option>acl_not_smtp_start</option>, <option>acl_not_smtp</option>, and
17589 <option>acl_not_smtp_mime</option>.
17590 </para>
17591 </listitem>
17592 <listitem>
17593 <para>
17594 From within a <function>local_scan()</function> function.
17595 </para>
17596 </listitem>
17597 </orderedlist>
17598 </listitem></varlistentry>
17599 <varlistentry>
17600 <term><varname>$recipients_count</varname></term>
17601 <listitem>
17602 <para>
17603 <indexterm role="variable">
17604 <primary><varname>$recipients_count</varname></primary>
17605 </indexterm>
17606 When a message is being processed, this variable contains the number of
17607 envelope recipients that came with the message. Duplicates are not excluded
17608 from the count. While a message is being received over SMTP, the number
17609 increases for each accepted recipient. It can be referenced in an ACL.
17610 </para>
17611 </listitem></varlistentry>
17612 <varlistentry>
17613 <term><varname>$regex_match_string</varname></term>
17614 <listitem>
17615 <para>
17616 <indexterm role="variable">
17617 <primary><varname>$regex_match_string</varname></primary>
17618 </indexterm>
17619 This variable is set to contain the matching regular expression after a
17620 <option>regex</option> ACL condition has matched (see section <xref linkend="SECTscanregex"/>).
17621 </para>
17622 </listitem></varlistentry>
17623 <varlistentry>
17624 <term><varname>$reply_address</varname></term>
17625 <listitem>
17626 <para>
17627 <indexterm role="variable">
17628 <primary><varname>$reply_address</varname></primary>
17629 </indexterm>
17630 When a message is being processed, this variable contains the contents of the
17631 <emphasis>Reply-To:</emphasis> header line if one exists and it is not empty, or otherwise the
17632 contents of the <emphasis>From:</emphasis> header line. Apart from the removal of leading
17633 white space, the value is not processed in any way. In particular, no RFC 2047
17634 decoding or character code translation takes place.
17635 </para>
17636 </listitem></varlistentry>
17637 <varlistentry>
17638 <term><varname>$return_path</varname></term>
17639 <listitem>
17640 <para>
17641 <indexterm role="variable">
17642 <primary><varname>$return_path</varname></primary>
17643 </indexterm>
17644 When a message is being delivered, this variable contains the return path &ndash;
17645 the sender field that will be sent as part of the envelope. It is not enclosed
17646 in &lt;&gt; characters. At the start of routing an address, <varname>$return_path</varname> has the
17647 same value as <varname>$sender_address</varname>, but if, for example, an incoming message to a
17648 mailing list has been expanded by a router which specifies a different address
17649 for bounce messages, <varname>$return_path</varname> subsequently contains the new bounce
17650 address, whereas <varname>$sender_address</varname> always contains the original sender address
17651 that was received with the message. In other words, <varname>$sender_address</varname> contains
17652 the incoming envelope sender, and <varname>$return_path</varname> contains the outgoing
17653 envelope sender.
17654 </para>
17655 </listitem></varlistentry>
17656 <varlistentry>
17657 <term><varname>$return_size_limit</varname></term>
17658 <listitem>
17659 <para>
17660 <indexterm role="variable">
17661 <primary><varname>$return_size_limit</varname></primary>
17662 </indexterm>
17663 This is an obsolete name for <varname>$bounce_return_size_limit</varname>.
17664 </para>
17665 </listitem></varlistentry>
17666 <varlistentry>
17667 <term><varname>$runrc</varname></term>
17668 <listitem>
17669 <para>
17670 <indexterm role="concept">
17671 <primary>return code</primary>
17672 <secondary>from <option>run</option> expansion</secondary>
17673 </indexterm>
17674 <indexterm role="variable">
17675 <primary><varname>$runrc</varname></primary>
17676 </indexterm>
17677 This variable contains the return code from a command that is run by the
17678 <option>${run...}</option> expansion item. <emphasis role="bold">Warning</emphasis>: In a router or transport, you cannot
17679 assume the order in which option values are expanded, except for those
17680 preconditions whose order of testing is documented. Therefore, you cannot
17681 reliably expect to set <varname>$runrc</varname> by the expansion of one option, and use it in
17682 another.
17683 </para>
17684 </listitem></varlistentry>
17685 <varlistentry>
17686 <term><varname>$self_hostname</varname></term>
17687 <listitem>
17688 <para>
17689 <indexterm role="option">
17690 <primary><option>self</option></primary>
17691 <secondary>value of host name</secondary>
17692 </indexterm>
17693 <indexterm role="variable">
17694 <primary><varname>$self_hostname</varname></primary>
17695 </indexterm>
17696 When an address is routed to a supposedly remote host that turns out to be the
17697 local host, what happens is controlled by the <option>self</option> generic router option.
17698 One of its values causes the address to be passed to another router. When this
17699 happens, <varname>$self_hostname</varname> is set to the name of the local host that the
17700 original router encountered. In other circumstances its contents are null.
17701 </para>
17702 </listitem></varlistentry>
17703 <varlistentry>
17704 <term><varname>$sender_address</varname></term>
17705 <listitem>
17706 <para>
17707 <indexterm role="variable">
17708 <primary><varname>$sender_address</varname></primary>
17709 </indexterm>
17710 When a message is being processed, this variable contains the sender&#x2019;s address
17711 that was received in the message&#x2019;s envelope. The case of letters in the address
17712 is retained, in both the local part and the domain. For bounce messages, the
17713 value of this variable is the empty string. See also <varname>$return_path</varname>.
17714 </para>
17715 </listitem></varlistentry>
17716 <varlistentry>
17717 <term><varname>$sender_address_data</varname></term>
17718 <listitem>
17719 <para>
17720 <indexterm role="variable">
17721 <primary><varname>$address_data</varname></primary>
17722 </indexterm>
17723 <indexterm role="variable">
17724 <primary><varname>$sender_address_data</varname></primary>
17725 </indexterm>
17726 If <varname>$address_data</varname> is set when the routers are called from an ACL to verify a
17727 sender address, the final value is preserved in <varname>$sender_address_data</varname>, to
17728 distinguish it from data from a recipient address. The value does not persist
17729 after the end of the current ACL statement. If you want to preserve it for
17730 longer, you can save it in an ACL variable.
17731 </para>
17732 </listitem></varlistentry>
17733 <varlistentry>
17734 <term><varname>$sender_address_domain</varname></term>
17735 <listitem>
17736 <para>
17737 <indexterm role="variable">
17738 <primary><varname>$sender_address_domain</varname></primary>
17739 </indexterm>
17740 The domain portion of <varname>$sender_address</varname>.
17741 </para>
17742 </listitem></varlistentry>
17743 <varlistentry>
17744 <term><varname>$sender_address_local_part</varname></term>
17745 <listitem>
17746 <para>
17747 <indexterm role="variable">
17748 <primary><varname>$sender_address_local_part</varname></primary>
17749 </indexterm>
17750 The local part portion of <varname>$sender_address</varname>.
17751 </para>
17752 </listitem></varlistentry>
17753 <varlistentry>
17754 <term><varname>$sender_data</varname></term>
17755 <listitem>
17756 <para>
17757 <indexterm role="variable">
17758 <primary><varname>$sender_data</varname></primary>
17759 </indexterm>
17760 This variable is set after a lookup success in an ACL <option>senders</option> condition or
17761 in a router <option>senders</option> option. It contains the data from the lookup, and the
17762 value remains set until the next <option>senders</option> test. Thus, you can do things like
17763 this:
17764 </para>
17765 <literallayout>
17766 <literal>require senders      = cdb*@;/some/file</literal>
17767 <literal>deny    </literal><emphasis>some further test involving</emphasis> <literal>$sender_data</literal>
17768 </literallayout>
17769 <para>
17770 <emphasis role="bold">Warning</emphasis>: This variable is set only when a lookup is used as an indexing
17771 method in the address list, using the semicolon syntax as in the example above.
17772 The variable is not set for a lookup that is used as part of the string
17773 expansion that all such lists undergo before being interpreted.
17774 </para>
17775 </listitem></varlistentry>
17776 <varlistentry>
17777 <term><varname>$sender_fullhost</varname></term>
17778 <listitem>
17779 <para>
17780 <indexterm role="variable">
17781 <primary><varname>$sender_fullhost</varname></primary>
17782 </indexterm>
17783 When a message is received from a remote host, this variable contains the host
17784 name and IP address in a single string. It ends with the IP address in square
17785 brackets, followed by a colon and a port number if the logging of ports is
17786 enabled. The format of the rest of the string depends on whether the host
17787 issued a HELO or EHLO SMTP command, and whether the host name was verified by
17788 looking up its IP address. (Looking up the IP address can be forced by the
17789 <option>host_lookup</option> option, independent of verification.) A plain host name at the
17790 start of the string is a verified host name; if this is not present,
17791 verification either failed or was not requested. A host name in parentheses is
17792 the argument of a HELO or EHLO command. This is omitted if it is identical to
17793 the verified host name or to the host&#x2019;s IP address in square brackets.
17794 </para>
17795 </listitem></varlistentry>
17796 <varlistentry>
17797 <term><varname>$sender_helo_name</varname></term>
17798 <listitem>
17799 <para>
17800 <indexterm role="variable">
17801 <primary><varname>$sender_helo_name</varname></primary>
17802 </indexterm>
17803 When a message is received from a remote host that has issued a HELO or EHLO
17804 command, the argument of that command is placed in this variable. It is also
17805 set if HELO or EHLO is used when a message is received using SMTP locally via
17806 the <option>-bs</option> or <option>-bS</option> options.
17807 </para>
17808 </listitem></varlistentry>
17809 <varlistentry>
17810 <term><varname>$sender_host_address</varname></term>
17811 <listitem>
17812 <para>
17813 <indexterm role="variable">
17814 <primary><varname>$sender_host_address</varname></primary>
17815 </indexterm>
17816 When a message is received from a remote host, this variable contains that
17817 host&#x2019;s IP address. For locally submitted messages, it is empty.
17818 </para>
17819 </listitem></varlistentry>
17820 <varlistentry>
17821 <term><varname>$sender_host_authenticated</varname></term>
17822 <listitem>
17823 <para>
17824 <indexterm role="variable">
17825 <primary><varname>$sender_host_authenticated</varname></primary>
17826 </indexterm>
17827 This variable contains the name (not the public name) of the authenticator
17828 driver that successfully authenticated the client from which the message was
17829 received. It is empty if there was no successful authentication. See also
17830 <varname>$authenticated_id</varname>.
17831 </para>
17832 </listitem></varlistentry>
17833 <varlistentry>
17834 <term><varname>$sender_host_name</varname></term>
17835 <listitem>
17836 <para>
17837 <indexterm role="variable">
17838 <primary><varname>$sender_host_name</varname></primary>
17839 </indexterm>
17840 When a message is received from a remote host, this variable contains the
17841 host&#x2019;s name as obtained by looking up its IP address. For messages received by
17842 other means, this variable is empty.
17843 </para>
17844 <para>
17845 <indexterm role="variable">
17846 <primary><varname>$host_lookup_failed</varname></primary>
17847 </indexterm>
17848 If the host name has not previously been looked up, a reference to
17849 <varname>$sender_host_name</varname> triggers a lookup (for messages from remote hosts).
17850 A looked up name is accepted only if it leads back to the original IP address
17851 via a forward lookup. If either the reverse or the forward lookup fails to find
17852 any data, or if the forward lookup does not yield the original IP address,
17853 <varname>$sender_host_name</varname> remains empty, and <varname>$host_lookup_failed</varname> is set to <quote>1</quote>.
17854 </para>
17855 <para>
17856 <indexterm role="variable">
17857 <primary><varname>$host_lookup_deferred</varname></primary>
17858 </indexterm>
17859 However, if either of the lookups cannot be completed (for example, there is a
17860 DNS timeout), <varname>$host_lookup_deferred</varname> is set to <quote>1</quote>, and
17861 <varname>$host_lookup_failed</varname> remains set to <quote>0</quote>.
17862 </para>
17863 <para>
17864 Once <varname>$host_lookup_failed</varname> is set to <quote>1</quote>, Exim does not try to look up the
17865 host name again if there is a subsequent reference to <varname>$sender_host_name</varname>
17866 in the same Exim process, but it does try again if <varname>$host_lookup_deferred</varname>
17867 is set to <quote>1</quote>.
17868 </para>
17869 <para>
17870 Exim does not automatically look up every calling host&#x2019;s name. If you want
17871 maximum efficiency, you should arrange your configuration so that it avoids
17872 these lookups altogether. The lookup happens only if one or more of the
17873 following are true:
17874 </para>
17875 <itemizedlist>
17876 <listitem>
17877 <para>
17878 A string containing <varname>$sender_host_name</varname> is expanded.
17879 </para>
17880 </listitem>
17881 <listitem>
17882 <para>
17883 The calling host matches the list in <option>host_lookup</option>. In the default
17884 configuration, this option is set to *, so it must be changed if lookups are
17885 to be avoided. (In the code, the default for <option>host_lookup</option> is unset.)
17886 </para>
17887 </listitem>
17888 <listitem>
17889 <para>
17890 Exim needs the host name in order to test an item in a host list. The items
17891 that require this are described in sections <xref linkend="SECThoslispatnam"/> and
17892 <xref linkend="SECThoslispatnamsk"/>.
17893 </para>
17894 </listitem>
17895 <listitem>
17896 <para>
17897 The calling host matches <option>helo_try_verify_hosts</option> or <option>helo_verify_hosts</option>.
17898 In this case, the host name is required to compare with the name quoted in any
17899 EHLO or HELO commands that the client issues.
17900 </para>
17901 </listitem>
17902 <listitem>
17903 <para>
17904 The remote host issues a EHLO or HELO command that quotes one of the
17905 domains in <option>helo_lookup_domains</option>. The default value of this option is
17906 </para>
17907 <literallayout class="monospaced">
17908   helo_lookup_domains = @ : @[]
17909 </literallayout>
17910 <para>
17911 which causes a lookup if a remote host (incorrectly) gives the server&#x2019;s name or
17912 IP address in an EHLO or HELO command.
17913 </para>
17914 </listitem>
17915 </itemizedlist>
17916 </listitem></varlistentry>
17917 <varlistentry>
17918 <term><varname>$sender_host_port</varname></term>
17919 <listitem>
17920 <para>
17921 <indexterm role="variable">
17922 <primary><varname>$sender_host_port</varname></primary>
17923 </indexterm>
17924 When a message is received from a remote host, this variable contains the port
17925 number that was used on the remote host.
17926 </para>
17927 </listitem></varlistentry>
17928 <varlistentry>
17929 <term><varname>$sender_ident</varname></term>
17930 <listitem>
17931 <para>
17932 <indexterm role="variable">
17933 <primary><varname>$sender_ident</varname></primary>
17934 </indexterm>
17935 When a message is received from a remote host, this variable contains the
17936 identification received in response to an RFC 1413 request. When a message has
17937 been received locally, this variable contains the login name of the user that
17938 called Exim.
17939 </para>
17940 </listitem></varlistentry>
17941 <varlistentry>
17942 <term><varname>$sender_rate_</varname><emphasis>xxx</emphasis></term>
17943 <listitem>
17944 <para>
17945 A number of variables whose names begin <varname>$sender_rate_</varname> are set as part of the
17946 <option>ratelimit</option> ACL condition. Details are given in section
17947 <xref linkend="SECTratelimiting"/>.
17948 </para>
17949 </listitem></varlistentry>
17950 <varlistentry>
17951 <term><varname>$sender_rcvhost</varname></term>
17952 <listitem>
17953 <para>
17954 <indexterm role="concept">
17955 <primary>DNS</primary>
17956 <secondary>reverse lookup</secondary>
17957 </indexterm>
17958 <indexterm role="concept">
17959 <primary>reverse DNS lookup</primary>
17960 </indexterm>
17961 <indexterm role="variable">
17962 <primary><varname>$sender_rcvhost</varname></primary>
17963 </indexterm>
17964 This is provided specifically for use in <emphasis>Received:</emphasis> headers. It starts with
17965 either the verified host name (as obtained from a reverse DNS lookup) or, if
17966 there is no verified host name, the IP address in square brackets. After that
17967 there may be text in parentheses. When the first item is a verified host name,
17968 the first thing in the parentheses is the IP address in square brackets,
17969 followed by a colon and a port number if port logging is enabled. When the
17970 first item is an IP address, the port is recorded as <quote>port=<emphasis>xxxx</emphasis></quote> inside
17971 the parentheses.
17972 </para>
17973 <para>
17974 There may also be items of the form <quote>helo=<emphasis>xxxx</emphasis></quote> if HELO or EHLO
17975 was used and its argument was not identical to the real host name or IP
17976 address, and <quote>ident=<emphasis>xxxx</emphasis></quote> if an RFC 1413 ident string is available. If
17977 all three items are present in the parentheses, a newline and tab are inserted
17978 into the string, to improve the formatting of the <emphasis>Received:</emphasis> header.
17979 </para>
17980 </listitem></varlistentry>
17981 <varlistentry>
17982 <term><varname>$sender_verify_failure</varname></term>
17983 <listitem>
17984 <para>
17985 <indexterm role="variable">
17986 <primary><varname>$sender_verify_failure</varname></primary>
17987 </indexterm>
17988 In an ACL, when a sender verification fails, this variable contains information
17989 about the failure. The details are the same as for
17990 <varname>$recipient_verify_failure</varname>.
17991 </para>
17992 </listitem></varlistentry>
17993 <varlistentry>
17994 <term><varname>$sending_ip_address</varname></term>
17995 <listitem>
17996 <para>
17997 <indexterm role="variable">
17998 <primary><varname>$sending_ip_address</varname></primary>
17999 </indexterm>
18000 This variable is set whenever an outgoing SMTP connection to another host has
18001 been set up. It contains the IP address of the local interface that is being
18002 used. This is useful if a host that has more than one IP address wants to take
18003 on different personalities depending on which one is being used. For incoming
18004 connections, see <varname>$received_ip_address</varname>.
18005 </para>
18006 </listitem></varlistentry>
18007 <varlistentry>
18008 <term><varname>$sending_port</varname></term>
18009 <listitem>
18010 <para>
18011 <indexterm role="variable">
18012 <primary><varname>$sending_port</varname></primary>
18013 </indexterm>
18014 This variable is set whenever an outgoing SMTP connection to another host has
18015 been set up. It contains the local port that is being used. For incoming
18016 connections, see <varname>$received_port</varname>.
18017 </para>
18018 </listitem></varlistentry>
18019 <varlistentry>
18020 <term><varname>$smtp_active_hostname</varname></term>
18021 <listitem>
18022 <para>
18023 <indexterm role="variable">
18024 <primary><varname>$smtp_active_hostname</varname></primary>
18025 </indexterm>
18026 During an incoming SMTP session, this variable contains the value of the active
18027 host name, as specified by the <option>smtp_active_hostname</option> option. The value of
18028 <varname>$smtp_active_hostname</varname> is saved with any message that is received, so its
18029 value can be consulted during routing and delivery.
18030 </para>
18031 </listitem></varlistentry>
18032 <varlistentry>
18033 <term><varname>$smtp_command</varname></term>
18034 <listitem>
18035 <para>
18036 <indexterm role="variable">
18037 <primary><varname>$smtp_command</varname></primary>
18038 </indexterm>
18039 During the processing of an incoming SMTP command, this variable contains the
18040 entire command. This makes it possible to distinguish between HELO and EHLO in
18041 the HELO ACL, and also to distinguish between commands such as these:
18042 </para>
18043 <literallayout class="monospaced">
18044 MAIL FROM:&lt;&gt;
18045 MAIL FROM: &lt;&gt;
18046 </literallayout>
18047 <para>
18048 For a MAIL command, extra parameters such as SIZE can be inspected. For a RCPT
18049 command, the address in <varname>$smtp_command</varname> is the original address before any
18050 rewriting, whereas the values in <varname>$local_part</varname> and <varname>$domain</varname> are taken from
18051 the address after SMTP-time rewriting.
18052 </para>
18053 </listitem></varlistentry>
18054 <varlistentry>
18055 <term><varname>$smtp_command_argument</varname></term>
18056 <listitem>
18057 <para>
18058 <indexterm role="concept">
18059 <primary>SMTP</primary>
18060 <secondary>command, argument for</secondary>
18061 </indexterm>
18062 <indexterm role="variable">
18063 <primary><varname>$smtp_command_argument</varname></primary>
18064 </indexterm>
18065 While an ACL is running to check an SMTP command, this variable contains the
18066 argument, that is, the text that follows the command name, with leading white
18067 space removed. Following the introduction of <varname>$smtp_command</varname>, this variable is
18068 somewhat redundant, but is retained for backwards compatibility.
18069 </para>
18070 </listitem></varlistentry>
18071 <varlistentry>
18072 <term><varname>$smtp_count_at_connection_start</varname></term>
18073 <listitem>
18074 <para>
18075 <indexterm role="variable">
18076 <primary><varname>$smtp_count_at_connection_start</varname></primary>
18077 </indexterm>
18078 This variable is set greater than zero only in processes spawned by the Exim
18079 daemon for handling incoming SMTP connections. The name is deliberately long,
18080 in order to emphasize what the contents are. When the daemon accepts a new
18081 connection, it increments this variable. A copy of the variable is passed to
18082 the child process that handles the connection, but its value is fixed, and
18083 never changes. It is only an approximation of how many incoming connections
18084 there actually are, because many other connections may come and go while a
18085 single connection is being processed. When a child process terminates, the
18086 daemon decrements its copy of the variable.
18087 </para>
18088 </listitem></varlistentry>
18089 <varlistentry>
18090 <term><varname>$sn0</varname> &ndash; <varname>$sn9</varname></term>
18091 <listitem>
18092 <para>
18093 These variables are copies of the values of the <varname>$n0</varname> &ndash; <varname>$n9</varname> accumulators
18094 that were current at the end of the system filter file. This allows a system
18095 filter file to set values that can be tested in users&#x2019; filter files. For
18096 example, a system filter could set a value indicating how likely it is that a
18097 message is junk mail.
18098 </para>
18099 </listitem></varlistentry>
18100 <varlistentry>
18101 <term><varname>$spam_</varname><emphasis>xxx</emphasis></term>
18102 <listitem>
18103 <para>
18104 A number of variables whose names start with <varname>$spam</varname> are available when Exim
18105 is compiled with the content-scanning extension. For details, see section
18106 <xref linkend="SECTscanspamass"/>.
18107 </para>
18108 </listitem></varlistentry>
18109 <varlistentry>
18110 <term><varname>$spool_directory</varname></term>
18111 <listitem>
18112 <para>
18113 <indexterm role="variable">
18114 <primary><varname>$spool_directory</varname></primary>
18115 </indexterm>
18116 The name of Exim&#x2019;s spool directory.
18117 </para>
18118 </listitem></varlistentry>
18119 <varlistentry>
18120 <term><varname>$spool_inodes</varname></term>
18121 <listitem>
18122 <para>
18123 <indexterm role="variable">
18124 <primary><varname>$spool_inodes</varname></primary>
18125 </indexterm>
18126 The number of free inodes in the disk partition where Exim&#x2019;s spool files are
18127 being written. The value is recalculated whenever the variable is referenced.
18128 If the relevant file system does not have the concept of inodes, the value of
18129 is -1. See also the <option>check_spool_inodes</option> option.
18130 </para>
18131 </listitem></varlistentry>
18132 <varlistentry>
18133 <term><varname>$spool_space</varname></term>
18134 <listitem>
18135 <para>
18136 <indexterm role="variable">
18137 <primary><varname>$spool_space</varname></primary>
18138 </indexterm>
18139 The amount of free space (as a number of kilobytes) in the disk partition where
18140 Exim&#x2019;s spool files are being written. The value is recalculated whenever the
18141 variable is referenced. If the operating system does not have the ability to
18142 find the amount of free space (only true for experimental systems), the space
18143 value is -1. For example, to check in an ACL that there is at least 50
18144 megabytes free on the spool, you could write:
18145 </para>
18146 <literallayout class="monospaced">
18147 condition = ${if &gt; {$spool_space}{50000}}
18148 </literallayout>
18149 <para>
18150 See also the <option>check_spool_space</option> option.
18151 </para>
18152 </listitem></varlistentry>
18153 <varlistentry>
18154 <term><varname>$thisaddress</varname></term>
18155 <listitem>
18156 <para>
18157 <indexterm role="variable">
18158 <primary><varname>$thisaddress</varname></primary>
18159 </indexterm>
18160 This variable is set only during the processing of the <option>foranyaddress</option>
18161 command in a filter file. Its use is explained in the description of that
18162 command, which can be found in the separate document entitled <emphasis>Exim&#x2019;s
18163 interfaces to mail filtering</emphasis>.
18164 </para>
18165 </listitem></varlistentry>
18166 <varlistentry>
18167 <term><varname>$tls_certificate_verified</varname></term>
18168 <listitem>
18169 <para>
18170 <indexterm role="variable">
18171 <primary><varname>$tls_certificate_verified</varname></primary>
18172 </indexterm>
18173 This variable is set to <quote>1</quote> if a TLS certificate was verified when the
18174 message was received, and <quote>0</quote> otherwise.
18175 </para>
18176 </listitem></varlistentry>
18177 <varlistentry>
18178 <term><varname>$tls_cipher</varname></term>
18179 <listitem>
18180 <para>
18181 <indexterm role="variable">
18182 <primary><varname>$tls_cipher</varname></primary>
18183 </indexterm>
18184 When a message is received from a remote host over an encrypted SMTP
18185 connection, this variable is set to the cipher suite that was negotiated, for
18186 example DES-CBC3-SHA. In other circumstances, in particular, for message
18187 received over unencrypted connections, the variable is empty. Testing
18188 <varname>$tls_cipher</varname> for emptiness is one way of distinguishing between encrypted and
18189 non-encrypted connections during ACL processing.
18190 </para>
18191 <para>
18192 The <varname>$tls_cipher</varname> variable retains its value during message delivery, except
18193 when an outward SMTP delivery takes place via the <command>smtp</command> transport. In this
18194 case, <varname>$tls_cipher</varname> is cleared before any outgoing SMTP connection is made,
18195 and then set to the outgoing cipher suite if one is negotiated. See chapter
18196 <xref linkend="CHAPTLS"/> for details of TLS support and chapter <xref linkend="CHAPsmtptrans"/> for
18197 details of the <command>smtp</command> transport.
18198 </para>
18199 </listitem></varlistentry>
18200 <varlistentry>
18201 <term><varname>$tls_peerdn</varname></term>
18202 <listitem>
18203 <para>
18204 <indexterm role="variable">
18205 <primary><varname>$tls_peerdn</varname></primary>
18206 </indexterm>
18207 When a message is received from a remote host over an encrypted SMTP
18208 connection, and Exim is configured to request a certificate from the client,
18209 the value of the Distinguished Name of the certificate is made available in the
18210 <varname>$tls_peerdn</varname> during subsequent processing. Like <varname>$tls_cipher</varname>, the
18211 value is retained during message delivery, except during outbound SMTP
18212 deliveries.
18213 </para>
18214 </listitem></varlistentry>
18215 <varlistentry>
18216 <term><varname>$tod_bsdinbox</varname></term>
18217 <listitem>
18218 <para>
18219 <indexterm role="variable">
18220 <primary><varname>$tod_bsdinbox</varname></primary>
18221 </indexterm>
18222 The time of day and the date, in the format required for BSD-style mailbox
18223 files, for example: Thu Oct 17 17:14:09 1995.
18224 </para>
18225 </listitem></varlistentry>
18226 <varlistentry>
18227 <term><varname>$tod_epoch</varname></term>
18228 <listitem>
18229 <para>
18230 <indexterm role="variable">
18231 <primary><varname>$tod_epoch</varname></primary>
18232 </indexterm>
18233 The time and date as a number of seconds since the start of the Unix epoch.
18234 </para>
18235 </listitem></varlistentry>
18236 <varlistentry>
18237 <term><varname>$tod_full</varname></term>
18238 <listitem>
18239 <para>
18240 <indexterm role="variable">
18241 <primary><varname>$tod_full</varname></primary>
18242 </indexterm>
18243 A full version of the time and date, for example: Wed, 16 Oct 1995 09:51:40
18244 +0100. The timezone is always given as a numerical offset from UTC, with
18245 positive values used for timezones that are ahead (east) of UTC, and negative
18246 values for those that are behind (west).
18247 </para>
18248 </listitem></varlistentry>
18249 <varlistentry>
18250 <term><varname>$tod_log</varname></term>
18251 <listitem>
18252 <para>
18253 <indexterm role="variable">
18254 <primary><varname>$tod_log</varname></primary>
18255 </indexterm>
18256 The time and date in the format used for writing Exim&#x2019;s log files, for example:
18257 1995-10-12 15:32:29, but without a timezone.
18258 </para>
18259 </listitem></varlistentry>
18260 <varlistentry>
18261 <term><varname>$tod_logfile</varname></term>
18262 <listitem>
18263 <para>
18264 <indexterm role="variable">
18265 <primary><varname>$tod_logfile</varname></primary>
18266 </indexterm>
18267 This variable contains the date in the format yyyymmdd. This is the format that
18268 is used for datestamping log files when <option>log_file_path</option> contains the <literal>%D</literal>
18269 flag.
18270 </para>
18271 </listitem></varlistentry>
18272 <varlistentry>
18273 <term><varname>$tod_zone</varname></term>
18274 <listitem>
18275 <para>
18276 <indexterm role="variable">
18277 <primary><varname>$tod_zone</varname></primary>
18278 </indexterm>
18279 This variable contains the numerical value of the local timezone, for example:
18280 -0500.
18281 </para>
18282 </listitem></varlistentry>
18283 <varlistentry>
18284 <term><varname>$tod_zulu</varname></term>
18285 <listitem>
18286 <para>
18287 <indexterm role="variable">
18288 <primary><varname>$tod_zulu</varname></primary>
18289 </indexterm>
18290 This variable contains the UTC date and time in <quote>Zulu</quote> format, as specified
18291 by ISO 8601, for example: 20030221154023Z.
18292 </para>
18293 </listitem></varlistentry>
18294 <varlistentry>
18295 <term><varname>$value</varname></term>
18296 <listitem>
18297 <para>
18298 <indexterm role="variable">
18299 <primary><varname>$value</varname></primary>
18300 </indexterm>
18301 This variable contains the result of an expansion lookup, extraction operation,
18302 or external command, as described above. It is also used during a
18303 <emphasis role="bold">reduce</emphasis> expansion.
18304 </para>
18305 </listitem></varlistentry>
18306 <varlistentry>
18307 <term><varname>$version_number</varname></term>
18308 <listitem>
18309 <para>
18310 <indexterm role="variable">
18311 <primary><varname>$version_number</varname></primary>
18312 </indexterm>
18313 The version number of Exim.
18314 </para>
18315 </listitem></varlistentry>
18316 <varlistentry>
18317 <term><varname>$warn_message_delay</varname></term>
18318 <listitem>
18319 <para>
18320 <indexterm role="variable">
18321 <primary><varname>$warn_message_delay</varname></primary>
18322 </indexterm>
18323 This variable is set only during the creation of a message warning about a
18324 delivery delay. Details of its use are explained in section <xref linkend="SECTcustwarn"/>.
18325 </para>
18326 </listitem></varlistentry>
18327 <varlistentry>
18328 <term><varname>$warn_message_recipients</varname></term>
18329 <listitem>
18330 <para>
18331 <indexterm role="variable">
18332 <primary><varname>$warn_message_recipients</varname></primary>
18333 </indexterm>
18334 This variable is set only during the creation of a message warning about a
18335 delivery delay. Details of its use are explained in section <xref linkend="SECTcustwarn"/>.
18336 </para>
18337 </listitem></varlistentry>
18338 </variablelist>
18339 <para>
18340 <indexterm role="concept" startref="IIDstrexp" class="endofrange"/>
18341 </para>
18342 </section>
18343 </chapter>
18344
18345 <chapter id="CHAPperl">
18346 <title>Embedded Perl</title>
18347 <para>
18348 <indexterm role="concept" id="IIDperl" class="startofrange">
18349 <primary>Perl</primary>
18350 <secondary>calling from Exim</secondary>
18351 </indexterm>
18352 Exim can be built to include an embedded Perl interpreter. When this is done,
18353 Perl subroutines can be called as part of the string expansion process. To make
18354 use of the Perl support, you need version 5.004 or later of Perl installed on
18355 your system. To include the embedded interpreter in the Exim binary, include
18356 the line
18357 </para>
18358 <literallayout class="monospaced">
18359 EXIM_PERL = perl.o
18360 </literallayout>
18361 <para>
18362 in your <filename>Local/Makefile</filename> and then build Exim in the normal way.
18363 </para>
18364 <section id="SECID85">
18365 <title>Setting up so Perl can be used</title>
18366 <para>
18367 <indexterm role="option">
18368 <primary><option>perl_startup</option></primary>
18369 </indexterm>
18370 Access to Perl subroutines is via a global configuration option called
18371 <option>perl_startup</option> and an expansion string operator <option>${perl ...}</option>. If there is
18372 no <option>perl_startup</option> option in the Exim configuration file then no Perl
18373 interpreter is started and there is almost no overhead for Exim (since none of
18374 the Perl library will be paged in unless used). If there is a <option>perl_startup</option>
18375 option then the associated value is taken to be Perl code which is executed in
18376 a newly created Perl interpreter.
18377 </para>
18378 <para>
18379 The value of <option>perl_startup</option> is not expanded in the Exim sense, so you do not
18380 need backslashes before any characters to escape special meanings. The option
18381 should usually be something like
18382 </para>
18383 <literallayout class="monospaced">
18384 perl_startup = do '/etc/exim.pl'
18385 </literallayout>
18386 <para>
18387 where <filename>/etc/exim.pl</filename> is Perl code which defines any subroutines you want to
18388 use from Exim. Exim can be configured either to start up a Perl interpreter as
18389 soon as it is entered, or to wait until the first time it is needed. Starting
18390 the interpreter at the beginning ensures that it is done while Exim still has
18391 its setuid privilege, but can impose an unnecessary overhead if Perl is not in
18392 fact used in a particular run. Also, note that this does not mean that Exim is
18393 necessarily running as root when Perl is called at a later time. By default,
18394 the interpreter is started only when it is needed, but this can be changed in
18395 two ways:
18396 </para>
18397 <itemizedlist>
18398 <listitem>
18399 <para>
18400 <indexterm role="option">
18401 <primary><option>perl_at_start</option></primary>
18402 </indexterm>
18403 Setting <option>perl_at_start</option> (a boolean option) in the configuration requests
18404 a startup when Exim is entered.
18405 </para>
18406 </listitem>
18407 <listitem>
18408 <para>
18409 The command line option <option>-ps</option> also requests a startup when Exim is entered,
18410 overriding the setting of <option>perl_at_start</option>.
18411 </para>
18412 </listitem>
18413 </itemizedlist>
18414 <para>
18415 There is also a command line option <option>-pd</option> (for delay) which suppresses the
18416 initial startup, even if <option>perl_at_start</option> is set.
18417 </para>
18418 </section>
18419 <section id="SECID86">
18420 <title>Calling Perl subroutines</title>
18421 <para>
18422 When the configuration file includes a <option>perl_startup</option> option you can make use
18423 of the string expansion item to call the Perl subroutines that are defined
18424 by the <option>perl_startup</option> code. The operator is used in any of the following
18425 forms:
18426 </para>
18427 <literallayout class="monospaced">
18428 ${perl{foo}}
18429 ${perl{foo}{argument}}
18430 ${perl{foo}{argument1}{argument2} ... }
18431 </literallayout>
18432 <para>
18433 which calls the subroutine <option>foo</option> with the given arguments. A maximum of eight
18434 arguments may be passed. Passing more than this results in an expansion failure
18435 with an error message of the form
18436 </para>
18437 <literallayout class="monospaced">
18438 Too many arguments passed to Perl subroutine "foo" (max is 8)
18439 </literallayout>
18440 <para>
18441 The return value of the Perl subroutine is evaluated in a scalar context before
18442 it is passed back to Exim to be inserted into the expanded string. If the
18443 return value is <emphasis>undef</emphasis>, the expansion is forced to fail in the same way as
18444 an explicit <quote>fail</quote> on an <option>if</option> or <option>lookup</option> item. If the subroutine aborts
18445 by obeying Perl&#x2019;s <option>die</option> function, the expansion fails with the error message
18446 that was passed to <option>die</option>.
18447 </para>
18448 </section>
18449 <section id="SECID87">
18450 <title>Calling Exim functions from Perl</title>
18451 <para>
18452 Within any Perl code called from Exim, the function <emphasis>Exim::expand_string()</emphasis>
18453 is available to call back into Exim&#x2019;s string expansion function. For example,
18454 the Perl code
18455 </para>
18456 <literallayout class="monospaced">
18457 my $lp = Exim::expand_string('$local_part');
18458 </literallayout>
18459 <para>
18460 makes the current Exim <varname>$local_part</varname> available in the Perl variable <varname>$lp</varname>.
18461 Note those are single quotes and not double quotes to protect against
18462 <varname>$local_part</varname> being interpolated as a Perl variable.
18463 </para>
18464 <para>
18465 If the string expansion is forced to fail by a <quote>fail</quote> item, the result of
18466 <emphasis>Exim::expand_string()</emphasis> is <option>undef</option>. If there is a syntax error in the
18467 expansion string, the Perl call from the original expansion string fails with
18468 an appropriate error message, in the same way as if <option>die</option> were used.
18469 </para>
18470 <para>
18471 <indexterm role="concept">
18472 <primary>debugging</primary>
18473 <secondary>from embedded Perl</secondary>
18474 </indexterm>
18475 <indexterm role="concept">
18476 <primary>log</primary>
18477 <secondary>writing from embedded Perl</secondary>
18478 </indexterm>
18479 Two other Exim functions are available for use from within Perl code.
18480 <emphasis>Exim::debug_write()</emphasis> writes a string to the standard error stream if Exim&#x2019;s
18481 debugging is enabled. If you want a newline at the end, you must supply it.
18482 <emphasis>Exim::log_write()</emphasis> writes a string to Exim&#x2019;s main log, adding a leading
18483 timestamp. In this case, you should not supply a terminating newline.
18484 </para>
18485 </section>
18486 <section id="SECID88">
18487 <title>Use of standard output and error by Perl</title>
18488 <para>
18489 <indexterm role="concept">
18490 <primary>Perl</primary>
18491 <secondary>standard output and error</secondary>
18492 </indexterm>
18493 You should not write to the standard error or output streams from within your
18494 Perl code, as it is not defined how these are set up. In versions of Exim
18495 before 4.50, it is possible for the standard output or error to refer to the
18496 SMTP connection during message reception via the daemon. Writing to this stream
18497 is certain to cause chaos. From Exim 4.50 onwards, the standard output and
18498 error streams are connected to <filename>/dev/null</filename> in the daemon. The chaos is
18499 avoided, but the output is lost.
18500 </para>
18501 <para>
18502 <indexterm role="concept">
18503 <primary>Perl</primary>
18504 <secondary>use of <option>warn</option></secondary>
18505 </indexterm>
18506 The Perl <option>warn</option> statement writes to the standard error stream by default.
18507 Calls to <option>warn</option> may be embedded in Perl modules that you use, but over which
18508 you have no control. When Exim starts up the Perl interpreter, it arranges for
18509 output from the <option>warn</option> statement to be written to the Exim main log. You can
18510 change this by including appropriate Perl magic somewhere in your Perl code.
18511 For example, to discard <option>warn</option> output completely, you need this:
18512 </para>
18513 <literallayout class="monospaced">
18514 $SIG{__WARN__} = sub { };
18515 </literallayout>
18516 <para>
18517 Whenever a <option>warn</option> is obeyed, the anonymous subroutine is called. In this
18518 example, the code for the subroutine is empty, so it does nothing, but you can
18519 include any Perl code that you like. The text of the <option>warn</option> message is passed
18520 as the first subroutine argument.
18521 <indexterm role="concept" startref="IIDperl" class="endofrange"/>
18522 </para>
18523 </section>
18524 </chapter>
18525
18526 <chapter id="CHAPinterfaces">
18527 <title>Starting the daemon and the use of network interfaces</title>
18528 <titleabbrev>Starting the daemon</titleabbrev>
18529 <para>
18530 <indexterm role="concept">
18531 <primary>daemon</primary>
18532 <secondary>starting</secondary>
18533 </indexterm>
18534 <indexterm role="concept">
18535 <primary>interface</primary>
18536 <secondary>listening</secondary>
18537 </indexterm>
18538 <indexterm role="concept">
18539 <primary>network interface</primary>
18540 </indexterm>
18541 <indexterm role="concept">
18542 <primary>interface</primary>
18543 <secondary>network</secondary>
18544 </indexterm>
18545 <indexterm role="concept">
18546 <primary>IP address</primary>
18547 <secondary>for listening</secondary>
18548 </indexterm>
18549 <indexterm role="concept">
18550 <primary>daemon</primary>
18551 <secondary>listening IP addresses</secondary>
18552 </indexterm>
18553 <indexterm role="concept">
18554 <primary>TCP/IP</primary>
18555 <secondary>setting listening interfaces</secondary>
18556 </indexterm>
18557 <indexterm role="concept">
18558 <primary>TCP/IP</primary>
18559 <secondary>setting listening ports</secondary>
18560 </indexterm>
18561 A host that is connected to a TCP/IP network may have one or more physical
18562 hardware network interfaces. Each of these interfaces may be configured as one
18563 or more <quote>logical</quote> interfaces, which are the entities that a program actually
18564 works with. Each of these logical interfaces is associated with an IP address.
18565 In addition, TCP/IP software supports <quote>loopback</quote> interfaces (127.0.0.1 in
18566 IPv4 and ::1 in IPv6), which do not use any physical hardware. Exim requires
18567 knowledge about the host&#x2019;s interfaces for use in three different circumstances:
18568 </para>
18569 <orderedlist numeration="arabic">
18570 <listitem>
18571 <para>
18572 When a listening daemon is started, Exim needs to know which interfaces
18573 and ports to listen on.
18574 </para>
18575 </listitem>
18576 <listitem>
18577 <para>
18578 When Exim is routing an address, it needs to know which IP addresses
18579 are associated with local interfaces. This is required for the correct
18580 processing of MX lists by removing the local host and others with the
18581 same or higher priority values. Also, Exim needs to detect cases
18582 when an address is routed to an IP address that in fact belongs to the
18583 local host. Unless the <option>self</option> router option or the <option>allow_localhost</option>
18584 option of the smtp transport is set (as appropriate), this is treated
18585 as an error situation.
18586 </para>
18587 </listitem>
18588 <listitem>
18589 <para>
18590 When Exim connects to a remote host, it may need to know which interface to use
18591 for the outgoing connection.
18592 </para>
18593 </listitem>
18594 </orderedlist>
18595 <para>
18596 Exim&#x2019;s default behaviour is likely to be appropriate in the vast majority
18597 of cases. If your host has only one interface, and you want all its IP
18598 addresses to be treated in the same way, and you are using only the
18599 standard SMTP port, you should not need to take any special action. The
18600 rest of this chapter does not apply to you.
18601 </para>
18602 <para>
18603 In a more complicated situation you may want to listen only on certain
18604 interfaces, or on different ports, and for this reason there are a number of
18605 options that can be used to influence Exim&#x2019;s behaviour. The rest of this
18606 chapter describes how they operate.
18607 </para>
18608 <para>
18609 When a message is received over TCP/IP, the interface and port that were
18610 actually used are set in <varname>$received_ip_address</varname> and <varname>$received_port</varname>.
18611 </para>
18612 <section id="SECID89">
18613 <title>Starting a listening daemon</title>
18614 <para>
18615 When a listening daemon is started (by means of the <option>-bd</option> command line
18616 option), the interfaces and ports on which it listens are controlled by the
18617 following options:
18618 </para>
18619 <itemizedlist>
18620 <listitem>
18621 <para>
18622 <option>daemon_smtp_ports</option> contains a list of default ports. (For backward
18623 compatibility, this option can also be specified in the singular.)
18624 </para>
18625 </listitem>
18626 <listitem>
18627 <para>
18628 <option>local_interfaces</option> contains list of interface IP addresses on which to
18629 listen. Each item may optionally also specify a port.
18630 </para>
18631 </listitem>
18632 </itemizedlist>
18633 <para>
18634 The default list separator in both cases is a colon, but this can be changed as
18635 described in section <xref linkend="SECTlistconstruct"/>. When IPv6 addresses are involved,
18636 it is usually best to change the separator to avoid having to double all the
18637 colons. For example:
18638 </para>
18639 <literallayout class="monospaced">
18640 local_interfaces = &lt;; 127.0.0.1 ; \
18641                       192.168.23.65 ; \
18642                       ::1 ; \
18643                       3ffe:ffff:836f::fe86:a061
18644 </literallayout>
18645 <para>
18646 There are two different formats for specifying a port along with an IP address
18647 in <option>local_interfaces</option>:
18648 </para>
18649 <orderedlist numeration="arabic">
18650 <listitem>
18651 <para>
18652 The port is added onto the address with a dot separator. For example, to listen
18653 on port 1234 on two different IP addresses:
18654 </para>
18655 <literallayout class="monospaced">
18656 local_interfaces = &lt;; 192.168.23.65.1234 ; \
18657                       3ffe:ffff:836f::fe86:a061.1234
18658 </literallayout>
18659 </listitem>
18660 <listitem>
18661 <para>
18662 The IP address is enclosed in square brackets, and the port is added
18663 with a colon separator, for example:
18664 </para>
18665 <literallayout class="monospaced">
18666 local_interfaces = &lt;; [192.168.23.65]:1234 ; \
18667                       [3ffe:ffff:836f::fe86:a061]:1234
18668 </literallayout>
18669 </listitem>
18670 </orderedlist>
18671 <para>
18672 When a port is not specified, the value of <option>daemon_smtp_ports</option> is used. The
18673 default setting contains just one port:
18674 </para>
18675 <literallayout class="monospaced">
18676 daemon_smtp_ports = smtp
18677 </literallayout>
18678 <para>
18679 If more than one port is listed, each interface that does not have its own port
18680 specified listens on all of them. Ports that are listed in
18681 <option>daemon_smtp_ports</option> can be identified either by name (defined in
18682 <filename>/etc/services</filename>) or by number. However, when ports are given with individual
18683 IP addresses in <option>local_interfaces</option>, only numbers (not names) can be used.
18684 </para>
18685 </section>
18686 <section id="SECID90">
18687 <title>Special IP listening addresses</title>
18688 <para>
18689 The addresses 0.0.0.0 and ::0 are treated specially. They are interpreted
18690 as <quote>all IPv4 interfaces</quote> and <quote>all IPv6 interfaces</quote>, respectively. In each
18691 case, Exim tells the TCP/IP stack to <quote>listen on all IPv<emphasis>x</emphasis> interfaces</quote>
18692 instead of setting up separate listening sockets for each interface. The
18693 default value of <option>local_interfaces</option> is
18694 </para>
18695 <literallayout class="monospaced">
18696 local_interfaces = 0.0.0.0
18697 </literallayout>
18698 <para>
18699 when Exim is built without IPv6 support; otherwise it is:
18700 </para>
18701 <literallayout class="monospaced">
18702 local_interfaces = &lt;; ::0 ; 0.0.0.0
18703 </literallayout>
18704 <para>
18705 Thus, by default, Exim listens on all available interfaces, on the SMTP port.
18706 </para>
18707 </section>
18708 <section id="SECID91">
18709 <title>Overriding local_interfaces and daemon_smtp_ports</title>
18710 <para>
18711 The <option>-oX</option> command line option can be used to override the values of
18712 <option>daemon_smtp_ports</option> and/or <option>local_interfaces</option> for a particular daemon
18713 instance. Another way of doing this would be to use macros and the <option>-D</option>
18714 option. However, <option>-oX</option> can be used by any admin user, whereas modification of
18715 the runtime configuration by <option>-D</option> is allowed only when the caller is root or
18716 exim.
18717 </para>
18718 <para>
18719 The value of <option>-oX</option> is a list of items. The default colon separator can be
18720 changed in the usual way if required. If there are any items that do not
18721 contain dots or colons (that is, are not IP addresses), the value of
18722 <option>daemon_smtp_ports</option> is replaced by the list of those items. If there are any
18723 items that do contain dots or colons, the value of <option>local_interfaces</option> is
18724 replaced by those items. Thus, for example,
18725 </para>
18726 <literallayout class="monospaced">
18727 -oX 1225
18728 </literallayout>
18729 <para>
18730 overrides <option>daemon_smtp_ports</option>, but leaves <option>local_interfaces</option> unchanged,
18731 whereas
18732 </para>
18733 <literallayout class="monospaced">
18734 -oX 192.168.34.5.1125
18735 </literallayout>
18736 <para>
18737 overrides <option>local_interfaces</option>, leaving <option>daemon_smtp_ports</option> unchanged.
18738 (However, since <option>local_interfaces</option> now contains no items without ports, the
18739 value of <option>daemon_smtp_ports</option> is no longer relevant in this example.)
18740 </para>
18741 </section>
18742 <section id="SECTsupobssmt">
18743 <title>Support for the obsolete SSMTP (or SMTPS) protocol</title>
18744 <para>
18745 <indexterm role="concept">
18746 <primary>ssmtp protocol</primary>
18747 </indexterm>
18748 <indexterm role="concept">
18749 <primary>smtps protocol</primary>
18750 </indexterm>
18751 <indexterm role="concept">
18752 <primary>SMTP</primary>
18753 <secondary>ssmtp protocol</secondary>
18754 </indexterm>
18755 <indexterm role="concept">
18756 <primary>SMTP</primary>
18757 <secondary>smtps protocol</secondary>
18758 </indexterm>
18759 Exim supports the obsolete SSMTP protocol (also known as SMTPS) that was used
18760 before the STARTTLS command was standardized for SMTP. Some legacy clients
18761 still use this protocol. If the <option>tls_on_connect_ports</option> option is set to a
18762 list of port numbers, connections to those ports must use SSMTP. The most
18763 common use of this option is expected to be
18764 </para>
18765 <literallayout class="monospaced">
18766 tls_on_connect_ports = 465
18767 </literallayout>
18768 <para>
18769 because 465 is the usual port number used by the legacy clients. There is also
18770 a command line option <option>-tls-on-connect</option>, which forces all ports to behave in
18771 this way when a daemon is started.
18772 </para>
18773 <para>
18774 <emphasis role="bold">Warning</emphasis>: Setting <option>tls_on_connect_ports</option> does not of itself cause the
18775 daemon to listen on those ports. You must still specify them in
18776 <option>daemon_smtp_ports</option>, <option>local_interfaces</option>, or the <option>-oX</option> option. (This is
18777 because <option>tls_on_connect_ports</option> applies to <option>inetd</option> connections as well as to
18778 connections via the daemon.)
18779 </para>
18780 </section>
18781 <section id="SECID92">
18782 <title>IPv6 address scopes</title>
18783 <para>
18784 <indexterm role="concept">
18785 <primary>IPv6</primary>
18786 <secondary>address scopes</secondary>
18787 </indexterm>
18788 IPv6 addresses have <quote>scopes</quote>, and a host with multiple hardware interfaces
18789 can, in principle, have the same link-local IPv6 address on different
18790 interfaces. Thus, additional information is needed, over and above the IP
18791 address, to distinguish individual interfaces. A convention of using a
18792 percent sign followed by something (often the interface name) has been
18793 adopted in some cases, leading to addresses like this:
18794 </para>
18795 <literallayout class="monospaced">
18796 fe80::202:b3ff:fe03:45c1%eth0
18797 </literallayout>
18798 <para>
18799 To accommodate this usage, a percent sign followed by an arbitrary string is
18800 allowed at the end of an IPv6 address. By default, Exim calls <function>getaddrinfo()</function>
18801 to convert a textual IPv6 address for actual use. This function recognizes the
18802 percent convention in operating systems that support it, and it processes the
18803 address appropriately. Unfortunately, some older libraries have problems with
18804 <function>getaddrinfo()</function>. If
18805 </para>
18806 <literallayout class="monospaced">
18807 IPV6_USE_INET_PTON=yes
18808 </literallayout>
18809 <para>
18810 is set in <filename>Local/Makefile</filename> (or an OS-dependent Makefile) when Exim is built,
18811 Exim uses <emphasis>inet_pton()</emphasis> to convert a textual IPv6 address for actual use,
18812 instead of <function>getaddrinfo()</function>. (Before version 4.14, it always used this
18813 function.) Of course, this means that the additional functionality of
18814 <function>getaddrinfo()</function> &ndash; recognizing scoped addresses &ndash; is lost.
18815 </para>
18816 </section>
18817 <section id="SECID93">
18818 <title>Disabling IPv6</title>
18819 <para>
18820 <indexterm role="concept">
18821 <primary>IPv6</primary>
18822 <secondary>disabling</secondary>
18823 </indexterm>
18824 Sometimes it happens that an Exim binary that was compiled with IPv6 support is
18825 run on a host whose kernel does not support IPv6. The binary will fall back to
18826 using IPv4, but it may waste resources looking up AAAA records, and trying to
18827 connect to IPv6 addresses, causing delays to mail delivery. If you set the
18828 <indexterm role="option">
18829 <primary><option>disable_ipv6</option></primary>
18830 </indexterm>
18831 <option>disable_ipv6</option> option true, even if the Exim binary has IPv6 support, no IPv6
18832 activities take place. AAAA records are never looked up, and any IPv6 addresses
18833 that are listed in <option>local_interfaces</option>, data for the <command>manualroute</command> router,
18834 etc. are ignored. If IP literals are enabled, the <command>ipliteral</command> router declines
18835 to handle IPv6 literal addresses.
18836 </para>
18837 <para>
18838 On the other hand, when IPv6 is in use, there may be times when you want to
18839 disable it for certain hosts or domains. You can use the <option>dns_ipv4_lookup</option>
18840 option to globally suppress the lookup of AAAA records for specified domains,
18841 and you can use the <option>ignore_target_hosts</option> generic router option to ignore
18842 IPv6 addresses in an individual router.
18843 </para>
18844 </section>
18845 <section id="SECID94">
18846 <title>Examples of starting a listening daemon</title>
18847 <para>
18848 The default case in an IPv6 environment is
18849 </para>
18850 <literallayout class="monospaced">
18851 daemon_smtp_ports = smtp
18852 local_interfaces = &lt;; ::0 ; 0.0.0.0
18853 </literallayout>
18854 <para>
18855 This specifies listening on the smtp port on all IPv6 and IPv4 interfaces.
18856 Either one or two sockets may be used, depending on the characteristics of
18857 the TCP/IP stack. (This is complicated and messy; for more information,
18858 read the comments in the <filename>daemon.c</filename> source file.)
18859 </para>
18860 <para>
18861 To specify listening on ports 25 and 26 on all interfaces:
18862 </para>
18863 <literallayout class="monospaced">
18864 daemon_smtp_ports = 25 : 26
18865 </literallayout>
18866 <para>
18867 (leaving <option>local_interfaces</option> at the default setting) or, more explicitly:
18868 </para>
18869 <literallayout class="monospaced">
18870 local_interfaces = &lt;; ::0.25     ; ::0.26 \
18871                       0.0.0.0.25 ; 0.0.0.0.26
18872 </literallayout>
18873 <para>
18874 To listen on the default port on all IPv4 interfaces, and on port 26 on the
18875 IPv4 loopback address only:
18876 </para>
18877 <literallayout class="monospaced">
18878 local_interfaces = 0.0.0.0 : 127.0.0.1.26
18879 </literallayout>
18880 <para>
18881 To specify listening on the default port on specific interfaces only:
18882 </para>
18883 <literallayout class="monospaced">
18884 local_interfaces = 192.168.34.67 : 192.168.34.67
18885 </literallayout>
18886 <para>
18887 <emphasis role="bold">Warning</emphasis>: Such a setting excludes listening on the loopback interfaces.
18888 </para>
18889 </section>
18890 <section id="SECTreclocipadd">
18891 <title>Recognizing the local host</title>
18892 <para>
18893 The <option>local_interfaces</option> option is also used when Exim needs to determine
18894 whether or not an IP address refers to the local host. That is, the IP
18895 addresses of all the interfaces on which a daemon is listening are always
18896 treated as local.
18897 </para>
18898 <para>
18899 For this usage, port numbers in <option>local_interfaces</option> are ignored. If either of
18900 the items 0.0.0.0 or ::0 are encountered, Exim gets a complete list of
18901 available interfaces from the operating system, and extracts the relevant
18902 (that is, IPv4 or IPv6) addresses to use for checking.
18903 </para>
18904 <para>
18905 Some systems set up large numbers of virtual interfaces in order to provide
18906 many virtual web servers. In this situation, you may want to listen for
18907 email on only a few of the available interfaces, but nevertheless treat all
18908 interfaces as local when routing. You can do this by setting
18909 <option>extra_local_interfaces</option> to a list of IP addresses, possibly including the
18910 <quote>all</quote> wildcard values. These addresses are recognized as local, but are not
18911 used for listening. Consider this example:
18912 </para>
18913 <literallayout class="monospaced">
18914 local_interfaces = &lt;; 127.0.0.1 ; ::1 ; \
18915                       192.168.53.235 ; \
18916                       3ffe:2101:12:1:a00:20ff:fe86:a061
18917
18918 extra_local_interfaces = &lt;; ::0 ; 0.0.0.0
18919 </literallayout>
18920 <para>
18921 The daemon listens on the loopback interfaces and just one IPv4 and one IPv6
18922 address, but all available interface addresses are treated as local when
18923 Exim is routing.
18924 </para>
18925 <para>
18926 In some environments the local host name may be in an MX list, but with an IP
18927 address that is not assigned to any local interface. In other cases it may be
18928 desirable to treat other host names as if they referred to the local host. Both
18929 these cases can be handled by setting the <option>hosts_treat_as_local</option> option.
18930 This contains host names rather than IP addresses. When a host is referenced
18931 during routing, either via an MX record or directly, it is treated as the local
18932 host if its name matches <option>hosts_treat_as_local</option>, or if any of its IP
18933 addresses match <option>local_interfaces</option> or <option>extra_local_interfaces</option>.
18934 </para>
18935 </section>
18936 <section id="SECID95">
18937 <title>Delivering to a remote host</title>
18938 <para>
18939 Delivery to a remote host is handled by the smtp transport. By default, it
18940 allows the system&#x2019;s TCP/IP functions to choose which interface to use (if
18941 there is more than one) when connecting to a remote host. However, the
18942 <option>interface</option> option can be set to specify which interface is used. See the
18943 description of the smtp transport in chapter <xref linkend="CHAPsmtptrans"/> for more
18944 details.
18945 </para>
18946 </section>
18947 </chapter>
18948
18949 <chapter id="CHAPmainconfig">
18950 <title>Main configuration</title>
18951 <para>
18952 <indexterm role="concept" id="IIDconfima" class="startofrange">
18953 <primary>configuration file</primary>
18954 <secondary>main section</secondary>
18955 </indexterm>
18956 <indexterm role="concept" id="IIDmaiconf" class="startofrange">
18957 <primary>main configuration</primary>
18958 </indexterm>
18959 The first part of the run time configuration file contains three types of item:
18960 </para>
18961 <itemizedlist>
18962 <listitem>
18963 <para>
18964 Macro definitions: These lines start with an upper case letter. See section
18965 <xref linkend="SECTmacrodefs"/> for details of macro processing.
18966 </para>
18967 </listitem>
18968 <listitem>
18969 <para>
18970 Named list definitions: These lines start with one of the words <quote>domainlist</quote>,
18971 <quote>hostlist</quote>, <quote>addresslist</quote>, or <quote>localpartlist</quote>. Their use is described in
18972 section <xref linkend="SECTnamedlists"/>.
18973 </para>
18974 </listitem>
18975 <listitem>
18976 <para>
18977 Main configuration settings: Each setting occupies one line of the file
18978 (with possible continuations). If any setting is preceded by the word
18979 <quote>hide</quote>, the <option>-bP</option> command line option displays its value to admin users
18980 only. See section <xref linkend="SECTcos"/> for a description of the syntax of these option
18981 settings.
18982 </para>
18983 </listitem>
18984 </itemizedlist>
18985 <para>
18986 This chapter specifies all the main configuration options, along with their
18987 types and default values. For ease of finding a particular option, they appear
18988 in alphabetical order in section <xref linkend="SECTalomo"/> below. However, because there
18989 are now so many options, they are first listed briefly in functional groups, as
18990 an aid to finding the name of the option you are looking for. Some options are
18991 listed in more than one group.
18992 </para>
18993 <section id="SECID96">
18994 <title>Miscellaneous</title>
18995 <informaltable frame="none">
18996 <tgroup cols="2" colsep="0" rowsep="0">
18997 <colspec colwidth="196pt" align="left"/>
18998 <colspec colwidth="254pt" align="left"/>
18999 <tbody>
19000 <row>
19001 <entry><option>bi_command</option></entry>
19002 <entry>to run for <option>-bi</option> command line option</entry>
19003 </row>
19004 <row>
19005 <entry><option>disable_ipv6</option></entry>
19006 <entry>do no IPv6 processing</entry>
19007 </row>
19008 <row>
19009 <entry><option>keep_malformed</option></entry>
19010 <entry>for broken files &ndash; should not happen</entry>
19011 </row>
19012 <row>
19013 <entry><option>localhost_number</option></entry>
19014 <entry>for unique message ids in clusters</entry>
19015 </row>
19016 <row>
19017 <entry><option>message_body_newlines</option></entry>
19018 <entry>retain newlines in <varname>$message_body</varname></entry>
19019 </row>
19020 <row>
19021 <entry><option>message_body_visible</option></entry>
19022 <entry>how much to show in <varname>$message_body</varname></entry>
19023 </row>
19024 <row>
19025 <entry><option>mua_wrapper</option></entry>
19026 <entry>run in <quote>MUA wrapper</quote> mode</entry>
19027 </row>
19028 <row>
19029 <entry><option>print_topbitchars</option></entry>
19030 <entry>top-bit characters are printing</entry>
19031 </row>
19032 <row>
19033 <entry><option>timezone</option></entry>
19034 <entry>force time zone</entry>
19035 </row>
19036 </tbody>
19037 </tgroup>
19038 </informaltable>
19039 </section>
19040 <section id="SECID97">
19041 <title>Exim parameters</title>
19042 <informaltable frame="none">
19043 <tgroup cols="2" colsep="0" rowsep="0">
19044 <colspec colwidth="196pt" align="left"/>
19045 <colspec colwidth="254pt" align="left"/>
19046 <tbody>
19047 <row>
19048 <entry><option>exim_group</option></entry>
19049 <entry>override compiled-in value</entry>
19050 </row>
19051 <row>
19052 <entry><option>exim_path</option></entry>
19053 <entry>override compiled-in value</entry>
19054 </row>
19055 <row>
19056 <entry><option>exim_user</option></entry>
19057 <entry>override compiled-in value</entry>
19058 </row>
19059 <row>
19060 <entry><option>primary_hostname</option></entry>
19061 <entry>default from <function>uname()</function></entry>
19062 </row>
19063 <row>
19064 <entry><option>split_spool_directory</option></entry>
19065 <entry>use multiple directories</entry>
19066 </row>
19067 <row>
19068 <entry><option>spool_directory</option></entry>
19069 <entry>override compiled-in value</entry>
19070 </row>
19071 </tbody>
19072 </tgroup>
19073 </informaltable>
19074 </section>
19075 <section id="SECID98">
19076 <title>Privilege controls</title>
19077 <informaltable frame="none">
19078 <tgroup cols="2" colsep="0" rowsep="0">
19079 <colspec colwidth="196pt" align="left"/>
19080 <colspec colwidth="254pt" align="left"/>
19081 <tbody>
19082 <row>
19083 <entry><option>admin_groups</option></entry>
19084 <entry>groups that are Exim admin users</entry>
19085 </row>
19086 <row>
19087 <entry><option>deliver_drop_privilege</option></entry>
19088 <entry>drop root for delivery processes</entry>
19089 </row>
19090 <row>
19091 <entry><option>local_from_check</option></entry>
19092 <entry>insert <emphasis>Sender:</emphasis> if necessary</entry>
19093 </row>
19094 <row>
19095 <entry><option>local_from_prefix</option></entry>
19096 <entry>for testing <emphasis>From:</emphasis> for local sender</entry>
19097 </row>
19098 <row>
19099 <entry><option>local_from_suffix</option></entry>
19100 <entry>for testing <emphasis>From:</emphasis> for local sender</entry>
19101 </row>
19102 <row>
19103 <entry><option>local_sender_retain</option></entry>
19104 <entry>keep <emphasis>Sender:</emphasis> from untrusted user</entry>
19105 </row>
19106 <row>
19107 <entry><option>never_users</option></entry>
19108 <entry>do not run deliveries as these</entry>
19109 </row>
19110 <row>
19111 <entry><option>prod_requires_admin</option></entry>
19112 <entry>forced delivery requires admin user</entry>
19113 </row>
19114 <row>
19115 <entry><option>queue_list_requires_admin</option></entry>
19116 <entry>queue listing requires admin user</entry>
19117 </row>
19118 <row>
19119 <entry><option>trusted_groups</option></entry>
19120 <entry>groups that are trusted</entry>
19121 </row>
19122 <row>
19123 <entry><option>trusted_users</option></entry>
19124 <entry>users that are trusted</entry>
19125 </row>
19126 </tbody>
19127 </tgroup>
19128 </informaltable>
19129 </section>
19130 <section id="SECID99">
19131 <title>Logging</title>
19132 <informaltable frame="none">
19133 <tgroup cols="2" colsep="0" rowsep="0">
19134 <colspec colwidth="196pt" align="left"/>
19135 <colspec colwidth="254pt" align="left"/>
19136 <tbody>
19137 <row>
19138 <entry><option>hosts_connection_nolog</option></entry>
19139 <entry>exemption from connect logging</entry>
19140 </row>
19141 <row>
19142 <entry><option>log_file_path</option></entry>
19143 <entry>override compiled-in value</entry>
19144 </row>
19145 <row>
19146 <entry><option>log_selector</option></entry>
19147 <entry>set/unset optional logging</entry>
19148 </row>
19149 <row>
19150 <entry><option>log_timezone</option></entry>
19151 <entry>add timezone to log lines</entry>
19152 </row>
19153 <row>
19154 <entry><option>message_logs</option></entry>
19155 <entry>create per-message logs</entry>
19156 </row>
19157 <row>
19158 <entry><option>preserve_message_logs</option></entry>
19159 <entry>after message completion</entry>
19160 </row>
19161 <row>
19162 <entry><option>process_log_path</option></entry>
19163 <entry>for SIGUSR1 and <emphasis>exiwhat</emphasis></entry>
19164 </row>
19165 <row>
19166 <entry><option>syslog_duplication</option></entry>
19167 <entry>controls duplicate log lines on syslog</entry>
19168 </row>
19169 <row>
19170 <entry><option>syslog_facility</option></entry>
19171 <entry>set syslog <quote>facility</quote> field</entry>
19172 </row>
19173 <row>
19174 <entry><option>syslog_processname</option></entry>
19175 <entry>set syslog <quote>ident</quote> field</entry>
19176 </row>
19177 <row>
19178 <entry><option>syslog_timestamp</option></entry>
19179 <entry>timestamp syslog lines</entry>
19180 </row>
19181 <row>
19182 <entry><option>write_rejectlog</option></entry>
19183 <entry>control use of message log</entry>
19184 </row>
19185 </tbody>
19186 </tgroup>
19187 </informaltable>
19188 </section>
19189 <section id="SECID100">
19190 <title>Frozen messages</title>
19191 <informaltable frame="none">
19192 <tgroup cols="2" colsep="0" rowsep="0">
19193 <colspec colwidth="196pt" align="left"/>
19194 <colspec colwidth="254pt" align="left"/>
19195 <tbody>
19196 <row>
19197 <entry><option>auto_thaw</option></entry>
19198 <entry>sets time for retrying frozen messages</entry>
19199 </row>
19200 <row>
19201 <entry><option>freeze_tell</option></entry>
19202 <entry>send message when freezing</entry>
19203 </row>
19204 <row>
19205 <entry><option>move_frozen_messages</option></entry>
19206 <entry>to another directory</entry>
19207 </row>
19208 <row>
19209 <entry><option>timeout_frozen_after</option></entry>
19210 <entry>keep frozen messages only so long</entry>
19211 </row>
19212 </tbody>
19213 </tgroup>
19214 </informaltable>
19215 </section>
19216 <section id="SECID101">
19217 <title>Data lookups</title>
19218 <informaltable frame="none">
19219 <tgroup cols="2" colsep="0" rowsep="0">
19220 <colspec colwidth="196pt" align="left"/>
19221 <colspec colwidth="254pt" align="left"/>
19222 <tbody>
19223 <row>
19224 <entry><option>ibase_servers</option></entry>
19225 <entry>InterBase servers</entry>
19226 </row>
19227 <row>
19228 <entry><option>ldap_default_servers</option></entry>
19229 <entry>used if no server in query</entry>
19230 </row>
19231 <row>
19232 <entry><option>ldap_version</option></entry>
19233 <entry>set protocol version</entry>
19234 </row>
19235 <row>
19236 <entry><option>lookup_open_max</option></entry>
19237 <entry>lookup files held open</entry>
19238 </row>
19239 <row>
19240 <entry><option>mysql_servers</option></entry>
19241 <entry>default MySQL servers</entry>
19242 </row>
19243 <row>
19244 <entry><option>oracle_servers</option></entry>
19245 <entry>Oracle servers</entry>
19246 </row>
19247 <row>
19248 <entry><option>pgsql_servers</option></entry>
19249 <entry>default PostgreSQL servers</entry>
19250 </row>
19251 <row>
19252 <entry><option>sqlite_lock_timeout</option></entry>
19253 <entry>as it says</entry>
19254 </row>
19255 </tbody>
19256 </tgroup>
19257 </informaltable>
19258 </section>
19259 <section id="SECID102">
19260 <title>Message ids</title>
19261 <informaltable frame="none">
19262 <tgroup cols="2" colsep="0" rowsep="0">
19263 <colspec colwidth="196pt" align="left"/>
19264 <colspec colwidth="254pt" align="left"/>
19265 <tbody>
19266 <row>
19267 <entry><option>message_id_header_domain</option></entry>
19268 <entry>used to build <emphasis>Message-ID:</emphasis> header</entry>
19269 </row>
19270 <row>
19271 <entry><option>message_id_header_text</option></entry>
19272 <entry>ditto</entry>
19273 </row>
19274 </tbody>
19275 </tgroup>
19276 </informaltable>
19277 </section>
19278 <section id="SECID103">
19279 <title>Embedded Perl Startup</title>
19280 <informaltable frame="none">
19281 <tgroup cols="2" colsep="0" rowsep="0">
19282 <colspec colwidth="196pt" align="left"/>
19283 <colspec colwidth="254pt" align="left"/>
19284 <tbody>
19285 <row>
19286 <entry><option>perl_at_start</option></entry>
19287 <entry>always start the interpreter</entry>
19288 </row>
19289 <row>
19290 <entry><option>perl_startup</option></entry>
19291 <entry>code to obey when starting Perl</entry>
19292 </row>
19293 </tbody>
19294 </tgroup>
19295 </informaltable>
19296 </section>
19297 <section id="SECID104">
19298 <title>Daemon</title>
19299 <informaltable frame="none">
19300 <tgroup cols="2" colsep="0" rowsep="0">
19301 <colspec colwidth="196pt" align="left"/>
19302 <colspec colwidth="254pt" align="left"/>
19303 <tbody>
19304 <row>
19305 <entry><option>daemon_smtp_ports</option></entry>
19306 <entry>default ports</entry>
19307 </row>
19308 <row>
19309 <entry><option>daemon_startup_retries</option></entry>
19310 <entry>number of times to retry</entry>
19311 </row>
19312 <row>
19313 <entry><option>daemon_startup_sleep</option></entry>
19314 <entry>time to sleep between tries</entry>
19315 </row>
19316 <row>
19317 <entry><option>extra_local_interfaces</option></entry>
19318 <entry>not necessarily listened on</entry>
19319 </row>
19320 <row>
19321 <entry><option>local_interfaces</option></entry>
19322 <entry>on which to listen, with optional ports</entry>
19323 </row>
19324 <row>
19325 <entry><option>pid_file_path</option></entry>
19326 <entry>override compiled-in value</entry>
19327 </row>
19328 <row>
19329 <entry><option>queue_run_max</option></entry>
19330 <entry>maximum simultaneous queue runners</entry>
19331 </row>
19332 </tbody>
19333 </tgroup>
19334 </informaltable>
19335 </section>
19336 <section id="SECID105">
19337 <title>Resource control</title>
19338 <informaltable frame="none">
19339 <tgroup cols="2" colsep="0" rowsep="0">
19340 <colspec colwidth="196pt" align="left"/>
19341 <colspec colwidth="254pt" align="left"/>
19342 <tbody>
19343 <row>
19344 <entry><option>check_log_inodes</option></entry>
19345 <entry>before accepting a message</entry>
19346 </row>
19347 <row>
19348 <entry><option>check_log_space</option></entry>
19349 <entry>before accepting a message</entry>
19350 </row>
19351 <row>
19352 <entry><option>check_spool_inodes</option></entry>
19353 <entry>before accepting a message</entry>
19354 </row>
19355 <row>
19356 <entry><option>check_spool_space</option></entry>
19357 <entry>before accepting a message</entry>
19358 </row>
19359 <row>
19360 <entry><option>deliver_queue_load_max</option></entry>
19361 <entry>no queue deliveries if load high</entry>
19362 </row>
19363 <row>
19364 <entry><option>queue_only_load</option></entry>
19365 <entry>queue incoming if load high</entry>
19366 </row>
19367 <row>
19368 <entry><option>queue_only_load_latch</option></entry>
19369 <entry>don&#x2019;t re-evaluate load for each message</entry>
19370 </row>
19371 <row>
19372 <entry><option>queue_run_max</option></entry>
19373 <entry>maximum simultaneous queue runners</entry>
19374 </row>
19375 <row>
19376 <entry><option>remote_max_parallel</option></entry>
19377 <entry>parallel SMTP delivery per message</entry>
19378 </row>
19379 <row>
19380 <entry><option>smtp_accept_max</option></entry>
19381 <entry>simultaneous incoming connections</entry>
19382 </row>
19383 <row>
19384 <entry><option>smtp_accept_max_nonmail</option></entry>
19385 <entry>non-mail commands</entry>
19386 </row>
19387 <row>
19388 <entry><option>smtp_accept_max_nonmail_hosts</option></entry>
19389 <entry>hosts to which the limit applies</entry>
19390 </row>
19391 <row>
19392 <entry><option>smtp_accept_max_per_connection</option></entry>
19393 <entry>messages per connection</entry>
19394 </row>
19395 <row>
19396 <entry><option>smtp_accept_max_per_host</option></entry>
19397 <entry>connections from one host</entry>
19398 </row>
19399 <row>
19400 <entry><option>smtp_accept_queue</option></entry>
19401 <entry>queue mail if more connections</entry>
19402 </row>
19403 <row>
19404 <entry><option>smtp_accept_queue_per_connection</option></entry>
19405 <entry>queue if more messages per connection</entry>
19406 </row>
19407 <row>
19408 <entry><option>smtp_accept_reserve</option></entry>
19409 <entry>only reserve hosts if more connections</entry>
19410 </row>
19411 <row>
19412 <entry><option>smtp_check_spool_space</option></entry>
19413 <entry>from SIZE on MAIL command</entry>
19414 </row>
19415 <row>
19416 <entry><option>smtp_connect_backlog</option></entry>
19417 <entry>passed to TCP/IP stack</entry>
19418 </row>
19419 <row>
19420 <entry><option>smtp_load_reserve</option></entry>
19421 <entry>SMTP from reserved hosts if load high</entry>
19422 </row>
19423 <row>
19424 <entry><option>smtp_reserve_hosts</option></entry>
19425 <entry>these are the reserve hosts</entry>
19426 </row>
19427 </tbody>
19428 </tgroup>
19429 </informaltable>
19430 </section>
19431 <section id="SECID106">
19432 <title>Policy controls</title>
19433 <informaltable frame="none">
19434 <tgroup cols="2" colsep="0" rowsep="0">
19435 <colspec colwidth="196pt" align="left"/>
19436 <colspec colwidth="254pt" align="left"/>
19437 <tbody>
19438 <row>
19439 <entry><option>acl_not_smtp</option></entry>
19440 <entry>ACL for non-SMTP messages</entry>
19441 </row>
19442 <row>
19443 <entry><option>acl_not_smtp_mime</option></entry>
19444 <entry>ACL for non-SMTP MIME parts</entry>
19445 </row>
19446 <row>
19447 <entry><option>acl_not_smtp_start</option></entry>
19448 <entry>ACL for start of non-SMTP message</entry>
19449 </row>
19450 <row>
19451 <entry><option>acl_smtp_auth</option></entry>
19452 <entry>ACL for AUTH</entry>
19453 </row>
19454 <row>
19455 <entry><option>acl_smtp_connect</option></entry>
19456 <entry>ACL for connection</entry>
19457 </row>
19458 <row>
19459 <entry><option>acl_smtp_data</option></entry>
19460 <entry>ACL for DATA</entry>
19461 </row>
19462 <row>
19463 <entry><option>acl_smtp_dkim</option></entry>
19464 <entry>ACL for DKIM verification</entry>
19465 </row>
19466 <row>
19467 <entry><option>acl_smtp_etrn</option></entry>
19468 <entry>ACL for ETRN</entry>
19469 </row>
19470 <row>
19471 <entry><option>acl_smtp_expn</option></entry>
19472 <entry>ACL for EXPN</entry>
19473 </row>
19474 <row>
19475 <entry><option>acl_smtp_helo</option></entry>
19476 <entry>ACL for EHLO or HELO</entry>
19477 </row>
19478 <row>
19479 <entry><option>acl_smtp_mail</option></entry>
19480 <entry>ACL for MAIL</entry>
19481 </row>
19482 <row>
19483 <entry><option>acl_smtp_mailauth</option></entry>
19484 <entry>ACL for AUTH on MAIL command</entry>
19485 </row>
19486 <row>
19487 <entry><option>acl_smtp_mime</option></entry>
19488 <entry>ACL for MIME parts</entry>
19489 </row>
19490 <row>
19491 <entry><option>acl_smtp_predata</option></entry>
19492 <entry>ACL for start of data</entry>
19493 </row>
19494 <row>
19495 <entry><option>acl_smtp_quit</option></entry>
19496 <entry>ACL for QUIT</entry>
19497 </row>
19498 <row>
19499 <entry><option>acl_smtp_rcpt</option></entry>
19500 <entry>ACL for RCPT</entry>
19501 </row>
19502 <row>
19503 <entry><option>acl_smtp_starttls</option></entry>
19504 <entry>ACL for STARTTLS</entry>
19505 </row>
19506 <row>
19507 <entry><option>acl_smtp_vrfy</option></entry>
19508 <entry>ACL for VRFY</entry>
19509 </row>
19510 <row>
19511 <entry><option>av_scanner</option></entry>
19512 <entry>specify virus scanner</entry>
19513 </row>
19514 <row>
19515 <entry><option>check_rfc2047_length</option></entry>
19516 <entry>check length of RFC 2047 <quote>encoded words</quote></entry>
19517 </row>
19518 <row>
19519 <entry><option>dns_csa_search_limit</option></entry>
19520 <entry>control CSA parent search depth</entry>
19521 </row>
19522 <row>
19523 <entry><option>dns_csa_use_reverse</option></entry>
19524 <entry>en/disable CSA IP reverse search</entry>
19525 </row>
19526 <row>
19527 <entry><option>header_maxsize</option></entry>
19528 <entry>total size of message header</entry>
19529 </row>
19530 <row>
19531 <entry><option>header_line_maxsize</option></entry>
19532 <entry>individual header line limit</entry>
19533 </row>
19534 <row>
19535 <entry><option>helo_accept_junk_hosts</option></entry>
19536 <entry>allow syntactic junk from these hosts</entry>
19537 </row>
19538 <row>
19539 <entry><option>helo_allow_chars</option></entry>
19540 <entry>allow illegal chars in HELO names</entry>
19541 </row>
19542 <row>
19543 <entry><option>helo_lookup_domains</option></entry>
19544 <entry>lookup hostname for these HELO names</entry>
19545 </row>
19546 <row>
19547 <entry><option>helo_try_verify_hosts</option></entry>
19548 <entry>HELO soft-checked for these hosts</entry>
19549 </row>
19550 <row>
19551 <entry><option>helo_verify_hosts</option></entry>
19552 <entry>HELO hard-checked for these hosts</entry>
19553 </row>
19554 <row>
19555 <entry><option>host_lookup</option></entry>
19556 <entry>host name looked up for these hosts</entry>
19557 </row>
19558 <row>
19559 <entry><option>host_lookup_order</option></entry>
19560 <entry>order of DNS and local name lookups</entry>
19561 </row>
19562 <row>
19563 <entry><option>host_reject_connection</option></entry>
19564 <entry>reject connection from these hosts</entry>
19565 </row>
19566 <row>
19567 <entry><option>hosts_treat_as_local</option></entry>
19568 <entry>useful in some cluster configurations</entry>
19569 </row>
19570 <row>
19571 <entry><option>local_scan_timeout</option></entry>
19572 <entry>timeout for <function>local_scan()</function></entry>
19573 </row>
19574 <row>
19575 <entry><option>message_size_limit</option></entry>
19576 <entry>for all messages</entry>
19577 </row>
19578 <row>
19579 <entry><option>percent_hack_domains</option></entry>
19580 <entry>recognize %-hack for these domains</entry>
19581 </row>
19582 <row>
19583 <entry><option>spamd_address</option></entry>
19584 <entry>set interface to SpamAssassin</entry>
19585 </row>
19586 <row>
19587 <entry><option>strict_acl_vars</option></entry>
19588 <entry>object to unset ACL variables</entry>
19589 </row>
19590 </tbody>
19591 </tgroup>
19592 </informaltable>
19593 </section>
19594 <section id="SECID107">
19595 <title>Callout cache</title>
19596 <informaltable frame="none">
19597 <tgroup cols="2" colsep="0" rowsep="0">
19598 <colspec colwidth="196pt" align="left"/>
19599 <colspec colwidth="254pt" align="left"/>
19600 <tbody>
19601 <row>
19602 <entry><option>callout_domain_negative_expire</option></entry>
19603 <entry>timeout for negative domain cache item</entry>
19604 </row>
19605 <row>
19606 <entry><option>callout_domain_positive_expire</option></entry>
19607 <entry>timeout for positive domain cache item</entry>
19608 </row>
19609 <row>
19610 <entry><option>callout_negative_expire</option></entry>
19611 <entry>timeout for negative address cache item</entry>
19612 </row>
19613 <row>
19614 <entry><option>callout_positive_expire</option></entry>
19615 <entry>timeout for positive address cache item</entry>
19616 </row>
19617 <row>
19618 <entry><option>callout_random_local_part</option></entry>
19619 <entry>string to use for <quote>random</quote> testing</entry>
19620 </row>
19621 </tbody>
19622 </tgroup>
19623 </informaltable>
19624 </section>
19625 <section id="SECID108">
19626 <title>TLS</title>
19627 <informaltable frame="none">
19628 <tgroup cols="2" colsep="0" rowsep="0">
19629 <colspec colwidth="196pt" align="left"/>
19630 <colspec colwidth="254pt" align="left"/>
19631 <tbody>
19632 <row>
19633 <entry><option>gnutls_require_kx</option></entry>
19634 <entry>control GnuTLS key exchanges</entry>
19635 </row>
19636 <row>
19637 <entry><option>gnutls_require_mac</option></entry>
19638 <entry>control GnuTLS MAC algorithms</entry>
19639 </row>
19640 <row>
19641 <entry><option>gnutls_require_protocols</option></entry>
19642 <entry>control GnuTLS protocols</entry>
19643 </row>
19644 <row>
19645 <entry><option>gnutls_compat_mode</option></entry>
19646 <entry>use GnuTLS compatibility mode</entry>
19647 </row>
19648 <row>
19649 <entry><option>openssl_options</option></entry>
19650 <entry>adjust OpenSSL compatibility options</entry>
19651 </row>
19652 <row>
19653 <entry><option>tls_advertise_hosts</option></entry>
19654 <entry>advertise TLS to these hosts</entry>
19655 </row>
19656 <row>
19657 <entry><option>tls_certificate</option></entry>
19658 <entry>location of server certificate</entry>
19659 </row>
19660 <row>
19661 <entry><option>tls_crl</option></entry>
19662 <entry>certificate revocation list</entry>
19663 </row>
19664 <row>
19665 <entry><option>tls_dhparam</option></entry>
19666 <entry>DH parameters for server</entry>
19667 </row>
19668 <row>
19669 <entry><option>tls_on_connect_ports</option></entry>
19670 <entry>specify SSMTP (SMTPS) ports</entry>
19671 </row>
19672 <row>
19673 <entry><option>tls_privatekey</option></entry>
19674 <entry>location of server private key</entry>
19675 </row>
19676 <row>
19677 <entry><option>tls_remember_esmtp</option></entry>
19678 <entry>don&#x2019;t reset after starting TLS</entry>
19679 </row>
19680 <row>
19681 <entry><option>tls_require_ciphers</option></entry>
19682 <entry>specify acceptable ciphers</entry>
19683 </row>
19684 <row>
19685 <entry><option>tls_try_verify_hosts</option></entry>
19686 <entry>try to verify client certificate</entry>
19687 </row>
19688 <row>
19689 <entry><option>tls_verify_certificates</option></entry>
19690 <entry>expected client certificates</entry>
19691 </row>
19692 <row>
19693 <entry><option>tls_verify_hosts</option></entry>
19694 <entry>insist on client certificate verify</entry>
19695 </row>
19696 </tbody>
19697 </tgroup>
19698 </informaltable>
19699 </section>
19700 <section id="SECID109">
19701 <title>Local user handling</title>
19702 <informaltable frame="none">
19703 <tgroup cols="2" colsep="0" rowsep="0">
19704 <colspec colwidth="196pt" align="left"/>
19705 <colspec colwidth="254pt" align="left"/>
19706 <tbody>
19707 <row>
19708 <entry><option>finduser_retries</option></entry>
19709 <entry>useful in NIS environments</entry>
19710 </row>
19711 <row>
19712 <entry><option>gecos_name</option></entry>
19713 <entry>used when creating <emphasis>Sender:</emphasis></entry>
19714 </row>
19715 <row>
19716 <entry><option>gecos_pattern</option></entry>
19717 <entry>ditto</entry>
19718 </row>
19719 <row>
19720 <entry><option>max_username_length</option></entry>
19721 <entry>for systems that truncate</entry>
19722 </row>
19723 <row>
19724 <entry><option>unknown_login</option></entry>
19725 <entry>used when no login name found</entry>
19726 </row>
19727 <row>
19728 <entry><option>unknown_username</option></entry>
19729 <entry>ditto</entry>
19730 </row>
19731 <row>
19732 <entry><option>uucp_from_pattern</option></entry>
19733 <entry>for recognizing <quote>From </quote> lines</entry>
19734 </row>
19735 <row>
19736 <entry><option>uucp_from_sender</option></entry>
19737 <entry>ditto</entry>
19738 </row>
19739 </tbody>
19740 </tgroup>
19741 </informaltable>
19742 </section>
19743 <section id="SECID110">
19744 <title>All incoming messages (SMTP and non-SMTP)</title>
19745 <informaltable frame="none">
19746 <tgroup cols="2" colsep="0" rowsep="0">
19747 <colspec colwidth="196pt" align="left"/>
19748 <colspec colwidth="254pt" align="left"/>
19749 <tbody>
19750 <row>
19751 <entry><option>header_maxsize</option></entry>
19752 <entry>total size of message header</entry>
19753 </row>
19754 <row>
19755 <entry><option>header_line_maxsize</option></entry>
19756 <entry>individual header line limit</entry>
19757 </row>
19758 <row>
19759 <entry><option>message_size_limit</option></entry>
19760 <entry>applies to all messages</entry>
19761 </row>
19762 <row>
19763 <entry><option>percent_hack_domains</option></entry>
19764 <entry>recognize %-hack for these domains</entry>
19765 </row>
19766 <row>
19767 <entry><option>received_header_text</option></entry>
19768 <entry>expanded to make <emphasis>Received:</emphasis></entry>
19769 </row>
19770 <row>
19771 <entry><option>received_headers_max</option></entry>
19772 <entry>for mail loop detection</entry>
19773 </row>
19774 <row>
19775 <entry><option>recipients_max</option></entry>
19776 <entry>limit per message</entry>
19777 </row>
19778 <row>
19779 <entry><option>recipients_max_reject</option></entry>
19780 <entry>permanently reject excess recipients</entry>
19781 </row>
19782 </tbody>
19783 </tgroup>
19784 </informaltable>
19785 </section>
19786 <section id="SECID111">
19787 <title>Non-SMTP incoming messages</title>
19788 <informaltable frame="none">
19789 <tgroup cols="2" colsep="0" rowsep="0">
19790 <colspec colwidth="196pt" align="left"/>
19791 <colspec colwidth="254pt" align="left"/>
19792 <tbody>
19793 <row>
19794 <entry><option>receive_timeout</option></entry>
19795 <entry>for non-SMTP messages</entry>
19796 </row>
19797 </tbody>
19798 </tgroup>
19799 </informaltable>
19800 </section>
19801 <section id="SECID112">
19802 <title>Incoming SMTP messages</title>
19803 <para>
19804 See also the <emphasis>Policy controls</emphasis> section above.
19805 </para>
19806 <informaltable frame="none">
19807 <tgroup cols="2" colsep="0" rowsep="0">
19808 <colspec colwidth="196pt" align="left"/>
19809 <colspec colwidth="254pt" align="left"/>
19810 <tbody>
19811 <row>
19812 <entry><option>host_lookup</option></entry>
19813 <entry>host name looked up for these hosts</entry>
19814 </row>
19815 <row>
19816 <entry><option>host_lookup_order</option></entry>
19817 <entry>order of DNS and local name lookups</entry>
19818 </row>
19819 <row>
19820 <entry><option>recipient_unqualified_hosts</option></entry>
19821 <entry>may send unqualified recipients</entry>
19822 </row>
19823 <row>
19824 <entry><option>rfc1413_hosts</option></entry>
19825 <entry>make ident calls to these hosts</entry>
19826 </row>
19827 <row>
19828 <entry><option>rfc1413_query_timeout</option></entry>
19829 <entry>zero disables ident calls</entry>
19830 </row>
19831 <row>
19832 <entry><option>sender_unqualified_hosts</option></entry>
19833 <entry>may send unqualified senders</entry>
19834 </row>
19835 <row>
19836 <entry><option>smtp_accept_keepalive</option></entry>
19837 <entry>some TCP/IP magic</entry>
19838 </row>
19839 <row>
19840 <entry><option>smtp_accept_max</option></entry>
19841 <entry>simultaneous incoming connections</entry>
19842 </row>
19843 <row>
19844 <entry><option>smtp_accept_max_nonmail</option></entry>
19845 <entry>non-mail commands</entry>
19846 </row>
19847 <row>
19848 <entry><option>smtp_accept_max_nonmail_hosts</option></entry>
19849 <entry>hosts to which the limit applies</entry>
19850 </row>
19851 <row>
19852 <entry><option>smtp_accept_max_per_connection</option></entry>
19853 <entry>messages per connection</entry>
19854 </row>
19855 <row>
19856 <entry><option>smtp_accept_max_per_host</option></entry>
19857 <entry>connections from one host</entry>
19858 </row>
19859 <row>
19860 <entry><option>smtp_accept_queue</option></entry>
19861 <entry>queue mail if more connections</entry>
19862 </row>
19863 <row>
19864 <entry><option>smtp_accept_queue_per_connection</option></entry>
19865 <entry>queue if more messages per connection</entry>
19866 </row>
19867 <row>
19868 <entry><option>smtp_accept_reserve</option></entry>
19869 <entry>only reserve hosts if more connections</entry>
19870 </row>
19871 <row>
19872 <entry><option>smtp_active_hostname</option></entry>
19873 <entry>host name to use in messages</entry>
19874 </row>
19875 <row>
19876 <entry><option>smtp_banner</option></entry>
19877 <entry>text for welcome banner</entry>
19878 </row>
19879 <row>
19880 <entry><option>smtp_check_spool_space</option></entry>
19881 <entry>from SIZE on MAIL command</entry>
19882 </row>
19883 <row>
19884 <entry><option>smtp_connect_backlog</option></entry>
19885 <entry>passed to TCP/IP stack</entry>
19886 </row>
19887 <row>
19888 <entry><option>smtp_enforce_sync</option></entry>
19889 <entry>of SMTP command/responses</entry>
19890 </row>
19891 <row>
19892 <entry><option>smtp_etrn_command</option></entry>
19893 <entry>what to run for ETRN</entry>
19894 </row>
19895 <row>
19896 <entry><option>smtp_etrn_serialize</option></entry>
19897 <entry>only one at once</entry>
19898 </row>
19899 <row>
19900 <entry><option>smtp_load_reserve</option></entry>
19901 <entry>only reserve hosts if this load</entry>
19902 </row>
19903 <row>
19904 <entry><option>smtp_max_unknown_commands</option></entry>
19905 <entry>before dropping connection</entry>
19906 </row>
19907 <row>
19908 <entry><option>smtp_ratelimit_hosts</option></entry>
19909 <entry>apply ratelimiting to these hosts</entry>
19910 </row>
19911 <row>
19912 <entry><option>smtp_ratelimit_mail</option></entry>
19913 <entry>ratelimit for MAIL commands</entry>
19914 </row>
19915 <row>
19916 <entry><option>smtp_ratelimit_rcpt</option></entry>
19917 <entry>ratelimit for RCPT commands</entry>
19918 </row>
19919 <row>
19920 <entry><option>smtp_receive_timeout</option></entry>
19921 <entry>per command or data line</entry>
19922 </row>
19923 <row>
19924 <entry><option>smtp_reserve_hosts</option></entry>
19925 <entry>these are the reserve hosts</entry>
19926 </row>
19927 <row>
19928 <entry><option>smtp_return_error_details</option></entry>
19929 <entry>give detail on rejections</entry>
19930 </row>
19931 </tbody>
19932 </tgroup>
19933 </informaltable>
19934 </section>
19935 <section id="SECID113">
19936 <title>SMTP extensions</title>
19937 <informaltable frame="none">
19938 <tgroup cols="2" colsep="0" rowsep="0">
19939 <colspec colwidth="196pt" align="left"/>
19940 <colspec colwidth="254pt" align="left"/>
19941 <tbody>
19942 <row>
19943 <entry><option>accept_8bitmime</option></entry>
19944 <entry>advertise 8BITMIME</entry>
19945 </row>
19946 <row>
19947 <entry><option>auth_advertise_hosts</option></entry>
19948 <entry>advertise AUTH to these hosts</entry>
19949 </row>
19950 <row>
19951 <entry><option>ignore_fromline_hosts</option></entry>
19952 <entry>allow <quote>From </quote> from these hosts</entry>
19953 </row>
19954 <row>
19955 <entry><option>ignore_fromline_local</option></entry>
19956 <entry>allow <quote>From </quote> from local SMTP</entry>
19957 </row>
19958 <row>
19959 <entry><option>pipelining_advertise_hosts</option></entry>
19960 <entry>advertise pipelining to these hosts</entry>
19961 </row>
19962 <row>
19963 <entry><option>tls_advertise_hosts</option></entry>
19964 <entry>advertise TLS to these hosts</entry>
19965 </row>
19966 </tbody>
19967 </tgroup>
19968 </informaltable>
19969 </section>
19970 <section id="SECID114">
19971 <title>Processing messages</title>
19972 <informaltable frame="none">
19973 <tgroup cols="2" colsep="0" rowsep="0">
19974 <colspec colwidth="196pt" align="left"/>
19975 <colspec colwidth="254pt" align="left"/>
19976 <tbody>
19977 <row>
19978 <entry><option>allow_domain_literals</option></entry>
19979 <entry>recognize domain literal syntax</entry>
19980 </row>
19981 <row>
19982 <entry><option>allow_mx_to_ip</option></entry>
19983 <entry>allow MX to point to IP address</entry>
19984 </row>
19985 <row>
19986 <entry><option>allow_utf8_domains</option></entry>
19987 <entry>in addresses</entry>
19988 </row>
19989 <row>
19990 <entry><option>check_rfc2047_length</option></entry>
19991 <entry>check length of RFC 2047 <quote>encoded words</quote></entry>
19992 </row>
19993 <row>
19994 <entry><option>delivery_date_remove</option></entry>
19995 <entry>from incoming messages</entry>
19996 </row>
19997 <row>
19998 <entry><option>envelope_to_remove</option></entry>
19999 <entry>from incoming messages</entry>
20000 </row>
20001 <row>
20002 <entry><option>extract_addresses_remove_arguments</option></entry>
20003 <entry>affects <option>-t</option> processing</entry>
20004 </row>
20005 <row>
20006 <entry><option>headers_charset</option></entry>
20007 <entry>default for translations</entry>
20008 </row>
20009 <row>
20010 <entry><option>qualify_domain</option></entry>
20011 <entry>default for senders</entry>
20012 </row>
20013 <row>
20014 <entry><option>qualify_recipient</option></entry>
20015 <entry>default for recipients</entry>
20016 </row>
20017 <row>
20018 <entry><option>return_path_remove</option></entry>
20019 <entry>from incoming messages</entry>
20020 </row>
20021 <row>
20022 <entry><option>strip_excess_angle_brackets</option></entry>
20023 <entry>in addresses</entry>
20024 </row>
20025 <row>
20026 <entry><option>strip_trailing_dot</option></entry>
20027 <entry>at end of addresses</entry>
20028 </row>
20029 <row>
20030 <entry><option>untrusted_set_sender</option></entry>
20031 <entry>untrusted can set envelope sender</entry>
20032 </row>
20033 </tbody>
20034 </tgroup>
20035 </informaltable>
20036 </section>
20037 <section id="SECID115">
20038 <title>System filter</title>
20039 <informaltable frame="none">
20040 <tgroup cols="2" colsep="0" rowsep="0">
20041 <colspec colwidth="196pt" align="left"/>
20042 <colspec colwidth="254pt" align="left"/>
20043 <tbody>
20044 <row>
20045 <entry><option>system_filter</option></entry>
20046 <entry>locate system filter</entry>
20047 </row>
20048 <row>
20049 <entry><option>system_filter_directory_transport</option></entry>
20050 <entry>transport for delivery to a directory</entry>
20051 </row>
20052 <row>
20053 <entry><option>system_filter_file_transport</option></entry>
20054 <entry>transport for delivery to a file</entry>
20055 </row>
20056 <row>
20057 <entry><option>system_filter_group</option></entry>
20058 <entry>group for filter running</entry>
20059 </row>
20060 <row>
20061 <entry><option>system_filter_pipe_transport</option></entry>
20062 <entry>transport for delivery to a pipe</entry>
20063 </row>
20064 <row>
20065 <entry><option>system_filter_reply_transport</option></entry>
20066 <entry>transport for autoreply delivery</entry>
20067 </row>
20068 <row>
20069 <entry><option>system_filter_user</option></entry>
20070 <entry>user for filter running</entry>
20071 </row>
20072 </tbody>
20073 </tgroup>
20074 </informaltable>
20075 </section>
20076 <section id="SECID116">
20077 <title>Routing and delivery</title>
20078 <informaltable frame="none">
20079 <tgroup cols="2" colsep="0" rowsep="0">
20080 <colspec colwidth="196pt" align="left"/>
20081 <colspec colwidth="254pt" align="left"/>
20082 <tbody>
20083 <row>
20084 <entry><option>disable_ipv6</option></entry>
20085 <entry>do no IPv6 processing</entry>
20086 </row>
20087 <row>
20088 <entry><option>dns_again_means_nonexist</option></entry>
20089 <entry>for broken domains</entry>
20090 </row>
20091 <row>
20092 <entry><option>dns_check_names_pattern</option></entry>
20093 <entry>pre-DNS syntax check</entry>
20094 </row>
20095 <row>
20096 <entry><option>dns_ipv4_lookup</option></entry>
20097 <entry>only v4 lookup for these domains</entry>
20098 </row>
20099 <row>
20100 <entry><option>dns_retrans</option></entry>
20101 <entry>parameter for resolver</entry>
20102 </row>
20103 <row>
20104 <entry><option>dns_retry</option></entry>
20105 <entry>parameter for resolver</entry>
20106 </row>
20107 <row>
20108 <entry><option>hold_domains</option></entry>
20109 <entry>hold delivery for these domains</entry>
20110 </row>
20111 <row>
20112 <entry><option>local_interfaces</option></entry>
20113 <entry>for routing checks</entry>
20114 </row>
20115 <row>
20116 <entry><option>queue_domains</option></entry>
20117 <entry>no immediate delivery for these</entry>
20118 </row>
20119 <row>
20120 <entry><option>queue_only</option></entry>
20121 <entry>no immediate delivery at all</entry>
20122 </row>
20123 <row>
20124 <entry><option>queue_only_file</option></entry>
20125 <entry>no immediate delivery if file exists</entry>
20126 </row>
20127 <row>
20128 <entry><option>queue_only_load</option></entry>
20129 <entry>no immediate delivery if load is high</entry>
20130 </row>
20131 <row>
20132 <entry><option>queue_only_load_latch</option></entry>
20133 <entry>don&#x2019;t re-evaluate load for each message</entry>
20134 </row>
20135 <row>
20136 <entry><option>queue_only_override</option></entry>
20137 <entry>allow command line to override</entry>
20138 </row>
20139 <row>
20140 <entry><option>queue_run_in_order</option></entry>
20141 <entry>order of arrival</entry>
20142 </row>
20143 <row>
20144 <entry><option>queue_run_max</option></entry>
20145 <entry>of simultaneous queue runners</entry>
20146 </row>
20147 <row>
20148 <entry><option>queue_smtp_domains</option></entry>
20149 <entry>no immediate SMTP delivery for these</entry>
20150 </row>
20151 <row>
20152 <entry><option>remote_max_parallel</option></entry>
20153 <entry>parallel SMTP delivery per message</entry>
20154 </row>
20155 <row>
20156 <entry><option>remote_sort_domains</option></entry>
20157 <entry>order of remote deliveries</entry>
20158 </row>
20159 <row>
20160 <entry><option>retry_data_expire</option></entry>
20161 <entry>timeout for retry data</entry>
20162 </row>
20163 <row>
20164 <entry><option>retry_interval_max</option></entry>
20165 <entry>safety net for retry rules</entry>
20166 </row>
20167 </tbody>
20168 </tgroup>
20169 </informaltable>
20170 </section>
20171 <section id="SECID117">
20172 <title>Bounce and warning messages</title>
20173 <informaltable frame="none">
20174 <tgroup cols="2" colsep="0" rowsep="0">
20175 <colspec colwidth="196pt" align="left"/>
20176 <colspec colwidth="254pt" align="left"/>
20177 <tbody>
20178 <row>
20179 <entry><option>bounce_message_file</option></entry>
20180 <entry>content of bounce</entry>
20181 </row>
20182 <row>
20183 <entry><option>bounce_message_text</option></entry>
20184 <entry>content of bounce</entry>
20185 </row>
20186 <row>
20187 <entry><option>bounce_return_body</option></entry>
20188 <entry>include body if returning message</entry>
20189 </row>
20190 <row>
20191 <entry><option>bounce_return_message</option></entry>
20192 <entry>include original message in bounce</entry>
20193 </row>
20194 <row>
20195 <entry><option>bounce_return_size_limit</option></entry>
20196 <entry>limit on returned message</entry>
20197 </row>
20198 <row>
20199 <entry><option>bounce_sender_authentication</option></entry>
20200 <entry>send authenticated sender with bounce</entry>
20201 </row>
20202 <row>
20203 <entry><option>dsn_from</option></entry>
20204 <entry>set <emphasis>From:</emphasis> contents in bounces</entry>
20205 </row>
20206 <row>
20207 <entry><option>errors_copy</option></entry>
20208 <entry>copy bounce messages</entry>
20209 </row>
20210 <row>
20211 <entry><option>errors_reply_to</option></entry>
20212 <entry><emphasis>Reply-to:</emphasis> in bounces</entry>
20213 </row>
20214 <row>
20215 <entry><option>delay_warning</option></entry>
20216 <entry>time schedule</entry>
20217 </row>
20218 <row>
20219 <entry><option>delay_warning_condition</option></entry>
20220 <entry>condition for warning messages</entry>
20221 </row>
20222 <row>
20223 <entry><option>ignore_bounce_errors_after</option></entry>
20224 <entry>discard undeliverable bounces</entry>
20225 </row>
20226 <row>
20227 <entry><option>smtp_return_error_details</option></entry>
20228 <entry>give detail on rejections</entry>
20229 </row>
20230 <row>
20231 <entry><option>warn_message_file</option></entry>
20232 <entry>content of warning message</entry>
20233 </row>
20234 </tbody>
20235 </tgroup>
20236 </informaltable>
20237 </section>
20238 <section id="SECTalomo">
20239 <title>Alphabetical list of main options</title>
20240 <para>
20241 Those options that undergo string expansion before use are marked with
20242 &dagger;.
20243 </para>
20244 <para>
20245 <indexterm role="option">
20246 <primary><option>accept_8bitmime</option></primary>
20247 </indexterm>
20248 </para>
20249 <informaltable frame="all">
20250 <tgroup cols="4" colsep="0" rowsep="0">
20251 <colspec colwidth="8*" align="left"/>
20252 <colspec colwidth="6*" align="center"/>
20253 <colspec colwidth="6*" align="center"/>
20254 <colspec colwidth="6*" align="right"/>
20255 <tbody>
20256 <row>
20257 <entry><option>accept_8bitmime</option></entry>
20258 <entry>Use: <emphasis>main</emphasis></entry>
20259 <entry>Type: <emphasis>boolean</emphasis></entry>
20260 <entry>Default: <emphasis>false</emphasis></entry>
20261 </row>
20262 </tbody>
20263 </tgroup>
20264 </informaltable>
20265 <para>
20266 <indexterm role="concept">
20267 <primary>8BITMIME</primary>
20268 </indexterm>
20269 <indexterm role="concept">
20270 <primary>8-bit characters</primary>
20271 </indexterm>
20272 This option causes Exim to send 8BITMIME in its response to an SMTP
20273 EHLO command, and to accept the BODY= parameter on MAIL commands.
20274 However, though Exim is 8-bit clean, it is not a protocol converter, and it
20275 takes no steps to do anything special with messages received by this route.
20276 Consequently, this option is turned off by default.
20277 </para>
20278 <para>
20279 <indexterm role="option">
20280 <primary><option>acl_not_smtp</option></primary>
20281 </indexterm>
20282 </para>
20283 <informaltable frame="all">
20284 <tgroup cols="4" colsep="0" rowsep="0">
20285 <colspec colwidth="8*" align="left"/>
20286 <colspec colwidth="6*" align="center"/>
20287 <colspec colwidth="6*" align="center"/>
20288 <colspec colwidth="6*" align="right"/>
20289 <tbody>
20290 <row>
20291 <entry><option>acl_not_smtp</option></entry>
20292 <entry>Use: <emphasis>main</emphasis></entry>
20293 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
20294 <entry>Default: <emphasis>unset</emphasis></entry>
20295 </row>
20296 </tbody>
20297 </tgroup>
20298 </informaltable>
20299 <para>
20300 <indexterm role="concept">
20301 <primary>access control lists (ACLs)</primary>
20302 <secondary>for non-SMTP messages</secondary>
20303 </indexterm>
20304 <indexterm role="concept">
20305 <primary>non-SMTP messages</primary>
20306 <secondary>ACLs for</secondary>
20307 </indexterm>
20308 This option defines the ACL that is run when a non-SMTP message has been
20309 read and is on the point of being accepted. See chapter <xref linkend="CHAPACL"/> for
20310 further details.
20311 </para>
20312 <para>
20313 <indexterm role="option">
20314 <primary><option>acl_not_smtp_mime</option></primary>
20315 </indexterm>
20316 </para>
20317 <informaltable frame="all">
20318 <tgroup cols="4" colsep="0" rowsep="0">
20319 <colspec colwidth="8*" align="left"/>
20320 <colspec colwidth="6*" align="center"/>
20321 <colspec colwidth="6*" align="center"/>
20322 <colspec colwidth="6*" align="right"/>
20323 <tbody>
20324 <row>
20325 <entry><option>acl_not_smtp_mime</option></entry>
20326 <entry>Use: <emphasis>main</emphasis></entry>
20327 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
20328 <entry>Default: <emphasis>unset</emphasis></entry>
20329 </row>
20330 </tbody>
20331 </tgroup>
20332 </informaltable>
20333 <para>
20334 This option defines the ACL that is run for individual MIME parts of non-SMTP
20335 messages. It operates in exactly the same way as <option>acl_smtp_mime</option> operates for
20336 SMTP messages.
20337 </para>
20338 <para>
20339 <indexterm role="option">
20340 <primary><option>acl_not_smtp_start</option></primary>
20341 </indexterm>
20342 </para>
20343 <informaltable frame="all">
20344 <tgroup cols="4" colsep="0" rowsep="0">
20345 <colspec colwidth="8*" align="left"/>
20346 <colspec colwidth="6*" align="center"/>
20347 <colspec colwidth="6*" align="center"/>
20348 <colspec colwidth="6*" align="right"/>
20349 <tbody>
20350 <row>
20351 <entry><option>acl_not_smtp_start</option></entry>
20352 <entry>Use: <emphasis>main</emphasis></entry>
20353 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
20354 <entry>Default: <emphasis>unset</emphasis></entry>
20355 </row>
20356 </tbody>
20357 </tgroup>
20358 </informaltable>
20359 <para>
20360 <indexterm role="concept">
20361 <primary>access control lists (ACLs)</primary>
20362 <secondary>at start of non-SMTP message</secondary>
20363 </indexterm>
20364 <indexterm role="concept">
20365 <primary>non-SMTP messages</primary>
20366 <secondary>ACLs for</secondary>
20367 </indexterm>
20368 This option defines the ACL that is run before Exim starts reading a
20369 non-SMTP message. See chapter <xref linkend="CHAPACL"/> for further details.
20370 </para>
20371 <para>
20372 <indexterm role="option">
20373 <primary><option>acl_smtp_auth</option></primary>
20374 </indexterm>
20375 </para>
20376 <informaltable frame="all">
20377 <tgroup cols="4" colsep="0" rowsep="0">
20378 <colspec colwidth="8*" align="left"/>
20379 <colspec colwidth="6*" align="center"/>
20380 <colspec colwidth="6*" align="center"/>
20381 <colspec colwidth="6*" align="right"/>
20382 <tbody>
20383 <row>
20384 <entry><option>acl_smtp_auth</option></entry>
20385 <entry>Use: <emphasis>main</emphasis></entry>
20386 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
20387 <entry>Default: <emphasis>unset</emphasis></entry>
20388 </row>
20389 </tbody>
20390 </tgroup>
20391 </informaltable>
20392 <para>
20393 <indexterm role="concept">
20394 <primary>access control lists (ACLs)</primary>
20395 <secondary>setting up for SMTP commands</secondary>
20396 </indexterm>
20397 <indexterm role="concept">
20398 <primary>AUTH</primary>
20399 <secondary>ACL for</secondary>
20400 </indexterm>
20401 This option defines the ACL that is run when an SMTP AUTH command is
20402 received. See chapter <xref linkend="CHAPACL"/> for further details.
20403 </para>
20404 <para>
20405 <indexterm role="option">
20406 <primary><option>acl_smtp_connect</option></primary>
20407 </indexterm>
20408 </para>
20409 <informaltable frame="all">
20410 <tgroup cols="4" colsep="0" rowsep="0">
20411 <colspec colwidth="8*" align="left"/>
20412 <colspec colwidth="6*" align="center"/>
20413 <colspec colwidth="6*" align="center"/>
20414 <colspec colwidth="6*" align="right"/>
20415 <tbody>
20416 <row>
20417 <entry><option>acl_smtp_connect</option></entry>
20418 <entry>Use: <emphasis>main</emphasis></entry>
20419 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
20420 <entry>Default: <emphasis>unset</emphasis></entry>
20421 </row>
20422 </tbody>
20423 </tgroup>
20424 </informaltable>
20425 <para>
20426 <indexterm role="concept">
20427 <primary>access control lists (ACLs)</primary>
20428 <secondary>on SMTP connection</secondary>
20429 </indexterm>
20430 This option defines the ACL that is run when an SMTP connection is received.
20431 See chapter <xref linkend="CHAPACL"/> for further details.
20432 </para>
20433 <para>
20434 <indexterm role="option">
20435 <primary><option>acl_smtp_data</option></primary>
20436 </indexterm>
20437 </para>
20438 <informaltable frame="all">
20439 <tgroup cols="4" colsep="0" rowsep="0">
20440 <colspec colwidth="8*" align="left"/>
20441 <colspec colwidth="6*" align="center"/>
20442 <colspec colwidth="6*" align="center"/>
20443 <colspec colwidth="6*" align="right"/>
20444 <tbody>
20445 <row>
20446 <entry><option>acl_smtp_data</option></entry>
20447 <entry>Use: <emphasis>main</emphasis></entry>
20448 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
20449 <entry>Default: <emphasis>unset</emphasis></entry>
20450 </row>
20451 </tbody>
20452 </tgroup>
20453 </informaltable>
20454 <para>
20455 <indexterm role="concept">
20456 <primary>DATA</primary>
20457 <secondary>ACL for</secondary>
20458 </indexterm>
20459 This option defines the ACL that is run after an SMTP DATA command has been
20460 processed and the message itself has been received, but before the final
20461 acknowledgment is sent. See chapter <xref linkend="CHAPACL"/> for further details.
20462 </para>
20463 <para>
20464 <indexterm role="option">
20465 <primary><option>acl_smtp_etrn</option></primary>
20466 </indexterm>
20467 </para>
20468 <informaltable frame="all">
20469 <tgroup cols="4" colsep="0" rowsep="0">
20470 <colspec colwidth="8*" align="left"/>
20471 <colspec colwidth="6*" align="center"/>
20472 <colspec colwidth="6*" align="center"/>
20473 <colspec colwidth="6*" align="right"/>
20474 <tbody>
20475 <row>
20476 <entry><option>acl_smtp_etrn</option></entry>
20477 <entry>Use: <emphasis>main</emphasis></entry>
20478 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
20479 <entry>Default: <emphasis>unset</emphasis></entry>
20480 </row>
20481 </tbody>
20482 </tgroup>
20483 </informaltable>
20484 <para>
20485 <indexterm role="concept">
20486 <primary>ETRN</primary>
20487 <secondary>ACL for</secondary>
20488 </indexterm>
20489 This option defines the ACL that is run when an SMTP ETRN command is
20490 received. See chapter <xref linkend="CHAPACL"/> for further details.
20491 </para>
20492 <para>
20493 <indexterm role="option">
20494 <primary><option>acl_smtp_expn</option></primary>
20495 </indexterm>
20496 </para>
20497 <informaltable frame="all">
20498 <tgroup cols="4" colsep="0" rowsep="0">
20499 <colspec colwidth="8*" align="left"/>
20500 <colspec colwidth="6*" align="center"/>
20501 <colspec colwidth="6*" align="center"/>
20502 <colspec colwidth="6*" align="right"/>
20503 <tbody>
20504 <row>
20505 <entry><option>acl_smtp_expn</option></entry>
20506 <entry>Use: <emphasis>main</emphasis></entry>
20507 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
20508 <entry>Default: <emphasis>unset</emphasis></entry>
20509 </row>
20510 </tbody>
20511 </tgroup>
20512 </informaltable>
20513 <para>
20514 <indexterm role="concept">
20515 <primary>EXPN</primary>
20516 <secondary>ACL for</secondary>
20517 </indexterm>
20518 This option defines the ACL that is run when an SMTP EXPN command is
20519 received. See chapter <xref linkend="CHAPACL"/> for further details.
20520 </para>
20521 <para>
20522 <indexterm role="option">
20523 <primary><option>acl_smtp_helo</option></primary>
20524 </indexterm>
20525 </para>
20526 <informaltable frame="all">
20527 <tgroup cols="4" colsep="0" rowsep="0">
20528 <colspec colwidth="8*" align="left"/>
20529 <colspec colwidth="6*" align="center"/>
20530 <colspec colwidth="6*" align="center"/>
20531 <colspec colwidth="6*" align="right"/>
20532 <tbody>
20533 <row>
20534 <entry><option>acl_smtp_helo</option></entry>
20535 <entry>Use: <emphasis>main</emphasis></entry>
20536 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
20537 <entry>Default: <emphasis>unset</emphasis></entry>
20538 </row>
20539 </tbody>
20540 </tgroup>
20541 </informaltable>
20542 <para>
20543 <indexterm role="concept">
20544 <primary>EHLO</primary>
20545 <secondary>ACL for</secondary>
20546 </indexterm>
20547 <indexterm role="concept">
20548 <primary>HELO</primary>
20549 <secondary>ACL for</secondary>
20550 </indexterm>
20551 This option defines the ACL that is run when an SMTP EHLO or HELO
20552 command is received. See chapter <xref linkend="CHAPACL"/> for further details.
20553 </para>
20554 <para>
20555 <indexterm role="option">
20556 <primary><option>acl_smtp_mail</option></primary>
20557 </indexterm>
20558 </para>
20559 <informaltable frame="all">
20560 <tgroup cols="4" colsep="0" rowsep="0">
20561 <colspec colwidth="8*" align="left"/>
20562 <colspec colwidth="6*" align="center"/>
20563 <colspec colwidth="6*" align="center"/>
20564 <colspec colwidth="6*" align="right"/>
20565 <tbody>
20566 <row>
20567 <entry><option>acl_smtp_mail</option></entry>
20568 <entry>Use: <emphasis>main</emphasis></entry>
20569 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
20570 <entry>Default: <emphasis>unset</emphasis></entry>
20571 </row>
20572 </tbody>
20573 </tgroup>
20574 </informaltable>
20575 <para>
20576 <indexterm role="concept">
20577 <primary>MAIL</primary>
20578 <secondary>ACL for</secondary>
20579 </indexterm>
20580 This option defines the ACL that is run when an SMTP MAIL command is
20581 received. See chapter <xref linkend="CHAPACL"/> for further details.
20582 </para>
20583 <para>
20584 <indexterm role="option">
20585 <primary><option>acl_smtp_mailauth</option></primary>
20586 </indexterm>
20587 </para>
20588 <informaltable frame="all">
20589 <tgroup cols="4" colsep="0" rowsep="0">
20590 <colspec colwidth="8*" align="left"/>
20591 <colspec colwidth="6*" align="center"/>
20592 <colspec colwidth="6*" align="center"/>
20593 <colspec colwidth="6*" align="right"/>
20594 <tbody>
20595 <row>
20596 <entry><option>acl_smtp_mailauth</option></entry>
20597 <entry>Use: <emphasis>main</emphasis></entry>
20598 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
20599 <entry>Default: <emphasis>unset</emphasis></entry>
20600 </row>
20601 </tbody>
20602 </tgroup>
20603 </informaltable>
20604 <para>
20605 <indexterm role="concept">
20606 <primary>AUTH</primary>
20607 <secondary>on MAIL command</secondary>
20608 </indexterm>
20609 This option defines the ACL that is run when there is an AUTH parameter on
20610 a MAIL command. See chapter <xref linkend="CHAPACL"/> for details of ACLs, and chapter
20611 <xref linkend="CHAPSMTPAUTH"/> for details of authentication.
20612 </para>
20613 <para>
20614 <indexterm role="option">
20615 <primary><option>acl_smtp_mime</option></primary>
20616 </indexterm>
20617 </para>
20618 <informaltable frame="all">
20619 <tgroup cols="4" colsep="0" rowsep="0">
20620 <colspec colwidth="8*" align="left"/>
20621 <colspec colwidth="6*" align="center"/>
20622 <colspec colwidth="6*" align="center"/>
20623 <colspec colwidth="6*" align="right"/>
20624 <tbody>
20625 <row>
20626 <entry><option>acl_smtp_mime</option></entry>
20627 <entry>Use: <emphasis>main</emphasis></entry>
20628 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
20629 <entry>Default: <emphasis>unset</emphasis></entry>
20630 </row>
20631 </tbody>
20632 </tgroup>
20633 </informaltable>
20634 <para>
20635 <indexterm role="concept">
20636 <primary>MIME content scanning</primary>
20637 <secondary>ACL for</secondary>
20638 </indexterm>
20639 This option is available when Exim is built with the content-scanning
20640 extension. It defines the ACL that is run for each MIME part in a message. See
20641 section <xref linkend="SECTscanmimepart"/> for details.
20642 </para>
20643 <para>
20644 <indexterm role="option">
20645 <primary><option>acl_smtp_predata</option></primary>
20646 </indexterm>
20647 </para>
20648 <informaltable frame="all">
20649 <tgroup cols="4" colsep="0" rowsep="0">
20650 <colspec colwidth="8*" align="left"/>
20651 <colspec colwidth="6*" align="center"/>
20652 <colspec colwidth="6*" align="center"/>
20653 <colspec colwidth="6*" align="right"/>
20654 <tbody>
20655 <row>
20656 <entry><option>acl_smtp_predata</option></entry>
20657 <entry>Use: <emphasis>main</emphasis></entry>
20658 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
20659 <entry>Default: <emphasis>unset</emphasis></entry>
20660 </row>
20661 </tbody>
20662 </tgroup>
20663 </informaltable>
20664 <para>
20665 This option defines the ACL that is run when an SMTP DATA command is
20666 received, before the message itself is received. See chapter <xref linkend="CHAPACL"/> for
20667 further details.
20668 </para>
20669 <para>
20670 <indexterm role="option">
20671 <primary><option>acl_smtp_quit</option></primary>
20672 </indexterm>
20673 </para>
20674 <informaltable frame="all">
20675 <tgroup cols="4" colsep="0" rowsep="0">
20676 <colspec colwidth="8*" align="left"/>
20677 <colspec colwidth="6*" align="center"/>
20678 <colspec colwidth="6*" align="center"/>
20679 <colspec colwidth="6*" align="right"/>
20680 <tbody>
20681 <row>
20682 <entry><option>acl_smtp_quit</option></entry>
20683 <entry>Use: <emphasis>main</emphasis></entry>
20684 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
20685 <entry>Default: <emphasis>unset</emphasis></entry>
20686 </row>
20687 </tbody>
20688 </tgroup>
20689 </informaltable>
20690 <para>
20691 <indexterm role="concept">
20692 <primary>QUIT, ACL for</primary>
20693 </indexterm>
20694 This option defines the ACL that is run when an SMTP QUIT command is
20695 received. See chapter <xref linkend="CHAPACL"/> for further details.
20696 </para>
20697 <para>
20698 <indexterm role="option">
20699 <primary><option>acl_smtp_rcpt</option></primary>
20700 </indexterm>
20701 </para>
20702 <informaltable frame="all">
20703 <tgroup cols="4" colsep="0" rowsep="0">
20704 <colspec colwidth="8*" align="left"/>
20705 <colspec colwidth="6*" align="center"/>
20706 <colspec colwidth="6*" align="center"/>
20707 <colspec colwidth="6*" align="right"/>
20708 <tbody>
20709 <row>
20710 <entry><option>acl_smtp_rcpt</option></entry>
20711 <entry>Use: <emphasis>main</emphasis></entry>
20712 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
20713 <entry>Default: <emphasis>unset</emphasis></entry>
20714 </row>
20715 </tbody>
20716 </tgroup>
20717 </informaltable>
20718 <para>
20719 <indexterm role="concept">
20720 <primary>RCPT</primary>
20721 <secondary>ACL for</secondary>
20722 </indexterm>
20723 This option defines the ACL that is run when an SMTP RCPT command is
20724 received. See chapter <xref linkend="CHAPACL"/> for further details.
20725 </para>
20726 <para>
20727 <indexterm role="option">
20728 <primary><option>acl_smtp_starttls</option></primary>
20729 </indexterm>
20730 </para>
20731 <informaltable frame="all">
20732 <tgroup cols="4" colsep="0" rowsep="0">
20733 <colspec colwidth="8*" align="left"/>
20734 <colspec colwidth="6*" align="center"/>
20735 <colspec colwidth="6*" align="center"/>
20736 <colspec colwidth="6*" align="right"/>
20737 <tbody>
20738 <row>
20739 <entry><option>acl_smtp_starttls</option></entry>
20740 <entry>Use: <emphasis>main</emphasis></entry>
20741 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
20742 <entry>Default: <emphasis>unset</emphasis></entry>
20743 </row>
20744 </tbody>
20745 </tgroup>
20746 </informaltable>
20747 <para>
20748 <indexterm role="concept">
20749 <primary>STARTTLS, ACL for</primary>
20750 </indexterm>
20751 This option defines the ACL that is run when an SMTP STARTTLS command is
20752 received. See chapter <xref linkend="CHAPACL"/> for further details.
20753 </para>
20754 <para>
20755 <indexterm role="option">
20756 <primary><option>acl_smtp_vrfy</option></primary>
20757 </indexterm>
20758 </para>
20759 <informaltable frame="all">
20760 <tgroup cols="4" colsep="0" rowsep="0">
20761 <colspec colwidth="8*" align="left"/>
20762 <colspec colwidth="6*" align="center"/>
20763 <colspec colwidth="6*" align="center"/>
20764 <colspec colwidth="6*" align="right"/>
20765 <tbody>
20766 <row>
20767 <entry><option>acl_smtp_vrfy</option></entry>
20768 <entry>Use: <emphasis>main</emphasis></entry>
20769 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
20770 <entry>Default: <emphasis>unset</emphasis></entry>
20771 </row>
20772 </tbody>
20773 </tgroup>
20774 </informaltable>
20775 <para>
20776 <indexterm role="concept">
20777 <primary>VRFY</primary>
20778 <secondary>ACL for</secondary>
20779 </indexterm>
20780 This option defines the ACL that is run when an SMTP VRFY command is
20781 received. See chapter <xref linkend="CHAPACL"/> for further details.
20782 </para>
20783 <para>
20784 <indexterm role="option">
20785 <primary><option>admin_groups</option></primary>
20786 </indexterm>
20787 </para>
20788 <informaltable frame="all">
20789 <tgroup cols="4" colsep="0" rowsep="0">
20790 <colspec colwidth="8*" align="left"/>
20791 <colspec colwidth="6*" align="center"/>
20792 <colspec colwidth="6*" align="center"/>
20793 <colspec colwidth="6*" align="right"/>
20794 <tbody>
20795 <row>
20796 <entry><option>admin_groups</option></entry>
20797 <entry>Use: <emphasis>main</emphasis></entry>
20798 <entry>Type: <emphasis>string list</emphasis>&dagger;<emphasis></emphasis></entry>
20799 <entry>Default: <emphasis>unset</emphasis></entry>
20800 </row>
20801 </tbody>
20802 </tgroup>
20803 </informaltable>
20804 <para>
20805 <indexterm role="concept">
20806 <primary>admin user</primary>
20807 </indexterm>
20808 This option is expanded just once, at the start of Exim&#x2019;s processing. If the
20809 current group or any of the supplementary groups of an Exim caller is in this
20810 colon-separated list, the caller has admin privileges. If all your system
20811 programmers are in a specific group, for example, you can give them all Exim
20812 admin privileges by putting that group in <option>admin_groups</option>. However, this does
20813 not permit them to read Exim&#x2019;s spool files (whose group owner is the Exim gid).
20814 To permit this, you have to add individuals to the Exim group.
20815 </para>
20816 <para>
20817 <indexterm role="option">
20818 <primary><option>allow_domain_literals</option></primary>
20819 </indexterm>
20820 </para>
20821 <informaltable frame="all">
20822 <tgroup cols="4" colsep="0" rowsep="0">
20823 <colspec colwidth="8*" align="left"/>
20824 <colspec colwidth="6*" align="center"/>
20825 <colspec colwidth="6*" align="center"/>
20826 <colspec colwidth="6*" align="right"/>
20827 <tbody>
20828 <row>
20829 <entry><option>allow_domain_literals</option></entry>
20830 <entry>Use: <emphasis>main</emphasis></entry>
20831 <entry>Type: <emphasis>boolean</emphasis></entry>
20832 <entry>Default: <emphasis>false</emphasis></entry>
20833 </row>
20834 </tbody>
20835 </tgroup>
20836 </informaltable>
20837 <para>
20838 <indexterm role="concept">
20839 <primary>domain literal</primary>
20840 </indexterm>
20841 If this option is set, the RFC 2822 domain literal format is permitted in
20842 email addresses. The option is not set by default, because the domain literal
20843 format is not normally required these days, and few people know about it. It
20844 has, however, been exploited by mail abusers.
20845 </para>
20846 <para>
20847 Unfortunately, it seems that some DNS black list maintainers are using this
20848 format to report black listing to postmasters. If you want to accept messages
20849 addressed to your hosts by IP address, you need to set
20850 <option>allow_domain_literals</option> true, and also to add <literal>@[]</literal> to the list of local
20851 domains (defined in the named domain list <option>local_domains</option> in the default
20852 configuration). This <quote>magic string</quote> matches the domain literal form of all
20853 the local host&#x2019;s IP addresses.
20854 </para>
20855 <para>
20856 <indexterm role="option">
20857 <primary><option>allow_mx_to_ip</option></primary>
20858 </indexterm>
20859 </para>
20860 <informaltable frame="all">
20861 <tgroup cols="4" colsep="0" rowsep="0">
20862 <colspec colwidth="8*" align="left"/>
20863 <colspec colwidth="6*" align="center"/>
20864 <colspec colwidth="6*" align="center"/>
20865 <colspec colwidth="6*" align="right"/>
20866 <tbody>
20867 <row>
20868 <entry><option>allow_mx_to_ip</option></entry>
20869 <entry>Use: <emphasis>main</emphasis></entry>
20870 <entry>Type: <emphasis>boolean</emphasis></entry>
20871 <entry>Default: <emphasis>false</emphasis></entry>
20872 </row>
20873 </tbody>
20874 </tgroup>
20875 </informaltable>
20876 <para>
20877 <indexterm role="concept">
20878 <primary>MX record</primary>
20879 <secondary>pointing to IP address</secondary>
20880 </indexterm>
20881 It appears that more and more DNS zone administrators are breaking the rules
20882 and putting domain names that look like IP addresses on the right hand side of
20883 MX records. Exim follows the rules and rejects this, giving an error message
20884 that explains the mis-configuration. However, some other MTAs support this
20885 practice, so to avoid <quote>Why can&#x2019;t Exim do this?</quote> complaints,
20886 <option>allow_mx_to_ip</option> exists, in order to enable this heinous activity. It is not
20887 recommended, except when you have no other choice.
20888 </para>
20889 <para>
20890 <indexterm role="option">
20891 <primary><option>allow_utf8_domains</option></primary>
20892 </indexterm>
20893 </para>
20894 <informaltable frame="all">
20895 <tgroup cols="4" colsep="0" rowsep="0">
20896 <colspec colwidth="8*" align="left"/>
20897 <colspec colwidth="6*" align="center"/>
20898 <colspec colwidth="6*" align="center"/>
20899 <colspec colwidth="6*" align="right"/>
20900 <tbody>
20901 <row>
20902 <entry><option>allow_utf8_domains</option></entry>
20903 <entry>Use: <emphasis>main</emphasis></entry>
20904 <entry>Type: <emphasis>boolean</emphasis></entry>
20905 <entry>Default: <emphasis>false</emphasis></entry>
20906 </row>
20907 </tbody>
20908 </tgroup>
20909 </informaltable>
20910 <para>
20911 <indexterm role="concept">
20912 <primary>domain</primary>
20913 <secondary>UTF-8 characters in</secondary>
20914 </indexterm>
20915 <indexterm role="concept">
20916 <primary>UTF-8</primary>
20917 <secondary>in domain name</secondary>
20918 </indexterm>
20919 Lots of discussion is going on about internationalized domain names. One
20920 camp is strongly in favour of just using UTF-8 characters, and it seems
20921 that at least two other MTAs permit this. This option allows Exim users to
20922 experiment if they wish.
20923 </para>
20924 <para>
20925 If it is set true, Exim&#x2019;s domain parsing function allows valid
20926 UTF-8 multicharacters to appear in domain name components, in addition to
20927 letters, digits, and hyphens. However, just setting this option is not
20928 enough; if you want to look up these domain names in the DNS, you must also
20929 adjust the value of <option>dns_check_names_pattern</option> to match the extended form. A
20930 suitable setting is:
20931 </para>
20932 <literallayout class="monospaced">
20933 dns_check_names_pattern = (?i)^(?&gt;(?(1)\.|())[a-z0-9\xc0-\xff]\
20934   (?&gt;[-a-z0-9\x80-\xff]*[a-z0-9\x80-\xbf])?)+$
20935 </literallayout>
20936 <para>
20937 Alternatively, you can just disable this feature by setting
20938 </para>
20939 <literallayout class="monospaced">
20940 dns_check_names_pattern =
20941 </literallayout>
20942 <para>
20943 That is, set the option to an empty string so that no check is done.
20944 </para>
20945 <para>
20946 <indexterm role="option">
20947 <primary><option>auth_advertise_hosts</option></primary>
20948 </indexterm>
20949 </para>
20950 <informaltable frame="all">
20951 <tgroup cols="4" colsep="0" rowsep="0">
20952 <colspec colwidth="8*" align="left"/>
20953 <colspec colwidth="6*" align="center"/>
20954 <colspec colwidth="6*" align="center"/>
20955 <colspec colwidth="6*" align="right"/>
20956 <tbody>
20957 <row>
20958 <entry><option>auth_advertise_hosts</option></entry>
20959 <entry>Use: <emphasis>main</emphasis></entry>
20960 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
20961 <entry>Default: <emphasis>*</emphasis></entry>
20962 </row>
20963 </tbody>
20964 </tgroup>
20965 </informaltable>
20966 <para>
20967 <indexterm role="concept">
20968 <primary>authentication</primary>
20969 <secondary>advertising</secondary>
20970 </indexterm>
20971 <indexterm role="concept">
20972 <primary>AUTH</primary>
20973 <secondary>advertising</secondary>
20974 </indexterm>
20975 If any server authentication mechanisms are configured, Exim advertises them in
20976 response to an EHLO command only if the calling host matches this list.
20977 Otherwise, Exim does not advertise AUTH.
20978 Exim does not accept AUTH commands from clients to which it has not
20979 advertised the availability of AUTH. The advertising of individual
20980 authentication mechanisms can be controlled by the use of the
20981 <option>server_advertise_condition</option> generic authenticator option on the individual
20982 authenticators. See chapter <xref linkend="CHAPSMTPAUTH"/> for further details.
20983 </para>
20984 <para>
20985 Certain mail clients (for example, Netscape) require the user to provide a name
20986 and password for authentication if AUTH is advertised, even though it may
20987 not be needed (the host may accept messages from hosts on its local LAN without
20988 authentication, for example). The <option>auth_advertise_hosts</option> option can be used
20989 to make these clients more friendly by excluding them from the set of hosts to
20990 which Exim advertises AUTH.
20991 </para>
20992 <para>
20993 <indexterm role="concept">
20994 <primary>AUTH</primary>
20995 <secondary>advertising when encrypted</secondary>
20996 </indexterm>
20997 If you want to advertise the availability of AUTH only when the connection
20998 is encrypted using TLS, you can make use of the fact that the value of this
20999 option is expanded, with a setting like this:
21000 </para>
21001 <literallayout class="monospaced">
21002 auth_advertise_hosts = ${if eq{$tls_cipher}{}{}{*}}
21003 </literallayout>
21004 <para>
21005 <indexterm role="variable">
21006 <primary><varname>$tls_cipher</varname></primary>
21007 </indexterm>
21008 If <varname>$tls_cipher</varname> is empty, the session is not encrypted, and the result of
21009 the expansion is empty, thus matching no hosts. Otherwise, the result of the
21010 expansion is *, which matches all hosts.
21011 </para>
21012 <para>
21013 <indexterm role="option">
21014 <primary><option>auto_thaw</option></primary>
21015 </indexterm>
21016 </para>
21017 <informaltable frame="all">
21018 <tgroup cols="4" colsep="0" rowsep="0">
21019 <colspec colwidth="8*" align="left"/>
21020 <colspec colwidth="6*" align="center"/>
21021 <colspec colwidth="6*" align="center"/>
21022 <colspec colwidth="6*" align="right"/>
21023 <tbody>
21024 <row>
21025 <entry><option>auto_thaw</option></entry>
21026 <entry>Use: <emphasis>main</emphasis></entry>
21027 <entry>Type: <emphasis>time</emphasis></entry>
21028 <entry>Default: <emphasis>0s</emphasis></entry>
21029 </row>
21030 </tbody>
21031 </tgroup>
21032 </informaltable>
21033 <para>
21034 <indexterm role="concept">
21035 <primary>thawing messages</primary>
21036 </indexterm>
21037 <indexterm role="concept">
21038 <primary>unfreezing messages</primary>
21039 </indexterm>
21040 If this option is set to a time greater than zero, a queue runner will try a
21041 new delivery attempt on any frozen message, other than a bounce message, if
21042 this much time has passed since it was frozen. This may result in the message
21043 being re-frozen if nothing has changed since the last attempt. It is a way of
21044 saying <quote>keep on trying, even though there are big problems</quote>.
21045 </para>
21046 <para>
21047 <emphasis role="bold">Note</emphasis>: This is an old option, which predates <option>timeout_frozen_after</option> and
21048 <option>ignore_bounce_errors_after</option>. It is retained for compatibility, but it is not
21049 thought to be very useful any more, and its use should probably be avoided.
21050 </para>
21051 <para revisionflag="changed">
21052 <indexterm role="option">
21053 <primary><option>av_scanner</option></primary>
21054 </indexterm>
21055 </para>
21056 <informaltable frame="all" revisionflag="changed">
21057 <tgroup cols="4" colsep="0" rowsep="0">
21058 <colspec colwidth="8*" align="left"/>
21059 <colspec colwidth="6*" align="center"/>
21060 <colspec colwidth="6*" align="center"/>
21061 <colspec colwidth="6*" align="right"/>
21062 <tbody>
21063 <row>
21064 <entry><option>av_scanner</option></entry>
21065 <entry>Use: <emphasis>main</emphasis></entry>
21066 <entry>Type: <emphasis>string</emphasis></entry>
21067 <entry>Default: <emphasis>see below</emphasis></entry>
21068 </row>
21069 </tbody>
21070 </tgroup>
21071 </informaltable>
21072 <para revisionflag="changed">
21073 This option is available if Exim is built with the content-scanning extension.
21074 It specifies which anti-virus scanner to use. The default value is:
21075 </para>
21076 <literallayout class="monospaced" revisionflag="changed">
21077 sophie:/var/run/sophie
21078 </literallayout>
21079 <para revisionflag="changed">
21080 If the value of <option>av_scanner</option> starts with a dollar character, it is expanded
21081 before use. See section <xref linkend="SECTscanvirus"/> for further details.
21082 </para>
21083 <para>
21084 <indexterm role="option">
21085 <primary><option>bi_command</option></primary>
21086 </indexterm>
21087 </para>
21088 <informaltable frame="all">
21089 <tgroup cols="4" colsep="0" rowsep="0">
21090 <colspec colwidth="8*" align="left"/>
21091 <colspec colwidth="6*" align="center"/>
21092 <colspec colwidth="6*" align="center"/>
21093 <colspec colwidth="6*" align="right"/>
21094 <tbody>
21095 <row>
21096 <entry><option>bi_command</option></entry>
21097 <entry>Use: <emphasis>main</emphasis></entry>
21098 <entry>Type: <emphasis>string</emphasis></entry>
21099 <entry>Default: <emphasis>unset</emphasis></entry>
21100 </row>
21101 </tbody>
21102 </tgroup>
21103 </informaltable>
21104 <para>
21105 <indexterm role="option">
21106 <primary><option>-bi</option></primary>
21107 </indexterm>
21108 This option supplies the name of a command that is run when Exim is called with
21109 the <option>-bi</option> option (see chapter <xref linkend="CHAPcommandline"/>). The string value is
21110 just the command name, it is not a complete command line. If an argument is
21111 required, it must come from the <option>-oA</option> command line option.
21112 </para>
21113 <para>
21114 <indexterm role="option">
21115 <primary><option>bounce_message_file</option></primary>
21116 </indexterm>
21117 </para>
21118 <informaltable frame="all">
21119 <tgroup cols="4" colsep="0" rowsep="0">
21120 <colspec colwidth="8*" align="left"/>
21121 <colspec colwidth="6*" align="center"/>
21122 <colspec colwidth="6*" align="center"/>
21123 <colspec colwidth="6*" align="right"/>
21124 <tbody>
21125 <row>
21126 <entry><option>bounce_message_file</option></entry>
21127 <entry>Use: <emphasis>main</emphasis></entry>
21128 <entry>Type: <emphasis>string</emphasis></entry>
21129 <entry>Default: <emphasis>unset</emphasis></entry>
21130 </row>
21131 </tbody>
21132 </tgroup>
21133 </informaltable>
21134 <para>
21135 <indexterm role="concept">
21136 <primary>bounce message</primary>
21137 <secondary>customizing</secondary>
21138 </indexterm>
21139 <indexterm role="concept">
21140 <primary>customizing</primary>
21141 <secondary>bounce message</secondary>
21142 </indexterm>
21143 This option defines a template file containing paragraphs of text to be used
21144 for constructing bounce messages.  Details of the file&#x2019;s contents are given in
21145 chapter <xref linkend="CHAPemsgcust"/>. See also <option>warn_message_file</option>.
21146 </para>
21147 <para>
21148 <indexterm role="option">
21149 <primary><option>bounce_message_text</option></primary>
21150 </indexterm>
21151 </para>
21152 <informaltable frame="all">
21153 <tgroup cols="4" colsep="0" rowsep="0">
21154 <colspec colwidth="8*" align="left"/>
21155 <colspec colwidth="6*" align="center"/>
21156 <colspec colwidth="6*" align="center"/>
21157 <colspec colwidth="6*" align="right"/>
21158 <tbody>
21159 <row>
21160 <entry><option>bounce_message_text</option></entry>
21161 <entry>Use: <emphasis>main</emphasis></entry>
21162 <entry>Type: <emphasis>string</emphasis></entry>
21163 <entry>Default: <emphasis>unset</emphasis></entry>
21164 </row>
21165 </tbody>
21166 </tgroup>
21167 </informaltable>
21168 <para>
21169 When this option is set, its contents are included in the default bounce
21170 message immediately after <quote>This message was created automatically by mail
21171 delivery software.</quote> It is not used if <option>bounce_message_file</option> is set.
21172 </para>
21173 <para>
21174 <indexterm role="option">
21175 <primary><option>bounce_return_body</option></primary>
21176 </indexterm>
21177 </para>
21178 <informaltable frame="all">
21179 <tgroup cols="4" colsep="0" rowsep="0">
21180 <colspec colwidth="8*" align="left"/>
21181 <colspec colwidth="6*" align="center"/>
21182 <colspec colwidth="6*" align="center"/>
21183 <colspec colwidth="6*" align="right"/>
21184 <tbody>
21185 <row>
21186 <entry><option>bounce_return_body</option></entry>
21187 <entry>Use: <emphasis>main</emphasis></entry>
21188 <entry>Type: <emphasis>boolean</emphasis></entry>
21189 <entry>Default: <emphasis>true</emphasis></entry>
21190 </row>
21191 </tbody>
21192 </tgroup>
21193 </informaltable>
21194 <para>
21195 <indexterm role="concept">
21196 <primary>bounce message</primary>
21197 <secondary>including body</secondary>
21198 </indexterm>
21199 This option controls whether the body of an incoming message is included in a
21200 bounce message when <option>bounce_return_message</option> is true. The default setting
21201 causes the entire message, both header and body, to be returned (subject to the
21202 value of <option>bounce_return_size_limit</option>). If this option is false, only the
21203 message header is included. In the case of a non-SMTP message containing an
21204 error that is detected during reception, only those header lines preceding the
21205 point at which the error was detected are returned.
21206 <indexterm role="concept">
21207 <primary>bounce message</primary>
21208 <secondary>including original</secondary>
21209 </indexterm>
21210 </para>
21211 <para>
21212 <indexterm role="option">
21213 <primary><option>bounce_return_message</option></primary>
21214 </indexterm>
21215 </para>
21216 <informaltable frame="all">
21217 <tgroup cols="4" colsep="0" rowsep="0">
21218 <colspec colwidth="8*" align="left"/>
21219 <colspec colwidth="6*" align="center"/>
21220 <colspec colwidth="6*" align="center"/>
21221 <colspec colwidth="6*" align="right"/>
21222 <tbody>
21223 <row>
21224 <entry><option>bounce_return_message</option></entry>
21225 <entry>Use: <emphasis>main</emphasis></entry>
21226 <entry>Type: <emphasis>boolean</emphasis></entry>
21227 <entry>Default: <emphasis>true</emphasis></entry>
21228 </row>
21229 </tbody>
21230 </tgroup>
21231 </informaltable>
21232 <para>
21233 If this option is set false, none of the original message is included in
21234 bounce messages generated by Exim. See also <option>bounce_return_size_limit</option> and
21235 <option>bounce_return_body</option>.
21236 </para>
21237 <para>
21238 <indexterm role="option">
21239 <primary><option>bounce_return_size_limit</option></primary>
21240 </indexterm>
21241 </para>
21242 <informaltable frame="all">
21243 <tgroup cols="4" colsep="0" rowsep="0">
21244 <colspec colwidth="8*" align="left"/>
21245 <colspec colwidth="6*" align="center"/>
21246 <colspec colwidth="6*" align="center"/>
21247 <colspec colwidth="6*" align="right"/>
21248 <tbody>
21249 <row>
21250 <entry><option>bounce_return_size_limit</option></entry>
21251 <entry>Use: <emphasis>main</emphasis></entry>
21252 <entry>Type: <emphasis>integer</emphasis></entry>
21253 <entry>Default: <emphasis>100K</emphasis></entry>
21254 </row>
21255 </tbody>
21256 </tgroup>
21257 </informaltable>
21258 <para>
21259 <indexterm role="concept">
21260 <primary>size</primary>
21261 <secondary>of bounce, limit</secondary>
21262 </indexterm>
21263 <indexterm role="concept">
21264 <primary>bounce message</primary>
21265 <secondary>size limit</secondary>
21266 </indexterm>
21267 <indexterm role="concept">
21268 <primary>limit</primary>
21269 <secondary>bounce message size</secondary>
21270 </indexterm>
21271 This option sets a limit in bytes on the size of messages that are returned to
21272 senders as part of bounce messages when <option>bounce_return_message</option> is true. The
21273 limit should be less than the value of the global <option>message_size_limit</option> and of
21274 any <option>message_size_limit</option> settings on transports, to allow for the bounce text
21275 that Exim generates. If this option is set to zero there is no limit.
21276 </para>
21277 <para>
21278 When the body of any message that is to be included in a bounce message is
21279 greater than the limit, it is truncated, and a comment pointing this out is
21280 added at the top. The actual cutoff may be greater than the value given, owing
21281 to the use of buffering for transferring the message in chunks (typically 8K in
21282 size). The idea is to save bandwidth on those undeliverable 15-megabyte
21283 messages.
21284 </para>
21285 <para>
21286 <indexterm role="option">
21287 <primary><option>bounce_sender_authentication</option></primary>
21288 </indexterm>
21289 </para>
21290 <informaltable frame="all">
21291 <tgroup cols="4" colsep="0" rowsep="0">
21292 <colspec colwidth="8*" align="left"/>
21293 <colspec colwidth="6*" align="center"/>
21294 <colspec colwidth="6*" align="center"/>
21295 <colspec colwidth="6*" align="right"/>
21296 <tbody>
21297 <row>
21298 <entry><option>bounce_sender_authentication</option></entry>
21299 <entry>Use: <emphasis>main</emphasis></entry>
21300 <entry>Type: <emphasis>string</emphasis></entry>
21301 <entry>Default: <emphasis>unset</emphasis></entry>
21302 </row>
21303 </tbody>
21304 </tgroup>
21305 </informaltable>
21306 <para>
21307 <indexterm role="concept">
21308 <primary>bounce message</primary>
21309 <secondary>sender authentication</secondary>
21310 </indexterm>
21311 <indexterm role="concept">
21312 <primary>authentication</primary>
21313 <secondary>bounce message</secondary>
21314 </indexterm>
21315 <indexterm role="concept">
21316 <primary>AUTH</primary>
21317 <secondary>on bounce message</secondary>
21318 </indexterm>
21319 This option provides an authenticated sender address that is sent with any
21320 bounce messages generated by Exim that are sent over an authenticated SMTP
21321 connection. A typical setting might be:
21322 </para>
21323 <literallayout class="monospaced">
21324 bounce_sender_authentication = mailer-daemon@my.domain.example
21325 </literallayout>
21326 <para>
21327 which would cause bounce messages to be sent using the SMTP command:
21328 </para>
21329 <literallayout class="monospaced">
21330 MAIL FROM:&lt;&gt; AUTH=mailer-daemon@my.domain.example
21331 </literallayout>
21332 <para>
21333 The value of <option>bounce_sender_authentication</option> must always be a complete email
21334 address.
21335 </para>
21336 <para>
21337 <indexterm role="option">
21338 <primary><option>callout_domain_negative_expire</option></primary>
21339 </indexterm>
21340 </para>
21341 <informaltable frame="all">
21342 <tgroup cols="4" colsep="0" rowsep="0">
21343 <colspec colwidth="8*" align="left"/>
21344 <colspec colwidth="6*" align="center"/>
21345 <colspec colwidth="6*" align="center"/>
21346 <colspec colwidth="6*" align="right"/>
21347 <tbody>
21348 <row>
21349 <entry><option>callout_domain_negative_expire</option></entry>
21350 <entry>Use: <emphasis>main</emphasis></entry>
21351 <entry>Type: <emphasis>time</emphasis></entry>
21352 <entry>Default: <emphasis>3h</emphasis></entry>
21353 </row>
21354 </tbody>
21355 </tgroup>
21356 </informaltable>
21357 <para>
21358 <indexterm role="concept">
21359 <primary>caching</primary>
21360 <secondary>callout timeouts</secondary>
21361 </indexterm>
21362 <indexterm role="concept">
21363 <primary>callout</primary>
21364 <secondary>caching timeouts</secondary>
21365 </indexterm>
21366 This option specifies the expiry time for negative callout cache data for a
21367 domain. See section <xref linkend="SECTcallver"/> for details of callout verification, and
21368 section <xref linkend="SECTcallvercache"/> for details of the caching.
21369 </para>
21370 <para>
21371 <indexterm role="option">
21372 <primary><option>callout_domain_positive_expire</option></primary>
21373 </indexterm>
21374 </para>
21375 <informaltable frame="all">
21376 <tgroup cols="4" colsep="0" rowsep="0">
21377 <colspec colwidth="8*" align="left"/>
21378 <colspec colwidth="6*" align="center"/>
21379 <colspec colwidth="6*" align="center"/>
21380 <colspec colwidth="6*" align="right"/>
21381 <tbody>
21382 <row>
21383 <entry><option>callout_domain_positive_expire</option></entry>
21384 <entry>Use: <emphasis>main</emphasis></entry>
21385 <entry>Type: <emphasis>time</emphasis></entry>
21386 <entry>Default: <emphasis>7d</emphasis></entry>
21387 </row>
21388 </tbody>
21389 </tgroup>
21390 </informaltable>
21391 <para>
21392 This option specifies the expiry time for positive callout cache data for a
21393 domain. See section <xref linkend="SECTcallver"/> for details of callout verification, and
21394 section <xref linkend="SECTcallvercache"/> for details of the caching.
21395 </para>
21396 <para>
21397 <indexterm role="option">
21398 <primary><option>callout_negative_expire</option></primary>
21399 </indexterm>
21400 </para>
21401 <informaltable frame="all">
21402 <tgroup cols="4" colsep="0" rowsep="0">
21403 <colspec colwidth="8*" align="left"/>
21404 <colspec colwidth="6*" align="center"/>
21405 <colspec colwidth="6*" align="center"/>
21406 <colspec colwidth="6*" align="right"/>
21407 <tbody>
21408 <row>
21409 <entry><option>callout_negative_expire</option></entry>
21410 <entry>Use: <emphasis>main</emphasis></entry>
21411 <entry>Type: <emphasis>time</emphasis></entry>
21412 <entry>Default: <emphasis>2h</emphasis></entry>
21413 </row>
21414 </tbody>
21415 </tgroup>
21416 </informaltable>
21417 <para>
21418 This option specifies the expiry time for negative callout cache data for an
21419 address. See section <xref linkend="SECTcallver"/> for details of callout verification, and
21420 section <xref linkend="SECTcallvercache"/> for details of the caching.
21421 </para>
21422 <para>
21423 <indexterm role="option">
21424 <primary><option>callout_positive_expire</option></primary>
21425 </indexterm>
21426 </para>
21427 <informaltable frame="all">
21428 <tgroup cols="4" colsep="0" rowsep="0">
21429 <colspec colwidth="8*" align="left"/>
21430 <colspec colwidth="6*" align="center"/>
21431 <colspec colwidth="6*" align="center"/>
21432 <colspec colwidth="6*" align="right"/>
21433 <tbody>
21434 <row>
21435 <entry><option>callout_positive_expire</option></entry>
21436 <entry>Use: <emphasis>main</emphasis></entry>
21437 <entry>Type: <emphasis>time</emphasis></entry>
21438 <entry>Default: <emphasis>24h</emphasis></entry>
21439 </row>
21440 </tbody>
21441 </tgroup>
21442 </informaltable>
21443 <para>
21444 This option specifies the expiry time for positive callout cache data for an
21445 address. See section <xref linkend="SECTcallver"/> for details of callout verification, and
21446 section <xref linkend="SECTcallvercache"/> for details of the caching.
21447 </para>
21448 <para>
21449 <indexterm role="option">
21450 <primary><option>callout_random_local_part</option></primary>
21451 </indexterm>
21452 </para>
21453 <informaltable frame="all">
21454 <tgroup cols="4" colsep="0" rowsep="0">
21455 <colspec colwidth="8*" align="left"/>
21456 <colspec colwidth="6*" align="center"/>
21457 <colspec colwidth="6*" align="center"/>
21458 <colspec colwidth="6*" align="right"/>
21459 <tbody>
21460 <row>
21461 <entry><option>callout_random_local_part</option></entry>
21462 <entry>Use: <emphasis>main</emphasis></entry>
21463 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
21464 <entry>Default: <emphasis>see below</emphasis></entry>
21465 </row>
21466 </tbody>
21467 </tgroup>
21468 </informaltable>
21469 <para>
21470 This option defines the <quote>random</quote> local part that can be used as part of
21471 callout verification. The default value is
21472 </para>
21473 <literallayout class="monospaced">
21474 $primary_host_name-$tod_epoch-testing
21475 </literallayout>
21476 <para>
21477 See section <xref linkend="CALLaddparcall"/> for details of how this value is used.
21478 </para>
21479 <para>
21480 <indexterm role="option">
21481 <primary><option>check_log_inodes</option></primary>
21482 </indexterm>
21483 </para>
21484 <informaltable frame="all">
21485 <tgroup cols="4" colsep="0" rowsep="0">
21486 <colspec colwidth="8*" align="left"/>
21487 <colspec colwidth="6*" align="center"/>
21488 <colspec colwidth="6*" align="center"/>
21489 <colspec colwidth="6*" align="right"/>
21490 <tbody>
21491 <row>
21492 <entry><option>check_log_inodes</option></entry>
21493 <entry>Use: <emphasis>main</emphasis></entry>
21494 <entry>Type: <emphasis>integer</emphasis></entry>
21495 <entry>Default: <emphasis>0</emphasis></entry>
21496 </row>
21497 </tbody>
21498 </tgroup>
21499 </informaltable>
21500 <para>
21501 See <option>check_spool_space</option> below.
21502 </para>
21503 <para>
21504 <indexterm role="option">
21505 <primary><option>check_log_space</option></primary>
21506 </indexterm>
21507 </para>
21508 <informaltable frame="all">
21509 <tgroup cols="4" colsep="0" rowsep="0">
21510 <colspec colwidth="8*" align="left"/>
21511 <colspec colwidth="6*" align="center"/>
21512 <colspec colwidth="6*" align="center"/>
21513 <colspec colwidth="6*" align="right"/>
21514 <tbody>
21515 <row>
21516 <entry><option>check_log_space</option></entry>
21517 <entry>Use: <emphasis>main</emphasis></entry>
21518 <entry>Type: <emphasis>integer</emphasis></entry>
21519 <entry>Default: <emphasis>0</emphasis></entry>
21520 </row>
21521 </tbody>
21522 </tgroup>
21523 </informaltable>
21524 <para>
21525 See <option>check_spool_space</option> below.
21526 </para>
21527 <para>
21528 <indexterm role="option">
21529 <primary><option>check_rfc2047_length</option></primary>
21530 </indexterm>
21531 <indexterm role="concept">
21532 <primary>RFC 2047</primary>
21533 <secondary>disabling length check</secondary>
21534 </indexterm>
21535 <indexterm role="option">
21536 <primary><option>check_rfc2047_length</option></primary>
21537 </indexterm>
21538 </para>
21539 <informaltable frame="all">
21540 <tgroup cols="4" colsep="0" rowsep="0">
21541 <colspec colwidth="8*" align="left"/>
21542 <colspec colwidth="6*" align="center"/>
21543 <colspec colwidth="6*" align="center"/>
21544 <colspec colwidth="6*" align="right"/>
21545 <tbody>
21546 <row>
21547 <entry><option>check_rfc2047_length</option></entry>
21548 <entry>Use: <emphasis>main</emphasis></entry>
21549 <entry>Type: <emphasis>boolean</emphasis></entry>
21550 <entry>Default: <emphasis>true</emphasis></entry>
21551 </row>
21552 </tbody>
21553 </tgroup>
21554 </informaltable>
21555 <para>
21556 RFC 2047 defines a way of encoding non-ASCII characters in headers using a
21557 system of <quote>encoded words</quote>. The RFC specifies a maximum length for an encoded
21558 word; strings to be encoded that exceed this length are supposed to use
21559 multiple encoded words. By default, Exim does not recognize encoded words that
21560 exceed the maximum length. However, it seems that some software, in violation
21561 of the RFC, generates overlong encoded words. If <option>check_rfc2047_length</option> is
21562 set false, Exim recognizes encoded words of any length.
21563 </para>
21564 <para>
21565 <indexterm role="option">
21566 <primary><option>check_spool_inodes</option></primary>
21567 </indexterm>
21568 </para>
21569 <informaltable frame="all">
21570 <tgroup cols="4" colsep="0" rowsep="0">
21571 <colspec colwidth="8*" align="left"/>
21572 <colspec colwidth="6*" align="center"/>
21573 <colspec colwidth="6*" align="center"/>
21574 <colspec colwidth="6*" align="right"/>
21575 <tbody>
21576 <row>
21577 <entry><option>check_spool_inodes</option></entry>
21578 <entry>Use: <emphasis>main</emphasis></entry>
21579 <entry>Type: <emphasis>integer</emphasis></entry>
21580 <entry>Default: <emphasis>0</emphasis></entry>
21581 </row>
21582 </tbody>
21583 </tgroup>
21584 </informaltable>
21585 <para>
21586 See <option>check_spool_space</option> below.
21587 </para>
21588 <para>
21589 <indexterm role="option">
21590 <primary><option>check_spool_space</option></primary>
21591 </indexterm>
21592 </para>
21593 <informaltable frame="all">
21594 <tgroup cols="4" colsep="0" rowsep="0">
21595 <colspec colwidth="8*" align="left"/>
21596 <colspec colwidth="6*" align="center"/>
21597 <colspec colwidth="6*" align="center"/>
21598 <colspec colwidth="6*" align="right"/>
21599 <tbody>
21600 <row>
21601 <entry><option>check_spool_space</option></entry>
21602 <entry>Use: <emphasis>main</emphasis></entry>
21603 <entry>Type: <emphasis>integer</emphasis></entry>
21604 <entry>Default: <emphasis>0</emphasis></entry>
21605 </row>
21606 </tbody>
21607 </tgroup>
21608 </informaltable>
21609 <para>
21610 <indexterm role="concept">
21611 <primary>checking disk space</primary>
21612 </indexterm>
21613 <indexterm role="concept">
21614 <primary>disk space, checking</primary>
21615 </indexterm>
21616 <indexterm role="concept">
21617 <primary>spool directory</primary>
21618 <secondary>checking space</secondary>
21619 </indexterm>
21620 The four <option>check_...</option> options allow for checking of disk resources before a
21621 message is accepted.
21622 </para>
21623 <para>
21624 <indexterm role="variable">
21625 <primary><varname>$log_inodes</varname></primary>
21626 </indexterm>
21627 <indexterm role="variable">
21628 <primary><varname>$log_space</varname></primary>
21629 </indexterm>
21630 <indexterm role="variable">
21631 <primary><varname>$spool_inodes</varname></primary>
21632 </indexterm>
21633 <indexterm role="variable">
21634 <primary><varname>$spool_space</varname></primary>
21635 </indexterm>
21636 When any of these options are set, they apply to all incoming messages. If you
21637 want to apply different checks to different kinds of message, you can do so by
21638 testing the variables <varname>$log_inodes</varname>, <varname>$log_space</varname>, <varname>$spool_inodes</varname>, and
21639 <varname>$spool_space</varname> in an ACL with appropriate additional conditions.
21640 </para>
21641 <para>
21642 <option>check_spool_space</option> and <option>check_spool_inodes</option> check the spool partition if
21643 either value is greater than zero, for example:
21644 </para>
21645 <literallayout class="monospaced">
21646 check_spool_space = 10M
21647 check_spool_inodes = 100
21648 </literallayout>
21649 <para>
21650 The spool partition is the one that contains the directory defined by
21651 SPOOL_DIRECTORY in <filename>Local/Makefile</filename>. It is used for holding messages in
21652 transit.
21653 </para>
21654 <para>
21655 <option>check_log_space</option> and <option>check_log_inodes</option>  check the partition in which log
21656 files are written if either is greater than zero. These should be set only if
21657 <option>log_file_path</option> and <option>spool_directory</option> refer to different partitions.
21658 </para>
21659 <para>
21660 If there is less space or fewer inodes than requested, Exim refuses to accept
21661 incoming mail. In the case of SMTP input this is done by giving a 452 temporary
21662 error response to the MAIL command. If ESMTP is in use and there was a
21663 SIZE parameter on the MAIL command, its value is added to the
21664 <option>check_spool_space</option> value, and the check is performed even if
21665 <option>check_spool_space</option> is zero, unless <option>no_smtp_check_spool_space</option> is set.
21666 </para>
21667 <para>
21668 The values for <option>check_spool_space</option> and <option>check_log_space</option> are held as a
21669 number of kilobytes. If a non-multiple of 1024 is specified, it is rounded up.
21670 </para>
21671 <para>
21672 For non-SMTP input and for batched SMTP input, the test is done at start-up; on
21673 failure a message is written to stderr and Exim exits with a non-zero code, as
21674 it obviously cannot send an error message of any kind.
21675 </para>
21676 <para>
21677 <indexterm role="option">
21678 <primary><option>daemon_smtp_ports</option></primary>
21679 </indexterm>
21680 </para>
21681 <informaltable frame="all">
21682 <tgroup cols="4" colsep="0" rowsep="0">
21683 <colspec colwidth="8*" align="left"/>
21684 <colspec colwidth="6*" align="center"/>
21685 <colspec colwidth="6*" align="center"/>
21686 <colspec colwidth="6*" align="right"/>
21687 <tbody>
21688 <row>
21689 <entry><option>daemon_smtp_ports</option></entry>
21690 <entry>Use: <emphasis>main</emphasis></entry>
21691 <entry>Type: <emphasis>string</emphasis></entry>
21692 <entry>Default: <emphasis><literal>smtp</literal></emphasis></entry>
21693 </row>
21694 </tbody>
21695 </tgroup>
21696 </informaltable>
21697 <para>
21698 <indexterm role="concept">
21699 <primary>port</primary>
21700 <secondary>for daemon</secondary>
21701 </indexterm>
21702 <indexterm role="concept">
21703 <primary>TCP/IP</primary>
21704 <secondary>setting listening ports</secondary>
21705 </indexterm>
21706 This option specifies one or more default SMTP ports on which the Exim daemon
21707 listens. See chapter <xref linkend="CHAPinterfaces"/> for details of how it is used. For
21708 backward compatibility, <option>daemon_smtp_port</option> (singular) is a synonym.
21709 </para>
21710 <para>
21711 <indexterm role="option">
21712 <primary><option>daemon_startup_retries</option></primary>
21713 </indexterm>
21714 </para>
21715 <informaltable frame="all">
21716 <tgroup cols="4" colsep="0" rowsep="0">
21717 <colspec colwidth="8*" align="left"/>
21718 <colspec colwidth="6*" align="center"/>
21719 <colspec colwidth="6*" align="center"/>
21720 <colspec colwidth="6*" align="right"/>
21721 <tbody>
21722 <row>
21723 <entry><option>daemon_startup_retries</option></entry>
21724 <entry>Use: <emphasis>main</emphasis></entry>
21725 <entry>Type: <emphasis>integer</emphasis></entry>
21726 <entry>Default: <emphasis>9</emphasis></entry>
21727 </row>
21728 </tbody>
21729 </tgroup>
21730 </informaltable>
21731 <para>
21732 <indexterm role="concept">
21733 <primary>daemon startup, retrying</primary>
21734 </indexterm>
21735 This option, along with <option>daemon_startup_sleep</option>, controls the retrying done by
21736 the daemon at startup when it cannot immediately bind a listening socket
21737 (typically because the socket is already in use): <option>daemon_startup_retries</option>
21738 defines the number of retries after the first failure, and
21739 <option>daemon_startup_sleep</option> defines the length of time to wait between retries.
21740 </para>
21741 <para>
21742 <indexterm role="option">
21743 <primary><option>daemon_startup_sleep</option></primary>
21744 </indexterm>
21745 </para>
21746 <informaltable frame="all">
21747 <tgroup cols="4" colsep="0" rowsep="0">
21748 <colspec colwidth="8*" align="left"/>
21749 <colspec colwidth="6*" align="center"/>
21750 <colspec colwidth="6*" align="center"/>
21751 <colspec colwidth="6*" align="right"/>
21752 <tbody>
21753 <row>
21754 <entry><option>daemon_startup_sleep</option></entry>
21755 <entry>Use: <emphasis>main</emphasis></entry>
21756 <entry>Type: <emphasis>time</emphasis></entry>
21757 <entry>Default: <emphasis>30s</emphasis></entry>
21758 </row>
21759 </tbody>
21760 </tgroup>
21761 </informaltable>
21762 <para>
21763 See <option>daemon_startup_retries</option>.
21764 </para>
21765 <para>
21766 <indexterm role="option">
21767 <primary><option>delay_warning</option></primary>
21768 </indexterm>
21769 </para>
21770 <informaltable frame="all">
21771 <tgroup cols="4" colsep="0" rowsep="0">
21772 <colspec colwidth="8*" align="left"/>
21773 <colspec colwidth="6*" align="center"/>
21774 <colspec colwidth="6*" align="center"/>
21775 <colspec colwidth="6*" align="right"/>
21776 <tbody>
21777 <row>
21778 <entry><option>delay_warning</option></entry>
21779 <entry>Use: <emphasis>main</emphasis></entry>
21780 <entry>Type: <emphasis>time list</emphasis></entry>
21781 <entry>Default: <emphasis>24h</emphasis></entry>
21782 </row>
21783 </tbody>
21784 </tgroup>
21785 </informaltable>
21786 <para>
21787 <indexterm role="concept">
21788 <primary>warning of delay</primary>
21789 </indexterm>
21790 <indexterm role="concept">
21791 <primary>delay warning, specifying</primary>
21792 </indexterm>
21793 When a message is delayed, Exim sends a warning message to the sender at
21794 intervals specified by this option. The data is a colon-separated list of times
21795 after which to send warning messages. If the value of the option is an empty
21796 string or a zero time, no warnings are sent. Up to 10 times may be given. If a
21797 message has been on the queue for longer than the last time, the last interval
21798 between the times is used to compute subsequent warning times. For example,
21799 with
21800 </para>
21801 <literallayout class="monospaced">
21802 delay_warning = 4h:8h:24h
21803 </literallayout>
21804 <para>
21805 the first message is sent after 4 hours, the second after 8 hours, and
21806 the third one after 24 hours. After that, messages are sent every 16 hours,
21807 because that is the interval between the last two times on the list. If you set
21808 just one time, it specifies the repeat interval. For example, with:
21809 </para>
21810 <literallayout class="monospaced">
21811 delay_warning = 6h
21812 </literallayout>
21813 <para>
21814 messages are repeated every six hours. To stop warnings after a given time, set
21815 a very large time at the end of the list. For example:
21816 </para>
21817 <literallayout class="monospaced">
21818 delay_warning = 2h:12h:99d
21819 </literallayout>
21820 <para>
21821 <indexterm role="option">
21822 <primary><option>delay_warning_condition</option></primary>
21823 </indexterm>
21824 </para>
21825 <informaltable frame="all">
21826 <tgroup cols="4" colsep="0" rowsep="0">
21827 <colspec colwidth="8*" align="left"/>
21828 <colspec colwidth="6*" align="center"/>
21829 <colspec colwidth="6*" align="center"/>
21830 <colspec colwidth="6*" align="right"/>
21831 <tbody>
21832 <row>
21833 <entry><option>delay_warning_condition</option></entry>
21834 <entry>Use: <emphasis>main</emphasis></entry>
21835 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
21836 <entry>Default: <emphasis>see below</emphasis></entry>
21837 </row>
21838 </tbody>
21839 </tgroup>
21840 </informaltable>
21841 <para>
21842 <indexterm role="variable">
21843 <primary><varname>$domain</varname></primary>
21844 </indexterm>
21845 The string is expanded at the time a warning message might be sent. If all the
21846 deferred addresses have the same domain, it is set in <varname>$domain</varname> during the
21847 expansion. Otherwise <varname>$domain</varname> is empty. If the result of the expansion is a
21848 forced failure, an empty string, or a string matching any of <quote>0</quote>, <quote>no</quote> or
21849 <quote>false</quote> (the comparison being done caselessly) then the warning message is
21850 not sent. The default is:
21851 </para>
21852 <literallayout class="monospaced">
21853 delay_warning_condition = ${if or {\
21854   { !eq{$h_list-id:$h_list-post:$h_list-subscribe:}{} }\
21855   { match{$h_precedence:}{(?i)bulk|list|junk} }\
21856   { match{$h_auto-submitted:}{(?i)auto-generated|auto-replied} }\
21857   } {no}{yes}}
21858 </literallayout>
21859 <para>
21860 This suppresses the sending of warnings for messages that contain <emphasis>List-ID:</emphasis>,
21861 <emphasis>List-Post:</emphasis>, or <emphasis>List-Subscribe:</emphasis> headers, or have <quote>bulk</quote>, <quote>list</quote> or
21862 <quote>junk</quote> in a <emphasis>Precedence:</emphasis> header, or have <quote>auto-generated</quote> or
21863 <quote>auto-replied</quote> in an <emphasis>Auto-Submitted:</emphasis> header.
21864 </para>
21865 <para>
21866 <indexterm role="option">
21867 <primary><option>deliver_drop_privilege</option></primary>
21868 </indexterm>
21869 </para>
21870 <informaltable frame="all">
21871 <tgroup cols="4" colsep="0" rowsep="0">
21872 <colspec colwidth="8*" align="left"/>
21873 <colspec colwidth="6*" align="center"/>
21874 <colspec colwidth="6*" align="center"/>
21875 <colspec colwidth="6*" align="right"/>
21876 <tbody>
21877 <row>
21878 <entry><option>deliver_drop_privilege</option></entry>
21879 <entry>Use: <emphasis>main</emphasis></entry>
21880 <entry>Type: <emphasis>boolean</emphasis></entry>
21881 <entry>Default: <emphasis>false</emphasis></entry>
21882 </row>
21883 </tbody>
21884 </tgroup>
21885 </informaltable>
21886 <para>
21887 <indexterm role="concept">
21888 <primary>unprivileged delivery</primary>
21889 </indexterm>
21890 <indexterm role="concept">
21891 <primary>delivery</primary>
21892 <secondary>unprivileged</secondary>
21893 </indexterm>
21894 If this option is set true, Exim drops its root privilege at the start of a
21895 delivery process, and runs as the Exim user throughout. This severely restricts
21896 the kinds of local delivery that are possible, but is viable in certain types
21897 of configuration. There is a discussion about the use of root privilege in
21898 chapter <xref linkend="CHAPsecurity"/>.
21899 </para>
21900 <para>
21901 <indexterm role="option">
21902 <primary><option>deliver_queue_load_max</option></primary>
21903 </indexterm>
21904 </para>
21905 <informaltable frame="all">
21906 <tgroup cols="4" colsep="0" rowsep="0">
21907 <colspec colwidth="8*" align="left"/>
21908 <colspec colwidth="6*" align="center"/>
21909 <colspec colwidth="6*" align="center"/>
21910 <colspec colwidth="6*" align="right"/>
21911 <tbody>
21912 <row>
21913 <entry><option>deliver_queue_load_max</option></entry>
21914 <entry>Use: <emphasis>main</emphasis></entry>
21915 <entry>Type: <emphasis>fixed-point</emphasis></entry>
21916 <entry>Default: <emphasis>unset</emphasis></entry>
21917 </row>
21918 </tbody>
21919 </tgroup>
21920 </informaltable>
21921 <para>
21922 <indexterm role="concept">
21923 <primary>load average</primary>
21924 </indexterm>
21925 <indexterm role="concept">
21926 <primary>queue runner</primary>
21927 <secondary>abandoning</secondary>
21928 </indexterm>
21929 When this option is set, a queue run is abandoned if the system load average
21930 becomes greater than the value of the option. The option has no effect on
21931 ancient operating systems on which Exim cannot determine the load average.
21932 See also <option>queue_only_load</option> and <option>smtp_load_reserve</option>.
21933 </para>
21934 <para>
21935 <indexterm role="option">
21936 <primary><option>delivery_date_remove</option></primary>
21937 </indexterm>
21938 </para>
21939 <informaltable frame="all">
21940 <tgroup cols="4" colsep="0" rowsep="0">
21941 <colspec colwidth="8*" align="left"/>
21942 <colspec colwidth="6*" align="center"/>
21943 <colspec colwidth="6*" align="center"/>
21944 <colspec colwidth="6*" align="right"/>
21945 <tbody>
21946 <row>
21947 <entry><option>delivery_date_remove</option></entry>
21948 <entry>Use: <emphasis>main</emphasis></entry>
21949 <entry>Type: <emphasis>boolean</emphasis></entry>
21950 <entry>Default: <emphasis>true</emphasis></entry>
21951 </row>
21952 </tbody>
21953 </tgroup>
21954 </informaltable>
21955 <para>
21956 <indexterm role="concept">
21957 <primary><emphasis>Delivery-date:</emphasis> header line</primary>
21958 </indexterm>
21959 Exim&#x2019;s transports have an option for adding a <emphasis>Delivery-date:</emphasis> header to a
21960 message when it is delivered, in exactly the same way as <emphasis>Return-path:</emphasis> is
21961 handled. <emphasis>Delivery-date:</emphasis> records the actual time of delivery. Such headers
21962 should not be present in incoming messages, and this option causes them to be
21963 removed at the time the message is received, to avoid any problems that might
21964 occur when a delivered message is subsequently sent on to some other recipient.
21965 </para>
21966 <para>
21967 <indexterm role="option">
21968 <primary><option>disable_fsync</option></primary>
21969 </indexterm>
21970 </para>
21971 <informaltable frame="all">
21972 <tgroup cols="4" colsep="0" rowsep="0">
21973 <colspec colwidth="8*" align="left"/>
21974 <colspec colwidth="6*" align="center"/>
21975 <colspec colwidth="6*" align="center"/>
21976 <colspec colwidth="6*" align="right"/>
21977 <tbody>
21978 <row>
21979 <entry><option>disable_fsync</option></entry>
21980 <entry>Use: <emphasis>main</emphasis></entry>
21981 <entry>Type: <emphasis>boolean</emphasis></entry>
21982 <entry>Default: <emphasis>false</emphasis></entry>
21983 </row>
21984 </tbody>
21985 </tgroup>
21986 </informaltable>
21987 <para>
21988 <indexterm role="concept">
21989 <primary><function>fsync()</function>, disabling</primary>
21990 </indexterm>
21991 This option is available only if Exim was built with the compile-time option
21992 ENABLE_DISABLE_FSYNC. When this is not set, a reference to <option>disable_fsync</option> in
21993 a runtime configuration generates an <quote>unknown option</quote> error. You should not
21994 build Exim with ENABLE_DISABLE_FSYNC or set <option>disable_fsync</option> unless you
21995 really, really, really understand what you are doing. <emphasis>No pre-compiled
21996 distributions of Exim should ever make this option available.</emphasis>
21997 </para>
21998 <para>
21999 When <option>disable_fsync</option> is set true, Exim no longer calls <function>fsync()</function> to force
22000 updated files&#x2019; data to be written to disc before continuing. Unexpected events
22001 such as crashes and power outages may cause data to be lost or scrambled.
22002 Here be Dragons. <emphasis role="bold">Beware.</emphasis>
22003 </para>
22004 <para>
22005 <indexterm role="option">
22006 <primary><option>disable_ipv6</option></primary>
22007 </indexterm>
22008 </para>
22009 <informaltable frame="all">
22010 <tgroup cols="4" colsep="0" rowsep="0">
22011 <colspec colwidth="8*" align="left"/>
22012 <colspec colwidth="6*" align="center"/>
22013 <colspec colwidth="6*" align="center"/>
22014 <colspec colwidth="6*" align="right"/>
22015 <tbody>
22016 <row>
22017 <entry><option>disable_ipv6</option></entry>
22018 <entry>Use: <emphasis>main</emphasis></entry>
22019 <entry>Type: <emphasis>boolean</emphasis></entry>
22020 <entry>Default: <emphasis>false</emphasis></entry>
22021 </row>
22022 </tbody>
22023 </tgroup>
22024 </informaltable>
22025 <para>
22026 <indexterm role="concept">
22027 <primary>IPv6</primary>
22028 <secondary>disabling</secondary>
22029 </indexterm>
22030 If this option is set true, even if the Exim binary has IPv6 support, no IPv6
22031 activities take place. AAAA records are never looked up, and any IPv6 addresses
22032 that are listed in <option>local_interfaces</option>, data for the <option>manualroute</option> router,
22033 etc. are ignored. If IP literals are enabled, the <command>ipliteral</command> router declines
22034 to handle IPv6 literal addresses.
22035 </para>
22036 <para>
22037 <indexterm role="option">
22038 <primary><option>dns_again_means_nonexist</option></primary>
22039 </indexterm>
22040 </para>
22041 <informaltable frame="all">
22042 <tgroup cols="4" colsep="0" rowsep="0">
22043 <colspec colwidth="8*" align="left"/>
22044 <colspec colwidth="6*" align="center"/>
22045 <colspec colwidth="6*" align="center"/>
22046 <colspec colwidth="6*" align="right"/>
22047 <tbody>
22048 <row>
22049 <entry><option>dns_again_means_nonexist</option></entry>
22050 <entry>Use: <emphasis>main</emphasis></entry>
22051 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
22052 <entry>Default: <emphasis>unset</emphasis></entry>
22053 </row>
22054 </tbody>
22055 </tgroup>
22056 </informaltable>
22057 <para>
22058 <indexterm role="concept">
22059 <primary>DNS</primary>
22060 <secondary><quote>try again</quote> response; overriding</secondary>
22061 </indexterm>
22062 DNS lookups give a <quote>try again</quote> response for the DNS errors
22063 <quote>non-authoritative host not found</quote> and <quote>SERVERFAIL</quote>. This can cause Exim to
22064 keep trying to deliver a message, or to give repeated temporary errors to
22065 incoming mail. Sometimes the effect is caused by a badly set up name server and
22066 may persist for a long time. If a domain which exhibits this problem matches
22067 anything in <option>dns_again_means_nonexist</option>, it is treated as if it did not exist.
22068 This option should be used with care. You can make it apply to reverse lookups
22069 by a setting such as this:
22070 </para>
22071 <literallayout class="monospaced">
22072 dns_again_means_nonexist = *.in-addr.arpa
22073 </literallayout>
22074 <para>
22075 This option applies to all DNS lookups that Exim does. It also applies when the
22076 <function>gethostbyname()</function> or <function>getipnodebyname()</function> functions give temporary errors,
22077 since these are most likely to be caused by DNS lookup problems. The
22078 <command>dnslookup</command> router has some options of its own for controlling what happens
22079 when lookups for MX or SRV records give temporary errors. These more specific
22080 options are applied after this global option.
22081 </para>
22082 <para>
22083 <indexterm role="option">
22084 <primary><option>dns_check_names_pattern</option></primary>
22085 </indexterm>
22086 </para>
22087 <informaltable frame="all">
22088 <tgroup cols="4" colsep="0" rowsep="0">
22089 <colspec colwidth="8*" align="left"/>
22090 <colspec colwidth="6*" align="center"/>
22091 <colspec colwidth="6*" align="center"/>
22092 <colspec colwidth="6*" align="right"/>
22093 <tbody>
22094 <row>
22095 <entry><option>dns_check_names_pattern</option></entry>
22096 <entry>Use: <emphasis>main</emphasis></entry>
22097 <entry>Type: <emphasis>string</emphasis></entry>
22098 <entry>Default: <emphasis>see below</emphasis></entry>
22099 </row>
22100 </tbody>
22101 </tgroup>
22102 </informaltable>
22103 <para>
22104 <indexterm role="concept">
22105 <primary>DNS</primary>
22106 <secondary>pre-check of name syntax</secondary>
22107 </indexterm>
22108 When this option is set to a non-empty string, it causes Exim to check domain
22109 names for characters that are not allowed in host names before handing them to
22110 the DNS resolver, because some resolvers give temporary errors for names that
22111 contain unusual characters. If a domain name contains any unwanted characters,
22112 a <quote>not found</quote> result is forced, and the resolver is not called. The check is
22113 done by matching the domain name against a regular expression, which is the
22114 value of this option. The default pattern is
22115 </para>
22116 <literallayout class="monospaced">
22117 dns_check_names_pattern = \
22118   (?i)^(?&gt;(?(1)\.|())[^\W_](?&gt;[a-z0-9/-]*[^\W_])?)+$
22119 </literallayout>
22120 <para>
22121 which permits only letters, digits, slashes, and hyphens in components, but
22122 they must start and end with a letter or digit. Slashes are not, in fact,
22123 permitted in host names, but they are found in certain NS records (which can be
22124 accessed in Exim by using a <option>dnsdb</option> lookup). If you set
22125 <option>allow_utf8_domains</option>, you must modify this pattern, or set the option to an
22126 empty string.
22127 </para>
22128 <para>
22129 <indexterm role="option">
22130 <primary><option>dns_csa_search_limit</option></primary>
22131 </indexterm>
22132 </para>
22133 <informaltable frame="all">
22134 <tgroup cols="4" colsep="0" rowsep="0">
22135 <colspec colwidth="8*" align="left"/>
22136 <colspec colwidth="6*" align="center"/>
22137 <colspec colwidth="6*" align="center"/>
22138 <colspec colwidth="6*" align="right"/>
22139 <tbody>
22140 <row>
22141 <entry><option>dns_csa_search_limit</option></entry>
22142 <entry>Use: <emphasis>main</emphasis></entry>
22143 <entry>Type: <emphasis>integer</emphasis></entry>
22144 <entry>Default: <emphasis>5</emphasis></entry>
22145 </row>
22146 </tbody>
22147 </tgroup>
22148 </informaltable>
22149 <para>
22150 This option controls the depth of parental searching for CSA SRV records in the
22151 DNS, as described in more detail in section <xref linkend="SECTverifyCSA"/>.
22152 </para>
22153 <para>
22154 <indexterm role="option">
22155 <primary><option>dns_csa_use_reverse</option></primary>
22156 </indexterm>
22157 </para>
22158 <informaltable frame="all">
22159 <tgroup cols="4" colsep="0" rowsep="0">
22160 <colspec colwidth="8*" align="left"/>
22161 <colspec colwidth="6*" align="center"/>
22162 <colspec colwidth="6*" align="center"/>
22163 <colspec colwidth="6*" align="right"/>
22164 <tbody>
22165 <row>
22166 <entry><option>dns_csa_use_reverse</option></entry>
22167 <entry>Use: <emphasis>main</emphasis></entry>
22168 <entry>Type: <emphasis>boolean</emphasis></entry>
22169 <entry>Default: <emphasis>true</emphasis></entry>
22170 </row>
22171 </tbody>
22172 </tgroup>
22173 </informaltable>
22174 <para>
22175 This option controls whether or not an IP address, given as a CSA domain, is
22176 reversed and looked up in the reverse DNS, as described in more detail in
22177 section <xref linkend="SECTverifyCSA"/>.
22178 </para>
22179 <para>
22180 <indexterm role="option">
22181 <primary><option>dns_ipv4_lookup</option></primary>
22182 </indexterm>
22183 </para>
22184 <informaltable frame="all">
22185 <tgroup cols="4" colsep="0" rowsep="0">
22186 <colspec colwidth="8*" align="left"/>
22187 <colspec colwidth="6*" align="center"/>
22188 <colspec colwidth="6*" align="center"/>
22189 <colspec colwidth="6*" align="right"/>
22190 <tbody>
22191 <row>
22192 <entry><option>dns_ipv4_lookup</option></entry>
22193 <entry>Use: <emphasis>main</emphasis></entry>
22194 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
22195 <entry>Default: <emphasis>unset</emphasis></entry>
22196 </row>
22197 </tbody>
22198 </tgroup>
22199 </informaltable>
22200 <para>
22201 <indexterm role="concept">
22202 <primary>IPv6</primary>
22203 <secondary>DNS lookup for AAAA records</secondary>
22204 </indexterm>
22205 <indexterm role="concept">
22206 <primary>DNS</primary>
22207 <secondary>IPv6 lookup for AAAA records</secondary>
22208 </indexterm>
22209 When Exim is compiled with IPv6 support and <option>disable_ipv6</option> is not set, it
22210 looks for IPv6 address records (AAAA records) as well as IPv4 address records
22211 (A records) when trying to find IP addresses for hosts, unless the host&#x2019;s
22212 domain matches this list.
22213 </para>
22214 <para>
22215 This is a fudge to help with name servers that give big delays or otherwise do
22216 not work for the AAAA record type. In due course, when the world&#x2019;s name
22217 servers have all been upgraded, there should be no need for this option.
22218 </para>
22219 <para>
22220 <indexterm role="option">
22221 <primary><option>dns_retrans</option></primary>
22222 </indexterm>
22223 </para>
22224 <informaltable frame="all">
22225 <tgroup cols="4" colsep="0" rowsep="0">
22226 <colspec colwidth="8*" align="left"/>
22227 <colspec colwidth="6*" align="center"/>
22228 <colspec colwidth="6*" align="center"/>
22229 <colspec colwidth="6*" align="right"/>
22230 <tbody>
22231 <row>
22232 <entry><option>dns_retrans</option></entry>
22233 <entry>Use: <emphasis>main</emphasis></entry>
22234 <entry>Type: <emphasis>time</emphasis></entry>
22235 <entry>Default: <emphasis>0s</emphasis></entry>
22236 </row>
22237 </tbody>
22238 </tgroup>
22239 </informaltable>
22240 <para>
22241 <indexterm role="concept">
22242 <primary>DNS</primary>
22243 <secondary>resolver options</secondary>
22244 </indexterm>
22245 The options <option>dns_retrans</option> and <option>dns_retry</option> can be used to set the
22246 retransmission and retry parameters for DNS lookups. Values of zero (the
22247 defaults) leave the system default settings unchanged. The first value is the
22248 time between retries, and the second is the number of retries. It isn&#x2019;t
22249 totally clear exactly how these settings affect the total time a DNS lookup may
22250 take. I haven&#x2019;t found any documentation about timeouts on DNS lookups; these
22251 parameter values are available in the external resolver interface structure,
22252 but nowhere does it seem to describe how they are used or what you might want
22253 to set in them.
22254 </para>
22255 <para>
22256 <indexterm role="option">
22257 <primary><option>dns_retry</option></primary>
22258 </indexterm>
22259 </para>
22260 <informaltable frame="all">
22261 <tgroup cols="4" colsep="0" rowsep="0">
22262 <colspec colwidth="8*" align="left"/>
22263 <colspec colwidth="6*" align="center"/>
22264 <colspec colwidth="6*" align="center"/>
22265 <colspec colwidth="6*" align="right"/>
22266 <tbody>
22267 <row>
22268 <entry><option>dns_retry</option></entry>
22269 <entry>Use: <emphasis>main</emphasis></entry>
22270 <entry>Type: <emphasis>integer</emphasis></entry>
22271 <entry>Default: <emphasis>0</emphasis></entry>
22272 </row>
22273 </tbody>
22274 </tgroup>
22275 </informaltable>
22276 <para>
22277 See <option>dns_retrans</option> above.
22278 </para>
22279 <para>
22280 <indexterm role="option">
22281 <primary><option>drop_cr</option></primary>
22282 </indexterm>
22283 </para>
22284 <informaltable frame="all">
22285 <tgroup cols="4" colsep="0" rowsep="0">
22286 <colspec colwidth="8*" align="left"/>
22287 <colspec colwidth="6*" align="center"/>
22288 <colspec colwidth="6*" align="center"/>
22289 <colspec colwidth="6*" align="right"/>
22290 <tbody>
22291 <row>
22292 <entry><option>drop_cr</option></entry>
22293 <entry>Use: <emphasis>main</emphasis></entry>
22294 <entry>Type: <emphasis>boolean</emphasis></entry>
22295 <entry>Default: <emphasis>false</emphasis></entry>
22296 </row>
22297 </tbody>
22298 </tgroup>
22299 </informaltable>
22300 <para>
22301 This is an obsolete option that is now a no-op. It used to affect the way Exim
22302 handled CR and LF characters in incoming messages. What happens now is
22303 described in section <xref linkend="SECTlineendings"/>.
22304 </para>
22305 <para>
22306 <indexterm role="option">
22307 <primary><option>dsn_from</option></primary>
22308 </indexterm>
22309 </para>
22310 <informaltable frame="all">
22311 <tgroup cols="4" colsep="0" rowsep="0">
22312 <colspec colwidth="8*" align="left"/>
22313 <colspec colwidth="6*" align="center"/>
22314 <colspec colwidth="6*" align="center"/>
22315 <colspec colwidth="6*" align="right"/>
22316 <tbody>
22317 <row>
22318 <entry><option>dsn_from</option></entry>
22319 <entry>Use: <emphasis>main</emphasis></entry>
22320 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
22321 <entry>Default: <emphasis>see below</emphasis></entry>
22322 </row>
22323 </tbody>
22324 </tgroup>
22325 </informaltable>
22326 <para>
22327 <indexterm role="concept">
22328 <primary><emphasis>From:</emphasis> header line</primary>
22329 <secondary>in bounces</secondary>
22330 </indexterm>
22331 <indexterm role="concept">
22332 <primary>bounce messages</primary>
22333 <secondary><emphasis>From:</emphasis> line, specifying</secondary>
22334 </indexterm>
22335 This option can be used to vary the contents of <emphasis>From:</emphasis> header lines in
22336 bounces and other automatically generated messages (<quote>Delivery Status
22337 Notifications</quote> &ndash; hence the name of the option). The default setting is:
22338 </para>
22339 <literallayout class="monospaced">
22340 dsn_from = Mail Delivery System &lt;Mailer-Daemon@$qualify_domain&gt;
22341 </literallayout>
22342 <para>
22343 The value is expanded every time it is needed. If the expansion fails, a
22344 panic is logged, and the default value is used.
22345 </para>
22346 <para>
22347 <indexterm role="option">
22348 <primary><option>envelope_to_remove</option></primary>
22349 </indexterm>
22350 </para>
22351 <informaltable frame="all">
22352 <tgroup cols="4" colsep="0" rowsep="0">
22353 <colspec colwidth="8*" align="left"/>
22354 <colspec colwidth="6*" align="center"/>
22355 <colspec colwidth="6*" align="center"/>
22356 <colspec colwidth="6*" align="right"/>
22357 <tbody>
22358 <row>
22359 <entry><option>envelope_to_remove</option></entry>
22360 <entry>Use: <emphasis>main</emphasis></entry>
22361 <entry>Type: <emphasis>boolean</emphasis></entry>
22362 <entry>Default: <emphasis>true</emphasis></entry>
22363 </row>
22364 </tbody>
22365 </tgroup>
22366 </informaltable>
22367 <para>
22368 <indexterm role="concept">
22369 <primary><emphasis>Envelope-to:</emphasis> header line</primary>
22370 </indexterm>
22371 Exim&#x2019;s transports have an option for adding an <emphasis>Envelope-to:</emphasis> header to a
22372 message when it is delivered, in exactly the same way as <emphasis>Return-path:</emphasis> is
22373 handled. <emphasis>Envelope-to:</emphasis> records the original recipient address from the
22374 messages&#x2019;s envelope that caused the delivery to happen. Such headers should not
22375 be present in incoming messages, and this option causes them to be removed at
22376 the time the message is received, to avoid any problems that might occur when a
22377 delivered message is subsequently sent on to some other recipient.
22378 </para>
22379 <para>
22380 <indexterm role="option">
22381 <primary><option>errors_copy</option></primary>
22382 </indexterm>
22383 </para>
22384 <informaltable frame="all">
22385 <tgroup cols="4" colsep="0" rowsep="0">
22386 <colspec colwidth="8*" align="left"/>
22387 <colspec colwidth="6*" align="center"/>
22388 <colspec colwidth="6*" align="center"/>
22389 <colspec colwidth="6*" align="right"/>
22390 <tbody>
22391 <row>
22392 <entry><option>errors_copy</option></entry>
22393 <entry>Use: <emphasis>main</emphasis></entry>
22394 <entry>Type: <emphasis>string list</emphasis>&dagger;<emphasis></emphasis></entry>
22395 <entry>Default: <emphasis>unset</emphasis></entry>
22396 </row>
22397 </tbody>
22398 </tgroup>
22399 </informaltable>
22400 <para>
22401 <indexterm role="concept">
22402 <primary>bounce message</primary>
22403 <secondary>copy to other address</secondary>
22404 </indexterm>
22405 <indexterm role="concept">
22406 <primary>copy of bounce message</primary>
22407 </indexterm>
22408 Setting this option causes Exim to send bcc copies of bounce messages that it
22409 generates to other addresses. <emphasis role="bold">Note</emphasis>: This does not apply to bounce messages
22410 coming from elsewhere. The value of the option is a colon-separated list of
22411 items. Each item consists of a pattern, terminated by white space, followed by
22412 a comma-separated list of email addresses. If a pattern contains spaces, it
22413 must be enclosed in double quotes.
22414 </para>
22415 <para>
22416 Each pattern is processed in the same way as a single item in an address list
22417 (see section <xref linkend="SECTaddresslist"/>). When a pattern matches the recipient of
22418 the bounce message, the message is copied to the addresses on the list. The
22419 items are scanned in order, and once a matching one is found, no further items
22420 are examined. For example:
22421 </para>
22422 <literallayout class="monospaced">
22423 errors_copy = spqr@mydomain   postmaster@mydomain.example :\
22424               rqps@mydomain   hostmaster@mydomain.example,\
22425                               postmaster@mydomain.example
22426 </literallayout>
22427 <para>
22428 <indexterm role="variable">
22429 <primary><varname>$domain</varname></primary>
22430 </indexterm>
22431 <indexterm role="variable">
22432 <primary><varname>$local_part</varname></primary>
22433 </indexterm>
22434 The address list is expanded before use. The expansion variables <varname>$local_part</varname>
22435 and <varname>$domain</varname> are set from the original recipient of the error message, and if
22436 there was any wildcard matching in the pattern, the expansion
22437 <indexterm role="concept">
22438 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
22439 <secondary>in <option>errors_copy</option></secondary>
22440 </indexterm>
22441 variables <varname>$0</varname>, <varname>$1</varname>, etc. are set in the normal way.
22442 </para>
22443 <para>
22444 <indexterm role="option">
22445 <primary><option>errors_reply_to</option></primary>
22446 </indexterm>
22447 </para>
22448 <informaltable frame="all">
22449 <tgroup cols="4" colsep="0" rowsep="0">
22450 <colspec colwidth="8*" align="left"/>
22451 <colspec colwidth="6*" align="center"/>
22452 <colspec colwidth="6*" align="center"/>
22453 <colspec colwidth="6*" align="right"/>
22454 <tbody>
22455 <row>
22456 <entry><option>errors_reply_to</option></entry>
22457 <entry>Use: <emphasis>main</emphasis></entry>
22458 <entry>Type: <emphasis>string</emphasis></entry>
22459 <entry>Default: <emphasis>unset</emphasis></entry>
22460 </row>
22461 </tbody>
22462 </tgroup>
22463 </informaltable>
22464 <para>
22465 <indexterm role="concept">
22466 <primary>bounce message</primary>
22467 <secondary><emphasis>Reply-to:</emphasis> in</secondary>
22468 </indexterm>
22469 By default, Exim&#x2019;s bounce and delivery warning messages contain the header line
22470 </para>
22471 <literallayout>
22472 <literal>From: Mail Delivery System &lt;Mailer-Daemon@</literal><emphasis>qualify-domain</emphasis><literal>&gt;</literal>
22473 </literallayout>
22474 <para>
22475 <indexterm role="option">
22476 <primary><option>quota_warn_message</option></primary>
22477 </indexterm>
22478 where <emphasis>qualify-domain</emphasis> is the value of the <option>qualify_domain</option> option.
22479 A warning message that is generated by the <option>quota_warn_message</option> option in an
22480 <command>appendfile</command> transport may contain its own <emphasis>From:</emphasis> header line that
22481 overrides the default.
22482 </para>
22483 <para>
22484 Experience shows that people reply to bounce messages. If the
22485 <option>errors_reply_to</option> option is set, a <emphasis>Reply-To:</emphasis> header is added to bounce
22486 and warning messages. For example:
22487 </para>
22488 <literallayout class="monospaced">
22489 errors_reply_to = postmaster@my.domain.example
22490 </literallayout>
22491 <para>
22492 The value of the option is not expanded. It must specify a valid RFC 2822
22493 address. However, if a warning message that is generated by the
22494 <option>quota_warn_message</option> option in an <command>appendfile</command> transport contain its
22495 own <emphasis>Reply-To:</emphasis> header line, the value of the <option>errors_reply_to</option> option is
22496 not used.
22497 </para>
22498 <para>
22499 <indexterm role="option">
22500 <primary><option>exim_group</option></primary>
22501 </indexterm>
22502 </para>
22503 <informaltable frame="all">
22504 <tgroup cols="4" colsep="0" rowsep="0">
22505 <colspec colwidth="8*" align="left"/>
22506 <colspec colwidth="6*" align="center"/>
22507 <colspec colwidth="6*" align="center"/>
22508 <colspec colwidth="6*" align="right"/>
22509 <tbody>
22510 <row>
22511 <entry><option>exim_group</option></entry>
22512 <entry>Use: <emphasis>main</emphasis></entry>
22513 <entry>Type: <emphasis>string</emphasis></entry>
22514 <entry>Default: <emphasis>compile-time configured</emphasis></entry>
22515 </row>
22516 </tbody>
22517 </tgroup>
22518 </informaltable>
22519 <para>
22520 <indexterm role="concept">
22521 <primary>gid (group id)</primary>
22522 <secondary>Exim&#x2019;s own</secondary>
22523 </indexterm>
22524 <indexterm role="concept">
22525 <primary>Exim group</primary>
22526 </indexterm>
22527 This option changes the gid under which Exim runs when it gives up root
22528 privilege. The default value is compiled into the binary. The value of this
22529 option is used only when <option>exim_user</option> is also set. Unless it consists entirely
22530 of digits, the string is looked up using <function>getgrnam()</function>, and failure causes a
22531 configuration error. See chapter <xref linkend="CHAPsecurity"/> for a discussion of
22532 security issues.
22533 </para>
22534 <para>
22535 <indexterm role="option">
22536 <primary><option>exim_path</option></primary>
22537 </indexterm>
22538 </para>
22539 <informaltable frame="all">
22540 <tgroup cols="4" colsep="0" rowsep="0">
22541 <colspec colwidth="8*" align="left"/>
22542 <colspec colwidth="6*" align="center"/>
22543 <colspec colwidth="6*" align="center"/>
22544 <colspec colwidth="6*" align="right"/>
22545 <tbody>
22546 <row>
22547 <entry><option>exim_path</option></entry>
22548 <entry>Use: <emphasis>main</emphasis></entry>
22549 <entry>Type: <emphasis>string</emphasis></entry>
22550 <entry>Default: <emphasis>see below</emphasis></entry>
22551 </row>
22552 </tbody>
22553 </tgroup>
22554 </informaltable>
22555 <para>
22556 <indexterm role="concept">
22557 <primary>Exim binary, path name</primary>
22558 </indexterm>
22559 This option specifies the path name of the Exim binary, which is used when Exim
22560 needs to re-exec itself. The default is set up to point to the file <emphasis>exim</emphasis> in
22561 the directory configured at compile time by the BIN_DIRECTORY setting. It
22562 is necessary to change <option>exim_path</option> if, exceptionally, Exim is run from some
22563 other place.
22564 <emphasis role="bold">Warning</emphasis>: Do not use a macro to define the value of this option, because
22565 you will break those Exim utilities that scan the configuration file to find
22566 where the binary is. (They then use the <option>-bP</option> option to extract option
22567 settings such as the value of <option>spool_directory</option>.)
22568 </para>
22569 <para>
22570 <indexterm role="option">
22571 <primary><option>exim_user</option></primary>
22572 </indexterm>
22573 </para>
22574 <informaltable frame="all">
22575 <tgroup cols="4" colsep="0" rowsep="0">
22576 <colspec colwidth="8*" align="left"/>
22577 <colspec colwidth="6*" align="center"/>
22578 <colspec colwidth="6*" align="center"/>
22579 <colspec colwidth="6*" align="right"/>
22580 <tbody>
22581 <row>
22582 <entry><option>exim_user</option></entry>
22583 <entry>Use: <emphasis>main</emphasis></entry>
22584 <entry>Type: <emphasis>string</emphasis></entry>
22585 <entry>Default: <emphasis>compile-time configured</emphasis></entry>
22586 </row>
22587 </tbody>
22588 </tgroup>
22589 </informaltable>
22590 <para>
22591 <indexterm role="concept">
22592 <primary>uid (user id)</primary>
22593 <secondary>Exim&#x2019;s own</secondary>
22594 </indexterm>
22595 <indexterm role="concept">
22596 <primary>Exim user</primary>
22597 </indexterm>
22598 This option changes the uid under which Exim runs when it gives up root
22599 privilege. The default value is compiled into the binary. Ownership of the run
22600 time configuration file and the use of the <option>-C</option> and <option>-D</option> command line
22601 options is checked against the values in the binary, not what is set here.
22602 </para>
22603 <para>
22604 Unless it consists entirely of digits, the string is looked up using
22605 <function>getpwnam()</function>, and failure causes a configuration error. If <option>exim_group</option> is
22606 not also supplied, the gid is taken from the result of <function>getpwnam()</function> if it is
22607 used. See chapter <xref linkend="CHAPsecurity"/> for a discussion of security issues.
22608 </para>
22609 <para>
22610 <indexterm role="option">
22611 <primary><option>extra_local_interfaces</option></primary>
22612 </indexterm>
22613 </para>
22614 <informaltable frame="all">
22615 <tgroup cols="4" colsep="0" rowsep="0">
22616 <colspec colwidth="8*" align="left"/>
22617 <colspec colwidth="6*" align="center"/>
22618 <colspec colwidth="6*" align="center"/>
22619 <colspec colwidth="6*" align="right"/>
22620 <tbody>
22621 <row>
22622 <entry><option>extra_local_interfaces</option></entry>
22623 <entry>Use: <emphasis>main</emphasis></entry>
22624 <entry>Type: <emphasis>string list</emphasis></entry>
22625 <entry>Default: <emphasis>unset</emphasis></entry>
22626 </row>
22627 </tbody>
22628 </tgroup>
22629 </informaltable>
22630 <para>
22631 This option defines network interfaces that are to be considered local when
22632 routing, but which are not used for listening by the daemon. See section
22633 <xref linkend="SECTreclocipadd"/> for details.
22634 </para>
22635 <para>
22636 <indexterm role="option">
22637 <primary><option>extract_addresses_remove_arguments</option></primary>
22638 </indexterm>
22639 </para>
22640 <informaltable frame="all">
22641 <tgroup cols="4" colsep="0" rowsep="0">
22642 <colspec colwidth="8*" align="left"/>
22643 <colspec colwidth="6*" align="center"/>
22644 <colspec colwidth="6*" align="center"/>
22645 <colspec colwidth="6*" align="right"/>
22646 <tbody>
22647 <row>
22648 <entry><option>extract_addresses_remove_ &nbsp;&nbsp;arguments</option></entry>
22649 <entry>Use: <emphasis>main</emphasis></entry>
22650 <entry>Type: <emphasis>boolean</emphasis></entry>
22651 <entry>Default: <emphasis>true</emphasis></entry>
22652 </row>
22653 </tbody>
22654 </tgroup>
22655 </informaltable>
22656 <para>
22657 <indexterm role="option">
22658 <primary><option>-t</option></primary>
22659 </indexterm>
22660 <indexterm role="concept">
22661 <primary>command line</primary>
22662 <secondary>addresses with <option>-t</option></secondary>
22663 </indexterm>
22664 <indexterm role="concept">
22665 <primary>Sendmail compatibility</primary>
22666 <secondary><option>-t</option> option</secondary>
22667 </indexterm>
22668 According to some Sendmail documentation (Sun, IRIX, HP-UX), if any addresses
22669 are present on the command line when the <option>-t</option> option is used to build an
22670 envelope from a message&#x2019;s <emphasis>To:</emphasis>, <emphasis>Cc:</emphasis> and <emphasis>Bcc:</emphasis> headers, the command
22671 line addresses are removed from the recipients list. This is also how Smail
22672 behaves. However, other Sendmail documentation (the O&#x2019;Reilly book) states that
22673 command line addresses are added to those obtained from the header lines. When
22674 <option>extract_addresses_remove_arguments</option> is true (the default), Exim subtracts
22675 argument headers. If it is set false, Exim adds rather than removes argument
22676 addresses.
22677 </para>
22678 <para>
22679 <indexterm role="option">
22680 <primary><option>finduser_retries</option></primary>
22681 </indexterm>
22682 </para>
22683 <informaltable frame="all">
22684 <tgroup cols="4" colsep="0" rowsep="0">
22685 <colspec colwidth="8*" align="left"/>
22686 <colspec colwidth="6*" align="center"/>
22687 <colspec colwidth="6*" align="center"/>
22688 <colspec colwidth="6*" align="right"/>
22689 <tbody>
22690 <row>
22691 <entry><option>finduser_retries</option></entry>
22692 <entry>Use: <emphasis>main</emphasis></entry>
22693 <entry>Type: <emphasis>integer</emphasis></entry>
22694 <entry>Default: <emphasis>0</emphasis></entry>
22695 </row>
22696 </tbody>
22697 </tgroup>
22698 </informaltable>
22699 <para>
22700 <indexterm role="concept">
22701 <primary>NIS, retrying user lookups</primary>
22702 </indexterm>
22703 On systems running NIS or other schemes in which user and group information is
22704 distributed from a remote system, there can be times when <function>getpwnam()</function> and
22705 related functions fail, even when given valid data, because things time out.
22706 Unfortunately these failures cannot be distinguished from genuine <quote>not found</quote>
22707 errors. If <option>finduser_retries</option> is set greater than zero, Exim will try that
22708 many extra times to find a user or a group, waiting for one second between
22709 retries.
22710 </para>
22711 <para>
22712 <indexterm role="concept">
22713 <primary><filename>/etc/passwd</filename></primary>
22714 <secondary>multiple reading of</secondary>
22715 </indexterm>
22716 You should not set this option greater than zero if your user information is in
22717 a traditional <filename>/etc/passwd</filename> file, because it will cause Exim needlessly to
22718 search the file multiple times for non-existent users, and also cause delay.
22719 </para>
22720 <para>
22721 <indexterm role="option">
22722 <primary><option>freeze_tell</option></primary>
22723 </indexterm>
22724 </para>
22725 <informaltable frame="all">
22726 <tgroup cols="4" colsep="0" rowsep="0">
22727 <colspec colwidth="8*" align="left"/>
22728 <colspec colwidth="6*" align="center"/>
22729 <colspec colwidth="6*" align="center"/>
22730 <colspec colwidth="6*" align="right"/>
22731 <tbody>
22732 <row>
22733 <entry><option>freeze_tell</option></entry>
22734 <entry>Use: <emphasis>main</emphasis></entry>
22735 <entry>Type: <emphasis>string list, comma separated</emphasis></entry>
22736 <entry>Default: <emphasis>unset</emphasis></entry>
22737 </row>
22738 </tbody>
22739 </tgroup>
22740 </informaltable>
22741 <para>
22742 <indexterm role="concept">
22743 <primary>freezing messages</primary>
22744 <secondary>sending a message when freezing</secondary>
22745 </indexterm>
22746 On encountering certain errors, or when configured to do so in a system filter,
22747 ACL, or special router, Exim freezes a message. This means that no further
22748 delivery attempts take place until an administrator thaws the message, or the
22749 <option>auto_thaw</option>, <option>ignore_bounce_errors_after</option>, or <option>timeout_frozen_after</option>
22750 feature cause it to be processed. If <option>freeze_tell</option> is set, Exim generates a
22751 warning message whenever it freezes something, unless the message it is
22752 freezing is a locally-generated bounce message. (Without this exception there
22753 is the possibility of looping.) The warning message is sent to the addresses
22754 supplied as the comma-separated value of this option. If several of the
22755 message&#x2019;s addresses cause freezing, only a single message is sent. If the
22756 freezing was automatic, the reason(s) for freezing can be found in the message
22757 log. If you configure freezing in a filter or ACL, you must arrange for any
22758 logging that you require.
22759 </para>
22760 <para>
22761 <indexterm role="option">
22762 <primary><option>gecos_name</option></primary>
22763 </indexterm>
22764 </para>
22765 <informaltable frame="all">
22766 <tgroup cols="4" colsep="0" rowsep="0">
22767 <colspec colwidth="8*" align="left"/>
22768 <colspec colwidth="6*" align="center"/>
22769 <colspec colwidth="6*" align="center"/>
22770 <colspec colwidth="6*" align="right"/>
22771 <tbody>
22772 <row>
22773 <entry><option>gecos_name</option></entry>
22774 <entry>Use: <emphasis>main</emphasis></entry>
22775 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
22776 <entry>Default: <emphasis>unset</emphasis></entry>
22777 </row>
22778 </tbody>
22779 </tgroup>
22780 </informaltable>
22781 <para>
22782 <indexterm role="concept">
22783 <primary>HP-UX</primary>
22784 </indexterm>
22785 <indexterm role="concept">
22786 <primary><quote>gecos</quote> field, parsing</primary>
22787 </indexterm>
22788 Some operating systems, notably HP-UX, use the <quote>gecos</quote> field in the system
22789 password file to hold other information in addition to users&#x2019; real names. Exim
22790 looks up this field for use when it is creating <emphasis>Sender:</emphasis> or <emphasis>From:</emphasis>
22791 headers. If either <option>gecos_pattern</option> or <option>gecos_name</option> are unset, the contents
22792 of the field are used unchanged, except that, if an ampersand is encountered,
22793 it is replaced by the user&#x2019;s login name with the first character forced to
22794 upper case, since this is a convention that is observed on many systems.
22795 </para>
22796 <para>
22797 When these options are set, <option>gecos_pattern</option> is treated as a regular
22798 expression that is to be applied to the field (again with &amp; replaced by the
22799 login name), and if it matches, <option>gecos_name</option> is expanded and used as the
22800 user&#x2019;s name.
22801 </para>
22802 <para>
22803 <indexterm role="concept">
22804 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
22805 <secondary>in <option>gecos_name</option></secondary>
22806 </indexterm>
22807 Numeric variables such as <varname>$1</varname>, <varname>$2</varname>, etc. can be used in the expansion to
22808 pick up sub-fields that were matched by the pattern. In HP-UX, where the user&#x2019;s
22809 name terminates at the first comma, the following can be used:
22810 </para>
22811 <literallayout class="monospaced">
22812 gecos_pattern = ([^,]*)
22813 gecos_name = $1
22814 </literallayout>
22815 <para>
22816 <indexterm role="option">
22817 <primary><option>gecos_pattern</option></primary>
22818 </indexterm>
22819 </para>
22820 <informaltable frame="all">
22821 <tgroup cols="4" colsep="0" rowsep="0">
22822 <colspec colwidth="8*" align="left"/>
22823 <colspec colwidth="6*" align="center"/>
22824 <colspec colwidth="6*" align="center"/>
22825 <colspec colwidth="6*" align="right"/>
22826 <tbody>
22827 <row>
22828 <entry><option>gecos_pattern</option></entry>
22829 <entry>Use: <emphasis>main</emphasis></entry>
22830 <entry>Type: <emphasis>string</emphasis></entry>
22831 <entry>Default: <emphasis>unset</emphasis></entry>
22832 </row>
22833 </tbody>
22834 </tgroup>
22835 </informaltable>
22836 <para>
22837 See <option>gecos_name</option> above.
22838 </para>
22839 <para>
22840 <indexterm role="option">
22841 <primary><option>gnutls_require_kx</option></primary>
22842 </indexterm>
22843 </para>
22844 <informaltable frame="all">
22845 <tgroup cols="4" colsep="0" rowsep="0">
22846 <colspec colwidth="8*" align="left"/>
22847 <colspec colwidth="6*" align="center"/>
22848 <colspec colwidth="6*" align="center"/>
22849 <colspec colwidth="6*" align="right"/>
22850 <tbody>
22851 <row>
22852 <entry><option>gnutls_require_kx</option></entry>
22853 <entry>Use: <emphasis>main</emphasis></entry>
22854 <entry>Type: <emphasis>string</emphasis></entry>
22855 <entry>Default: <emphasis>unset</emphasis></entry>
22856 </row>
22857 </tbody>
22858 </tgroup>
22859 </informaltable>
22860 <para>
22861 This option controls the key exchange mechanisms when GnuTLS is used in an Exim
22862 server. For details, see section <xref linkend="SECTreqciphgnu"/>.
22863 </para>
22864 <para>
22865 <indexterm role="option">
22866 <primary><option>gnutls_require_mac</option></primary>
22867 </indexterm>
22868 </para>
22869 <informaltable frame="all">
22870 <tgroup cols="4" colsep="0" rowsep="0">
22871 <colspec colwidth="8*" align="left"/>
22872 <colspec colwidth="6*" align="center"/>
22873 <colspec colwidth="6*" align="center"/>
22874 <colspec colwidth="6*" align="right"/>
22875 <tbody>
22876 <row>
22877 <entry><option>gnutls_require_mac</option></entry>
22878 <entry>Use: <emphasis>main</emphasis></entry>
22879 <entry>Type: <emphasis>string</emphasis></entry>
22880 <entry>Default: <emphasis>unset</emphasis></entry>
22881 </row>
22882 </tbody>
22883 </tgroup>
22884 </informaltable>
22885 <para>
22886 This option controls the MAC algorithms when GnuTLS is used in an Exim
22887 server. For details, see section <xref linkend="SECTreqciphgnu"/>.
22888 </para>
22889 <para>
22890 <indexterm role="option">
22891 <primary><option>gnutls_require_protocols</option></primary>
22892 </indexterm>
22893 </para>
22894 <informaltable frame="all">
22895 <tgroup cols="4" colsep="0" rowsep="0">
22896 <colspec colwidth="8*" align="left"/>
22897 <colspec colwidth="6*" align="center"/>
22898 <colspec colwidth="6*" align="center"/>
22899 <colspec colwidth="6*" align="right"/>
22900 <tbody>
22901 <row>
22902 <entry><option>gnutls_require_protocols</option></entry>
22903 <entry>Use: <emphasis>main</emphasis></entry>
22904 <entry>Type: <emphasis>string</emphasis></entry>
22905 <entry>Default: <emphasis>unset</emphasis></entry>
22906 </row>
22907 </tbody>
22908 </tgroup>
22909 </informaltable>
22910 <para>
22911 This option controls the protocols when GnuTLS is used in an Exim
22912 server. For details, see section <xref linkend="SECTreqciphgnu"/>.
22913 </para>
22914 <para>
22915 <indexterm role="option">
22916 <primary><option>gnutls_compat_mode</option></primary>
22917 </indexterm>
22918 </para>
22919 <informaltable frame="all">
22920 <tgroup cols="4" colsep="0" rowsep="0">
22921 <colspec colwidth="8*" align="left"/>
22922 <colspec colwidth="6*" align="center"/>
22923 <colspec colwidth="6*" align="center"/>
22924 <colspec colwidth="6*" align="right"/>
22925 <tbody>
22926 <row>
22927 <entry><option>gnutls_compat_mode</option></entry>
22928 <entry>Use: <emphasis>main</emphasis></entry>
22929 <entry>Type: <emphasis>boolean</emphasis></entry>
22930 <entry>Default: <emphasis>unset</emphasis></entry>
22931 </row>
22932 </tbody>
22933 </tgroup>
22934 </informaltable>
22935 <para>
22936 This option controls whether GnuTLS is used in compatibility mode in an Exim
22937 server. This reduces security slightly, but improves interworking with older
22938 implementations of TLS.
22939 </para>
22940 <para>
22941 <indexterm role="option">
22942 <primary><option>headers_charset</option></primary>
22943 </indexterm>
22944 </para>
22945 <informaltable frame="all">
22946 <tgroup cols="4" colsep="0" rowsep="0">
22947 <colspec colwidth="8*" align="left"/>
22948 <colspec colwidth="6*" align="center"/>
22949 <colspec colwidth="6*" align="center"/>
22950 <colspec colwidth="6*" align="right"/>
22951 <tbody>
22952 <row>
22953 <entry><option>headers_charset</option></entry>
22954 <entry>Use: <emphasis>main</emphasis></entry>
22955 <entry>Type: <emphasis>string</emphasis></entry>
22956 <entry>Default: <emphasis>see below</emphasis></entry>
22957 </row>
22958 </tbody>
22959 </tgroup>
22960 </informaltable>
22961 <para>
22962 This option sets a default character set for translating from encoded MIME
22963 <quote>words</quote> in header lines, when referenced by an <varname>$h_xxx</varname> expansion item. The
22964 default is the value of HEADERS_CHARSET in <filename>Local/Makefile</filename>. The
22965 ultimate default is ISO-8859-1. For more details see the description of header
22966 insertions in section <xref linkend="SECTexpansionitems"/>.
22967 </para>
22968 <para>
22969 <indexterm role="option">
22970 <primary><option>header_maxsize</option></primary>
22971 </indexterm>
22972 </para>
22973 <informaltable frame="all">
22974 <tgroup cols="4" colsep="0" rowsep="0">
22975 <colspec colwidth="8*" align="left"/>
22976 <colspec colwidth="6*" align="center"/>
22977 <colspec colwidth="6*" align="center"/>
22978 <colspec colwidth="6*" align="right"/>
22979 <tbody>
22980 <row>
22981 <entry><option>header_maxsize</option></entry>
22982 <entry>Use: <emphasis>main</emphasis></entry>
22983 <entry>Type: <emphasis>integer</emphasis></entry>
22984 <entry>Default: <emphasis>see below</emphasis></entry>
22985 </row>
22986 </tbody>
22987 </tgroup>
22988 </informaltable>
22989 <para>
22990 <indexterm role="concept">
22991 <primary>header section</primary>
22992 <secondary>maximum size of</secondary>
22993 </indexterm>
22994 <indexterm role="concept">
22995 <primary>limit</primary>
22996 <secondary>size of message header section</secondary>
22997 </indexterm>
22998 This option controls the overall maximum size of a message&#x2019;s header
22999 section. The default is the value of HEADER_MAXSIZE in
23000 <filename>Local/Makefile</filename>; the default for that is 1M. Messages with larger header
23001 sections are rejected.
23002 </para>
23003 <para>
23004 <indexterm role="option">
23005 <primary><option>header_line_maxsize</option></primary>
23006 </indexterm>
23007 </para>
23008 <informaltable frame="all">
23009 <tgroup cols="4" colsep="0" rowsep="0">
23010 <colspec colwidth="8*" align="left"/>
23011 <colspec colwidth="6*" align="center"/>
23012 <colspec colwidth="6*" align="center"/>
23013 <colspec colwidth="6*" align="right"/>
23014 <tbody>
23015 <row>
23016 <entry><option>header_line_maxsize</option></entry>
23017 <entry>Use: <emphasis>main</emphasis></entry>
23018 <entry>Type: <emphasis>integer</emphasis></entry>
23019 <entry>Default: <emphasis>0</emphasis></entry>
23020 </row>
23021 </tbody>
23022 </tgroup>
23023 </informaltable>
23024 <para>
23025 <indexterm role="concept">
23026 <primary>header lines</primary>
23027 <secondary>maximum size of</secondary>
23028 </indexterm>
23029 <indexterm role="concept">
23030 <primary>limit</primary>
23031 <secondary>size of one header line</secondary>
23032 </indexterm>
23033 This option limits the length of any individual header line in a message, after
23034 all the continuations have been joined together. Messages with individual
23035 header lines that are longer than the limit are rejected. The default value of
23036 zero means <quote>no limit</quote>.
23037 </para>
23038 <para>
23039 <indexterm role="option">
23040 <primary><option>helo_accept_junk_hosts</option></primary>
23041 </indexterm>
23042 </para>
23043 <informaltable frame="all">
23044 <tgroup cols="4" colsep="0" rowsep="0">
23045 <colspec colwidth="8*" align="left"/>
23046 <colspec colwidth="6*" align="center"/>
23047 <colspec colwidth="6*" align="center"/>
23048 <colspec colwidth="6*" align="right"/>
23049 <tbody>
23050 <row>
23051 <entry><option>helo_accept_junk_hosts</option></entry>
23052 <entry>Use: <emphasis>main</emphasis></entry>
23053 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
23054 <entry>Default: <emphasis>unset</emphasis></entry>
23055 </row>
23056 </tbody>
23057 </tgroup>
23058 </informaltable>
23059 <para>
23060 <indexterm role="concept">
23061 <primary>HELO</primary>
23062 <secondary>accepting junk data</secondary>
23063 </indexterm>
23064 <indexterm role="concept">
23065 <primary>EHLO</primary>
23066 <secondary>accepting junk data</secondary>
23067 </indexterm>
23068 Exim checks the syntax of HELO and EHLO commands for incoming SMTP
23069 mail, and gives an error response for invalid data. Unfortunately, there are
23070 some SMTP clients that send syntactic junk. They can be accommodated by setting
23071 this option. Note that this is a syntax check only. See <option>helo_verify_hosts</option>
23072 if you want to do semantic checking.
23073 See also <option>helo_allow_chars</option> for a way of extending the permitted character
23074 set.
23075 </para>
23076 <para>
23077 <indexterm role="option">
23078 <primary><option>helo_allow_chars</option></primary>
23079 </indexterm>
23080 </para>
23081 <informaltable frame="all">
23082 <tgroup cols="4" colsep="0" rowsep="0">
23083 <colspec colwidth="8*" align="left"/>
23084 <colspec colwidth="6*" align="center"/>
23085 <colspec colwidth="6*" align="center"/>
23086 <colspec colwidth="6*" align="right"/>
23087 <tbody>
23088 <row>
23089 <entry><option>helo_allow_chars</option></entry>
23090 <entry>Use: <emphasis>main</emphasis></entry>
23091 <entry>Type: <emphasis>string</emphasis></entry>
23092 <entry>Default: <emphasis>unset</emphasis></entry>
23093 </row>
23094 </tbody>
23095 </tgroup>
23096 </informaltable>
23097 <para>
23098 <indexterm role="concept">
23099 <primary>HELO</primary>
23100 <secondary>underscores in</secondary>
23101 </indexterm>
23102 <indexterm role="concept">
23103 <primary>EHLO</primary>
23104 <secondary>underscores in</secondary>
23105 </indexterm>
23106 <indexterm role="concept">
23107 <primary>underscore in EHLO/HELO</primary>
23108 </indexterm>
23109 This option can be set to a string of rogue characters that are permitted in
23110 all EHLO and HELO names in addition to the standard letters, digits,
23111 hyphens, and dots. If you really must allow underscores, you can set
23112 </para>
23113 <literallayout class="monospaced">
23114 helo_allow_chars = _
23115 </literallayout>
23116 <para>
23117 Note that the value is one string, not a list.
23118 </para>
23119 <para>
23120 <indexterm role="option">
23121 <primary><option>helo_lookup_domains</option></primary>
23122 </indexterm>
23123 </para>
23124 <informaltable frame="all">
23125 <tgroup cols="4" colsep="0" rowsep="0">
23126 <colspec colwidth="8*" align="left"/>
23127 <colspec colwidth="6*" align="center"/>
23128 <colspec colwidth="6*" align="center"/>
23129 <colspec colwidth="6*" align="right"/>
23130 <tbody>
23131 <row>
23132 <entry><option>helo_lookup_domains</option></entry>
23133 <entry>Use: <emphasis>main</emphasis></entry>
23134 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
23135 <entry>Default: <emphasis><literal>@:@[]</literal></emphasis></entry>
23136 </row>
23137 </tbody>
23138 </tgroup>
23139 </informaltable>
23140 <para>
23141 <indexterm role="concept">
23142 <primary>HELO</primary>
23143 <secondary>forcing reverse lookup</secondary>
23144 </indexterm>
23145 <indexterm role="concept">
23146 <primary>EHLO</primary>
23147 <secondary>forcing reverse lookup</secondary>
23148 </indexterm>
23149 If the domain given by a client in a HELO or EHLO command matches this
23150 list, a reverse lookup is done in order to establish the host&#x2019;s true name. The
23151 default forces a lookup if the client host gives the server&#x2019;s name or any of
23152 its IP addresses (in brackets), something that broken clients have been seen to
23153 do.
23154 </para>
23155 <para>
23156 <indexterm role="option">
23157 <primary><option>helo_try_verify_hosts</option></primary>
23158 </indexterm>
23159 </para>
23160 <informaltable frame="all">
23161 <tgroup cols="4" colsep="0" rowsep="0">
23162 <colspec colwidth="8*" align="left"/>
23163 <colspec colwidth="6*" align="center"/>
23164 <colspec colwidth="6*" align="center"/>
23165 <colspec colwidth="6*" align="right"/>
23166 <tbody>
23167 <row>
23168 <entry><option>helo_try_verify_hosts</option></entry>
23169 <entry>Use: <emphasis>main</emphasis></entry>
23170 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
23171 <entry>Default: <emphasis>unset</emphasis></entry>
23172 </row>
23173 </tbody>
23174 </tgroup>
23175 </informaltable>
23176 <para>
23177 <indexterm role="concept">
23178 <primary>HELO verifying</primary>
23179 <secondary>optional</secondary>
23180 </indexterm>
23181 <indexterm role="concept">
23182 <primary>EHLO</primary>
23183 <secondary>verifying, optional</secondary>
23184 </indexterm>
23185 By default, Exim just checks the syntax of HELO and EHLO commands (see
23186 <option>helo_accept_junk_hosts</option> and <option>helo_allow_chars</option>). However, some sites like
23187 to do more extensive checking of the data supplied by these commands. The ACL
23188 condition <literal>verify = helo</literal> is provided to make this possible.
23189 Formerly, it was necessary also to set this option (<option>helo_try_verify_hosts</option>)
23190 to force the check to occur. From release 4.53 onwards, this is no longer
23191 necessary. If the check has not been done before <literal>verify = helo</literal> is
23192 encountered, it is done at that time. Consequently, this option is obsolete.
23193 Its specification is retained here for backwards compatibility.
23194 </para>
23195 <para>
23196 When an EHLO or HELO command is received, if the calling host matches
23197 <option>helo_try_verify_hosts</option>, Exim checks that the host name given in the HELO or
23198 EHLO command either:
23199 </para>
23200 <itemizedlist>
23201 <listitem>
23202 <para>
23203 is an IP literal matching the calling address of the host, or
23204 </para>
23205 </listitem>
23206 <listitem>
23207 <para>
23208 <indexterm role="concept">
23209 <primary>DNS</primary>
23210 <secondary>reverse lookup</secondary>
23211 </indexterm>
23212 <indexterm role="concept">
23213 <primary>reverse DNS lookup</primary>
23214 </indexterm>
23215 matches the host name that Exim obtains by doing a reverse lookup of the
23216 calling host address, or
23217 </para>
23218 </listitem>
23219 <listitem>
23220 <para>
23221 when looked up using <function>gethostbyname()</function> (or <function>getipnodebyname()</function> when
23222 available) yields the calling host address.
23223 </para>
23224 </listitem>
23225 </itemizedlist>
23226 <para>
23227 However, the EHLO or HELO command is not rejected if any of the checks
23228 fail. Processing continues, but the result of the check is remembered, and can
23229 be detected later in an ACL by the <literal>verify = helo</literal> condition.
23230 </para>
23231 <para>
23232 <indexterm role="option">
23233 <primary><option>helo_verify_hosts</option></primary>
23234 </indexterm>
23235 </para>
23236 <informaltable frame="all">
23237 <tgroup cols="4" colsep="0" rowsep="0">
23238 <colspec colwidth="8*" align="left"/>
23239 <colspec colwidth="6*" align="center"/>
23240 <colspec colwidth="6*" align="center"/>
23241 <colspec colwidth="6*" align="right"/>
23242 <tbody>
23243 <row>
23244 <entry><option>helo_verify_hosts</option></entry>
23245 <entry>Use: <emphasis>main</emphasis></entry>
23246 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
23247 <entry>Default: <emphasis>unset</emphasis></entry>
23248 </row>
23249 </tbody>
23250 </tgroup>
23251 </informaltable>
23252 <para>
23253 <indexterm role="concept">
23254 <primary>HELO verifying</primary>
23255 <secondary>mandatory</secondary>
23256 </indexterm>
23257 <indexterm role="concept">
23258 <primary>EHLO</primary>
23259 <secondary>verifying, mandatory</secondary>
23260 </indexterm>
23261 Like <option>helo_try_verify_hosts</option>, this option is obsolete, and retained only for
23262 backwards compatibility. For hosts that match this option, Exim checks the host
23263 name given in the HELO or EHLO in the same way as for
23264 <option>helo_try_verify_hosts</option>. If the check fails, the HELO or EHLO command is
23265 rejected with a 550 error, and entries are written to the main and reject logs.
23266 If a MAIL command is received before EHLO or HELO, it is rejected with a 503
23267 error.
23268 </para>
23269 <para>
23270 <indexterm role="option">
23271 <primary><option>hold_domains</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>hold_domains</option></entry>
23283 <entry>Use: <emphasis>main</emphasis></entry>
23284 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
23285 <entry>Default: <emphasis>unset</emphasis></entry>
23286 </row>
23287 </tbody>
23288 </tgroup>
23289 </informaltable>
23290 <para>
23291 <indexterm role="concept">
23292 <primary>domain</primary>
23293 <secondary>delaying delivery</secondary>
23294 </indexterm>
23295 <indexterm role="concept">
23296 <primary>delivery</primary>
23297 <secondary>delaying certain domains</secondary>
23298 </indexterm>
23299 This option allows mail for particular domains to be held on the queue
23300 manually. The option is overridden if a message delivery is forced with the
23301 <option>-M</option>, <option>-qf</option>, <option>-Rf</option> or <option>-Sf</option> options, and also while testing or
23302 verifying addresses using <option>-bt</option> or <option>-bv</option>. Otherwise, if a domain matches an
23303 item in <option>hold_domains</option>, no routing or delivery for that address is done, and
23304 it is deferred every time the message is looked at.
23305 </para>
23306 <para>
23307 This option is intended as a temporary operational measure for delaying the
23308 delivery of mail while some problem is being sorted out, or some new
23309 configuration tested. If you just want to delay the processing of some
23310 domains until a queue run occurs, you should use <option>queue_domains</option> or
23311 <option>queue_smtp_domains</option>, not <option>hold_domains</option>.
23312 </para>
23313 <para>
23314 A setting of <option>hold_domains</option> does not override Exim&#x2019;s code for removing
23315 messages from the queue if they have been there longer than the longest retry
23316 time in any retry rule. If you want to hold messages for longer than the normal
23317 retry times, insert a dummy retry rule with a long retry time.
23318 </para>
23319 <para>
23320 <indexterm role="option">
23321 <primary><option>host_lookup</option></primary>
23322 </indexterm>
23323 </para>
23324 <informaltable frame="all">
23325 <tgroup cols="4" colsep="0" rowsep="0">
23326 <colspec colwidth="8*" align="left"/>
23327 <colspec colwidth="6*" align="center"/>
23328 <colspec colwidth="6*" align="center"/>
23329 <colspec colwidth="6*" align="right"/>
23330 <tbody>
23331 <row>
23332 <entry><option>host_lookup</option></entry>
23333 <entry>Use: <emphasis>main</emphasis></entry>
23334 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
23335 <entry>Default: <emphasis>unset</emphasis></entry>
23336 </row>
23337 </tbody>
23338 </tgroup>
23339 </informaltable>
23340 <para>
23341 <indexterm role="concept">
23342 <primary>host name</primary>
23343 <secondary>lookup, forcing</secondary>
23344 </indexterm>
23345 Exim does not look up the name of a calling host from its IP address unless it
23346 is required to compare against some host list, or the host matches
23347 <option>helo_try_verify_hosts</option> or <option>helo_verify_hosts</option>, or the host matches this
23348 option (which normally contains IP addresses rather than host names). The
23349 default configuration file contains
23350 </para>
23351 <literallayout class="monospaced">
23352 host_lookup = *
23353 </literallayout>
23354 <para>
23355 which causes a lookup to happen for all hosts. If the expense of these lookups
23356 is felt to be too great, the setting can be changed or removed.
23357 </para>
23358 <para>
23359 After a successful reverse lookup, Exim does a forward lookup on the name it
23360 has obtained, to verify that it yields the IP address that it started with. If
23361 this check fails, Exim behaves as if the name lookup failed.
23362 </para>
23363 <para>
23364 <indexterm role="variable">
23365 <primary><varname>$host_lookup_failed</varname></primary>
23366 </indexterm>
23367 <indexterm role="variable">
23368 <primary><varname>$sender_host_name</varname></primary>
23369 </indexterm>
23370 After any kind of failure, the host name (in <varname>$sender_host_name</varname>) remains
23371 unset, and <varname>$host_lookup_failed</varname> is set to the string <quote>1</quote>. See also
23372 <option>dns_again_means_nonexist</option>, <option>helo_lookup_domains</option>, and
23373 <literal>verify = reverse_host_lookup</literal> in ACLs.
23374 </para>
23375 <para>
23376 <indexterm role="option">
23377 <primary><option>host_lookup_order</option></primary>
23378 </indexterm>
23379 </para>
23380 <informaltable frame="all">
23381 <tgroup cols="4" colsep="0" rowsep="0">
23382 <colspec colwidth="8*" align="left"/>
23383 <colspec colwidth="6*" align="center"/>
23384 <colspec colwidth="6*" align="center"/>
23385 <colspec colwidth="6*" align="right"/>
23386 <tbody>
23387 <row>
23388 <entry><option>host_lookup_order</option></entry>
23389 <entry>Use: <emphasis>main</emphasis></entry>
23390 <entry>Type: <emphasis>string list</emphasis></entry>
23391 <entry>Default: <emphasis><literal>bydns:byaddr</literal></emphasis></entry>
23392 </row>
23393 </tbody>
23394 </tgroup>
23395 </informaltable>
23396 <para>
23397 This option specifies the order of different lookup methods when Exim is trying
23398 to find a host name from an IP address. The default is to do a DNS lookup
23399 first, and then to try a local lookup (using <function>gethostbyaddr()</function> or equivalent)
23400 if that fails. You can change the order of these lookups, or omit one entirely,
23401 if you want.
23402 </para>
23403 <para>
23404 <emphasis role="bold">Warning</emphasis>: The <quote>byaddr</quote> method does not always yield aliases when there are
23405 multiple PTR records in the DNS and the IP address is not listed in
23406 <filename>/etc/hosts</filename>. Different operating systems give different results in this
23407 case. That is why the default tries a DNS lookup first.
23408 </para>
23409 <para>
23410 <indexterm role="option">
23411 <primary><option>host_reject_connection</option></primary>
23412 </indexterm>
23413 </para>
23414 <informaltable frame="all">
23415 <tgroup cols="4" colsep="0" rowsep="0">
23416 <colspec colwidth="8*" align="left"/>
23417 <colspec colwidth="6*" align="center"/>
23418 <colspec colwidth="6*" align="center"/>
23419 <colspec colwidth="6*" align="right"/>
23420 <tbody>
23421 <row>
23422 <entry><option>host_reject_connection</option></entry>
23423 <entry>Use: <emphasis>main</emphasis></entry>
23424 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
23425 <entry>Default: <emphasis>unset</emphasis></entry>
23426 </row>
23427 </tbody>
23428 </tgroup>
23429 </informaltable>
23430 <para>
23431 <indexterm role="concept">
23432 <primary>host</primary>
23433 <secondary>rejecting connections from</secondary>
23434 </indexterm>
23435 If this option is set, incoming SMTP calls from the hosts listed are rejected
23436 as soon as the connection is made.
23437 This option is obsolete, and retained only for backward compatibility, because
23438 nowadays the ACL specified by <option>acl_smtp_connect</option> can also reject incoming
23439 connections immediately.
23440 </para>
23441 <para>
23442 The ability to give an immediate rejection (either by this option or using an
23443 ACL) is provided for use in unusual cases. Many hosts will just try again,
23444 sometimes without much delay. Normally, it is better to use an ACL to reject
23445 incoming messages at a later stage, such as after RCPT commands. See
23446 chapter <xref linkend="CHAPACL"/>.
23447 </para>
23448 <para>
23449 <indexterm role="option">
23450 <primary><option>hosts_connection_nolog</option></primary>
23451 </indexterm>
23452 </para>
23453 <informaltable frame="all">
23454 <tgroup cols="4" colsep="0" rowsep="0">
23455 <colspec colwidth="8*" align="left"/>
23456 <colspec colwidth="6*" align="center"/>
23457 <colspec colwidth="6*" align="center"/>
23458 <colspec colwidth="6*" align="right"/>
23459 <tbody>
23460 <row>
23461 <entry><option>hosts_connection_nolog</option></entry>
23462 <entry>Use: <emphasis>main</emphasis></entry>
23463 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
23464 <entry>Default: <emphasis>unset</emphasis></entry>
23465 </row>
23466 </tbody>
23467 </tgroup>
23468 </informaltable>
23469 <para>
23470 <indexterm role="concept">
23471 <primary>host</primary>
23472 <secondary>not logging connections from</secondary>
23473 </indexterm>
23474 This option defines a list of hosts for which connection logging does not
23475 happen, even though the <option>smtp_connection</option> log selector is set. For example,
23476 you might want not to log SMTP connections from local processes, or from
23477 127.0.0.1, or from your local LAN. This option is consulted in the main loop of
23478 the daemon; you should therefore strive to restrict its value to a short inline
23479 list of IP addresses and networks. To disable logging SMTP connections from
23480 local processes, you must create a host list with an empty item. For example:
23481 </para>
23482 <literallayout class="monospaced">
23483 hosts_connection_nolog = :
23484 </literallayout>
23485 <para>
23486 If the <option>smtp_connection</option> log selector is not set, this option has no effect.
23487 </para>
23488 <para>
23489 <indexterm role="option">
23490 <primary><option>hosts_treat_as_local</option></primary>
23491 </indexterm>
23492 </para>
23493 <informaltable frame="all">
23494 <tgroup cols="4" colsep="0" rowsep="0">
23495 <colspec colwidth="8*" align="left"/>
23496 <colspec colwidth="6*" align="center"/>
23497 <colspec colwidth="6*" align="center"/>
23498 <colspec colwidth="6*" align="right"/>
23499 <tbody>
23500 <row>
23501 <entry><option>hosts_treat_as_local</option></entry>
23502 <entry>Use: <emphasis>main</emphasis></entry>
23503 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
23504 <entry>Default: <emphasis>unset</emphasis></entry>
23505 </row>
23506 </tbody>
23507 </tgroup>
23508 </informaltable>
23509 <para>
23510 <indexterm role="concept">
23511 <primary>local host</primary>
23512 <secondary>domains treated as</secondary>
23513 </indexterm>
23514 <indexterm role="concept">
23515 <primary>host</primary>
23516 <secondary>treated as local</secondary>
23517 </indexterm>
23518 If this option is set, any host names that match the domain list are treated as
23519 if they were the local host when Exim is scanning host lists obtained from MX
23520 records
23521 or other sources. Note that the value of this option is a domain list, not a
23522 host list, because it is always used to check host names, not IP addresses.
23523 </para>
23524 <para>
23525 This option also applies when Exim is matching the special items
23526 <literal>@mx_any</literal>, <literal>@mx_primary</literal>, and <literal>@mx_secondary</literal> in a domain list (see
23527 section <xref linkend="SECTdomainlist"/>), and when checking the <option>hosts</option> option in the
23528 <command>smtp</command> transport for the local host (see the <option>allow_localhost</option> option in
23529 that transport). See also <option>local_interfaces</option>, <option>extra_local_interfaces</option>, and
23530 chapter <xref linkend="CHAPinterfaces"/>, which contains a discussion about local network
23531 interfaces and recognizing the local host.
23532 </para>
23533 <para>
23534 <indexterm role="option">
23535 <primary><option>ibase_servers</option></primary>
23536 </indexterm>
23537 </para>
23538 <informaltable frame="all">
23539 <tgroup cols="4" colsep="0" rowsep="0">
23540 <colspec colwidth="8*" align="left"/>
23541 <colspec colwidth="6*" align="center"/>
23542 <colspec colwidth="6*" align="center"/>
23543 <colspec colwidth="6*" align="right"/>
23544 <tbody>
23545 <row>
23546 <entry><option>ibase_servers</option></entry>
23547 <entry>Use: <emphasis>main</emphasis></entry>
23548 <entry>Type: <emphasis>string list</emphasis></entry>
23549 <entry>Default: <emphasis>unset</emphasis></entry>
23550 </row>
23551 </tbody>
23552 </tgroup>
23553 </informaltable>
23554 <para>
23555 <indexterm role="concept">
23556 <primary>InterBase</primary>
23557 <secondary>server list</secondary>
23558 </indexterm>
23559 This option provides a list of InterBase servers and associated connection data,
23560 to be used in conjunction with <command>ibase</command> lookups (see section <xref linkend="SECID72"/>).
23561 The option is available only if Exim has been built with InterBase support.
23562 </para>
23563 <para>
23564 <indexterm role="option">
23565 <primary><option>ignore_bounce_errors_after</option></primary>
23566 </indexterm>
23567 </para>
23568 <informaltable frame="all">
23569 <tgroup cols="4" colsep="0" rowsep="0">
23570 <colspec colwidth="8*" align="left"/>
23571 <colspec colwidth="6*" align="center"/>
23572 <colspec colwidth="6*" align="center"/>
23573 <colspec colwidth="6*" align="right"/>
23574 <tbody>
23575 <row>
23576 <entry><option>ignore_bounce_errors_after</option></entry>
23577 <entry>Use: <emphasis>main</emphasis></entry>
23578 <entry>Type: <emphasis>time</emphasis></entry>
23579 <entry>Default: <emphasis>10w</emphasis></entry>
23580 </row>
23581 </tbody>
23582 </tgroup>
23583 </informaltable>
23584 <para>
23585 <indexterm role="concept">
23586 <primary>bounce message</primary>
23587 <secondary>discarding</secondary>
23588 </indexterm>
23589 <indexterm role="concept">
23590 <primary>discarding bounce message</primary>
23591 </indexterm>
23592 This option affects the processing of bounce messages that cannot be delivered,
23593 that is, those that suffer a permanent delivery failure. (Bounce messages that
23594 suffer temporary delivery failures are of course retried in the usual way.)
23595 </para>
23596 <para>
23597 After a permanent delivery failure, bounce messages are frozen,
23598 because there is no sender to whom they can be returned. When a frozen bounce
23599 message has been on the queue for more than the given time, it is unfrozen at
23600 the next queue run, and a further delivery is attempted. If delivery fails
23601 again, the bounce message is discarded. This makes it possible to keep failed
23602 bounce messages around for a shorter time than the normal maximum retry time
23603 for frozen messages. For example,
23604 </para>
23605 <literallayout class="monospaced">
23606 ignore_bounce_errors_after = 12h
23607 </literallayout>
23608 <para>
23609 retries failed bounce message deliveries after 12 hours, discarding any further
23610 failures. If the value of this option is set to a zero time period, bounce
23611 failures are discarded immediately. Setting a very long time (as in the default
23612 value) has the effect of disabling this option. For ways of automatically
23613 dealing with other kinds of frozen message, see <option>auto_thaw</option> and
23614 <option>timeout_frozen_after</option>.
23615 </para>
23616 <para>
23617 <indexterm role="option">
23618 <primary><option>ignore_fromline_hosts</option></primary>
23619 </indexterm>
23620 </para>
23621 <informaltable frame="all">
23622 <tgroup cols="4" colsep="0" rowsep="0">
23623 <colspec colwidth="8*" align="left"/>
23624 <colspec colwidth="6*" align="center"/>
23625 <colspec colwidth="6*" align="center"/>
23626 <colspec colwidth="6*" align="right"/>
23627 <tbody>
23628 <row>
23629 <entry><option>ignore_fromline_hosts</option></entry>
23630 <entry>Use: <emphasis>main</emphasis></entry>
23631 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
23632 <entry>Default: <emphasis>unset</emphasis></entry>
23633 </row>
23634 </tbody>
23635 </tgroup>
23636 </informaltable>
23637 <para>
23638 <indexterm role="concept">
23639 <primary><quote>From</quote> line</primary>
23640 </indexterm>
23641 <indexterm role="concept">
23642 <primary>UUCP</primary>
23643 <secondary><quote>From</quote> line</secondary>
23644 </indexterm>
23645 Some broken SMTP clients insist on sending a UUCP-like <quote>From&nbsp;</quote> line before
23646 the headers of a message. By default this is treated as the start of the
23647 message&#x2019;s body, which means that any following headers are not recognized as
23648 such. Exim can be made to ignore it by setting <option>ignore_fromline_hosts</option> to
23649 match those hosts that insist on sending it. If the sender is actually a local
23650 process rather than a remote host, and is using <option>-bs</option> to inject the messages,
23651 <option>ignore_fromline_local</option> must be set to achieve this effect.
23652 </para>
23653 <para>
23654 <indexterm role="option">
23655 <primary><option>ignore_fromline_local</option></primary>
23656 </indexterm>
23657 </para>
23658 <informaltable frame="all">
23659 <tgroup cols="4" colsep="0" rowsep="0">
23660 <colspec colwidth="8*" align="left"/>
23661 <colspec colwidth="6*" align="center"/>
23662 <colspec colwidth="6*" align="center"/>
23663 <colspec colwidth="6*" align="right"/>
23664 <tbody>
23665 <row>
23666 <entry><option>ignore_fromline_local</option></entry>
23667 <entry>Use: <emphasis>main</emphasis></entry>
23668 <entry>Type: <emphasis>boolean</emphasis></entry>
23669 <entry>Default: <emphasis>false</emphasis></entry>
23670 </row>
23671 </tbody>
23672 </tgroup>
23673 </informaltable>
23674 <para>
23675 See <option>ignore_fromline_hosts</option> above.
23676 </para>
23677 <para>
23678 <indexterm role="option">
23679 <primary><option>keep_malformed</option></primary>
23680 </indexterm>
23681 </para>
23682 <informaltable frame="all">
23683 <tgroup cols="4" colsep="0" rowsep="0">
23684 <colspec colwidth="8*" align="left"/>
23685 <colspec colwidth="6*" align="center"/>
23686 <colspec colwidth="6*" align="center"/>
23687 <colspec colwidth="6*" align="right"/>
23688 <tbody>
23689 <row>
23690 <entry><option>keep_malformed</option></entry>
23691 <entry>Use: <emphasis>main</emphasis></entry>
23692 <entry>Type: <emphasis>time</emphasis></entry>
23693 <entry>Default: <emphasis>4d</emphasis></entry>
23694 </row>
23695 </tbody>
23696 </tgroup>
23697 </informaltable>
23698 <para>
23699 This option specifies the length of time to keep messages whose spool files
23700 have been corrupted in some way. This should, of course, never happen. At the
23701 next attempt to deliver such a message, it gets removed. The incident is
23702 logged.
23703 </para>
23704 <para>
23705 <indexterm role="option">
23706 <primary><option>ldap_default_servers</option></primary>
23707 </indexterm>
23708 </para>
23709 <informaltable frame="all">
23710 <tgroup cols="4" colsep="0" rowsep="0">
23711 <colspec colwidth="8*" align="left"/>
23712 <colspec colwidth="6*" align="center"/>
23713 <colspec colwidth="6*" align="center"/>
23714 <colspec colwidth="6*" align="right"/>
23715 <tbody>
23716 <row>
23717 <entry><option>ldap_default_servers</option></entry>
23718 <entry>Use: <emphasis>main</emphasis></entry>
23719 <entry>Type: <emphasis>string list</emphasis></entry>
23720 <entry>Default: <emphasis>unset</emphasis></entry>
23721 </row>
23722 </tbody>
23723 </tgroup>
23724 </informaltable>
23725 <para>
23726 <indexterm role="concept">
23727 <primary>LDAP</primary>
23728 <secondary>default servers</secondary>
23729 </indexterm>
23730 This option provides a list of LDAP servers which are tried in turn when an
23731 LDAP query does not contain a server. See section <xref linkend="SECTforldaque"/> for
23732 details of LDAP queries. This option is available only when Exim has been built
23733 with LDAP support.
23734 </para>
23735 <para>
23736 <indexterm role="option">
23737 <primary><option>ldap_version</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>ldap_version</option></entry>
23749 <entry>Use: <emphasis>main</emphasis></entry>
23750 <entry>Type: <emphasis>integer</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>LDAP</primary>
23759 <secondary>protocol version, forcing</secondary>
23760 </indexterm>
23761 This option can be used to force Exim to set a specific protocol version for
23762 LDAP. If it option is unset, it is shown by the <option>-bP</option> command line option as
23763 -1. When this is the case, the default is 3 if LDAP_VERSION3 is defined in
23764 the LDAP headers; otherwise it is 2. This option is available only when Exim
23765 has been built with LDAP support.
23766 </para>
23767 <para>
23768 <indexterm role="option">
23769 <primary><option>local_from_check</option></primary>
23770 </indexterm>
23771 </para>
23772 <informaltable frame="all">
23773 <tgroup cols="4" colsep="0" rowsep="0">
23774 <colspec colwidth="8*" align="left"/>
23775 <colspec colwidth="6*" align="center"/>
23776 <colspec colwidth="6*" align="center"/>
23777 <colspec colwidth="6*" align="right"/>
23778 <tbody>
23779 <row>
23780 <entry><option>local_from_check</option></entry>
23781 <entry>Use: <emphasis>main</emphasis></entry>
23782 <entry>Type: <emphasis>boolean</emphasis></entry>
23783 <entry>Default: <emphasis>true</emphasis></entry>
23784 </row>
23785 </tbody>
23786 </tgroup>
23787 </informaltable>
23788 <para>
23789 <indexterm role="concept">
23790 <primary><emphasis>Sender:</emphasis> header line</primary>
23791 <secondary>disabling addition of</secondary>
23792 </indexterm>
23793 <indexterm role="concept">
23794 <primary><emphasis>From:</emphasis> header line</primary>
23795 <secondary>disabling checking of</secondary>
23796 </indexterm>
23797 When a message is submitted locally (that is, not over a TCP/IP connection) by
23798 an untrusted user, Exim removes any existing <emphasis>Sender:</emphasis> header line, and
23799 checks that the <emphasis>From:</emphasis> header line matches the login of the calling user and
23800 the domain specified by <option>qualify_domain</option>.
23801 </para>
23802 <para>
23803 <emphasis role="bold">Note</emphasis>: An unqualified address (no domain) in the <emphasis>From:</emphasis> header in a
23804 locally submitted message is automatically qualified by Exim, unless the
23805 <option>-bnq</option> command line option is used.
23806 </para>
23807 <para>
23808 You can use <option>local_from_prefix</option> and <option>local_from_suffix</option> to permit affixes
23809 on the local part. If the <emphasis>From:</emphasis> header line does not match, Exim adds a
23810 <emphasis>Sender:</emphasis> header with an address constructed from the calling user&#x2019;s login
23811 and the default qualify domain.
23812 </para>
23813 <para>
23814 If <option>local_from_check</option> is set false, the <emphasis>From:</emphasis> header check is disabled,
23815 and no <emphasis>Sender:</emphasis> header is ever added. If, in addition, you want to retain
23816 <emphasis>Sender:</emphasis> header lines supplied by untrusted users, you must also set
23817 <option>local_sender_retain</option> to be true.
23818 </para>
23819 <para>
23820 <indexterm role="concept">
23821 <primary>envelope sender</primary>
23822 </indexterm>
23823 These options affect only the header lines in the message. The envelope sender
23824 is still forced to be the login id at the qualify domain unless
23825 <option>untrusted_set_sender</option> permits the user to supply an envelope sender.
23826 </para>
23827 <para>
23828 For messages received over TCP/IP, an ACL can specify <quote>submission mode</quote> to
23829 request similar header line checking. See section <xref linkend="SECTthesenhea"/>, which
23830 has more details about <emphasis>Sender:</emphasis> processing.
23831 </para>
23832 <para>
23833 <indexterm role="option">
23834 <primary><option>local_from_prefix</option></primary>
23835 </indexterm>
23836 </para>
23837 <informaltable frame="all">
23838 <tgroup cols="4" colsep="0" rowsep="0">
23839 <colspec colwidth="8*" align="left"/>
23840 <colspec colwidth="6*" align="center"/>
23841 <colspec colwidth="6*" align="center"/>
23842 <colspec colwidth="6*" align="right"/>
23843 <tbody>
23844 <row>
23845 <entry><option>local_from_prefix</option></entry>
23846 <entry>Use: <emphasis>main</emphasis></entry>
23847 <entry>Type: <emphasis>string</emphasis></entry>
23848 <entry>Default: <emphasis>unset</emphasis></entry>
23849 </row>
23850 </tbody>
23851 </tgroup>
23852 </informaltable>
23853 <para>
23854 When Exim checks the <emphasis>From:</emphasis> header line of locally submitted messages for
23855 matching the login id (see <option>local_from_check</option> above), it can be configured to
23856 ignore certain prefixes and suffixes in the local part of the address. This is
23857 done by setting <option>local_from_prefix</option> and/or <option>local_from_suffix</option> to
23858 appropriate lists, in the same form as the <option>local_part_prefix</option> and
23859 <option>local_part_suffix</option> router options (see chapter <xref linkend="CHAProutergeneric"/>). For
23860 example, if
23861 </para>
23862 <literallayout class="monospaced">
23863 local_from_prefix = *-
23864 </literallayout>
23865 <para>
23866 is set, a <emphasis>From:</emphasis> line containing
23867 </para>
23868 <literallayout class="monospaced">
23869 From: anything-user@your.domain.example
23870 </literallayout>
23871 <para>
23872 will not cause a <emphasis>Sender:</emphasis> header to be added if <emphasis>user@your.domain.example</emphasis>
23873 matches the actual sender address that is constructed from the login name and
23874 qualify domain.
23875 </para>
23876 <para>
23877 <indexterm role="option">
23878 <primary><option>local_from_suffix</option></primary>
23879 </indexterm>
23880 </para>
23881 <informaltable frame="all">
23882 <tgroup cols="4" colsep="0" rowsep="0">
23883 <colspec colwidth="8*" align="left"/>
23884 <colspec colwidth="6*" align="center"/>
23885 <colspec colwidth="6*" align="center"/>
23886 <colspec colwidth="6*" align="right"/>
23887 <tbody>
23888 <row>
23889 <entry><option>local_from_suffix</option></entry>
23890 <entry>Use: <emphasis>main</emphasis></entry>
23891 <entry>Type: <emphasis>string</emphasis></entry>
23892 <entry>Default: <emphasis>unset</emphasis></entry>
23893 </row>
23894 </tbody>
23895 </tgroup>
23896 </informaltable>
23897 <para>
23898 See <option>local_from_prefix</option> above.
23899 </para>
23900 <para>
23901 <indexterm role="option">
23902 <primary><option>local_interfaces</option></primary>
23903 </indexterm>
23904 </para>
23905 <informaltable frame="all">
23906 <tgroup cols="4" colsep="0" rowsep="0">
23907 <colspec colwidth="8*" align="left"/>
23908 <colspec colwidth="6*" align="center"/>
23909 <colspec colwidth="6*" align="center"/>
23910 <colspec colwidth="6*" align="right"/>
23911 <tbody>
23912 <row>
23913 <entry><option>local_interfaces</option></entry>
23914 <entry>Use: <emphasis>main</emphasis></entry>
23915 <entry>Type: <emphasis>string list</emphasis></entry>
23916 <entry>Default: <emphasis>see below</emphasis></entry>
23917 </row>
23918 </tbody>
23919 </tgroup>
23920 </informaltable>
23921 <para>
23922 This option controls which network interfaces are used by the daemon for
23923 listening; they are also used to identify the local host when routing. Chapter
23924 <xref linkend="CHAPinterfaces"/> contains a full description of this option and the related
23925 options <option>daemon_smtp_ports</option>, <option>extra_local_interfaces</option>,
23926 <option>hosts_treat_as_local</option>, and <option>tls_on_connect_ports</option>. The default value for
23927 <option>local_interfaces</option> is
23928 </para>
23929 <literallayout class="monospaced">
23930 local_interfaces = 0.0.0.0
23931 </literallayout>
23932 <para>
23933 when Exim is built without IPv6 support; otherwise it is
23934 </para>
23935 <literallayout class="monospaced">
23936 local_interfaces = &lt;; ::0 ; 0.0.0.0
23937 </literallayout>
23938 <para>
23939 <indexterm role="option">
23940 <primary><option>local_scan_timeout</option></primary>
23941 </indexterm>
23942 </para>
23943 <informaltable frame="all">
23944 <tgroup cols="4" colsep="0" rowsep="0">
23945 <colspec colwidth="8*" align="left"/>
23946 <colspec colwidth="6*" align="center"/>
23947 <colspec colwidth="6*" align="center"/>
23948 <colspec colwidth="6*" align="right"/>
23949 <tbody>
23950 <row>
23951 <entry><option>local_scan_timeout</option></entry>
23952 <entry>Use: <emphasis>main</emphasis></entry>
23953 <entry>Type: <emphasis>time</emphasis></entry>
23954 <entry>Default: <emphasis>5m</emphasis></entry>
23955 </row>
23956 </tbody>
23957 </tgroup>
23958 </informaltable>
23959 <para>
23960 <indexterm role="concept">
23961 <primary>timeout</primary>
23962 <secondary>for <function>local_scan()</function> function</secondary>
23963 </indexterm>
23964 <indexterm role="concept">
23965 <primary><function>local_scan()</function> function</primary>
23966 <secondary>timeout</secondary>
23967 </indexterm>
23968 This timeout applies to the <function>local_scan()</function> function (see chapter
23969 <xref linkend="CHAPlocalscan"/>). Zero means <quote>no timeout</quote>. If the timeout is exceeded,
23970 the incoming message is rejected with a temporary error if it is an SMTP
23971 message. For a non-SMTP message, the message is dropped and Exim ends with a
23972 non-zero code. The incident is logged on the main and reject logs.
23973 </para>
23974 <para>
23975 <indexterm role="option">
23976 <primary><option>local_sender_retain</option></primary>
23977 </indexterm>
23978 </para>
23979 <informaltable frame="all">
23980 <tgroup cols="4" colsep="0" rowsep="0">
23981 <colspec colwidth="8*" align="left"/>
23982 <colspec colwidth="6*" align="center"/>
23983 <colspec colwidth="6*" align="center"/>
23984 <colspec colwidth="6*" align="right"/>
23985 <tbody>
23986 <row>
23987 <entry><option>local_sender_retain</option></entry>
23988 <entry>Use: <emphasis>main</emphasis></entry>
23989 <entry>Type: <emphasis>boolean</emphasis></entry>
23990 <entry>Default: <emphasis>false</emphasis></entry>
23991 </row>
23992 </tbody>
23993 </tgroup>
23994 </informaltable>
23995 <para>
23996 <indexterm role="concept">
23997 <primary><emphasis>Sender:</emphasis> header line</primary>
23998 <secondary>retaining from local submission</secondary>
23999 </indexterm>
24000 When a message is submitted locally (that is, not over a TCP/IP connection) by
24001 an untrusted user, Exim removes any existing <emphasis>Sender:</emphasis> header line. If you
24002 do not want this to happen, you must set <option>local_sender_retain</option>, and you must
24003 also set <option>local_from_check</option> to be false (Exim will complain if you do not).
24004 See also the ACL modifier <literal>control = suppress_local_fixups</literal>. Section
24005 <xref linkend="SECTthesenhea"/> has more details about <emphasis>Sender:</emphasis> processing.
24006 </para>
24007 <para>
24008 <indexterm role="option">
24009 <primary><option>localhost_number</option></primary>
24010 </indexterm>
24011 </para>
24012 <informaltable frame="all">
24013 <tgroup cols="4" colsep="0" rowsep="0">
24014 <colspec colwidth="8*" align="left"/>
24015 <colspec colwidth="6*" align="center"/>
24016 <colspec colwidth="6*" align="center"/>
24017 <colspec colwidth="6*" align="right"/>
24018 <tbody>
24019 <row>
24020 <entry><option>localhost_number</option></entry>
24021 <entry>Use: <emphasis>main</emphasis></entry>
24022 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
24023 <entry>Default: <emphasis>unset</emphasis></entry>
24024 </row>
24025 </tbody>
24026 </tgroup>
24027 </informaltable>
24028 <para>
24029 <indexterm role="concept">
24030 <primary>host</primary>
24031 <secondary>locally unique number for</secondary>
24032 </indexterm>
24033 <indexterm role="concept">
24034 <primary>message ids</primary>
24035 <secondary>with multiple hosts</secondary>
24036 </indexterm>
24037 <indexterm role="variable">
24038 <primary><varname>$localhost_number</varname></primary>
24039 </indexterm>
24040 Exim&#x2019;s message ids are normally unique only within the local host. If
24041 uniqueness among a set of hosts is required, each host must set a different
24042 value for the <option>localhost_number</option> option. The string is expanded immediately
24043 after reading the configuration file (so that a number can be computed from the
24044 host name, for example) and the result of the expansion must be a number in the
24045 range 0&ndash;16 (or 0&ndash;10 on operating systems with case-insensitive file
24046 systems). This is available in subsequent string expansions via the variable
24047 <varname>$localhost_number</varname>. When <option>localhost_number is set</option>, the final two
24048 characters of the message id, instead of just being a fractional part of the
24049 time, are computed from the time and the local host number as described in
24050 section <xref linkend="SECTmessiden"/>.
24051 </para>
24052 <para>
24053 <indexterm role="option">
24054 <primary><option>log_file_path</option></primary>
24055 </indexterm>
24056 </para>
24057 <informaltable frame="all">
24058 <tgroup cols="4" colsep="0" rowsep="0">
24059 <colspec colwidth="8*" align="left"/>
24060 <colspec colwidth="6*" align="center"/>
24061 <colspec colwidth="6*" align="center"/>
24062 <colspec colwidth="6*" align="right"/>
24063 <tbody>
24064 <row>
24065 <entry><option>log_file_path</option></entry>
24066 <entry>Use: <emphasis>main</emphasis></entry>
24067 <entry>Type: <emphasis>string list</emphasis>&dagger;<emphasis></emphasis></entry>
24068 <entry>Default: <emphasis>set at compile time</emphasis></entry>
24069 </row>
24070 </tbody>
24071 </tgroup>
24072 </informaltable>
24073 <para>
24074 <indexterm role="concept">
24075 <primary>log</primary>
24076 <secondary>file path for</secondary>
24077 </indexterm>
24078 This option sets the path which is used to determine the names of Exim&#x2019;s log
24079 files, or indicates that logging is to be to syslog, or both. It is expanded
24080 when Exim is entered, so it can, for example, contain a reference to the host
24081 name. If no specific path is set for the log files at compile or run time, they
24082 are written in a sub-directory called <filename>log</filename> in Exim&#x2019;s spool directory.
24083 Chapter <xref linkend="CHAPlog"/> contains further details about Exim&#x2019;s logging, and
24084 section <xref linkend="SECTwhelogwri"/> describes how the contents of <option>log_file_path</option> are
24085 used. If this string is fixed at your installation (contains no expansion
24086 variables) it is recommended that you do not set this option in the
24087 configuration file, but instead supply the path using LOG_FILE_PATH in
24088 <filename>Local/Makefile</filename> so that it is available to Exim for logging errors detected
24089 early on &ndash; in particular, failure to read the configuration file.
24090 </para>
24091 <para>
24092 <indexterm role="option">
24093 <primary><option>log_selector</option></primary>
24094 </indexterm>
24095 </para>
24096 <informaltable frame="all">
24097 <tgroup cols="4" colsep="0" rowsep="0">
24098 <colspec colwidth="8*" align="left"/>
24099 <colspec colwidth="6*" align="center"/>
24100 <colspec colwidth="6*" align="center"/>
24101 <colspec colwidth="6*" align="right"/>
24102 <tbody>
24103 <row>
24104 <entry><option>log_selector</option></entry>
24105 <entry>Use: <emphasis>main</emphasis></entry>
24106 <entry>Type: <emphasis>string</emphasis></entry>
24107 <entry>Default: <emphasis>unset</emphasis></entry>
24108 </row>
24109 </tbody>
24110 </tgroup>
24111 </informaltable>
24112 <para>
24113 <indexterm role="concept">
24114 <primary>log</primary>
24115 <secondary>selectors</secondary>
24116 </indexterm>
24117 This option can be used to reduce or increase the number of things that Exim
24118 writes to its log files. Its argument is made up of names preceded by plus or
24119 minus characters. For example:
24120 </para>
24121 <literallayout class="monospaced">
24122 log_selector = +arguments -retry_defer
24123 </literallayout>
24124 <para>
24125 A list of possible names and what they control is given in the chapter on
24126 logging, in section <xref linkend="SECTlogselector"/>.
24127 </para>
24128 <para>
24129 <indexterm role="option">
24130 <primary><option>log_timezone</option></primary>
24131 </indexterm>
24132 </para>
24133 <informaltable frame="all">
24134 <tgroup cols="4" colsep="0" rowsep="0">
24135 <colspec colwidth="8*" align="left"/>
24136 <colspec colwidth="6*" align="center"/>
24137 <colspec colwidth="6*" align="center"/>
24138 <colspec colwidth="6*" align="right"/>
24139 <tbody>
24140 <row>
24141 <entry><option>log_timezone</option></entry>
24142 <entry>Use: <emphasis>main</emphasis></entry>
24143 <entry>Type: <emphasis>boolean</emphasis></entry>
24144 <entry>Default: <emphasis>false</emphasis></entry>
24145 </row>
24146 </tbody>
24147 </tgroup>
24148 </informaltable>
24149 <para>
24150 <indexterm role="concept">
24151 <primary>log</primary>
24152 <secondary>timezone for entries</secondary>
24153 </indexterm>
24154 <indexterm role="variable">
24155 <primary><varname>$tod_log</varname></primary>
24156 </indexterm>
24157 <indexterm role="variable">
24158 <primary><varname>$tod_zone</varname></primary>
24159 </indexterm>
24160 By default, the timestamps on log lines are in local time without the
24161 timezone. This means that if your timezone changes twice a year, the timestamps
24162 in log lines are ambiguous for an hour when the clocks go back. One way of
24163 avoiding this problem is to set the timezone to UTC. An alternative is to set
24164 <option>log_timezone</option> true. This turns on the addition of the timezone offset to
24165 timestamps in log lines. Turning on this option can add quite a lot to the size
24166 of log files because each line is extended by 6 characters. Note that the
24167 <varname>$tod_log</varname> variable contains the log timestamp without the zone, but there is
24168 another variable called <varname>$tod_zone</varname> that contains just the timezone offset.
24169 </para>
24170 <para>
24171 <indexterm role="option">
24172 <primary><option>lookup_open_max</option></primary>
24173 </indexterm>
24174 </para>
24175 <informaltable frame="all">
24176 <tgroup cols="4" colsep="0" rowsep="0">
24177 <colspec colwidth="8*" align="left"/>
24178 <colspec colwidth="6*" align="center"/>
24179 <colspec colwidth="6*" align="center"/>
24180 <colspec colwidth="6*" align="right"/>
24181 <tbody>
24182 <row>
24183 <entry><option>lookup_open_max</option></entry>
24184 <entry>Use: <emphasis>main</emphasis></entry>
24185 <entry>Type: <emphasis>integer</emphasis></entry>
24186 <entry>Default: <emphasis>25</emphasis></entry>
24187 </row>
24188 </tbody>
24189 </tgroup>
24190 </informaltable>
24191 <para>
24192 <indexterm role="concept">
24193 <primary>too many open files</primary>
24194 </indexterm>
24195 <indexterm role="concept">
24196 <primary>open files, too many</primary>
24197 </indexterm>
24198 <indexterm role="concept">
24199 <primary>file</primary>
24200 <secondary>too many open</secondary>
24201 </indexterm>
24202 <indexterm role="concept">
24203 <primary>lookup</primary>
24204 <secondary>maximum open files</secondary>
24205 </indexterm>
24206 <indexterm role="concept">
24207 <primary>limit</primary>
24208 <secondary>open files for lookups</secondary>
24209 </indexterm>
24210 This option limits the number of simultaneously open files for single-key
24211 lookups that use regular files (that is, <command>lsearch</command>, <command>dbm</command>, and <command>cdb</command>).
24212 Exim normally keeps these files open during routing, because often the same
24213 file is required several times. If the limit is reached, Exim closes the least
24214 recently used file. Note that if you are using the <emphasis>ndbm</emphasis> library, it
24215 actually opens two files for each logical DBM database, though it still counts
24216 as one for the purposes of <option>lookup_open_max</option>. If you are getting <quote>too many
24217 open files</quote> errors with NDBM, you need to reduce the value of
24218 <option>lookup_open_max</option>.
24219 </para>
24220 <para>
24221 <indexterm role="option">
24222 <primary><option>max_username_length</option></primary>
24223 </indexterm>
24224 </para>
24225 <informaltable frame="all">
24226 <tgroup cols="4" colsep="0" rowsep="0">
24227 <colspec colwidth="8*" align="left"/>
24228 <colspec colwidth="6*" align="center"/>
24229 <colspec colwidth="6*" align="center"/>
24230 <colspec colwidth="6*" align="right"/>
24231 <tbody>
24232 <row>
24233 <entry><option>max_username_length</option></entry>
24234 <entry>Use: <emphasis>main</emphasis></entry>
24235 <entry>Type: <emphasis>integer</emphasis></entry>
24236 <entry>Default: <emphasis>0</emphasis></entry>
24237 </row>
24238 </tbody>
24239 </tgroup>
24240 </informaltable>
24241 <para>
24242 <indexterm role="concept">
24243 <primary>length of login name</primary>
24244 </indexterm>
24245 <indexterm role="concept">
24246 <primary>user name</primary>
24247 <secondary>maximum length</secondary>
24248 </indexterm>
24249 <indexterm role="concept">
24250 <primary>limit</primary>
24251 <secondary>user name length</secondary>
24252 </indexterm>
24253 Some operating systems are broken in that they truncate long arguments to
24254 <function>getpwnam()</function> to eight characters, instead of returning <quote>no such user</quote>. If
24255 this option is set greater than zero, any attempt to call <function>getpwnam()</function> with
24256 an argument that is longer behaves as if <function>getpwnam()</function> failed.
24257 </para>
24258 <para>
24259 <indexterm role="option">
24260 <primary><option>message_body_newlines</option></primary>
24261 </indexterm>
24262 </para>
24263 <informaltable frame="all">
24264 <tgroup cols="4" colsep="0" rowsep="0">
24265 <colspec colwidth="8*" align="left"/>
24266 <colspec colwidth="6*" align="center"/>
24267 <colspec colwidth="6*" align="center"/>
24268 <colspec colwidth="6*" align="right"/>
24269 <tbody>
24270 <row>
24271 <entry><option>message_body_newlines</option></entry>
24272 <entry>Use: <emphasis>main</emphasis></entry>
24273 <entry>Type: <emphasis>bool</emphasis></entry>
24274 <entry>Default: <emphasis>false</emphasis></entry>
24275 </row>
24276 </tbody>
24277 </tgroup>
24278 </informaltable>
24279 <para>
24280 <indexterm role="concept">
24281 <primary>message body</primary>
24282 <secondary>newlines in variables</secondary>
24283 </indexterm>
24284 <indexterm role="concept">
24285 <primary>newline</primary>
24286 <secondary>in message body variables</secondary>
24287 </indexterm>
24288 <indexterm role="variable">
24289 <primary><varname>$message_body</varname></primary>
24290 </indexterm>
24291 <indexterm role="variable">
24292 <primary><varname>$message_body_end</varname></primary>
24293 </indexterm>
24294 By default, newlines in the message body are replaced by spaces when setting
24295 the <varname>$message_body</varname> and <varname>$message_body_end</varname> expansion variables. If this
24296 option is set true, this no longer happens.
24297 </para>
24298 <para>
24299 <indexterm role="option">
24300 <primary><option>message_body_visible</option></primary>
24301 </indexterm>
24302 </para>
24303 <informaltable frame="all">
24304 <tgroup cols="4" colsep="0" rowsep="0">
24305 <colspec colwidth="8*" align="left"/>
24306 <colspec colwidth="6*" align="center"/>
24307 <colspec colwidth="6*" align="center"/>
24308 <colspec colwidth="6*" align="right"/>
24309 <tbody>
24310 <row>
24311 <entry><option>message_body_visible</option></entry>
24312 <entry>Use: <emphasis>main</emphasis></entry>
24313 <entry>Type: <emphasis>integer</emphasis></entry>
24314 <entry>Default: <emphasis>500</emphasis></entry>
24315 </row>
24316 </tbody>
24317 </tgroup>
24318 </informaltable>
24319 <para>
24320 <indexterm role="concept">
24321 <primary>body of message</primary>
24322 <secondary>visible size</secondary>
24323 </indexterm>
24324 <indexterm role="concept">
24325 <primary>message body</primary>
24326 <secondary>visible size</secondary>
24327 </indexterm>
24328 <indexterm role="variable">
24329 <primary><varname>$message_body</varname></primary>
24330 </indexterm>
24331 <indexterm role="variable">
24332 <primary><varname>$message_body_end</varname></primary>
24333 </indexterm>
24334 This option specifies how much of a message&#x2019;s body is to be included in the
24335 <varname>$message_body</varname> and <varname>$message_body_end</varname> expansion variables.
24336 </para>
24337 <para>
24338 <indexterm role="option">
24339 <primary><option>message_id_header_domain</option></primary>
24340 </indexterm>
24341 </para>
24342 <informaltable frame="all">
24343 <tgroup cols="4" colsep="0" rowsep="0">
24344 <colspec colwidth="8*" align="left"/>
24345 <colspec colwidth="6*" align="center"/>
24346 <colspec colwidth="6*" align="center"/>
24347 <colspec colwidth="6*" align="right"/>
24348 <tbody>
24349 <row>
24350 <entry><option>message_id_header_domain</option></entry>
24351 <entry>Use: <emphasis>main</emphasis></entry>
24352 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
24353 <entry>Default: <emphasis>unset</emphasis></entry>
24354 </row>
24355 </tbody>
24356 </tgroup>
24357 </informaltable>
24358 <para>
24359 <indexterm role="concept">
24360 <primary><emphasis>Message-ID:</emphasis> header line</primary>
24361 </indexterm>
24362 If this option is set, the string is expanded and used as the right hand side
24363 (domain) of the <emphasis>Message-ID:</emphasis> header that Exim creates if a
24364 locally-originated incoming message does not have one. <quote>Locally-originated</quote>
24365 means <quote>not received over TCP/IP.</quote>
24366 Otherwise, the primary host name is used.
24367 Only letters, digits, dot and hyphen are accepted; any other characters are
24368 replaced by hyphens. If the expansion is forced to fail, or if the result is an
24369 empty string, the option is ignored.
24370 </para>
24371 <para>
24372 <indexterm role="option">
24373 <primary><option>message_id_header_text</option></primary>
24374 </indexterm>
24375 </para>
24376 <informaltable frame="all">
24377 <tgroup cols="4" colsep="0" rowsep="0">
24378 <colspec colwidth="8*" align="left"/>
24379 <colspec colwidth="6*" align="center"/>
24380 <colspec colwidth="6*" align="center"/>
24381 <colspec colwidth="6*" align="right"/>
24382 <tbody>
24383 <row>
24384 <entry><option>message_id_header_text</option></entry>
24385 <entry>Use: <emphasis>main</emphasis></entry>
24386 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
24387 <entry>Default: <emphasis>unset</emphasis></entry>
24388 </row>
24389 </tbody>
24390 </tgroup>
24391 </informaltable>
24392 <para>
24393 If this variable is set, the string is expanded and used to augment the text of
24394 the <emphasis>Message-id:</emphasis> header that Exim creates if a locally-originated incoming
24395 message does not have one. The text of this header is required by RFC 2822 to
24396 take the form of an address. By default, Exim uses its internal message id as
24397 the local part, and the primary host name as the domain. If this option is set,
24398 it is expanded, and provided the expansion is not forced to fail, and does not
24399 yield an empty string, the result is inserted into the header immediately
24400 before the @, separated from the internal message id by a dot. Any characters
24401 that are illegal in an address are automatically converted into hyphens. This
24402 means that variables such as <varname>$tod_log</varname> can be used, because the spaces and
24403 colons will become hyphens.
24404 </para>
24405 <para>
24406 <indexterm role="option">
24407 <primary><option>message_logs</option></primary>
24408 </indexterm>
24409 </para>
24410 <informaltable frame="all">
24411 <tgroup cols="4" colsep="0" rowsep="0">
24412 <colspec colwidth="8*" align="left"/>
24413 <colspec colwidth="6*" align="center"/>
24414 <colspec colwidth="6*" align="center"/>
24415 <colspec colwidth="6*" align="right"/>
24416 <tbody>
24417 <row>
24418 <entry><option>message_logs</option></entry>
24419 <entry>Use: <emphasis>main</emphasis></entry>
24420 <entry>Type: <emphasis>boolean</emphasis></entry>
24421 <entry>Default: <emphasis>true</emphasis></entry>
24422 </row>
24423 </tbody>
24424 </tgroup>
24425 </informaltable>
24426 <para>
24427 <indexterm role="concept">
24428 <primary>message logs</primary>
24429 <secondary>disabling</secondary>
24430 </indexterm>
24431 <indexterm role="concept">
24432 <primary>log</primary>
24433 <secondary>message log; disabling</secondary>
24434 </indexterm>
24435 If this option is turned off, per-message log files are not created in the
24436 <filename>msglog</filename> spool sub-directory. This reduces the amount of disk I/O required by
24437 Exim, by reducing the number of files involved in handling a message from a
24438 minimum of four (header spool file, body spool file, delivery journal, and
24439 per-message log) to three. The other major I/O activity is Exim&#x2019;s main log,
24440 which is not affected by this option.
24441 </para>
24442 <para>
24443 <indexterm role="option">
24444 <primary><option>message_size_limit</option></primary>
24445 </indexterm>
24446 </para>
24447 <informaltable frame="all">
24448 <tgroup cols="4" colsep="0" rowsep="0">
24449 <colspec colwidth="8*" align="left"/>
24450 <colspec colwidth="6*" align="center"/>
24451 <colspec colwidth="6*" align="center"/>
24452 <colspec colwidth="6*" align="right"/>
24453 <tbody>
24454 <row>
24455 <entry><option>message_size_limit</option></entry>
24456 <entry>Use: <emphasis>main</emphasis></entry>
24457 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
24458 <entry>Default: <emphasis>50M</emphasis></entry>
24459 </row>
24460 </tbody>
24461 </tgroup>
24462 </informaltable>
24463 <para>
24464 <indexterm role="concept">
24465 <primary>message</primary>
24466 <secondary>size limit</secondary>
24467 </indexterm>
24468 <indexterm role="concept">
24469 <primary>limit</primary>
24470 <secondary>message size</secondary>
24471 </indexterm>
24472 <indexterm role="concept">
24473 <primary>size</primary>
24474 <secondary>of message, limit</secondary>
24475 </indexterm>
24476 This option limits the maximum size of message that Exim will process. The
24477 value is expanded for each incoming connection so, for example, it can be made
24478 to depend on the IP address of the remote host for messages arriving via
24479 TCP/IP. After expansion, the value must be a sequence of decimal digits,
24480 optionally followed by K or M.
24481 </para>
24482 <para>
24483 <emphasis role="bold">Note</emphasis>: This limit cannot be made to depend on a message&#x2019;s sender or any
24484 other properties of an individual message, because it has to be advertised in
24485 the server&#x2019;s response to EHLO. String expansion failure causes a temporary
24486 error. A value of zero means no limit, but its use is not recommended. See also
24487 <option>bounce_return_size_limit</option>.
24488 </para>
24489 <para>
24490 Incoming SMTP messages are failed with a 552 error if the limit is
24491 exceeded; locally-generated messages either get a stderr message or a delivery
24492 failure message to the sender, depending on the <option>-oe</option> setting. Rejection of
24493 an oversized message is logged in both the main and the reject logs. See also
24494 the generic transport option <option>message_size_limit</option>, which limits the size of
24495 message that an individual transport can process.
24496 </para>
24497 <para revisionflag="changed">
24498 If you use a virus-scanner and set this option to to a value larger than the
24499 maximum size that your virus-scanner is configured to support, you may get
24500 failures triggered by large mails.  The right size to configure for the
24501 virus-scanner depends upon what data is passed and the options in use but it&#x2019;s
24502 probably safest to just set it to a little larger than this value.  Eg, with a
24503 default Exim message size of 50M and a default ClamAV StreamMaxLength of 10M,
24504 some problems may result.
24505 </para>
24506 <para>
24507 <indexterm role="option">
24508 <primary><option>move_frozen_messages</option></primary>
24509 </indexterm>
24510 </para>
24511 <informaltable frame="all">
24512 <tgroup cols="4" colsep="0" rowsep="0">
24513 <colspec colwidth="8*" align="left"/>
24514 <colspec colwidth="6*" align="center"/>
24515 <colspec colwidth="6*" align="center"/>
24516 <colspec colwidth="6*" align="right"/>
24517 <tbody>
24518 <row>
24519 <entry><option>move_frozen_messages</option></entry>
24520 <entry>Use: <emphasis>main</emphasis></entry>
24521 <entry>Type: <emphasis>boolean</emphasis></entry>
24522 <entry>Default: <emphasis>false</emphasis></entry>
24523 </row>
24524 </tbody>
24525 </tgroup>
24526 </informaltable>
24527 <para>
24528 <indexterm role="concept">
24529 <primary>frozen messages</primary>
24530 <secondary>moving</secondary>
24531 </indexterm>
24532 This option, which is available only if Exim has been built with the setting
24533 </para>
24534 <literallayout class="monospaced">
24535 SUPPORT_MOVE_FROZEN_MESSAGES=yes
24536 </literallayout>
24537 <para>
24538 in <filename>Local/Makefile</filename>, causes frozen messages and their message logs to be
24539 moved from the <filename>input</filename> and <filename>msglog</filename> directories on the spool to <filename>Finput</filename>
24540 and <filename>Fmsglog</filename>, respectively. There is currently no support in Exim or the
24541 standard utilities for handling such moved messages, and they do not show up in
24542 lists generated by <option>-bp</option> or by the Exim monitor.
24543 </para>
24544 <para>
24545 <indexterm role="option">
24546 <primary><option>mua_wrapper</option></primary>
24547 </indexterm>
24548 </para>
24549 <informaltable frame="all">
24550 <tgroup cols="4" colsep="0" rowsep="0">
24551 <colspec colwidth="8*" align="left"/>
24552 <colspec colwidth="6*" align="center"/>
24553 <colspec colwidth="6*" align="center"/>
24554 <colspec colwidth="6*" align="right"/>
24555 <tbody>
24556 <row>
24557 <entry><option>mua_wrapper</option></entry>
24558 <entry>Use: <emphasis>main</emphasis></entry>
24559 <entry>Type: <emphasis>boolean</emphasis></entry>
24560 <entry>Default: <emphasis>false</emphasis></entry>
24561 </row>
24562 </tbody>
24563 </tgroup>
24564 </informaltable>
24565 <para>
24566 Setting this option true causes Exim to run in a very restrictive mode in which
24567 it passes messages synchronously to a smart host. Chapter <xref linkend="CHAPnonqueueing"/>
24568 contains a full description of this facility.
24569 </para>
24570 <para>
24571 <indexterm role="option">
24572 <primary><option>mysql_servers</option></primary>
24573 </indexterm>
24574 </para>
24575 <informaltable frame="all">
24576 <tgroup cols="4" colsep="0" rowsep="0">
24577 <colspec colwidth="8*" align="left"/>
24578 <colspec colwidth="6*" align="center"/>
24579 <colspec colwidth="6*" align="center"/>
24580 <colspec colwidth="6*" align="right"/>
24581 <tbody>
24582 <row>
24583 <entry><option>mysql_servers</option></entry>
24584 <entry>Use: <emphasis>main</emphasis></entry>
24585 <entry>Type: <emphasis>string list</emphasis></entry>
24586 <entry>Default: <emphasis>unset</emphasis></entry>
24587 </row>
24588 </tbody>
24589 </tgroup>
24590 </informaltable>
24591 <para>
24592 <indexterm role="concept">
24593 <primary>MySQL</primary>
24594 <secondary>server list</secondary>
24595 </indexterm>
24596 This option provides a list of MySQL servers and associated connection data, to
24597 be used in conjunction with <command>mysql</command> lookups (see section <xref linkend="SECID72"/>). The
24598 option is available only if Exim has been built with MySQL support.
24599 </para>
24600 <para>
24601 <indexterm role="option">
24602 <primary><option>never_users</option></primary>
24603 </indexterm>
24604 </para>
24605 <informaltable frame="all">
24606 <tgroup cols="4" colsep="0" rowsep="0">
24607 <colspec colwidth="8*" align="left"/>
24608 <colspec colwidth="6*" align="center"/>
24609 <colspec colwidth="6*" align="center"/>
24610 <colspec colwidth="6*" align="right"/>
24611 <tbody>
24612 <row>
24613 <entry><option>never_users</option></entry>
24614 <entry>Use: <emphasis>main</emphasis></entry>
24615 <entry>Type: <emphasis>string list</emphasis>&dagger;<emphasis></emphasis></entry>
24616 <entry>Default: <emphasis>unset</emphasis></entry>
24617 </row>
24618 </tbody>
24619 </tgroup>
24620 </informaltable>
24621 <para>
24622 This option is expanded just once, at the start of Exim&#x2019;s processing. Local
24623 message deliveries are normally run in processes that are setuid to the
24624 recipient, and remote deliveries are normally run under Exim&#x2019;s own uid and gid.
24625 It is usually desirable to prevent any deliveries from running as root, as a
24626 safety precaution.
24627 </para>
24628 <para>
24629 When Exim is built, an option called FIXED_NEVER_USERS can be set to a
24630 list of users that must not be used for local deliveries. This list is fixed in
24631 the binary and cannot be overridden by the configuration file. By default, it
24632 contains just the single user name <quote>root</quote>. The <option>never_users</option> runtime option
24633 can be used to add more users to the fixed list.
24634 </para>
24635 <para>
24636 If a message is to be delivered as one of the users on the fixed list or the
24637 <option>never_users</option> list, an error occurs, and delivery is deferred. A common
24638 example is
24639 </para>
24640 <literallayout class="monospaced">
24641 never_users = root:daemon:bin
24642 </literallayout>
24643 <para>
24644 Including root is redundant if it is also on the fixed list, but it does no
24645 harm. This option overrides the <option>pipe_as_creator</option> option of the <command>pipe</command>
24646 transport driver.
24647 </para>
24648 <para revisionflag="changed">
24649 <indexterm role="option">
24650 <primary><option>openssl_options</option></primary>
24651 </indexterm>
24652 </para>
24653 <informaltable frame="all" revisionflag="changed">
24654 <tgroup cols="4" colsep="0" rowsep="0">
24655 <colspec colwidth="8*" align="left"/>
24656 <colspec colwidth="6*" align="center"/>
24657 <colspec colwidth="6*" align="center"/>
24658 <colspec colwidth="6*" align="right"/>
24659 <tbody>
24660 <row>
24661 <entry><option>openssl_options</option></entry>
24662 <entry>Use: <emphasis>main</emphasis></entry>
24663 <entry>Type: <emphasis>string list</emphasis></entry>
24664 <entry>Default: <emphasis>+dont_insert_empty_fragments</emphasis></entry>
24665 </row>
24666 </tbody>
24667 </tgroup>
24668 </informaltable>
24669 <para revisionflag="changed">
24670 <indexterm role="concept">
24671 <primary>OpenSSL </primary>
24672 <secondary>compatibility</secondary>
24673 </indexterm>
24674 This option allows an administrator to adjust the SSL options applied
24675 by OpenSSL to connections.  It is given as a space-separated list of items,
24676 each one to be +added or -subtracted from the current value.  The default
24677 value is one option which happens to have been set historically.  You can
24678 remove all options with:
24679 </para>
24680 <literallayout class="monospaced" revisionflag="changed">
24681 openssl_options = -all
24682 </literallayout>
24683 <para revisionflag="changed">
24684 This option is only available if Exim is built against OpenSSL.  The values
24685 available for this option vary according to the age of your OpenSSL install.
24686 The <quote>all</quote> value controls a subset of flags which are available, typically
24687 the bug workaround options.  The <emphasis>SSL_CTX_set_options</emphasis> man page will
24688 list the values known on your system and Exim should support all the
24689 <quote>bug workaround</quote> options and many of the <quote>modifying</quote> options.  The Exim
24690 names lose the leading <quote>SSL_OP_</quote> and are lower-cased.
24691 </para>
24692 <para revisionflag="changed">
24693 Note that adjusting the options can have severe impact upon the security of
24694 SSL as used by Exim.  It is possible to disable safety checks and shoot
24695 yourself in the foot in various unpleasant ways.  This option should not be
24696 adjusted lightly.  An unrecognised item will be detected at by invoking Exim
24697 with the <option>-bV</option> flag.
24698 </para>
24699 <para revisionflag="changed">
24700 An example:
24701 </para>
24702 <literallayout class="monospaced" revisionflag="changed">
24703 openssl_options = -all +microsoft_big_sslv3_buffer
24704 </literallayout>
24705 <para>
24706 <indexterm role="option">
24707 <primary><option>oracle_servers</option></primary>
24708 </indexterm>
24709 </para>
24710 <informaltable frame="all">
24711 <tgroup cols="4" colsep="0" rowsep="0">
24712 <colspec colwidth="8*" align="left"/>
24713 <colspec colwidth="6*" align="center"/>
24714 <colspec colwidth="6*" align="center"/>
24715 <colspec colwidth="6*" align="right"/>
24716 <tbody>
24717 <row>
24718 <entry><option>oracle_servers</option></entry>
24719 <entry>Use: <emphasis>main</emphasis></entry>
24720 <entry>Type: <emphasis>string list</emphasis></entry>
24721 <entry>Default: <emphasis>unset</emphasis></entry>
24722 </row>
24723 </tbody>
24724 </tgroup>
24725 </informaltable>
24726 <para>
24727 <indexterm role="concept">
24728 <primary>Oracle</primary>
24729 <secondary>server list</secondary>
24730 </indexterm>
24731 This option provides a list of Oracle servers and associated connection data,
24732 to be used in conjunction with <command>oracle</command> lookups (see section <xref linkend="SECID72"/>).
24733 The option is available only if Exim has been built with Oracle support.
24734 </para>
24735 <para>
24736 <indexterm role="option">
24737 <primary><option>percent_hack_domains</option></primary>
24738 </indexterm>
24739 </para>
24740 <informaltable frame="all">
24741 <tgroup cols="4" colsep="0" rowsep="0">
24742 <colspec colwidth="8*" align="left"/>
24743 <colspec colwidth="6*" align="center"/>
24744 <colspec colwidth="6*" align="center"/>
24745 <colspec colwidth="6*" align="right"/>
24746 <tbody>
24747 <row>
24748 <entry><option>percent_hack_domains</option></entry>
24749 <entry>Use: <emphasis>main</emphasis></entry>
24750 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
24751 <entry>Default: <emphasis>unset</emphasis></entry>
24752 </row>
24753 </tbody>
24754 </tgroup>
24755 </informaltable>
24756 <para>
24757 <indexterm role="concept">
24758 <primary><quote>percent hack</quote></primary>
24759 </indexterm>
24760 <indexterm role="concept">
24761 <primary>source routing</primary>
24762 <secondary>in email address</secondary>
24763 </indexterm>
24764 <indexterm role="concept">
24765 <primary>address</primary>
24766 <secondary>source-routed</secondary>
24767 </indexterm>
24768 The <quote>percent hack</quote> is the convention whereby a local part containing a
24769 percent sign is re-interpreted as a new email address, with the percent
24770 replaced by @. This is sometimes called <quote>source routing</quote>, though that term is
24771 also applied to RFC 2822 addresses that begin with an @ character. If this
24772 option is set, Exim implements the percent facility for those domains listed,
24773 but no others. This happens before an incoming SMTP address is tested against
24774 an ACL.
24775 </para>
24776 <para>
24777 <emphasis role="bold">Warning</emphasis>: The <quote>percent hack</quote> has often been abused by people who are
24778 trying to get round relaying restrictions. For this reason, it is best avoided
24779 if at all possible. Unfortunately, a number of less security-conscious MTAs
24780 implement it unconditionally. If you are running Exim on a gateway host, and
24781 routing mail through to internal MTAs without processing the local parts, it is
24782 a good idea to reject recipient addresses with percent characters in their
24783 local parts. Exim&#x2019;s default configuration does this.
24784 </para>
24785 <para>
24786 <indexterm role="option">
24787 <primary><option>perl_at_start</option></primary>
24788 </indexterm>
24789 </para>
24790 <informaltable frame="all">
24791 <tgroup cols="4" colsep="0" rowsep="0">
24792 <colspec colwidth="8*" align="left"/>
24793 <colspec colwidth="6*" align="center"/>
24794 <colspec colwidth="6*" align="center"/>
24795 <colspec colwidth="6*" align="right"/>
24796 <tbody>
24797 <row>
24798 <entry><option>perl_at_start</option></entry>
24799 <entry>Use: <emphasis>main</emphasis></entry>
24800 <entry>Type: <emphasis>boolean</emphasis></entry>
24801 <entry>Default: <emphasis>false</emphasis></entry>
24802 </row>
24803 </tbody>
24804 </tgroup>
24805 </informaltable>
24806 <para>
24807 This option is available only when Exim is built with an embedded Perl
24808 interpreter. See chapter <xref linkend="CHAPperl"/> for details of its use.
24809 </para>
24810 <para>
24811 <indexterm role="option">
24812 <primary><option>perl_startup</option></primary>
24813 </indexterm>
24814 </para>
24815 <informaltable frame="all">
24816 <tgroup cols="4" colsep="0" rowsep="0">
24817 <colspec colwidth="8*" align="left"/>
24818 <colspec colwidth="6*" align="center"/>
24819 <colspec colwidth="6*" align="center"/>
24820 <colspec colwidth="6*" align="right"/>
24821 <tbody>
24822 <row>
24823 <entry><option>perl_startup</option></entry>
24824 <entry>Use: <emphasis>main</emphasis></entry>
24825 <entry>Type: <emphasis>string</emphasis></entry>
24826 <entry>Default: <emphasis>unset</emphasis></entry>
24827 </row>
24828 </tbody>
24829 </tgroup>
24830 </informaltable>
24831 <para>
24832 This option is available only when Exim is built with an embedded Perl
24833 interpreter. See chapter <xref linkend="CHAPperl"/> for details of its use.
24834 </para>
24835 <para>
24836 <indexterm role="option">
24837 <primary><option>pgsql_servers</option></primary>
24838 </indexterm>
24839 </para>
24840 <informaltable frame="all">
24841 <tgroup cols="4" colsep="0" rowsep="0">
24842 <colspec colwidth="8*" align="left"/>
24843 <colspec colwidth="6*" align="center"/>
24844 <colspec colwidth="6*" align="center"/>
24845 <colspec colwidth="6*" align="right"/>
24846 <tbody>
24847 <row>
24848 <entry><option>pgsql_servers</option></entry>
24849 <entry>Use: <emphasis>main</emphasis></entry>
24850 <entry>Type: <emphasis>string list</emphasis></entry>
24851 <entry>Default: <emphasis>unset</emphasis></entry>
24852 </row>
24853 </tbody>
24854 </tgroup>
24855 </informaltable>
24856 <para>
24857 <indexterm role="concept">
24858 <primary>PostgreSQL lookup type</primary>
24859 <secondary>server list</secondary>
24860 </indexterm>
24861 This option provides a list of PostgreSQL servers and associated connection
24862 data, to be used in conjunction with <command>pgsql</command> lookups (see section
24863 <xref linkend="SECID72"/>). The option is available only if Exim has been built with
24864 PostgreSQL support.
24865 </para>
24866 <para>
24867 <indexterm role="option">
24868 <primary><option>pid_file_path</option></primary>
24869 </indexterm>
24870 </para>
24871 <informaltable frame="all">
24872 <tgroup cols="4" colsep="0" rowsep="0">
24873 <colspec colwidth="8*" align="left"/>
24874 <colspec colwidth="6*" align="center"/>
24875 <colspec colwidth="6*" align="center"/>
24876 <colspec colwidth="6*" align="right"/>
24877 <tbody>
24878 <row>
24879 <entry><option>pid_file_path</option></entry>
24880 <entry>Use: <emphasis>main</emphasis></entry>
24881 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
24882 <entry>Default: <emphasis>set at compile time</emphasis></entry>
24883 </row>
24884 </tbody>
24885 </tgroup>
24886 </informaltable>
24887 <para>
24888 <indexterm role="concept">
24889 <primary>daemon</primary>
24890 <secondary>pid file path</secondary>
24891 </indexterm>
24892 <indexterm role="concept">
24893 <primary>pid file, path for</primary>
24894 </indexterm>
24895 This option sets the name of the file to which the Exim daemon writes its
24896 process id. The string is expanded, so it can contain, for example, references
24897 to the host name:
24898 </para>
24899 <literallayout class="monospaced">
24900 pid_file_path = /var/log/$primary_hostname/exim.pid
24901 </literallayout>
24902 <para>
24903 If no path is set, the pid is written to the file <filename>exim-daemon.pid</filename> in Exim&#x2019;s
24904 spool directory.
24905 The value set by the option can be overridden by the <option>-oP</option> command line
24906 option. A pid file is not written if a <quote>non-standard</quote> daemon is run by means
24907 of the <option>-oX</option> option, unless a path is explicitly supplied by <option>-oP</option>.
24908 </para>
24909 <para>
24910 <indexterm role="option">
24911 <primary><option>pipelining_advertise_hosts</option></primary>
24912 </indexterm>
24913 </para>
24914 <informaltable frame="all">
24915 <tgroup cols="4" colsep="0" rowsep="0">
24916 <colspec colwidth="8*" align="left"/>
24917 <colspec colwidth="6*" align="center"/>
24918 <colspec colwidth="6*" align="center"/>
24919 <colspec colwidth="6*" align="right"/>
24920 <tbody>
24921 <row>
24922 <entry><option>pipelining_advertise_hosts</option></entry>
24923 <entry>Use: <emphasis>main</emphasis></entry>
24924 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
24925 <entry>Default: <emphasis>*</emphasis></entry>
24926 </row>
24927 </tbody>
24928 </tgroup>
24929 </informaltable>
24930 <para>
24931 <indexterm role="concept">
24932 <primary>PIPELINING</primary>
24933 <secondary>suppressing advertising</secondary>
24934 </indexterm>
24935 This option can be used to suppress the advertisement of the SMTP
24936 PIPELINING extension to specific hosts. See also the <emphasis role="bold">no_pipelining</emphasis>
24937 control in section <xref linkend="SECTcontrols"/>. When PIPELINING is not advertised and
24938 <option>smtp_enforce_sync</option> is true, an Exim server enforces strict synchronization
24939 for each SMTP command and response. When PIPELINING is advertised, Exim assumes
24940 that clients will use it; <quote>out of order</quote> commands that are <quote>expected</quote> do
24941 not count as protocol errors (see <option>smtp_max_synprot_errors</option>).
24942 </para>
24943 <para>
24944 <indexterm role="option">
24945 <primary><option>preserve_message_logs</option></primary>
24946 </indexterm>
24947 </para>
24948 <informaltable frame="all">
24949 <tgroup cols="4" colsep="0" rowsep="0">
24950 <colspec colwidth="8*" align="left"/>
24951 <colspec colwidth="6*" align="center"/>
24952 <colspec colwidth="6*" align="center"/>
24953 <colspec colwidth="6*" align="right"/>
24954 <tbody>
24955 <row>
24956 <entry><option>preserve_message_logs</option></entry>
24957 <entry>Use: <emphasis>main</emphasis></entry>
24958 <entry>Type: <emphasis>boolean</emphasis></entry>
24959 <entry>Default: <emphasis>false</emphasis></entry>
24960 </row>
24961 </tbody>
24962 </tgroup>
24963 </informaltable>
24964 <para>
24965 <indexterm role="concept">
24966 <primary>message logs</primary>
24967 <secondary>preserving</secondary>
24968 </indexterm>
24969 If this option is set, message log files are not deleted when messages are
24970 completed. Instead, they are moved to a sub-directory of the spool directory
24971 called <filename>msglog.OLD</filename>, where they remain available for statistical or debugging
24972 purposes. This is a dangerous option to set on systems with any appreciable
24973 volume of mail. Use with care!
24974 </para>
24975 <para>
24976 <indexterm role="option">
24977 <primary><option>primary_hostname</option></primary>
24978 </indexterm>
24979 </para>
24980 <informaltable frame="all">
24981 <tgroup cols="4" colsep="0" rowsep="0">
24982 <colspec colwidth="8*" align="left"/>
24983 <colspec colwidth="6*" align="center"/>
24984 <colspec colwidth="6*" align="center"/>
24985 <colspec colwidth="6*" align="right"/>
24986 <tbody>
24987 <row>
24988 <entry><option>primary_hostname</option></entry>
24989 <entry>Use: <emphasis>main</emphasis></entry>
24990 <entry>Type: <emphasis>string</emphasis></entry>
24991 <entry>Default: <emphasis>see below</emphasis></entry>
24992 </row>
24993 </tbody>
24994 </tgroup>
24995 </informaltable>
24996 <para>
24997 <indexterm role="concept">
24998 <primary>name</primary>
24999 <secondary>of local host</secondary>
25000 </indexterm>
25001 <indexterm role="concept">
25002 <primary>host</primary>
25003 <secondary>name of local</secondary>
25004 </indexterm>
25005 <indexterm role="concept">
25006 <primary>local host</primary>
25007 <secondary>name of</secondary>
25008 </indexterm>
25009 <indexterm role="variable">
25010 <primary><varname>$primary_hostname</varname></primary>
25011 </indexterm>
25012 This specifies the name of the current host. It is used in the default EHLO or
25013 HELO command for outgoing SMTP messages (changeable via the <option>helo_data</option>
25014 option in the <command>smtp</command> transport), and as the default for <option>qualify_domain</option>.
25015 The value is also used by default in some SMTP response messages from an Exim
25016 server. This can be changed dynamically by setting <option>smtp_active_hostname</option>.
25017 </para>
25018 <para>
25019 If <option>primary_hostname</option> is not set, Exim calls <function>uname()</function> to find the host
25020 name. If this fails, Exim panics and dies. If the name returned by <function>uname()</function>
25021 contains only one component, Exim passes it to <function>gethostbyname()</function> (or
25022 <function>getipnodebyname()</function> when available) in order to obtain the fully qualified
25023 version. The variable <varname>$primary_hostname</varname> contains the host name, whether set
25024 explicitly by this option, or defaulted.
25025 </para>
25026 <para>
25027 <indexterm role="option">
25028 <primary><option>print_topbitchars</option></primary>
25029 </indexterm>
25030 </para>
25031 <informaltable frame="all">
25032 <tgroup cols="4" colsep="0" rowsep="0">
25033 <colspec colwidth="8*" align="left"/>
25034 <colspec colwidth="6*" align="center"/>
25035 <colspec colwidth="6*" align="center"/>
25036 <colspec colwidth="6*" align="right"/>
25037 <tbody>
25038 <row>
25039 <entry><option>print_topbitchars</option></entry>
25040 <entry>Use: <emphasis>main</emphasis></entry>
25041 <entry>Type: <emphasis>boolean</emphasis></entry>
25042 <entry>Default: <emphasis>false</emphasis></entry>
25043 </row>
25044 </tbody>
25045 </tgroup>
25046 </informaltable>
25047 <para>
25048 <indexterm role="concept">
25049 <primary>printing characters</primary>
25050 </indexterm>
25051 <indexterm role="concept">
25052 <primary>8-bit characters</primary>
25053 </indexterm>
25054 By default, Exim considers only those characters whose codes lie in the range
25055 32&ndash;126 to be printing characters. In a number of circumstances (for example,
25056 when writing log entries) non-printing characters are converted into escape
25057 sequences, primarily to avoid messing up the layout. If <option>print_topbitchars</option>
25058 is set, code values of 128 and above are also considered to be printing
25059 characters.
25060 </para>
25061 <para>
25062 This option also affects the header syntax checks performed by the
25063 <command>autoreply</command> transport, and whether Exim uses RFC 2047 encoding of
25064 the user&#x2019;s full name when constructing From: and Sender: addresses (as
25065 described in section <xref linkend="SECTconstr"/>). Setting this option can cause
25066 Exim to generate eight bit message headers that do not conform to the
25067 standards.
25068 </para>
25069 <para>
25070 <indexterm role="option">
25071 <primary><option>process_log_path</option></primary>
25072 </indexterm>
25073 </para>
25074 <informaltable frame="all">
25075 <tgroup cols="4" colsep="0" rowsep="0">
25076 <colspec colwidth="8*" align="left"/>
25077 <colspec colwidth="6*" align="center"/>
25078 <colspec colwidth="6*" align="center"/>
25079 <colspec colwidth="6*" align="right"/>
25080 <tbody>
25081 <row>
25082 <entry><option>process_log_path</option></entry>
25083 <entry>Use: <emphasis>main</emphasis></entry>
25084 <entry>Type: <emphasis>string</emphasis></entry>
25085 <entry>Default: <emphasis>unset</emphasis></entry>
25086 </row>
25087 </tbody>
25088 </tgroup>
25089 </informaltable>
25090 <para>
25091 <indexterm role="concept">
25092 <primary>process log path</primary>
25093 </indexterm>
25094 <indexterm role="concept">
25095 <primary>log</primary>
25096 <secondary>process log</secondary>
25097 </indexterm>
25098 <indexterm role="concept">
25099 <primary><emphasis>exiwhat</emphasis></primary>
25100 </indexterm>
25101 This option sets the name of the file to which an Exim process writes its
25102 <quote>process log</quote> when sent a USR1 signal. This is used by the <emphasis>exiwhat</emphasis>
25103 utility script. If this option is unset, the file called <filename>exim-process.info</filename>
25104 in Exim&#x2019;s spool directory is used. The ability to specify the name explicitly
25105 can be useful in environments where two different Exims are running, using
25106 different spool directories.
25107 </para>
25108 <para>
25109 <indexterm role="option">
25110 <primary><option>prod_requires_admin</option></primary>
25111 </indexterm>
25112 </para>
25113 <informaltable frame="all">
25114 <tgroup cols="4" colsep="0" rowsep="0">
25115 <colspec colwidth="8*" align="left"/>
25116 <colspec colwidth="6*" align="center"/>
25117 <colspec colwidth="6*" align="center"/>
25118 <colspec colwidth="6*" align="right"/>
25119 <tbody>
25120 <row>
25121 <entry><option>prod_requires_admin</option></entry>
25122 <entry>Use: <emphasis>main</emphasis></entry>
25123 <entry>Type: <emphasis>boolean</emphasis></entry>
25124 <entry>Default: <emphasis>true</emphasis></entry>
25125 </row>
25126 </tbody>
25127 </tgroup>
25128 </informaltable>
25129 <para>
25130 <indexterm role="option">
25131 <primary><option>-M</option></primary>
25132 </indexterm>
25133 <indexterm role="option">
25134 <primary><option>-R</option></primary>
25135 </indexterm>
25136 <indexterm role="option">
25137 <primary><option>-q</option></primary>
25138 </indexterm>
25139 The <option>-M</option>, <option>-R</option>, and <option>-q</option> command-line options require the caller to be an
25140 admin user unless <option>prod_requires_admin</option> is set false. See also
25141 <option>queue_list_requires_admin</option>.
25142 </para>
25143 <para>
25144 <indexterm role="option">
25145 <primary><option>qualify_domain</option></primary>
25146 </indexterm>
25147 </para>
25148 <informaltable frame="all">
25149 <tgroup cols="4" colsep="0" rowsep="0">
25150 <colspec colwidth="8*" align="left"/>
25151 <colspec colwidth="6*" align="center"/>
25152 <colspec colwidth="6*" align="center"/>
25153 <colspec colwidth="6*" align="right"/>
25154 <tbody>
25155 <row>
25156 <entry><option>qualify_domain</option></entry>
25157 <entry>Use: <emphasis>main</emphasis></entry>
25158 <entry>Type: <emphasis>string</emphasis></entry>
25159 <entry>Default: <emphasis>see below</emphasis></entry>
25160 </row>
25161 </tbody>
25162 </tgroup>
25163 </informaltable>
25164 <para>
25165 <indexterm role="concept">
25166 <primary>domain</primary>
25167 <secondary>for qualifying addresses</secondary>
25168 </indexterm>
25169 <indexterm role="concept">
25170 <primary>address</primary>
25171 <secondary>qualification</secondary>
25172 </indexterm>
25173 This option specifies the domain name that is added to any envelope sender
25174 addresses that do not have a domain qualification. It also applies to
25175 recipient addresses if <option>qualify_recipient</option> is not set. Unqualified addresses
25176 are accepted by default only for locally-generated messages. Qualification is
25177 also applied to addresses in header lines such as <emphasis>From:</emphasis> and <emphasis>To:</emphasis> for
25178 locally-generated messages, unless the <option>-bnq</option> command line option is used.
25179 </para>
25180 <para>
25181 Messages from external sources must always contain fully qualified addresses,
25182 unless the sending host matches <option>sender_unqualified_hosts</option> or
25183 <option>recipient_unqualified_hosts</option> (as appropriate), in which case incoming
25184 addresses are qualified with <option>qualify_domain</option> or <option>qualify_recipient</option> as
25185 necessary. Internally, Exim always works with fully qualified envelope
25186 addresses. If <option>qualify_domain</option> is not set, it defaults to the
25187 <option>primary_hostname</option> value.
25188 </para>
25189 <para>
25190 <indexterm role="option">
25191 <primary><option>qualify_recipient</option></primary>
25192 </indexterm>
25193 </para>
25194 <informaltable frame="all">
25195 <tgroup cols="4" colsep="0" rowsep="0">
25196 <colspec colwidth="8*" align="left"/>
25197 <colspec colwidth="6*" align="center"/>
25198 <colspec colwidth="6*" align="center"/>
25199 <colspec colwidth="6*" align="right"/>
25200 <tbody>
25201 <row>
25202 <entry><option>qualify_recipient</option></entry>
25203 <entry>Use: <emphasis>main</emphasis></entry>
25204 <entry>Type: <emphasis>string</emphasis></entry>
25205 <entry>Default: <emphasis>see below</emphasis></entry>
25206 </row>
25207 </tbody>
25208 </tgroup>
25209 </informaltable>
25210 <para>
25211 This option allows you to specify a different domain for qualifying recipient
25212 addresses to the one that is used for senders. See <option>qualify_domain</option> above.
25213 </para>
25214 <para>
25215 <indexterm role="option">
25216 <primary><option>queue_domains</option></primary>
25217 </indexterm>
25218 </para>
25219 <informaltable frame="all">
25220 <tgroup cols="4" colsep="0" rowsep="0">
25221 <colspec colwidth="8*" align="left"/>
25222 <colspec colwidth="6*" align="center"/>
25223 <colspec colwidth="6*" align="center"/>
25224 <colspec colwidth="6*" align="right"/>
25225 <tbody>
25226 <row>
25227 <entry><option>queue_domains</option></entry>
25228 <entry>Use: <emphasis>main</emphasis></entry>
25229 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
25230 <entry>Default: <emphasis>unset</emphasis></entry>
25231 </row>
25232 </tbody>
25233 </tgroup>
25234 </informaltable>
25235 <para>
25236 <indexterm role="concept">
25237 <primary>domain</primary>
25238 <secondary>specifying non-immediate delivery</secondary>
25239 </indexterm>
25240 <indexterm role="concept">
25241 <primary>queueing incoming messages</primary>
25242 </indexterm>
25243 <indexterm role="concept">
25244 <primary>message</primary>
25245 <secondary>queueing certain domains</secondary>
25246 </indexterm>
25247 This option lists domains for which immediate delivery is not required.
25248 A delivery process is started whenever a message is received, but only those
25249 domains that do not match are processed. All other deliveries wait until the
25250 next queue run. See also <option>hold_domains</option> and <option>queue_smtp_domains</option>.
25251 </para>
25252 <para>
25253 <indexterm role="option">
25254 <primary><option>queue_list_requires_admin</option></primary>
25255 </indexterm>
25256 </para>
25257 <informaltable frame="all">
25258 <tgroup cols="4" colsep="0" rowsep="0">
25259 <colspec colwidth="8*" align="left"/>
25260 <colspec colwidth="6*" align="center"/>
25261 <colspec colwidth="6*" align="center"/>
25262 <colspec colwidth="6*" align="right"/>
25263 <tbody>
25264 <row>
25265 <entry><option>queue_list_requires_admin</option></entry>
25266 <entry>Use: <emphasis>main</emphasis></entry>
25267 <entry>Type: <emphasis>boolean</emphasis></entry>
25268 <entry>Default: <emphasis>true</emphasis></entry>
25269 </row>
25270 </tbody>
25271 </tgroup>
25272 </informaltable>
25273 <para>
25274 <indexterm role="option">
25275 <primary><option>-bp</option></primary>
25276 </indexterm>
25277 The <option>-bp</option> command-line option, which lists the messages that are on the
25278 queue, requires the caller to be an admin user unless
25279 <option>queue_list_requires_admin</option> is set false. See also <option>prod_requires_admin</option>.
25280 </para>
25281 <para>
25282 <indexterm role="option">
25283 <primary><option>queue_only</option></primary>
25284 </indexterm>
25285 </para>
25286 <informaltable frame="all">
25287 <tgroup cols="4" colsep="0" rowsep="0">
25288 <colspec colwidth="8*" align="left"/>
25289 <colspec colwidth="6*" align="center"/>
25290 <colspec colwidth="6*" align="center"/>
25291 <colspec colwidth="6*" align="right"/>
25292 <tbody>
25293 <row>
25294 <entry><option>queue_only</option></entry>
25295 <entry>Use: <emphasis>main</emphasis></entry>
25296 <entry>Type: <emphasis>boolean</emphasis></entry>
25297 <entry>Default: <emphasis>false</emphasis></entry>
25298 </row>
25299 </tbody>
25300 </tgroup>
25301 </informaltable>
25302 <para>
25303 <indexterm role="concept">
25304 <primary>queueing incoming messages</primary>
25305 </indexterm>
25306 <indexterm role="concept">
25307 <primary>message</primary>
25308 <secondary>queueing unconditionally</secondary>
25309 </indexterm>
25310 If <option>queue_only</option> is set, a delivery process is not automatically started
25311 whenever a message is received. Instead, the message waits on the queue for the
25312 next queue run. Even if <option>queue_only</option> is false, incoming messages may not get
25313 delivered immediately when certain conditions (such as heavy load) occur.
25314 </para>
25315 <para>
25316 The <option>-odq</option> command line has the same effect as <option>queue_only</option>. The <option>-odb</option>
25317 and <option>-odi</option> command line options override <option>queue_only</option> unless
25318 <option>queue_only_override</option> is set false. See also <option>queue_only_file</option>,
25319 <option>queue_only_load</option>, and <option>smtp_accept_queue</option>.
25320 </para>
25321 <para>
25322 <indexterm role="option">
25323 <primary><option>queue_only_file</option></primary>
25324 </indexterm>
25325 </para>
25326 <informaltable frame="all">
25327 <tgroup cols="4" colsep="0" rowsep="0">
25328 <colspec colwidth="8*" align="left"/>
25329 <colspec colwidth="6*" align="center"/>
25330 <colspec colwidth="6*" align="center"/>
25331 <colspec colwidth="6*" align="right"/>
25332 <tbody>
25333 <row>
25334 <entry><option>queue_only_file</option></entry>
25335 <entry>Use: <emphasis>main</emphasis></entry>
25336 <entry>Type: <emphasis>string</emphasis></entry>
25337 <entry>Default: <emphasis>unset</emphasis></entry>
25338 </row>
25339 </tbody>
25340 </tgroup>
25341 </informaltable>
25342 <para>
25343 <indexterm role="concept">
25344 <primary>queueing incoming messages</primary>
25345 </indexterm>
25346 <indexterm role="concept">
25347 <primary>message</primary>
25348 <secondary>queueing by file existence</secondary>
25349 </indexterm>
25350 This option can be set to a colon-separated list of absolute path names, each
25351 one optionally preceded by <quote>smtp</quote>. When Exim is receiving a message,
25352 it tests for the existence of each listed path using a call to <function>stat()</function>. For
25353 each path that exists, the corresponding queueing option is set.
25354 For paths with no prefix, <option>queue_only</option> is set; for paths prefixed by
25355 <quote>smtp</quote>, <option>queue_smtp_domains</option> is set to match all domains. So, for example,
25356 </para>
25357 <literallayout class="monospaced">
25358 queue_only_file = smtp/some/file
25359 </literallayout>
25360 <para>
25361 causes Exim to behave as if <option>queue_smtp_domains</option> were set to <quote>*</quote> whenever
25362 <filename>/some/file</filename> exists.
25363 </para>
25364 <para>
25365 <indexterm role="option">
25366 <primary><option>queue_only_load</option></primary>
25367 </indexterm>
25368 </para>
25369 <informaltable frame="all">
25370 <tgroup cols="4" colsep="0" rowsep="0">
25371 <colspec colwidth="8*" align="left"/>
25372 <colspec colwidth="6*" align="center"/>
25373 <colspec colwidth="6*" align="center"/>
25374 <colspec colwidth="6*" align="right"/>
25375 <tbody>
25376 <row>
25377 <entry><option>queue_only_load</option></entry>
25378 <entry>Use: <emphasis>main</emphasis></entry>
25379 <entry>Type: <emphasis>fixed-point</emphasis></entry>
25380 <entry>Default: <emphasis>unset</emphasis></entry>
25381 </row>
25382 </tbody>
25383 </tgroup>
25384 </informaltable>
25385 <para>
25386 <indexterm role="concept">
25387 <primary>load average</primary>
25388 </indexterm>
25389 <indexterm role="concept">
25390 <primary>queueing incoming messages</primary>
25391 </indexterm>
25392 <indexterm role="concept">
25393 <primary>message</primary>
25394 <secondary>queueing by load</secondary>
25395 </indexterm>
25396 If the system load average is higher than this value, incoming messages from
25397 all sources are queued, and no automatic deliveries are started. If this
25398 happens during local or remote SMTP input, all subsequent messages received on
25399 the same SMTP connection are queued by default, whatever happens to the load in
25400 the meantime, but this can be changed by setting <option>queue_only_load_latch</option>
25401 false.
25402 </para>
25403 <para>
25404 Deliveries will subsequently be performed by queue runner processes. This
25405 option has no effect on ancient operating systems on which Exim cannot
25406 determine the load average. See also <option>deliver_queue_load_max</option> and
25407 <option>smtp_load_reserve</option>.
25408 </para>
25409 <para>
25410 <indexterm role="option">
25411 <primary><option>queue_only_load_latch</option></primary>
25412 </indexterm>
25413 </para>
25414 <informaltable frame="all">
25415 <tgroup cols="4" colsep="0" rowsep="0">
25416 <colspec colwidth="8*" align="left"/>
25417 <colspec colwidth="6*" align="center"/>
25418 <colspec colwidth="6*" align="center"/>
25419 <colspec colwidth="6*" align="right"/>
25420 <tbody>
25421 <row>
25422 <entry><option>queue_only_load_latch</option></entry>
25423 <entry>Use: <emphasis>main</emphasis></entry>
25424 <entry>Type: <emphasis>boolean</emphasis></entry>
25425 <entry>Default: <emphasis>true</emphasis></entry>
25426 </row>
25427 </tbody>
25428 </tgroup>
25429 </informaltable>
25430 <para>
25431 <indexterm role="concept">
25432 <primary>load average</primary>
25433 <secondary>re-evaluating per message</secondary>
25434 </indexterm>
25435 When this option is true (the default), once one message has been queued
25436 because the load average is higher than the value set by <option>queue_only_load</option>,
25437 all subsequent messages received on the same SMTP connection are also queued.
25438 This is a deliberate choice; even though the load average may fall below the
25439 threshold, it doesn&#x2019;t seem right to deliver later messages on the same
25440 connection when not delivering earlier ones. However, there are special
25441 circumstances such as very long-lived connections from scanning appliances
25442 where this is not the best strategy. In such cases, <option>queue_only_load_latch</option>
25443 should be set false. This causes the value of the load average to be
25444 re-evaluated for each message.
25445 </para>
25446 <para>
25447 <indexterm role="option">
25448 <primary><option>queue_only_override</option></primary>
25449 </indexterm>
25450 </para>
25451 <informaltable frame="all">
25452 <tgroup cols="4" colsep="0" rowsep="0">
25453 <colspec colwidth="8*" align="left"/>
25454 <colspec colwidth="6*" align="center"/>
25455 <colspec colwidth="6*" align="center"/>
25456 <colspec colwidth="6*" align="right"/>
25457 <tbody>
25458 <row>
25459 <entry><option>queue_only_override</option></entry>
25460 <entry>Use: <emphasis>main</emphasis></entry>
25461 <entry>Type: <emphasis>boolean</emphasis></entry>
25462 <entry>Default: <emphasis>true</emphasis></entry>
25463 </row>
25464 </tbody>
25465 </tgroup>
25466 </informaltable>
25467 <para>
25468 <indexterm role="concept">
25469 <primary>queueing incoming messages</primary>
25470 </indexterm>
25471 When this option is true, the <option>-od</option><emphasis>x</emphasis> command line options override the
25472 setting of <option>queue_only</option> or <option>queue_only_file</option> in the configuration file. If
25473 <option>queue_only_override</option> is set false, the <option>-od</option><emphasis>x</emphasis> options cannot be used
25474 to override; they are accepted, but ignored.
25475 </para>
25476 <para>
25477 <indexterm role="option">
25478 <primary><option>queue_run_in_order</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>queue_run_in_order</option></entry>
25490 <entry>Use: <emphasis>main</emphasis></entry>
25491 <entry>Type: <emphasis>boolean</emphasis></entry>
25492 <entry>Default: <emphasis>false</emphasis></entry>
25493 </row>
25494 </tbody>
25495 </tgroup>
25496 </informaltable>
25497 <para>
25498 <indexterm role="concept">
25499 <primary>queue runner</primary>
25500 <secondary>processing messages in order</secondary>
25501 </indexterm>
25502 If this option is set, queue runs happen in order of message arrival instead of
25503 in an arbitrary order. For this to happen, a complete list of the entire queue
25504 must be set up before the deliveries start. When the queue is all held in a
25505 single directory (the default), a single list is created for both the ordered
25506 and the non-ordered cases. However, if <option>split_spool_directory</option> is set, a
25507 single list is not created when <option>queue_run_in_order</option> is false. In this case,
25508 the sub-directories are processed one at a time (in a random order), and this
25509 avoids setting up one huge list for the whole queue. Thus, setting
25510 <option>queue_run_in_order</option> with <option>split_spool_directory</option> may degrade performance
25511 when the queue is large, because of the extra work in setting up the single,
25512 large list. In most situations, <option>queue_run_in_order</option> should not be set.
25513 </para>
25514 <para>
25515 <indexterm role="option">
25516 <primary><option>queue_run_max</option></primary>
25517 </indexterm>
25518 </para>
25519 <informaltable frame="all">
25520 <tgroup cols="4" colsep="0" rowsep="0">
25521 <colspec colwidth="8*" align="left"/>
25522 <colspec colwidth="6*" align="center"/>
25523 <colspec colwidth="6*" align="center"/>
25524 <colspec colwidth="6*" align="right"/>
25525 <tbody>
25526 <row>
25527 <entry><option>queue_run_max</option></entry>
25528 <entry>Use: <emphasis>main</emphasis></entry>
25529 <entry>Type: <emphasis>integer</emphasis></entry>
25530 <entry>Default: <emphasis>5</emphasis></entry>
25531 </row>
25532 </tbody>
25533 </tgroup>
25534 </informaltable>
25535 <para>
25536 <indexterm role="concept">
25537 <primary>queue runner</primary>
25538 <secondary>maximum number of</secondary>
25539 </indexterm>
25540 This controls the maximum number of queue runner processes that an Exim daemon
25541 can run simultaneously. This does not mean that it starts them all at once,
25542 but rather that if the maximum number are still running when the time comes to
25543 start another one, it refrains from starting another one. This can happen with
25544 very large queues and/or very sluggish deliveries. This option does not,
25545 however, interlock with other processes, so additional queue runners can be
25546 started by other means, or by killing and restarting the daemon.
25547 </para>
25548 <para>
25549 Setting this option to zero does not suppress queue runs; rather, it disables
25550 the limit, allowing any number of simultaneous queue runner processes to be
25551 run. If you do not want queue runs to occur, omit the <option>-q</option><emphasis>xx</emphasis> setting on
25552 the daemon&#x2019;s command line.
25553 </para>
25554 <para>
25555 <indexterm role="option">
25556 <primary><option>queue_smtp_domains</option></primary>
25557 </indexterm>
25558 </para>
25559 <informaltable frame="all">
25560 <tgroup cols="4" colsep="0" rowsep="0">
25561 <colspec colwidth="8*" align="left"/>
25562 <colspec colwidth="6*" align="center"/>
25563 <colspec colwidth="6*" align="center"/>
25564 <colspec colwidth="6*" align="right"/>
25565 <tbody>
25566 <row>
25567 <entry><option>queue_smtp_domains</option></entry>
25568 <entry>Use: <emphasis>main</emphasis></entry>
25569 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
25570 <entry>Default: <emphasis>unset</emphasis></entry>
25571 </row>
25572 </tbody>
25573 </tgroup>
25574 </informaltable>
25575 <para>
25576 <indexterm role="concept">
25577 <primary>queueing incoming messages</primary>
25578 </indexterm>
25579 <indexterm role="concept">
25580 <primary>message</primary>
25581 <secondary>queueing remote deliveries</secondary>
25582 </indexterm>
25583 When this option is set, a delivery process is started whenever a message is
25584 received, routing is performed, and local deliveries take place.
25585 However, if any SMTP deliveries are required for domains that match
25586 <option>queue_smtp_domains</option>, they are not immediately delivered, but instead the
25587 message waits on the queue for the next queue run. Since routing of the message
25588 has taken place, Exim knows to which remote hosts it must be delivered, and so
25589 when the queue run happens, multiple messages for the same host are delivered
25590 over a single SMTP connection. The <option>-odqs</option> command line option causes all
25591 SMTP deliveries to be queued in this way, and is equivalent to setting
25592 <option>queue_smtp_domains</option> to <quote>*</quote>. See also <option>hold_domains</option> and
25593 <option>queue_domains</option>.
25594 </para>
25595 <para>
25596 <indexterm role="option">
25597 <primary><option>receive_timeout</option></primary>
25598 </indexterm>
25599 </para>
25600 <informaltable frame="all">
25601 <tgroup cols="4" colsep="0" rowsep="0">
25602 <colspec colwidth="8*" align="left"/>
25603 <colspec colwidth="6*" align="center"/>
25604 <colspec colwidth="6*" align="center"/>
25605 <colspec colwidth="6*" align="right"/>
25606 <tbody>
25607 <row>
25608 <entry><option>receive_timeout</option></entry>
25609 <entry>Use: <emphasis>main</emphasis></entry>
25610 <entry>Type: <emphasis>time</emphasis></entry>
25611 <entry>Default: <emphasis>0s</emphasis></entry>
25612 </row>
25613 </tbody>
25614 </tgroup>
25615 </informaltable>
25616 <para>
25617 <indexterm role="concept">
25618 <primary>timeout</primary>
25619 <secondary>for non-SMTP input</secondary>
25620 </indexterm>
25621 This option sets the timeout for accepting a non-SMTP message, that is, the
25622 maximum time that Exim waits when reading a message on the standard input. If
25623 the value is zero, it will wait for ever. This setting is overridden by the
25624 <option>-or</option> command line option. The timeout for incoming SMTP messages is
25625 controlled by <option>smtp_receive_timeout</option>.
25626 </para>
25627 <para>
25628 <indexterm role="option">
25629 <primary><option>received_header_text</option></primary>
25630 </indexterm>
25631 </para>
25632 <informaltable frame="all">
25633 <tgroup cols="4" colsep="0" rowsep="0">
25634 <colspec colwidth="8*" align="left"/>
25635 <colspec colwidth="6*" align="center"/>
25636 <colspec colwidth="6*" align="center"/>
25637 <colspec colwidth="6*" align="right"/>
25638 <tbody>
25639 <row>
25640 <entry><option>received_header_text</option></entry>
25641 <entry>Use: <emphasis>main</emphasis></entry>
25642 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
25643 <entry>Default: <emphasis>see below</emphasis></entry>
25644 </row>
25645 </tbody>
25646 </tgroup>
25647 </informaltable>
25648 <para>
25649 <indexterm role="concept">
25650 <primary>customizing</primary>
25651 <secondary><emphasis>Received:</emphasis> header</secondary>
25652 </indexterm>
25653 <indexterm role="concept">
25654 <primary><emphasis>Received:</emphasis> header line</primary>
25655 <secondary>customizing</secondary>
25656 </indexterm>
25657 This string defines the contents of the <emphasis>Received:</emphasis> message header that is
25658 added to each message, except for the timestamp, which is automatically added
25659 on at the end (preceded by a semicolon). The string is expanded each time it is
25660 used. If the expansion yields an empty string, no <emphasis>Received:</emphasis> header line is
25661 added to the message. Otherwise, the string should start with the text
25662 <quote>Received:</quote> and conform to the RFC 2822 specification for <emphasis>Received:</emphasis>
25663 header lines. The default setting is:
25664 </para>
25665 <literallayout class="monospaced">
25666 received_header_text = Received: \
25667   ${if def:sender_rcvhost {from $sender_rcvhost\n\t}\
25668   {${if def:sender_ident \
25669   {from ${quote_local_part:$sender_ident} }}\
25670   ${if def:sender_helo_name {(helo=$sender_helo_name)\n\t}}}}\
25671   by $primary_hostname \
25672   ${if def:received_protocol {with $received_protocol}} \
25673   ${if def:tls_cipher {($tls_cipher)\n\t}}\
25674   (Exim $version_number)\n\t\
25675   ${if def:sender_address \
25676   {(envelope-from &lt;$sender_address&gt;)\n\t}}\
25677   id $message_exim_id\
25678   ${if def:received_for {\n\tfor $received_for}}
25679 </literallayout>
25680 <para>
25681 The reference to the TLS cipher is omitted when Exim is built without TLS
25682 support. The use of conditional expansions ensures that this works for both
25683 locally generated messages and messages received from remote hosts, giving
25684 header lines such as the following:
25685 </para>
25686 <literallayout class="monospaced">
25687 Received: from scrooge.carol.example ([192.168.12.25] ident=root)
25688 by marley.carol.example with esmtp (Exim 4.00)
25689 (envelope-from &lt;bob@carol.example&gt;)
25690 id 16IOWa-00019l-00
25691 for chas@dickens.example; Tue, 25 Dec 2001 14:43:44 +0000
25692 Received: by scrooge.carol.example with local (Exim 4.00)
25693 id 16IOWW-000083-00; Tue, 25 Dec 2001 14:43:41 +0000
25694 </literallayout>
25695 <para>
25696 Until the body of the message has been received, the timestamp is the time when
25697 the message started to be received. Once the body has arrived, and all policy
25698 checks have taken place, the timestamp is updated to the time at which the
25699 message was accepted.
25700 </para>
25701 <para>
25702 <indexterm role="option">
25703 <primary><option>received_headers_max</option></primary>
25704 </indexterm>
25705 </para>
25706 <informaltable frame="all">
25707 <tgroup cols="4" colsep="0" rowsep="0">
25708 <colspec colwidth="8*" align="left"/>
25709 <colspec colwidth="6*" align="center"/>
25710 <colspec colwidth="6*" align="center"/>
25711 <colspec colwidth="6*" align="right"/>
25712 <tbody>
25713 <row>
25714 <entry><option>received_headers_max</option></entry>
25715 <entry>Use: <emphasis>main</emphasis></entry>
25716 <entry>Type: <emphasis>integer</emphasis></entry>
25717 <entry>Default: <emphasis>30</emphasis></entry>
25718 </row>
25719 </tbody>
25720 </tgroup>
25721 </informaltable>
25722 <para>
25723 <indexterm role="concept">
25724 <primary>loop</primary>
25725 <secondary>prevention</secondary>
25726 </indexterm>
25727 <indexterm role="concept">
25728 <primary>mail loop prevention</primary>
25729 </indexterm>
25730 <indexterm role="concept">
25731 <primary><emphasis>Received:</emphasis> header line</primary>
25732 <secondary>counting</secondary>
25733 </indexterm>
25734 When a message is to be delivered, the number of <emphasis>Received:</emphasis> headers is
25735 counted, and if it is greater than this parameter, a mail loop is assumed to
25736 have occurred, the delivery is abandoned, and an error message is generated.
25737 This applies to both local and remote deliveries.
25738 </para>
25739 <para>
25740 <indexterm role="option">
25741 <primary><option>recipient_unqualified_hosts</option></primary>
25742 </indexterm>
25743 </para>
25744 <informaltable frame="all">
25745 <tgroup cols="4" colsep="0" rowsep="0">
25746 <colspec colwidth="8*" align="left"/>
25747 <colspec colwidth="6*" align="center"/>
25748 <colspec colwidth="6*" align="center"/>
25749 <colspec colwidth="6*" align="right"/>
25750 <tbody>
25751 <row>
25752 <entry><option>recipient_unqualified_hosts</option></entry>
25753 <entry>Use: <emphasis>main</emphasis></entry>
25754 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
25755 <entry>Default: <emphasis>unset</emphasis></entry>
25756 </row>
25757 </tbody>
25758 </tgroup>
25759 </informaltable>
25760 <para>
25761 <indexterm role="concept">
25762 <primary>unqualified addresses</primary>
25763 </indexterm>
25764 <indexterm role="concept">
25765 <primary>host</primary>
25766 <secondary>unqualified addresses from</secondary>
25767 </indexterm>
25768 This option lists those hosts from which Exim is prepared to accept unqualified
25769 recipient addresses in message envelopes. The addresses are made fully
25770 qualified by the addition of the <option>qualify_recipient</option> value. This option also
25771 affects message header lines. Exim does not reject unqualified recipient
25772 addresses in headers, but it qualifies them only if the message came from a
25773 host that matches <option>recipient_unqualified_hosts</option>,
25774 or if the message was submitted locally (not using TCP/IP), and the <option>-bnq</option>
25775 option was not set.
25776 </para>
25777 <para>
25778 <indexterm role="option">
25779 <primary><option>recipients_max</option></primary>
25780 </indexterm>
25781 </para>
25782 <informaltable frame="all">
25783 <tgroup cols="4" colsep="0" rowsep="0">
25784 <colspec colwidth="8*" align="left"/>
25785 <colspec colwidth="6*" align="center"/>
25786 <colspec colwidth="6*" align="center"/>
25787 <colspec colwidth="6*" align="right"/>
25788 <tbody>
25789 <row>
25790 <entry><option>recipients_max</option></entry>
25791 <entry>Use: <emphasis>main</emphasis></entry>
25792 <entry>Type: <emphasis>integer</emphasis></entry>
25793 <entry>Default: <emphasis>0</emphasis></entry>
25794 </row>
25795 </tbody>
25796 </tgroup>
25797 </informaltable>
25798 <para>
25799 <indexterm role="concept">
25800 <primary>limit</primary>
25801 <secondary>number of recipients</secondary>
25802 </indexterm>
25803 <indexterm role="concept">
25804 <primary>recipient</primary>
25805 <secondary>maximum number</secondary>
25806 </indexterm>
25807 If this option is set greater than zero, it specifies the maximum number of
25808 original recipients for any message. Additional recipients that are generated
25809 by aliasing or forwarding do not count. SMTP messages get a 452 response for
25810 all recipients over the limit; earlier recipients are delivered as normal.
25811 Non-SMTP messages with too many recipients are failed, and no deliveries are
25812 done.
25813 </para>
25814 <para>
25815 <indexterm role="concept">
25816 <primary>RCPT</primary>
25817 <secondary>maximum number of incoming</secondary>
25818 </indexterm>
25819 <emphasis role="bold">Note</emphasis>: The RFCs specify that an SMTP server should accept at least 100
25820 RCPT commands in a single message.
25821 </para>
25822 <para>
25823 <indexterm role="option">
25824 <primary><option>recipients_max_reject</option></primary>
25825 </indexterm>
25826 </para>
25827 <informaltable frame="all">
25828 <tgroup cols="4" colsep="0" rowsep="0">
25829 <colspec colwidth="8*" align="left"/>
25830 <colspec colwidth="6*" align="center"/>
25831 <colspec colwidth="6*" align="center"/>
25832 <colspec colwidth="6*" align="right"/>
25833 <tbody>
25834 <row>
25835 <entry><option>recipients_max_reject</option></entry>
25836 <entry>Use: <emphasis>main</emphasis></entry>
25837 <entry>Type: <emphasis>boolean</emphasis></entry>
25838 <entry>Default: <emphasis>false</emphasis></entry>
25839 </row>
25840 </tbody>
25841 </tgroup>
25842 </informaltable>
25843 <para>
25844 If this option is set true, Exim rejects SMTP messages containing too many
25845 recipients by giving 552 errors to the surplus RCPT commands, and a 554
25846 error to the eventual DATA command. Otherwise (the default) it gives a 452
25847 error to the surplus RCPT commands and accepts the message on behalf of the
25848 initial set of recipients. The remote server should then re-send the message
25849 for the remaining recipients at a later time.
25850 </para>
25851 <para>
25852 <indexterm role="option">
25853 <primary><option>remote_max_parallel</option></primary>
25854 </indexterm>
25855 </para>
25856 <informaltable frame="all">
25857 <tgroup cols="4" colsep="0" rowsep="0">
25858 <colspec colwidth="8*" align="left"/>
25859 <colspec colwidth="6*" align="center"/>
25860 <colspec colwidth="6*" align="center"/>
25861 <colspec colwidth="6*" align="right"/>
25862 <tbody>
25863 <row>
25864 <entry><option>remote_max_parallel</option></entry>
25865 <entry>Use: <emphasis>main</emphasis></entry>
25866 <entry>Type: <emphasis>integer</emphasis></entry>
25867 <entry>Default: <emphasis>2</emphasis></entry>
25868 </row>
25869 </tbody>
25870 </tgroup>
25871 </informaltable>
25872 <para>
25873 <indexterm role="concept">
25874 <primary>delivery</primary>
25875 <secondary>parallelism for remote</secondary>
25876 </indexterm>
25877 This option controls parallel delivery of one message to a number of remote
25878 hosts. If the value is less than 2, parallel delivery is disabled, and Exim
25879 does all the remote deliveries for a message one by one. Otherwise, if a single
25880 message has to be delivered to more than one remote host, or if several copies
25881 have to be sent to the same remote host, up to <option>remote_max_parallel</option>
25882 deliveries are done simultaneously. If more than <option>remote_max_parallel</option>
25883 deliveries are required, the maximum number of processes are started, and as
25884 each one finishes, another is begun. The order of starting processes is the
25885 same as if sequential delivery were being done, and can be controlled by the
25886 <option>remote_sort_domains</option> option. If parallel delivery takes place while running
25887 with debugging turned on, the debugging output from each delivery process is
25888 tagged with its process id.
25889 </para>
25890 <para>
25891 This option controls only the maximum number of parallel deliveries for one
25892 message in one Exim delivery process. Because Exim has no central queue
25893 manager, there is no way of controlling the total number of simultaneous
25894 deliveries if the configuration allows a delivery attempt as soon as a message
25895 is received.
25896 </para>
25897 <para>
25898 <indexterm role="concept">
25899 <primary>number of deliveries</primary>
25900 </indexterm>
25901 <indexterm role="concept">
25902 <primary>delivery</primary>
25903 <secondary>maximum number of</secondary>
25904 </indexterm>
25905 If you want to control the total number of deliveries on the system, you
25906 need to set the <option>queue_only</option> option. This ensures that all incoming messages
25907 are added to the queue without starting a delivery process. Then set up an Exim
25908 daemon to start queue runner processes at appropriate intervals (probably
25909 fairly often, for example, every minute), and limit the total number of queue
25910 runners by setting the <option>queue_run_max</option> parameter. Because each queue runner
25911 delivers only one message at a time, the maximum number of deliveries that can
25912 then take place at once is <option>queue_run_max</option> multiplied by
25913 <option>remote_max_parallel</option>.
25914 </para>
25915 <para>
25916 If it is purely remote deliveries you want to control, use
25917 <option>queue_smtp_domains</option> instead of <option>queue_only</option>. This has the added benefit of
25918 doing the SMTP routing before queueing, so that several messages for the same
25919 host will eventually get delivered down the same connection.
25920 </para>
25921 <para>
25922 <indexterm role="option">
25923 <primary><option>remote_sort_domains</option></primary>
25924 </indexterm>
25925 </para>
25926 <informaltable frame="all">
25927 <tgroup cols="4" colsep="0" rowsep="0">
25928 <colspec colwidth="8*" align="left"/>
25929 <colspec colwidth="6*" align="center"/>
25930 <colspec colwidth="6*" align="center"/>
25931 <colspec colwidth="6*" align="right"/>
25932 <tbody>
25933 <row>
25934 <entry><option>remote_sort_domains</option></entry>
25935 <entry>Use: <emphasis>main</emphasis></entry>
25936 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
25937 <entry>Default: <emphasis>unset</emphasis></entry>
25938 </row>
25939 </tbody>
25940 </tgroup>
25941 </informaltable>
25942 <para>
25943 <indexterm role="concept">
25944 <primary>sorting remote deliveries</primary>
25945 </indexterm>
25946 <indexterm role="concept">
25947 <primary>delivery</primary>
25948 <secondary>sorting remote</secondary>
25949 </indexterm>
25950 When there are a number of remote deliveries for a message, they are sorted by
25951 domain into the order given by this list. For example,
25952 </para>
25953 <literallayout class="monospaced">
25954 remote_sort_domains = *.cam.ac.uk:*.uk
25955 </literallayout>
25956 <para>
25957 would attempt to deliver to all addresses in the <emphasis>cam.ac.uk</emphasis> domain first,
25958 then to those in the <option>uk</option> domain, then to any others.
25959 </para>
25960 <para>
25961 <indexterm role="option">
25962 <primary><option>retry_data_expire</option></primary>
25963 </indexterm>
25964 </para>
25965 <informaltable frame="all">
25966 <tgroup cols="4" colsep="0" rowsep="0">
25967 <colspec colwidth="8*" align="left"/>
25968 <colspec colwidth="6*" align="center"/>
25969 <colspec colwidth="6*" align="center"/>
25970 <colspec colwidth="6*" align="right"/>
25971 <tbody>
25972 <row>
25973 <entry><option>retry_data_expire</option></entry>
25974 <entry>Use: <emphasis>main</emphasis></entry>
25975 <entry>Type: <emphasis>time</emphasis></entry>
25976 <entry>Default: <emphasis>7d</emphasis></entry>
25977 </row>
25978 </tbody>
25979 </tgroup>
25980 </informaltable>
25981 <para>
25982 <indexterm role="concept">
25983 <primary>hints database</primary>
25984 <secondary>data expiry</secondary>
25985 </indexterm>
25986 This option sets a <quote>use before</quote> time on retry information in Exim&#x2019;s hints
25987 database. Any older retry data is ignored. This means that, for example, once a
25988 host has not been tried for 7 days, Exim behaves as if it has no knowledge of
25989 past failures.
25990 </para>
25991 <para>
25992 <indexterm role="option">
25993 <primary><option>retry_interval_max</option></primary>
25994 </indexterm>
25995 </para>
25996 <informaltable frame="all">
25997 <tgroup cols="4" colsep="0" rowsep="0">
25998 <colspec colwidth="8*" align="left"/>
25999 <colspec colwidth="6*" align="center"/>
26000 <colspec colwidth="6*" align="center"/>
26001 <colspec colwidth="6*" align="right"/>
26002 <tbody>
26003 <row>
26004 <entry><option>retry_interval_max</option></entry>
26005 <entry>Use: <emphasis>main</emphasis></entry>
26006 <entry>Type: <emphasis>time</emphasis></entry>
26007 <entry>Default: <emphasis>24h</emphasis></entry>
26008 </row>
26009 </tbody>
26010 </tgroup>
26011 </informaltable>
26012 <para>
26013 <indexterm role="concept">
26014 <primary>retry</primary>
26015 <secondary>limit on interval</secondary>
26016 </indexterm>
26017 <indexterm role="concept">
26018 <primary>limit</primary>
26019 <secondary>on retry interval</secondary>
26020 </indexterm>
26021 Chapter <xref linkend="CHAPretry"/> describes Exim&#x2019;s mechanisms for controlling the
26022 intervals between delivery attempts for messages that cannot be delivered
26023 straight away. This option sets an overall limit to the length of time between
26024 retries. It cannot be set greater than 24 hours; any attempt to do so forces
26025 the default value.
26026 </para>
26027 <para>
26028 <indexterm role="option">
26029 <primary><option>return_path_remove</option></primary>
26030 </indexterm>
26031 </para>
26032 <informaltable frame="all">
26033 <tgroup cols="4" colsep="0" rowsep="0">
26034 <colspec colwidth="8*" align="left"/>
26035 <colspec colwidth="6*" align="center"/>
26036 <colspec colwidth="6*" align="center"/>
26037 <colspec colwidth="6*" align="right"/>
26038 <tbody>
26039 <row>
26040 <entry><option>return_path_remove</option></entry>
26041 <entry>Use: <emphasis>main</emphasis></entry>
26042 <entry>Type: <emphasis>boolean</emphasis></entry>
26043 <entry>Default: <emphasis>true</emphasis></entry>
26044 </row>
26045 </tbody>
26046 </tgroup>
26047 </informaltable>
26048 <para>
26049 <indexterm role="concept">
26050 <primary><emphasis>Return-path:</emphasis> header line</primary>
26051 <secondary>removing</secondary>
26052 </indexterm>
26053 RFC 2821, section 4.4, states that an SMTP server must insert a
26054 <emphasis>Return-path:</emphasis> header line into a message when it makes a <quote>final delivery</quote>.
26055 The <emphasis>Return-path:</emphasis> header preserves the sender address as received in the
26056 MAIL command. This description implies that this header should not be present
26057 in an incoming message. If <option>return_path_remove</option> is true, any existing
26058 <emphasis>Return-path:</emphasis> headers are removed from messages at the time they are
26059 received. Exim&#x2019;s transports have options for adding <emphasis>Return-path:</emphasis> headers at
26060 the time of delivery. They are normally used only for final local deliveries.
26061 </para>
26062 <para>
26063 <indexterm role="option">
26064 <primary><option>return_size_limit</option></primary>
26065 </indexterm>
26066 </para>
26067 <informaltable frame="all">
26068 <tgroup cols="4" colsep="0" rowsep="0">
26069 <colspec colwidth="8*" align="left"/>
26070 <colspec colwidth="6*" align="center"/>
26071 <colspec colwidth="6*" align="center"/>
26072 <colspec colwidth="6*" align="right"/>
26073 <tbody>
26074 <row>
26075 <entry><option>return_size_limit</option></entry>
26076 <entry>Use: <emphasis>main</emphasis></entry>
26077 <entry>Type: <emphasis>integer</emphasis></entry>
26078 <entry>Default: <emphasis>100K</emphasis></entry>
26079 </row>
26080 </tbody>
26081 </tgroup>
26082 </informaltable>
26083 <para>
26084 This option is an obsolete synonym for <option>bounce_return_size_limit</option>.
26085 </para>
26086 <para>
26087 <indexterm role="option">
26088 <primary><option>rfc1413_hosts</option></primary>
26089 </indexterm>
26090 </para>
26091 <informaltable frame="all">
26092 <tgroup cols="4" colsep="0" rowsep="0">
26093 <colspec colwidth="8*" align="left"/>
26094 <colspec colwidth="6*" align="center"/>
26095 <colspec colwidth="6*" align="center"/>
26096 <colspec colwidth="6*" align="right"/>
26097 <tbody>
26098 <row>
26099 <entry><option>rfc1413_hosts</option></entry>
26100 <entry>Use: <emphasis>main</emphasis></entry>
26101 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
26102 <entry>Default: <emphasis>*</emphasis></entry>
26103 </row>
26104 </tbody>
26105 </tgroup>
26106 </informaltable>
26107 <para>
26108 <indexterm role="concept">
26109 <primary>RFC 1413</primary>
26110 </indexterm>
26111 <indexterm role="concept">
26112 <primary>host</primary>
26113 <secondary>for RFC 1413 calls</secondary>
26114 </indexterm>
26115 RFC 1413 identification calls are made to any client host which matches an item
26116 in the list.
26117 </para>
26118 <para>
26119 <indexterm role="option">
26120 <primary><option>rfc1413_query_timeout</option></primary>
26121 </indexterm>
26122 </para>
26123 <informaltable frame="all">
26124 <tgroup cols="4" colsep="0" rowsep="0">
26125 <colspec colwidth="8*" align="left"/>
26126 <colspec colwidth="6*" align="center"/>
26127 <colspec colwidth="6*" align="center"/>
26128 <colspec colwidth="6*" align="right"/>
26129 <tbody>
26130 <row>
26131 <entry><option>rfc1413_query_timeout</option></entry>
26132 <entry>Use: <emphasis>main</emphasis></entry>
26133 <entry>Type: <emphasis>time</emphasis></entry>
26134 <entry>Default: <emphasis>5s</emphasis></entry>
26135 </row>
26136 </tbody>
26137 </tgroup>
26138 </informaltable>
26139 <para>
26140 <indexterm role="concept">
26141 <primary>RFC 1413</primary>
26142 <secondary>query timeout</secondary>
26143 </indexterm>
26144 <indexterm role="concept">
26145 <primary>timeout</primary>
26146 <secondary>for RFC 1413 call</secondary>
26147 </indexterm>
26148 This sets the timeout on RFC 1413 identification calls. If it is set to zero,
26149 no RFC 1413 calls are ever made.
26150 </para>
26151 <para>
26152 <indexterm role="option">
26153 <primary><option>sender_unqualified_hosts</option></primary>
26154 </indexterm>
26155 </para>
26156 <informaltable frame="all">
26157 <tgroup cols="4" colsep="0" rowsep="0">
26158 <colspec colwidth="8*" align="left"/>
26159 <colspec colwidth="6*" align="center"/>
26160 <colspec colwidth="6*" align="center"/>
26161 <colspec colwidth="6*" align="right"/>
26162 <tbody>
26163 <row>
26164 <entry><option>sender_unqualified_hosts</option></entry>
26165 <entry>Use: <emphasis>main</emphasis></entry>
26166 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
26167 <entry>Default: <emphasis>unset</emphasis></entry>
26168 </row>
26169 </tbody>
26170 </tgroup>
26171 </informaltable>
26172 <para>
26173 <indexterm role="concept">
26174 <primary>unqualified addresses</primary>
26175 </indexterm>
26176 <indexterm role="concept">
26177 <primary>host</primary>
26178 <secondary>unqualified addresses from</secondary>
26179 </indexterm>
26180 This option lists those hosts from which Exim is prepared to accept unqualified
26181 sender addresses. The addresses are made fully qualified by the addition of
26182 <option>qualify_domain</option>. This option also affects message header lines. Exim does
26183 not reject unqualified addresses in headers that contain sender addresses, but
26184 it qualifies them only if the message came from a host that matches
26185 <option>sender_unqualified_hosts</option>, or if the message was submitted locally (not
26186 using TCP/IP), and the <option>-bnq</option> option was not set.
26187 </para>
26188 <para>
26189 <indexterm role="option">
26190 <primary><option>smtp_accept_keepalive</option></primary>
26191 </indexterm>
26192 </para>
26193 <informaltable frame="all">
26194 <tgroup cols="4" colsep="0" rowsep="0">
26195 <colspec colwidth="8*" align="left"/>
26196 <colspec colwidth="6*" align="center"/>
26197 <colspec colwidth="6*" align="center"/>
26198 <colspec colwidth="6*" align="right"/>
26199 <tbody>
26200 <row>
26201 <entry><option>smtp_accept_keepalive</option></entry>
26202 <entry>Use: <emphasis>main</emphasis></entry>
26203 <entry>Type: <emphasis>boolean</emphasis></entry>
26204 <entry>Default: <emphasis>true</emphasis></entry>
26205 </row>
26206 </tbody>
26207 </tgroup>
26208 </informaltable>
26209 <para>
26210 <indexterm role="concept">
26211 <primary>keepalive</primary>
26212 <secondary>on incoming connection</secondary>
26213 </indexterm>
26214 This option controls the setting of the SO_KEEPALIVE option on incoming
26215 TCP/IP socket connections. When set, it causes the kernel to probe idle
26216 connections periodically, by sending packets with <quote>old</quote> sequence numbers. The
26217 other end of the connection should send an acknowledgment if the connection is
26218 still okay or a reset if the connection has been aborted. The reason for doing
26219 this is that it has the beneficial effect of freeing up certain types of
26220 connection that can get stuck when the remote host is disconnected without
26221 tidying up the TCP/IP call properly. The keepalive mechanism takes several
26222 hours to detect unreachable hosts.
26223 </para>
26224 <para>
26225 <indexterm role="option">
26226 <primary><option>smtp_accept_max</option></primary>
26227 </indexterm>
26228 </para>
26229 <informaltable frame="all">
26230 <tgroup cols="4" colsep="0" rowsep="0">
26231 <colspec colwidth="8*" align="left"/>
26232 <colspec colwidth="6*" align="center"/>
26233 <colspec colwidth="6*" align="center"/>
26234 <colspec colwidth="6*" align="right"/>
26235 <tbody>
26236 <row>
26237 <entry><option>smtp_accept_max</option></entry>
26238 <entry>Use: <emphasis>main</emphasis></entry>
26239 <entry>Type: <emphasis>integer</emphasis></entry>
26240 <entry>Default: <emphasis>20</emphasis></entry>
26241 </row>
26242 </tbody>
26243 </tgroup>
26244 </informaltable>
26245 <para>
26246 <indexterm role="concept">
26247 <primary>limit</primary>
26248 <secondary>incoming SMTP connections</secondary>
26249 </indexterm>
26250 <indexterm role="concept">
26251 <primary>SMTP</primary>
26252 <secondary>incoming connection count</secondary>
26253 </indexterm>
26254 <indexterm role="concept">
26255 <primary>inetd</primary>
26256 </indexterm>
26257 This option specifies the maximum number of simultaneous incoming SMTP calls
26258 that Exim will accept. It applies only to the listening daemon; there is no
26259 control (in Exim) when incoming SMTP is being handled by <emphasis>inetd</emphasis>. If the
26260 value is set to zero, no limit is applied. However, it is required to be
26261 non-zero if either <option>smtp_accept_max_per_host</option> or <option>smtp_accept_queue</option> is
26262 set. See also <option>smtp_accept_reserve</option> and <option>smtp_load_reserve</option>.
26263 </para>
26264 <para>
26265 A new SMTP connection is immediately rejected if the <option>smtp_accept_max</option> limit
26266 has been reached. If not, Exim first checks <option>smtp_accept_max_per_host</option>. If
26267 that limit has not been reached for the client host, <option>smtp_accept_reserve</option>
26268 and <option>smtp_load_reserve</option> are then checked before accepting the connection.
26269 </para>
26270 <para>
26271 <indexterm role="option">
26272 <primary><option>smtp_accept_max_nonmail</option></primary>
26273 </indexterm>
26274 </para>
26275 <informaltable frame="all">
26276 <tgroup cols="4" colsep="0" rowsep="0">
26277 <colspec colwidth="8*" align="left"/>
26278 <colspec colwidth="6*" align="center"/>
26279 <colspec colwidth="6*" align="center"/>
26280 <colspec colwidth="6*" align="right"/>
26281 <tbody>
26282 <row>
26283 <entry><option>smtp_accept_max_nonmail</option></entry>
26284 <entry>Use: <emphasis>main</emphasis></entry>
26285 <entry>Type: <emphasis>integer</emphasis></entry>
26286 <entry>Default: <emphasis>10</emphasis></entry>
26287 </row>
26288 </tbody>
26289 </tgroup>
26290 </informaltable>
26291 <para>
26292 <indexterm role="concept">
26293 <primary>limit</primary>
26294 <secondary>non-mail SMTP commands</secondary>
26295 </indexterm>
26296 <indexterm role="concept">
26297 <primary>SMTP</primary>
26298 <secondary>limiting non-mail commands</secondary>
26299 </indexterm>
26300 Exim counts the number of <quote>non-mail</quote> commands in an SMTP session, and drops
26301 the connection if there are too many. This option defines <quote>too many</quote>. The
26302 check catches some denial-of-service attacks, repeated failing AUTHs, or a mad
26303 client looping sending EHLO, for example. The check is applied only if the
26304 client host matches <option>smtp_accept_max_nonmail_hosts</option>.
26305 </para>
26306 <para>
26307 When a new message is expected, one occurrence of RSET is not counted. This
26308 allows a client to send one RSET between messages (this is not necessary,
26309 but some clients do it). Exim also allows one uncounted occurrence of HELO
26310 or EHLO, and one occurrence of STARTTLS between messages. After
26311 starting up a TLS session, another EHLO is expected, and so it too is not
26312 counted. The first occurrence of AUTH in a connection, or immediately
26313 following STARTTLS is not counted. Otherwise, all commands other than
26314 MAIL, RCPT, DATA, and QUIT are counted.
26315 </para>
26316 <para>
26317 <indexterm role="option">
26318 <primary><option>smtp_accept_max_nonmail_hosts</option></primary>
26319 </indexterm>
26320 </para>
26321 <informaltable frame="all">
26322 <tgroup cols="4" colsep="0" rowsep="0">
26323 <colspec colwidth="8*" align="left"/>
26324 <colspec colwidth="6*" align="center"/>
26325 <colspec colwidth="6*" align="center"/>
26326 <colspec colwidth="6*" align="right"/>
26327 <tbody>
26328 <row>
26329 <entry><option>smtp_accept_max_nonmail_hosts</option></entry>
26330 <entry>Use: <emphasis>main</emphasis></entry>
26331 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
26332 <entry>Default: <emphasis>*</emphasis></entry>
26333 </row>
26334 </tbody>
26335 </tgroup>
26336 </informaltable>
26337 <para>
26338 You can control which hosts are subject to the <option>smtp_accept_max_nonmail</option>
26339 check by setting this option. The default value makes it apply to all hosts. By
26340 changing the value, you can exclude any badly-behaved hosts that you have to
26341 live with.
26342 </para>
26343 <para>
26344 <indexterm role="option">
26345 <primary><option>smtp_accept_max_per_connection</option></primary>
26346 </indexterm>
26347 </para>
26348 <informaltable frame="all">
26349 <tgroup cols="4" colsep="0" rowsep="0">
26350 <colspec colwidth="8*" align="left"/>
26351 <colspec colwidth="6*" align="center"/>
26352 <colspec colwidth="6*" align="center"/>
26353 <colspec colwidth="6*" align="right"/>
26354 <tbody>
26355 <row>
26356 <entry><option>smtp_accept_max_per_ &nbsp;&nbsp;connection</option></entry>
26357 <entry>Use: <emphasis>main</emphasis></entry>
26358 <entry>Type: <emphasis>integer</emphasis></entry>
26359 <entry>Default: <emphasis>1000</emphasis></entry>
26360 </row>
26361 </tbody>
26362 </tgroup>
26363 </informaltable>
26364 <para>
26365 <indexterm role="concept">
26366 <primary>SMTP</primary>
26367 <secondary>limiting incoming message count</secondary>
26368 </indexterm>
26369 <indexterm role="concept">
26370 <primary>limit</primary>
26371 <secondary>messages per SMTP connection</secondary>
26372 </indexterm>
26373 The value of this option limits the number of MAIL commands that Exim is
26374 prepared to accept over a single SMTP connection, whether or not each command
26375 results in the transfer of a message. After the limit is reached, a 421
26376 response is given to subsequent MAIL commands. This limit is a safety
26377 precaution against a client that goes mad (incidents of this type have been
26378 seen).
26379 </para>
26380 <para>
26381 <indexterm role="option">
26382 <primary><option>smtp_accept_max_per_host</option></primary>
26383 </indexterm>
26384 </para>
26385 <informaltable frame="all">
26386 <tgroup cols="4" colsep="0" rowsep="0">
26387 <colspec colwidth="8*" align="left"/>
26388 <colspec colwidth="6*" align="center"/>
26389 <colspec colwidth="6*" align="center"/>
26390 <colspec colwidth="6*" align="right"/>
26391 <tbody>
26392 <row>
26393 <entry><option>smtp_accept_max_per_host</option></entry>
26394 <entry>Use: <emphasis>main</emphasis></entry>
26395 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
26396 <entry>Default: <emphasis>unset</emphasis></entry>
26397 </row>
26398 </tbody>
26399 </tgroup>
26400 </informaltable>
26401 <para>
26402 <indexterm role="concept">
26403 <primary>limit</primary>
26404 <secondary>SMTP connections from one host</secondary>
26405 </indexterm>
26406 <indexterm role="concept">
26407 <primary>host</primary>
26408 <secondary>limiting SMTP connections from</secondary>
26409 </indexterm>
26410 This option restricts the number of simultaneous IP connections from a single
26411 host (strictly, from a single IP address) to the Exim daemon. The option is
26412 expanded, to enable different limits to be applied to different hosts by
26413 reference to <varname>$sender_host_address</varname>. Once the limit is reached, additional
26414 connection attempts from the same host are rejected with error code 421. This
26415 is entirely independent of <option>smtp_accept_reserve</option>. The option&#x2019;s default value
26416 of zero imposes no limit. If this option is set greater than zero, it is
26417 required that <option>smtp_accept_max</option> be non-zero.
26418 </para>
26419 <para>
26420 <emphasis role="bold">Warning</emphasis>: When setting this option you should not use any expansion
26421 constructions that take an appreciable amount of time. The expansion and test
26422 happen in the main daemon loop, in order to reject additional connections
26423 without forking additional processes (otherwise a denial-of-service attack
26424 could cause a vast number or processes to be created). While the daemon is
26425 doing this processing, it cannot accept any other incoming connections.
26426 </para>
26427 <para>
26428 <indexterm role="option">
26429 <primary><option>smtp_accept_queue</option></primary>
26430 </indexterm>
26431 </para>
26432 <informaltable frame="all">
26433 <tgroup cols="4" colsep="0" rowsep="0">
26434 <colspec colwidth="8*" align="left"/>
26435 <colspec colwidth="6*" align="center"/>
26436 <colspec colwidth="6*" align="center"/>
26437 <colspec colwidth="6*" align="right"/>
26438 <tbody>
26439 <row>
26440 <entry><option>smtp_accept_queue</option></entry>
26441 <entry>Use: <emphasis>main</emphasis></entry>
26442 <entry>Type: <emphasis>integer</emphasis></entry>
26443 <entry>Default: <emphasis>0</emphasis></entry>
26444 </row>
26445 </tbody>
26446 </tgroup>
26447 </informaltable>
26448 <para>
26449 <indexterm role="concept">
26450 <primary>SMTP</primary>
26451 <secondary>incoming connection count</secondary>
26452 </indexterm>
26453 <indexterm role="concept">
26454 <primary>queueing incoming messages</primary>
26455 </indexterm>
26456 <indexterm role="concept">
26457 <primary>message</primary>
26458 <secondary>queueing by SMTP connection count</secondary>
26459 </indexterm>
26460 If the number of simultaneous incoming SMTP connections being handled via the
26461 listening daemon exceeds this value, messages received by SMTP are just placed
26462 on the queue; no delivery processes are started automatically. The count is
26463 fixed at the start of an SMTP connection. It cannot be updated in the
26464 subprocess that receives messages, and so the queueing or not queueing applies
26465 to all messages received in the same connection.
26466 </para>
26467 <para>
26468 A value of zero implies no limit, and clearly any non-zero value is useful only
26469 if it is less than the <option>smtp_accept_max</option> value (unless that is zero). See
26470 also <option>queue_only</option>, <option>queue_only_load</option>, <option>queue_smtp_domains</option>, and the
26471 various <option>-od</option><emphasis>x</emphasis> command line options.
26472 </para>
26473 <para>
26474 <indexterm role="option">
26475 <primary><option>smtp_accept_queue_per_connection</option></primary>
26476 </indexterm>
26477 </para>
26478 <informaltable frame="all">
26479 <tgroup cols="4" colsep="0" rowsep="0">
26480 <colspec colwidth="8*" align="left"/>
26481 <colspec colwidth="6*" align="center"/>
26482 <colspec colwidth="6*" align="center"/>
26483 <colspec colwidth="6*" align="right"/>
26484 <tbody>
26485 <row>
26486 <entry><option>smtp_accept_queue_per_ &nbsp;&nbsp;connection</option></entry>
26487 <entry>Use: <emphasis>main</emphasis></entry>
26488 <entry>Type: <emphasis>integer</emphasis></entry>
26489 <entry>Default: <emphasis>10</emphasis></entry>
26490 </row>
26491 </tbody>
26492 </tgroup>
26493 </informaltable>
26494 <para>
26495 <indexterm role="concept">
26496 <primary>queueing incoming messages</primary>
26497 </indexterm>
26498 <indexterm role="concept">
26499 <primary>message</primary>
26500 <secondary>queueing by message count</secondary>
26501 </indexterm>
26502 This option limits the number of delivery processes that Exim starts
26503 automatically when receiving messages via SMTP, whether via the daemon or by
26504 the use of <option>-bs</option> or <option>-bS</option>. If the value of the option is greater than zero,
26505 and the number of messages received in a single SMTP session exceeds this
26506 number, subsequent messages are placed on the queue, but no delivery processes
26507 are started. This helps to limit the number of Exim processes when a server
26508 restarts after downtime and there is a lot of mail waiting for it on other
26509 systems. On large systems, the default should probably be increased, and on
26510 dial-in client systems it should probably be set to zero (that is, disabled).
26511 </para>
26512 <para>
26513 <indexterm role="option">
26514 <primary><option>smtp_accept_reserve</option></primary>
26515 </indexterm>
26516 </para>
26517 <informaltable frame="all">
26518 <tgroup cols="4" colsep="0" rowsep="0">
26519 <colspec colwidth="8*" align="left"/>
26520 <colspec colwidth="6*" align="center"/>
26521 <colspec colwidth="6*" align="center"/>
26522 <colspec colwidth="6*" align="right"/>
26523 <tbody>
26524 <row>
26525 <entry><option>smtp_accept_reserve</option></entry>
26526 <entry>Use: <emphasis>main</emphasis></entry>
26527 <entry>Type: <emphasis>integer</emphasis></entry>
26528 <entry>Default: <emphasis>0</emphasis></entry>
26529 </row>
26530 </tbody>
26531 </tgroup>
26532 </informaltable>
26533 <para>
26534 <indexterm role="concept">
26535 <primary>SMTP</primary>
26536 <secondary>incoming call count</secondary>
26537 </indexterm>
26538 <indexterm role="concept">
26539 <primary>host</primary>
26540 <secondary>reserved</secondary>
26541 </indexterm>
26542 When <option>smtp_accept_max</option> is set greater than zero, this option specifies a
26543 number of SMTP connections that are reserved for connections from the hosts
26544 that are specified in <option>smtp_reserve_hosts</option>. The value set in
26545 <option>smtp_accept_max</option> includes this reserve pool. The specified hosts are not
26546 restricted to this number of connections; the option specifies a minimum number
26547 of connection slots for them, not a maximum. It is a guarantee that this group
26548 of hosts can always get at least <option>smtp_accept_reserve</option> connections. However,
26549 the limit specified by <option>smtp_accept_max_per_host</option> is still applied to each
26550 individual host.
26551 </para>
26552 <para>
26553 For example, if <option>smtp_accept_max</option> is set to 50 and <option>smtp_accept_reserve</option> is
26554 set to 5, once there are 45 active connections (from any hosts), new
26555 connections are accepted only from hosts listed in <option>smtp_reserve_hosts</option>,
26556 provided the other criteria for acceptance are met.
26557 </para>
26558 <para>
26559 <indexterm role="option">
26560 <primary><option>smtp_active_hostname</option></primary>
26561 </indexterm>
26562 </para>
26563 <informaltable frame="all">
26564 <tgroup cols="4" colsep="0" rowsep="0">
26565 <colspec colwidth="8*" align="left"/>
26566 <colspec colwidth="6*" align="center"/>
26567 <colspec colwidth="6*" align="center"/>
26568 <colspec colwidth="6*" align="right"/>
26569 <tbody>
26570 <row>
26571 <entry><option>smtp_active_hostname</option></entry>
26572 <entry>Use: <emphasis>main</emphasis></entry>
26573 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
26574 <entry>Default: <emphasis>unset</emphasis></entry>
26575 </row>
26576 </tbody>
26577 </tgroup>
26578 </informaltable>
26579 <para>
26580 <indexterm role="concept">
26581 <primary>host</primary>
26582 <secondary>name in SMTP responses</secondary>
26583 </indexterm>
26584 <indexterm role="concept">
26585 <primary>SMTP</primary>
26586 <secondary>host name in responses</secondary>
26587 </indexterm>
26588 <indexterm role="variable">
26589 <primary><varname>$primary_hostname</varname></primary>
26590 </indexterm>
26591 This option is provided for multi-homed servers that want to masquerade as
26592 several different hosts. At the start of an incoming SMTP connection, its value
26593 is expanded and used instead of the value of <varname>$primary_hostname</varname> in SMTP
26594 responses. For example, it is used as domain name in the response to an
26595 incoming HELO or EHLO command.
26596 </para>
26597 <para>
26598 <indexterm role="variable">
26599 <primary><varname>$smtp_active_hostname</varname></primary>
26600 </indexterm>
26601 The active hostname is placed in the <varname>$smtp_active_hostname</varname> variable, which
26602 is saved with any messages that are received. It is therefore available for use
26603 in routers and transports when the message is later delivered.
26604 </para>
26605 <para>
26606 If this option is unset, or if its expansion is forced to fail, or if the
26607 expansion results in an empty string, the value of <varname>$primary_hostname</varname> is
26608 used. Other expansion failures cause a message to be written to the main and
26609 panic logs, and the SMTP command receives a temporary error. Typically, the
26610 value of <option>smtp_active_hostname</option> depends on the incoming interface address.
26611 For example:
26612 </para>
26613 <literallayout class="monospaced">
26614 smtp_active_hostname = ${if eq{$received_ip_address}{10.0.0.1}\
26615   {cox.mydomain}{box.mydomain}}
26616 </literallayout>
26617 <para>
26618 Although <varname>$smtp_active_hostname</varname> is primarily concerned with incoming
26619 messages, it is also used as the default for HELO commands in callout
26620 verification if there is no remote transport from which to obtain a
26621 <option>helo_data</option> value.
26622 </para>
26623 <para>
26624 <indexterm role="option">
26625 <primary><option>smtp_banner</option></primary>
26626 </indexterm>
26627 </para>
26628 <informaltable frame="all">
26629 <tgroup cols="4" colsep="0" rowsep="0">
26630 <colspec colwidth="8*" align="left"/>
26631 <colspec colwidth="6*" align="center"/>
26632 <colspec colwidth="6*" align="center"/>
26633 <colspec colwidth="6*" align="right"/>
26634 <tbody>
26635 <row>
26636 <entry><option>smtp_banner</option></entry>
26637 <entry>Use: <emphasis>main</emphasis></entry>
26638 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
26639 <entry>Default: <emphasis>see below</emphasis></entry>
26640 </row>
26641 </tbody>
26642 </tgroup>
26643 </informaltable>
26644 <para>
26645 <indexterm role="concept">
26646 <primary>SMTP</primary>
26647 <secondary>welcome banner</secondary>
26648 </indexterm>
26649 <indexterm role="concept">
26650 <primary>banner for SMTP</primary>
26651 </indexterm>
26652 <indexterm role="concept">
26653 <primary>welcome banner for SMTP</primary>
26654 </indexterm>
26655 <indexterm role="concept">
26656 <primary>customizing</primary>
26657 <secondary>SMTP banner</secondary>
26658 </indexterm>
26659 This string, which is expanded every time it is used, is output as the initial
26660 positive response to an SMTP connection. The default setting is:
26661 </para>
26662 <literallayout class="monospaced">
26663 smtp_banner = $smtp_active_hostname ESMTP Exim \
26664   $version_number $tod_full
26665 </literallayout>
26666 <para>
26667 Failure to expand the string causes a panic error. If you want to create a
26668 multiline response to the initial SMTP connection, use <quote>\n</quote> in the string at
26669 appropriate points, but not at the end. Note that the 220 code is not included
26670 in this string. Exim adds it automatically (several times in the case of a
26671 multiline response).
26672 </para>
26673 <para>
26674 <indexterm role="option">
26675 <primary><option>smtp_check_spool_space</option></primary>
26676 </indexterm>
26677 </para>
26678 <informaltable frame="all">
26679 <tgroup cols="4" colsep="0" rowsep="0">
26680 <colspec colwidth="8*" align="left"/>
26681 <colspec colwidth="6*" align="center"/>
26682 <colspec colwidth="6*" align="center"/>
26683 <colspec colwidth="6*" align="right"/>
26684 <tbody>
26685 <row>
26686 <entry><option>smtp_check_spool_space</option></entry>
26687 <entry>Use: <emphasis>main</emphasis></entry>
26688 <entry>Type: <emphasis>boolean</emphasis></entry>
26689 <entry>Default: <emphasis>true</emphasis></entry>
26690 </row>
26691 </tbody>
26692 </tgroup>
26693 </informaltable>
26694 <para>
26695 <indexterm role="concept">
26696 <primary>checking disk space</primary>
26697 </indexterm>
26698 <indexterm role="concept">
26699 <primary>disk space, checking</primary>
26700 </indexterm>
26701 <indexterm role="concept">
26702 <primary>spool directory</primary>
26703 <secondary>checking space</secondary>
26704 </indexterm>
26705 When this option is set, if an incoming SMTP session encounters the SIZE
26706 option on a MAIL command, it checks that there is enough space in the
26707 spool directory&#x2019;s partition to accept a message of that size, while still
26708 leaving free the amount specified by <option>check_spool_space</option> (even if that value
26709 is zero). If there isn&#x2019;t enough space, a temporary error code is returned.
26710 </para>
26711 <para>
26712 <indexterm role="option">
26713 <primary><option>smtp_connect_backlog</option></primary>
26714 </indexterm>
26715 </para>
26716 <informaltable frame="all">
26717 <tgroup cols="4" colsep="0" rowsep="0">
26718 <colspec colwidth="8*" align="left"/>
26719 <colspec colwidth="6*" align="center"/>
26720 <colspec colwidth="6*" align="center"/>
26721 <colspec colwidth="6*" align="right"/>
26722 <tbody>
26723 <row>
26724 <entry><option>smtp_connect_backlog</option></entry>
26725 <entry>Use: <emphasis>main</emphasis></entry>
26726 <entry>Type: <emphasis>integer</emphasis></entry>
26727 <entry>Default: <emphasis>20</emphasis></entry>
26728 </row>
26729 </tbody>
26730 </tgroup>
26731 </informaltable>
26732 <para>
26733 <indexterm role="concept">
26734 <primary>connection backlog</primary>
26735 </indexterm>
26736 <indexterm role="concept">
26737 <primary>SMTP</primary>
26738 <secondary>connection backlog</secondary>
26739 </indexterm>
26740 <indexterm role="concept">
26741 <primary>backlog of connections</primary>
26742 </indexterm>
26743 This option specifies a maximum number of waiting SMTP connections. Exim passes
26744 this value to the TCP/IP system when it sets up its listener. Once this number
26745 of connections are waiting for the daemon&#x2019;s attention, subsequent connection
26746 attempts are refused at the TCP/IP level. At least, that is what the manuals
26747 say; in some circumstances such connection attempts have been observed to time
26748 out instead. For large systems it is probably a good idea to increase the
26749 value (to 50, say). It also gives some protection against denial-of-service
26750 attacks by SYN flooding.
26751 </para>
26752 <para>
26753 <indexterm role="option">
26754 <primary><option>smtp_enforce_sync</option></primary>
26755 </indexterm>
26756 </para>
26757 <informaltable frame="all">
26758 <tgroup cols="4" colsep="0" rowsep="0">
26759 <colspec colwidth="8*" align="left"/>
26760 <colspec colwidth="6*" align="center"/>
26761 <colspec colwidth="6*" align="center"/>
26762 <colspec colwidth="6*" align="right"/>
26763 <tbody>
26764 <row>
26765 <entry><option>smtp_enforce_sync</option></entry>
26766 <entry>Use: <emphasis>main</emphasis></entry>
26767 <entry>Type: <emphasis>boolean</emphasis></entry>
26768 <entry>Default: <emphasis>true</emphasis></entry>
26769 </row>
26770 </tbody>
26771 </tgroup>
26772 </informaltable>
26773 <para>
26774 <indexterm role="concept">
26775 <primary>SMTP</primary>
26776 <secondary>synchronization checking</secondary>
26777 </indexterm>
26778 <indexterm role="concept">
26779 <primary>synchronization checking in SMTP</primary>
26780 </indexterm>
26781 The SMTP protocol specification requires the client to wait for a response from
26782 the server at certain points in the dialogue. Without PIPELINING these
26783 synchronization points are after every command; with PIPELINING they are
26784 fewer, but they still exist.
26785 </para>
26786 <para>
26787 Some spamming sites send out a complete set of SMTP commands without waiting
26788 for any response. Exim protects against this by rejecting a message if the
26789 client has sent further input when it should not have. The error response <quote>554
26790 SMTP synchronization error</quote> is sent, and the connection is dropped. Testing
26791 for this error cannot be perfect because of transmission delays (unexpected
26792 input may be on its way but not yet received when Exim checks). However, it
26793 does detect many instances.
26794 </para>
26795 <para>
26796 The check can be globally disabled by setting <option>smtp_enforce_sync</option> false.
26797 If you want to disable the check selectively (for example, only for certain
26798 hosts), you can do so by an appropriate use of a <option>control</option> modifier in an ACL
26799 (see section <xref linkend="SECTcontrols"/>). See also <option>pipelining_advertise_hosts</option>.
26800 </para>
26801 <para>
26802 <indexterm role="option">
26803 <primary><option>smtp_etrn_command</option></primary>
26804 </indexterm>
26805 </para>
26806 <informaltable frame="all">
26807 <tgroup cols="4" colsep="0" rowsep="0">
26808 <colspec colwidth="8*" align="left"/>
26809 <colspec colwidth="6*" align="center"/>
26810 <colspec colwidth="6*" align="center"/>
26811 <colspec colwidth="6*" align="right"/>
26812 <tbody>
26813 <row>
26814 <entry><option>smtp_etrn_command</option></entry>
26815 <entry>Use: <emphasis>main</emphasis></entry>
26816 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
26817 <entry>Default: <emphasis>unset</emphasis></entry>
26818 </row>
26819 </tbody>
26820 </tgroup>
26821 </informaltable>
26822 <para>
26823 <indexterm role="concept">
26824 <primary>ETRN</primary>
26825 <secondary>command to be run</secondary>
26826 </indexterm>
26827 <indexterm role="variable">
26828 <primary><varname>$domain</varname></primary>
26829 </indexterm>
26830 If this option is set, the given command is run whenever an SMTP ETRN
26831 command is received from a host that is permitted to issue such commands (see
26832 chapter <xref linkend="CHAPACL"/>). The string is split up into separate arguments which
26833 are independently expanded. The expansion variable <varname>$domain</varname> is set to the
26834 argument of the ETRN command, and no syntax checking is done on it. For
26835 example:
26836 </para>
26837 <literallayout class="monospaced">
26838 smtp_etrn_command = /etc/etrn_command $domain \
26839                     $sender_host_address
26840 </literallayout>
26841 <para>
26842 A new process is created to run the command, but Exim does not wait for it to
26843 complete. Consequently, its status cannot be checked. If the command cannot be
26844 run, a line is written to the panic log, but the ETRN caller still receives
26845 a 250 success response. Exim is normally running under its own uid when
26846 receiving SMTP, so it is not possible for it to change the uid before running
26847 the command.
26848 </para>
26849 <para>
26850 <indexterm role="option">
26851 <primary><option>smtp_etrn_serialize</option></primary>
26852 </indexterm>
26853 </para>
26854 <informaltable frame="all">
26855 <tgroup cols="4" colsep="0" rowsep="0">
26856 <colspec colwidth="8*" align="left"/>
26857 <colspec colwidth="6*" align="center"/>
26858 <colspec colwidth="6*" align="center"/>
26859 <colspec colwidth="6*" align="right"/>
26860 <tbody>
26861 <row>
26862 <entry><option>smtp_etrn_serialize</option></entry>
26863 <entry>Use: <emphasis>main</emphasis></entry>
26864 <entry>Type: <emphasis>boolean</emphasis></entry>
26865 <entry>Default: <emphasis>true</emphasis></entry>
26866 </row>
26867 </tbody>
26868 </tgroup>
26869 </informaltable>
26870 <para>
26871 <indexterm role="concept">
26872 <primary>ETRN</primary>
26873 <secondary>serializing</secondary>
26874 </indexterm>
26875 When this option is set, it prevents the simultaneous execution of more than
26876 one identical command as a result of ETRN in an SMTP connection. See
26877 section <xref linkend="SECTETRN"/> for details.
26878 </para>
26879 <para>
26880 <indexterm role="option">
26881 <primary><option>smtp_load_reserve</option></primary>
26882 </indexterm>
26883 </para>
26884 <informaltable frame="all">
26885 <tgroup cols="4" colsep="0" rowsep="0">
26886 <colspec colwidth="8*" align="left"/>
26887 <colspec colwidth="6*" align="center"/>
26888 <colspec colwidth="6*" align="center"/>
26889 <colspec colwidth="6*" align="right"/>
26890 <tbody>
26891 <row>
26892 <entry><option>smtp_load_reserve</option></entry>
26893 <entry>Use: <emphasis>main</emphasis></entry>
26894 <entry>Type: <emphasis>fixed-point</emphasis></entry>
26895 <entry>Default: <emphasis>unset</emphasis></entry>
26896 </row>
26897 </tbody>
26898 </tgroup>
26899 </informaltable>
26900 <para>
26901 <indexterm role="concept">
26902 <primary>load average</primary>
26903 </indexterm>
26904 If the system load average ever gets higher than this, incoming SMTP calls are
26905 accepted only from those hosts that match an entry in <option>smtp_reserve_hosts</option>.
26906 If <option>smtp_reserve_hosts</option> is not set, no incoming SMTP calls are accepted when
26907 the load is over the limit. The option has no effect on ancient operating
26908 systems on which Exim cannot determine the load average. See also
26909 <option>deliver_queue_load_max</option> and <option>queue_only_load</option>.
26910 </para>
26911 <para>
26912 <indexterm role="option">
26913 <primary><option>smtp_max_synprot_errors</option></primary>
26914 </indexterm>
26915 </para>
26916 <informaltable frame="all">
26917 <tgroup cols="4" colsep="0" rowsep="0">
26918 <colspec colwidth="8*" align="left"/>
26919 <colspec colwidth="6*" align="center"/>
26920 <colspec colwidth="6*" align="center"/>
26921 <colspec colwidth="6*" align="right"/>
26922 <tbody>
26923 <row>
26924 <entry><option>smtp_max_synprot_errors</option></entry>
26925 <entry>Use: <emphasis>main</emphasis></entry>
26926 <entry>Type: <emphasis>integer</emphasis></entry>
26927 <entry>Default: <emphasis>3</emphasis></entry>
26928 </row>
26929 </tbody>
26930 </tgroup>
26931 </informaltable>
26932 <para>
26933 <indexterm role="concept">
26934 <primary>SMTP</primary>
26935 <secondary>limiting syntax and protocol errors</secondary>
26936 </indexterm>
26937 <indexterm role="concept">
26938 <primary>limit</primary>
26939 <secondary>SMTP syntax and protocol errors</secondary>
26940 </indexterm>
26941 Exim rejects SMTP commands that contain syntax or protocol errors. In
26942 particular, a syntactically invalid email address, as in this command:
26943 </para>
26944 <literallayout class="monospaced">
26945 RCPT TO:&lt;abc xyz@a.b.c&gt;
26946 </literallayout>
26947 <para>
26948 causes immediate rejection of the command, before any other tests are done.
26949 (The ACL cannot be run if there is no valid address to set up for it.) An
26950 example of a protocol error is receiving RCPT before MAIL. If there are
26951 too many syntax or protocol errors in one SMTP session, the connection is
26952 dropped. The limit is set by this option.
26953 </para>
26954 <para>
26955 <indexterm role="concept">
26956 <primary>PIPELINING</primary>
26957 <secondary>expected errors</secondary>
26958 </indexterm>
26959 When the PIPELINING extension to SMTP is in use, some protocol errors are
26960 <quote>expected</quote>, for instance, a RCPT command after a rejected MAIL command.
26961 Exim assumes that PIPELINING will be used if it advertises it (see
26962 <option>pipelining_advertise_hosts</option>), and in this situation, <quote>expected</quote> errors do
26963 not count towards the limit.
26964 </para>
26965 <para>
26966 <indexterm role="option">
26967 <primary><option>smtp_max_unknown_commands</option></primary>
26968 </indexterm>
26969 </para>
26970 <informaltable frame="all">
26971 <tgroup cols="4" colsep="0" rowsep="0">
26972 <colspec colwidth="8*" align="left"/>
26973 <colspec colwidth="6*" align="center"/>
26974 <colspec colwidth="6*" align="center"/>
26975 <colspec colwidth="6*" align="right"/>
26976 <tbody>
26977 <row>
26978 <entry><option>smtp_max_unknown_commands</option></entry>
26979 <entry>Use: <emphasis>main</emphasis></entry>
26980 <entry>Type: <emphasis>integer</emphasis></entry>
26981 <entry>Default: <emphasis>3</emphasis></entry>
26982 </row>
26983 </tbody>
26984 </tgroup>
26985 </informaltable>
26986 <para>
26987 <indexterm role="concept">
26988 <primary>SMTP</primary>
26989 <secondary>limiting unknown commands</secondary>
26990 </indexterm>
26991 <indexterm role="concept">
26992 <primary>limit</primary>
26993 <secondary>unknown SMTP commands</secondary>
26994 </indexterm>
26995 If there are too many unrecognized commands in an incoming SMTP session, an
26996 Exim server drops the connection. This is a defence against some kinds of abuse
26997 that subvert web
26998 clients
26999 into making connections to SMTP ports; in these circumstances, a number of
27000 non-SMTP command lines are sent first.
27001 </para>
27002 <para>
27003 <indexterm role="option">
27004 <primary><option>smtp_ratelimit_hosts</option></primary>
27005 </indexterm>
27006 </para>
27007 <informaltable frame="all">
27008 <tgroup cols="4" colsep="0" rowsep="0">
27009 <colspec colwidth="8*" align="left"/>
27010 <colspec colwidth="6*" align="center"/>
27011 <colspec colwidth="6*" align="center"/>
27012 <colspec colwidth="6*" align="right"/>
27013 <tbody>
27014 <row>
27015 <entry><option>smtp_ratelimit_hosts</option></entry>
27016 <entry>Use: <emphasis>main</emphasis></entry>
27017 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
27018 <entry>Default: <emphasis>unset</emphasis></entry>
27019 </row>
27020 </tbody>
27021 </tgroup>
27022 </informaltable>
27023 <para>
27024 <indexterm role="concept">
27025 <primary>SMTP</primary>
27026 <secondary>rate limiting</secondary>
27027 </indexterm>
27028 <indexterm role="concept">
27029 <primary>limit</primary>
27030 <secondary>rate of message arrival</secondary>
27031 </indexterm>
27032 <indexterm role="concept">
27033 <primary>RCPT</primary>
27034 <secondary>rate limiting</secondary>
27035 </indexterm>
27036 Some sites find it helpful to be able to limit the rate at which certain hosts
27037 can send them messages, and the rate at which an individual message can specify
27038 recipients.
27039 </para>
27040 <para>
27041 Exim has two rate-limiting facilities. This section describes the older
27042 facility, which can limit rates within a single connection. The newer
27043 <option>ratelimit</option> ACL condition can limit rates across all connections. See section
27044 <xref linkend="SECTratelimiting"/> for details of the newer facility.
27045 </para>
27046 <para>
27047 When a host matches <option>smtp_ratelimit_hosts</option>, the values of
27048 <option>smtp_ratelimit_mail</option> and <option>smtp_ratelimit_rcpt</option> are used to control the
27049 rate of acceptance of MAIL and RCPT commands in a single SMTP session,
27050 respectively. Each option, if set, must contain a set of four comma-separated
27051 values:
27052 </para>
27053 <itemizedlist>
27054 <listitem>
27055 <para>
27056 A threshold, before which there is no rate limiting.
27057 </para>
27058 </listitem>
27059 <listitem>
27060 <para>
27061 An initial time delay. Unlike other times in Exim, numbers with decimal
27062 fractional parts are allowed here.
27063 </para>
27064 </listitem>
27065 <listitem>
27066 <para>
27067 A factor by which to increase the delay each time.
27068 </para>
27069 </listitem>
27070 <listitem>
27071 <para>
27072 A maximum value for the delay. This should normally be less than 5 minutes,
27073 because after that time, the client is liable to timeout the SMTP command.
27074 </para>
27075 </listitem>
27076 </itemizedlist>
27077 <para>
27078 For example, these settings have been used successfully at the site which
27079 first suggested this feature, for controlling mail from their customers:
27080 </para>
27081 <literallayout class="monospaced">
27082 smtp_ratelimit_mail = 2,0.5s,1.05,4m
27083 smtp_ratelimit_rcpt = 4,0.25s,1.015,4m
27084 </literallayout>
27085 <para>
27086 The first setting specifies delays that are applied to MAIL commands after
27087 two have been received over a single connection. The initial delay is 0.5
27088 seconds, increasing by a factor of 1.05 each time. The second setting applies
27089 delays to RCPT commands when more than four occur in a single message.
27090 </para>
27091 <para>
27092 <indexterm role="option">
27093 <primary><option>smtp_ratelimit_mail</option></primary>
27094 </indexterm>
27095 </para>
27096 <informaltable frame="all">
27097 <tgroup cols="4" colsep="0" rowsep="0">
27098 <colspec colwidth="8*" align="left"/>
27099 <colspec colwidth="6*" align="center"/>
27100 <colspec colwidth="6*" align="center"/>
27101 <colspec colwidth="6*" align="right"/>
27102 <tbody>
27103 <row>
27104 <entry><option>smtp_ratelimit_mail</option></entry>
27105 <entry>Use: <emphasis>main</emphasis></entry>
27106 <entry>Type: <emphasis>string</emphasis></entry>
27107 <entry>Default: <emphasis>unset</emphasis></entry>
27108 </row>
27109 </tbody>
27110 </tgroup>
27111 </informaltable>
27112 <para>
27113 See <option>smtp_ratelimit_hosts</option> above.
27114 </para>
27115 <para>
27116 <indexterm role="option">
27117 <primary><option>smtp_ratelimit_rcpt</option></primary>
27118 </indexterm>
27119 </para>
27120 <informaltable frame="all">
27121 <tgroup cols="4" colsep="0" rowsep="0">
27122 <colspec colwidth="8*" align="left"/>
27123 <colspec colwidth="6*" align="center"/>
27124 <colspec colwidth="6*" align="center"/>
27125 <colspec colwidth="6*" align="right"/>
27126 <tbody>
27127 <row>
27128 <entry><option>smtp_ratelimit_rcpt</option></entry>
27129 <entry>Use: <emphasis>main</emphasis></entry>
27130 <entry>Type: <emphasis>string</emphasis></entry>
27131 <entry>Default: <emphasis>unset</emphasis></entry>
27132 </row>
27133 </tbody>
27134 </tgroup>
27135 </informaltable>
27136 <para>
27137 See <option>smtp_ratelimit_hosts</option> above.
27138 </para>
27139 <para>
27140 <indexterm role="option">
27141 <primary><option>smtp_receive_timeout</option></primary>
27142 </indexterm>
27143 </para>
27144 <informaltable frame="all">
27145 <tgroup cols="4" colsep="0" rowsep="0">
27146 <colspec colwidth="8*" align="left"/>
27147 <colspec colwidth="6*" align="center"/>
27148 <colspec colwidth="6*" align="center"/>
27149 <colspec colwidth="6*" align="right"/>
27150 <tbody>
27151 <row>
27152 <entry><option>smtp_receive_timeout</option></entry>
27153 <entry>Use: <emphasis>main</emphasis></entry>
27154 <entry>Type: <emphasis>time</emphasis></entry>
27155 <entry>Default: <emphasis>5m</emphasis></entry>
27156 </row>
27157 </tbody>
27158 </tgroup>
27159 </informaltable>
27160 <para>
27161 <indexterm role="concept">
27162 <primary>timeout</primary>
27163 <secondary>for SMTP input</secondary>
27164 </indexterm>
27165 <indexterm role="concept">
27166 <primary>SMTP</primary>
27167 <secondary>input timeout</secondary>
27168 </indexterm>
27169 This sets a timeout value for SMTP reception. It applies to all forms of SMTP
27170 input, including batch SMTP. If a line of input (either an SMTP command or a
27171 data line) is not received within this time, the SMTP connection is dropped and
27172 the message is abandoned.
27173 A line is written to the log containing one of the following messages:
27174 </para>
27175 <literallayout class="monospaced">
27176 SMTP command timeout on connection from...
27177 SMTP data timeout on connection from...
27178 </literallayout>
27179 <para>
27180 The former means that Exim was expecting to read an SMTP command; the latter
27181 means that it was in the DATA phase, reading the contents of a message.
27182 </para>
27183 <para>
27184 <indexterm role="option">
27185 <primary><option>-os</option></primary>
27186 </indexterm>
27187 The value set by this option can be overridden by the
27188 <option>-os</option> command-line option. A setting of zero time disables the timeout, but
27189 this should never be used for SMTP over TCP/IP. (It can be useful in some cases
27190 of local input using <option>-bs</option> or <option>-bS</option>.) For non-SMTP input, the reception
27191 timeout is controlled by <option>receive_timeout</option> and <option>-or</option>.
27192 </para>
27193 <para>
27194 <indexterm role="option">
27195 <primary><option>smtp_reserve_hosts</option></primary>
27196 </indexterm>
27197 </para>
27198 <informaltable frame="all">
27199 <tgroup cols="4" colsep="0" rowsep="0">
27200 <colspec colwidth="8*" align="left"/>
27201 <colspec colwidth="6*" align="center"/>
27202 <colspec colwidth="6*" align="center"/>
27203 <colspec colwidth="6*" align="right"/>
27204 <tbody>
27205 <row>
27206 <entry><option>smtp_reserve_hosts</option></entry>
27207 <entry>Use: <emphasis>main</emphasis></entry>
27208 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
27209 <entry>Default: <emphasis>unset</emphasis></entry>
27210 </row>
27211 </tbody>
27212 </tgroup>
27213 </informaltable>
27214 <para>
27215 This option defines hosts for which SMTP connections are reserved; see
27216 <option>smtp_accept_reserve</option> and <option>smtp_load_reserve</option> above.
27217 </para>
27218 <para>
27219 <indexterm role="option">
27220 <primary><option>smtp_return_error_details</option></primary>
27221 </indexterm>
27222 </para>
27223 <informaltable frame="all">
27224 <tgroup cols="4" colsep="0" rowsep="0">
27225 <colspec colwidth="8*" align="left"/>
27226 <colspec colwidth="6*" align="center"/>
27227 <colspec colwidth="6*" align="center"/>
27228 <colspec colwidth="6*" align="right"/>
27229 <tbody>
27230 <row>
27231 <entry><option>smtp_return_error_details</option></entry>
27232 <entry>Use: <emphasis>main</emphasis></entry>
27233 <entry>Type: <emphasis>boolean</emphasis></entry>
27234 <entry>Default: <emphasis>false</emphasis></entry>
27235 </row>
27236 </tbody>
27237 </tgroup>
27238 </informaltable>
27239 <para>
27240 <indexterm role="concept">
27241 <primary>SMTP</primary>
27242 <secondary>details policy failures</secondary>
27243 </indexterm>
27244 <indexterm role="concept">
27245 <primary>policy control</primary>
27246 <secondary>rejection, returning details</secondary>
27247 </indexterm>
27248 In the default state, Exim uses bland messages such as
27249 <quote>Administrative prohibition</quote> when it rejects SMTP commands for policy
27250 reasons. Many sysadmins like this because it gives away little information
27251 to spammers. However, some other sysadmins who are applying strict checking
27252 policies want to give out much fuller information about failures. Setting
27253 <option>smtp_return_error_details</option> true causes Exim to be more forthcoming. For
27254 example, instead of <quote>Administrative prohibition</quote>, it might give:
27255 </para>
27256 <literallayout class="monospaced">
27257 550-Rejected after DATA: '&gt;' missing at end of address:
27258 550 failing address in "From" header is: &lt;user@dom.ain
27259 </literallayout>
27260 <para>
27261 <indexterm role="option">
27262 <primary><option>spamd_address</option></primary>
27263 </indexterm>
27264 </para>
27265 <informaltable frame="all">
27266 <tgroup cols="4" colsep="0" rowsep="0">
27267 <colspec colwidth="8*" align="left"/>
27268 <colspec colwidth="6*" align="center"/>
27269 <colspec colwidth="6*" align="center"/>
27270 <colspec colwidth="6*" align="right"/>
27271 <tbody>
27272 <row>
27273 <entry><option>spamd_address</option></entry>
27274 <entry>Use: <emphasis>main</emphasis></entry>
27275 <entry>Type: <emphasis>string</emphasis></entry>
27276 <entry>Default: <emphasis>see below</emphasis></entry>
27277 </row>
27278 </tbody>
27279 </tgroup>
27280 </informaltable>
27281 <para>
27282 This option is available when Exim is compiled with the content-scanning
27283 extension. It specifies how Exim connects to SpamAssassin&#x2019;s <option>spamd</option> daemon.
27284 The default value is
27285 </para>
27286 <literallayout class="monospaced">
27287 127.0.0.1 783
27288 </literallayout>
27289 <para>
27290 See section <xref linkend="SECTscanspamass"/> for more details.
27291 </para>
27292 <para>
27293 <indexterm role="option">
27294 <primary><option>split_spool_directory</option></primary>
27295 </indexterm>
27296 </para>
27297 <informaltable frame="all">
27298 <tgroup cols="4" colsep="0" rowsep="0">
27299 <colspec colwidth="8*" align="left"/>
27300 <colspec colwidth="6*" align="center"/>
27301 <colspec colwidth="6*" align="center"/>
27302 <colspec colwidth="6*" align="right"/>
27303 <tbody>
27304 <row>
27305 <entry><option>split_spool_directory</option></entry>
27306 <entry>Use: <emphasis>main</emphasis></entry>
27307 <entry>Type: <emphasis>boolean</emphasis></entry>
27308 <entry>Default: <emphasis>false</emphasis></entry>
27309 </row>
27310 </tbody>
27311 </tgroup>
27312 </informaltable>
27313 <para>
27314 <indexterm role="concept">
27315 <primary>multiple spool directories</primary>
27316 </indexterm>
27317 <indexterm role="concept">
27318 <primary>spool directory</primary>
27319 <secondary>split</secondary>
27320 </indexterm>
27321 <indexterm role="concept">
27322 <primary>directories, multiple</primary>
27323 </indexterm>
27324 If this option is set, it causes Exim to split its input directory into 62
27325 subdirectories, each with a single alphanumeric character as its name. The
27326 sixth character of the message id is used to allocate messages to
27327 subdirectories; this is the least significant base-62 digit of the time of
27328 arrival of the message.
27329 </para>
27330 <para>
27331 Splitting up the spool in this way may provide better performance on systems
27332 where there are long mail queues, by reducing the number of files in any one
27333 directory. The msglog directory is also split up in a similar way to the input
27334 directory; however, if <option>preserve_message_logs</option> is set, all old msglog files
27335 are still placed in the single directory <filename>msglog.OLD</filename>.
27336 </para>
27337 <para>
27338 It is not necessary to take any special action for existing messages when
27339 changing <option>split_spool_directory</option>. Exim notices messages that are in the
27340 <quote>wrong</quote> place, and continues to process them. If the option is turned off
27341 after a period of being on, the subdirectories will eventually empty and be
27342 automatically deleted.
27343 </para>
27344 <para>
27345 When <option>split_spool_directory</option> is set, the behaviour of queue runner processes
27346 changes. Instead of creating a list of all messages in the queue, and then
27347 trying to deliver each one in turn, it constructs a list of those in one
27348 sub-directory and tries to deliver them, before moving on to the next
27349 sub-directory. The sub-directories are processed in a random order. This
27350 spreads out the scanning of the input directories, and uses less memory. It is
27351 particularly beneficial when there are lots of messages on the queue. However,
27352 if <option>queue_run_in_order</option> is set, none of this new processing happens. The
27353 entire queue has to be scanned and sorted before any deliveries can start.
27354 </para>
27355 <para>
27356 <indexterm role="option">
27357 <primary><option>spool_directory</option></primary>
27358 </indexterm>
27359 </para>
27360 <informaltable frame="all">
27361 <tgroup cols="4" colsep="0" rowsep="0">
27362 <colspec colwidth="8*" align="left"/>
27363 <colspec colwidth="6*" align="center"/>
27364 <colspec colwidth="6*" align="center"/>
27365 <colspec colwidth="6*" align="right"/>
27366 <tbody>
27367 <row>
27368 <entry><option>spool_directory</option></entry>
27369 <entry>Use: <emphasis>main</emphasis></entry>
27370 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
27371 <entry>Default: <emphasis>set at compile time</emphasis></entry>
27372 </row>
27373 </tbody>
27374 </tgroup>
27375 </informaltable>
27376 <para>
27377 <indexterm role="concept">
27378 <primary>spool directory</primary>
27379 <secondary>path to</secondary>
27380 </indexterm>
27381 This defines the directory in which Exim keeps its spool, that is, the messages
27382 it is waiting to deliver. The default value is taken from the compile-time
27383 configuration setting, if there is one. If not, this option must be set. The
27384 string is expanded, so it can contain, for example, a reference to
27385 <varname>$primary_hostname</varname>.
27386 </para>
27387 <para>
27388 If the spool directory name is fixed on your installation, it is recommended
27389 that you set it at build time rather than from this option, particularly if the
27390 log files are being written to the spool directory (see <option>log_file_path</option>).
27391 Otherwise log files cannot be used for errors that are detected early on, such
27392 as failures in the configuration file.
27393 </para>
27394 <para>
27395 By using this option to override the compiled-in path, it is possible to run
27396 tests of Exim without using the standard spool.
27397 </para>
27398 <para>
27399 <indexterm role="option">
27400 <primary><option>sqlite_lock_timeout</option></primary>
27401 </indexterm>
27402 </para>
27403 <informaltable frame="all">
27404 <tgroup cols="4" colsep="0" rowsep="0">
27405 <colspec colwidth="8*" align="left"/>
27406 <colspec colwidth="6*" align="center"/>
27407 <colspec colwidth="6*" align="center"/>
27408 <colspec colwidth="6*" align="right"/>
27409 <tbody>
27410 <row>
27411 <entry><option>sqlite_lock_timeout</option></entry>
27412 <entry>Use: <emphasis>main</emphasis></entry>
27413 <entry>Type: <emphasis>time</emphasis></entry>
27414 <entry>Default: <emphasis>5s</emphasis></entry>
27415 </row>
27416 </tbody>
27417 </tgroup>
27418 </informaltable>
27419 <para>
27420 <indexterm role="concept">
27421 <primary>sqlite lookup type</primary>
27422 <secondary>lock timeout</secondary>
27423 </indexterm>
27424 This option controls the timeout that the <command>sqlite</command> lookup uses when trying to
27425 access an SQLite database. See section <xref linkend="SECTsqlite"/> for more details.
27426 </para>
27427 <para>
27428 <indexterm role="option">
27429 <primary><option>strict_acl_vars</option></primary>
27430 </indexterm>
27431 </para>
27432 <informaltable frame="all">
27433 <tgroup cols="4" colsep="0" rowsep="0">
27434 <colspec colwidth="8*" align="left"/>
27435 <colspec colwidth="6*" align="center"/>
27436 <colspec colwidth="6*" align="center"/>
27437 <colspec colwidth="6*" align="right"/>
27438 <tbody>
27439 <row>
27440 <entry><option>strict_acl_vars</option></entry>
27441 <entry>Use: <emphasis>main</emphasis></entry>
27442 <entry>Type: <emphasis>boolean</emphasis></entry>
27443 <entry>Default: <emphasis>false</emphasis></entry>
27444 </row>
27445 </tbody>
27446 </tgroup>
27447 </informaltable>
27448 <para>
27449 <indexterm role="concept">
27450 <primary>access control lists (ACLs)</primary>
27451 <secondary>variables, handling unset</secondary>
27452 </indexterm>
27453 This option controls what happens if a syntactically valid but undefined ACL
27454 variable is referenced. If it is false (the default), an empty string
27455 is substituted; if it is true, an error is generated. See section
27456 <xref linkend="SECTaclvariables"/> for details of ACL variables.
27457 </para>
27458 <para>
27459 <indexterm role="option">
27460 <primary><option>strip_excess_angle_brackets</option></primary>
27461 </indexterm>
27462 </para>
27463 <informaltable frame="all">
27464 <tgroup cols="4" colsep="0" rowsep="0">
27465 <colspec colwidth="8*" align="left"/>
27466 <colspec colwidth="6*" align="center"/>
27467 <colspec colwidth="6*" align="center"/>
27468 <colspec colwidth="6*" align="right"/>
27469 <tbody>
27470 <row>
27471 <entry><option>strip_excess_angle_brackets</option></entry>
27472 <entry>Use: <emphasis>main</emphasis></entry>
27473 <entry>Type: <emphasis>boolean</emphasis></entry>
27474 <entry>Default: <emphasis>false</emphasis></entry>
27475 </row>
27476 </tbody>
27477 </tgroup>
27478 </informaltable>
27479 <para>
27480 <indexterm role="concept">
27481 <primary>angle brackets, excess</primary>
27482 </indexterm>
27483 If this option is set, redundant pairs of angle brackets round <quote>route-addr</quote>
27484 items in addresses are stripped. For example, <emphasis>&lt;&lt;xxx@a.b.c.d&gt;&gt;</emphasis> is
27485 treated as <emphasis>&lt;xxx@a.b.c.d&gt;</emphasis>. If this is in the envelope and the message is
27486 passed on to another MTA, the excess angle brackets are not passed on. If this
27487 option is not set, multiple pairs of angle brackets cause a syntax error.
27488 </para>
27489 <para>
27490 <indexterm role="option">
27491 <primary><option>strip_trailing_dot</option></primary>
27492 </indexterm>
27493 </para>
27494 <informaltable frame="all">
27495 <tgroup cols="4" colsep="0" rowsep="0">
27496 <colspec colwidth="8*" align="left"/>
27497 <colspec colwidth="6*" align="center"/>
27498 <colspec colwidth="6*" align="center"/>
27499 <colspec colwidth="6*" align="right"/>
27500 <tbody>
27501 <row>
27502 <entry><option>strip_trailing_dot</option></entry>
27503 <entry>Use: <emphasis>main</emphasis></entry>
27504 <entry>Type: <emphasis>boolean</emphasis></entry>
27505 <entry>Default: <emphasis>false</emphasis></entry>
27506 </row>
27507 </tbody>
27508 </tgroup>
27509 </informaltable>
27510 <para>
27511 <indexterm role="concept">
27512 <primary>trailing dot on domain</primary>
27513 </indexterm>
27514 <indexterm role="concept">
27515 <primary>dot</primary>
27516 <secondary>trailing on domain</secondary>
27517 </indexterm>
27518 If this option is set, a trailing dot at the end of a domain in an address is
27519 ignored. If this is in the envelope and the message is passed on to another
27520 MTA, the dot is not passed on. If this option is not set, a dot at the end of a
27521 domain causes a syntax error.
27522 However, addresses in header lines are checked only when an ACL requests header
27523 syntax checking.
27524 </para>
27525 <para>
27526 <indexterm role="option">
27527 <primary><option>syslog_duplication</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>syslog_duplication</option></entry>
27539 <entry>Use: <emphasis>main</emphasis></entry>
27540 <entry>Type: <emphasis>boolean</emphasis></entry>
27541 <entry>Default: <emphasis>true</emphasis></entry>
27542 </row>
27543 </tbody>
27544 </tgroup>
27545 </informaltable>
27546 <para>
27547 <indexterm role="concept">
27548 <primary>syslog</primary>
27549 <secondary>duplicate log lines; suppressing</secondary>
27550 </indexterm>
27551 When Exim is logging to syslog, it writes the log lines for its three
27552 separate logs at different syslog priorities so that they can in principle
27553 be separated on the logging hosts. Some installations do not require this
27554 separation, and in those cases, the duplication of certain log lines is a
27555 nuisance. If <option>syslog_duplication</option> is set false, only one copy of any
27556 particular log line is written to syslog. For lines that normally go to
27557 both the main log and the reject log, the reject log version (possibly
27558 containing message header lines) is written, at LOG_NOTICE priority.
27559 Lines that normally go to both the main and the panic log are written at
27560 the LOG_ALERT priority.
27561 </para>
27562 <para>
27563 <indexterm role="option">
27564 <primary><option>syslog_facility</option></primary>
27565 </indexterm>
27566 </para>
27567 <informaltable frame="all">
27568 <tgroup cols="4" colsep="0" rowsep="0">
27569 <colspec colwidth="8*" align="left"/>
27570 <colspec colwidth="6*" align="center"/>
27571 <colspec colwidth="6*" align="center"/>
27572 <colspec colwidth="6*" align="right"/>
27573 <tbody>
27574 <row>
27575 <entry><option>syslog_facility</option></entry>
27576 <entry>Use: <emphasis>main</emphasis></entry>
27577 <entry>Type: <emphasis>string</emphasis></entry>
27578 <entry>Default: <emphasis>unset</emphasis></entry>
27579 </row>
27580 </tbody>
27581 </tgroup>
27582 </informaltable>
27583 <para>
27584 <indexterm role="concept">
27585 <primary>syslog</primary>
27586 <secondary>facility; setting</secondary>
27587 </indexterm>
27588 This option sets the syslog <quote>facility</quote> name, used when Exim is logging to
27589 syslog. The value must be one of the strings <quote>mail</quote>, <quote>user</quote>, <quote>news</quote>,
27590 <quote>uucp</quote>, <quote>daemon</quote>, or <quote>local<emphasis>x</emphasis></quote> where <emphasis>x</emphasis> is a digit between 0 and 7.
27591 If this option is unset, <quote>mail</quote> is used. See chapter <xref linkend="CHAPlog"/> for
27592 details of Exim&#x2019;s logging.
27593 </para>
27594 <para>
27595 <indexterm role="option">
27596 <primary><option>syslog_processname</option></primary>
27597 </indexterm>
27598 </para>
27599 <informaltable frame="all">
27600 <tgroup cols="4" colsep="0" rowsep="0">
27601 <colspec colwidth="8*" align="left"/>
27602 <colspec colwidth="6*" align="center"/>
27603 <colspec colwidth="6*" align="center"/>
27604 <colspec colwidth="6*" align="right"/>
27605 <tbody>
27606 <row>
27607 <entry><option>syslog_processname</option></entry>
27608 <entry>Use: <emphasis>main</emphasis></entry>
27609 <entry>Type: <emphasis>string</emphasis></entry>
27610 <entry>Default: <emphasis><literal>exim</literal></emphasis></entry>
27611 </row>
27612 </tbody>
27613 </tgroup>
27614 </informaltable>
27615 <para>
27616 <indexterm role="concept">
27617 <primary>syslog</primary>
27618 <secondary>process name; setting</secondary>
27619 </indexterm>
27620 This option sets the syslog <quote>ident</quote> name, used when Exim is logging to
27621 syslog. The value must be no longer than 32 characters. See chapter
27622 <xref linkend="CHAPlog"/> for details of Exim&#x2019;s logging.
27623 </para>
27624 <para>
27625 <indexterm role="option">
27626 <primary><option>syslog_timestamp</option></primary>
27627 </indexterm>
27628 </para>
27629 <informaltable frame="all">
27630 <tgroup cols="4" colsep="0" rowsep="0">
27631 <colspec colwidth="8*" align="left"/>
27632 <colspec colwidth="6*" align="center"/>
27633 <colspec colwidth="6*" align="center"/>
27634 <colspec colwidth="6*" align="right"/>
27635 <tbody>
27636 <row>
27637 <entry><option>syslog_timestamp</option></entry>
27638 <entry>Use: <emphasis>main</emphasis></entry>
27639 <entry>Type: <emphasis>boolean</emphasis></entry>
27640 <entry>Default: <emphasis>true</emphasis></entry>
27641 </row>
27642 </tbody>
27643 </tgroup>
27644 </informaltable>
27645 <para>
27646 <indexterm role="concept">
27647 <primary>syslog</primary>
27648 <secondary>timestamps</secondary>
27649 </indexterm>
27650 If <option>syslog_timestamp</option> is set false, the timestamps on Exim&#x2019;s log lines are
27651 omitted when these lines are sent to syslog. See chapter <xref linkend="CHAPlog"/> for
27652 details of Exim&#x2019;s logging.
27653 </para>
27654 <para>
27655 <indexterm role="option">
27656 <primary><option>system_filter</option></primary>
27657 </indexterm>
27658 </para>
27659 <informaltable frame="all">
27660 <tgroup cols="4" colsep="0" rowsep="0">
27661 <colspec colwidth="8*" align="left"/>
27662 <colspec colwidth="6*" align="center"/>
27663 <colspec colwidth="6*" align="center"/>
27664 <colspec colwidth="6*" align="right"/>
27665 <tbody>
27666 <row>
27667 <entry><option>system_filter</option></entry>
27668 <entry>Use: <emphasis>main</emphasis></entry>
27669 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
27670 <entry>Default: <emphasis>unset</emphasis></entry>
27671 </row>
27672 </tbody>
27673 </tgroup>
27674 </informaltable>
27675 <para>
27676 <indexterm role="concept">
27677 <primary>filter</primary>
27678 <secondary>system filter</secondary>
27679 </indexterm>
27680 <indexterm role="concept">
27681 <primary>system filter</primary>
27682 <secondary>specifying</secondary>
27683 </indexterm>
27684 <indexterm role="concept">
27685 <primary>Sieve filter</primary>
27686 <secondary>not available for system filter</secondary>
27687 </indexterm>
27688 This option specifies an Exim filter file that is applied to all messages at
27689 the start of each delivery attempt, before any routing is done. System filters
27690 must be Exim filters; they cannot be Sieve filters. If the system filter
27691 generates any deliveries to files or pipes, or any new mail messages, the
27692 appropriate <option>system_filter_..._transport</option> option(s) must be set, to define
27693 which transports are to be used. Details of this facility are given in chapter
27694 <xref linkend="CHAPsystemfilter"/>.
27695 </para>
27696 <para>
27697 <indexterm role="option">
27698 <primary><option>system_filter_directory_transport</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>system_filter_directory_transport</option></entry>
27710 <entry>Use: <emphasis>main</emphasis></entry>
27711 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
27712 <entry>Default: <emphasis>unset</emphasis></entry>
27713 </row>
27714 </tbody>
27715 </tgroup>
27716 </informaltable>
27717 <para>
27718 <indexterm role="variable">
27719 <primary><varname>$address_file</varname></primary>
27720 </indexterm>
27721 This sets the name of the transport driver that is to be used when the
27722 <option>save</option> command in a system message filter specifies a path ending in <quote>/</quote>,
27723 implying delivery of each message into a separate file in some directory.
27724 During the delivery, the variable <varname>$address_file</varname> contains the path name.
27725 </para>
27726 <para>
27727 <indexterm role="option">
27728 <primary><option>system_filter_file_transport</option></primary>
27729 </indexterm>
27730 </para>
27731 <informaltable frame="all">
27732 <tgroup cols="4" colsep="0" rowsep="0">
27733 <colspec colwidth="8*" align="left"/>
27734 <colspec colwidth="6*" align="center"/>
27735 <colspec colwidth="6*" align="center"/>
27736 <colspec colwidth="6*" align="right"/>
27737 <tbody>
27738 <row>
27739 <entry><option>system_filter_file_transport</option></entry>
27740 <entry>Use: <emphasis>main</emphasis></entry>
27741 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
27742 <entry>Default: <emphasis>unset</emphasis></entry>
27743 </row>
27744 </tbody>
27745 </tgroup>
27746 </informaltable>
27747 <para>
27748 <indexterm role="concept">
27749 <primary>file</primary>
27750 <secondary>transport for system filter</secondary>
27751 </indexterm>
27752 This sets the name of the transport driver that is to be used when the <option>save</option>
27753 command in a system message filter specifies a path not ending in <quote>/</quote>. During
27754 the delivery, the variable <varname>$address_file</varname> contains the path name.
27755 </para>
27756 <para>
27757 <indexterm role="option">
27758 <primary><option>system_filter_group</option></primary>
27759 </indexterm>
27760 </para>
27761 <informaltable frame="all">
27762 <tgroup cols="4" colsep="0" rowsep="0">
27763 <colspec colwidth="8*" align="left"/>
27764 <colspec colwidth="6*" align="center"/>
27765 <colspec colwidth="6*" align="center"/>
27766 <colspec colwidth="6*" align="right"/>
27767 <tbody>
27768 <row>
27769 <entry><option>system_filter_group</option></entry>
27770 <entry>Use: <emphasis>main</emphasis></entry>
27771 <entry>Type: <emphasis>string</emphasis></entry>
27772 <entry>Default: <emphasis>unset</emphasis></entry>
27773 </row>
27774 </tbody>
27775 </tgroup>
27776 </informaltable>
27777 <para>
27778 <indexterm role="concept">
27779 <primary>gid (group id)</primary>
27780 <secondary>system filter</secondary>
27781 </indexterm>
27782 This option is used only when <option>system_filter_user</option> is also set. It sets the
27783 gid under which the system filter is run, overriding any gid that is associated
27784 with the user. The value may be numerical or symbolic.
27785 </para>
27786 <para>
27787 <indexterm role="option">
27788 <primary><option>system_filter_pipe_transport</option></primary>
27789 </indexterm>
27790 </para>
27791 <informaltable frame="all">
27792 <tgroup cols="4" colsep="0" rowsep="0">
27793 <colspec colwidth="8*" align="left"/>
27794 <colspec colwidth="6*" align="center"/>
27795 <colspec colwidth="6*" align="center"/>
27796 <colspec colwidth="6*" align="right"/>
27797 <tbody>
27798 <row>
27799 <entry><option>system_filter_pipe_transport</option></entry>
27800 <entry>Use: <emphasis>main</emphasis></entry>
27801 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
27802 <entry>Default: <emphasis>unset</emphasis></entry>
27803 </row>
27804 </tbody>
27805 </tgroup>
27806 </informaltable>
27807 <para>
27808 <indexterm role="concept">
27809 <primary><command>pipe</command> transport</primary>
27810 <secondary>for system filter</secondary>
27811 </indexterm>
27812 <indexterm role="variable">
27813 <primary><varname>$address_pipe</varname></primary>
27814 </indexterm>
27815 This specifies the transport driver that is to be used when a <option>pipe</option> command
27816 is used in a system filter. During the delivery, the variable <varname>$address_pipe</varname>
27817 contains the pipe command.
27818 </para>
27819 <para>
27820 <indexterm role="option">
27821 <primary><option>system_filter_reply_transport</option></primary>
27822 </indexterm>
27823 </para>
27824 <informaltable frame="all">
27825 <tgroup cols="4" colsep="0" rowsep="0">
27826 <colspec colwidth="8*" align="left"/>
27827 <colspec colwidth="6*" align="center"/>
27828 <colspec colwidth="6*" align="center"/>
27829 <colspec colwidth="6*" align="right"/>
27830 <tbody>
27831 <row>
27832 <entry><option>system_filter_reply_transport</option></entry>
27833 <entry>Use: <emphasis>main</emphasis></entry>
27834 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
27835 <entry>Default: <emphasis>unset</emphasis></entry>
27836 </row>
27837 </tbody>
27838 </tgroup>
27839 </informaltable>
27840 <para>
27841 <indexterm role="concept">
27842 <primary><command>autoreply</command> transport</primary>
27843 <secondary>for system filter</secondary>
27844 </indexterm>
27845 This specifies the transport driver that is to be used when a <option>mail</option> command
27846 is used in a system filter.
27847 </para>
27848 <para revisionflag="changed">
27849 <indexterm role="option">
27850 <primary><option>system_filter_user</option></primary>
27851 </indexterm>
27852 </para>
27853 <informaltable frame="all" revisionflag="changed">
27854 <tgroup cols="4" colsep="0" rowsep="0">
27855 <colspec colwidth="8*" align="left"/>
27856 <colspec colwidth="6*" align="center"/>
27857 <colspec colwidth="6*" align="center"/>
27858 <colspec colwidth="6*" align="right"/>
27859 <tbody>
27860 <row>
27861 <entry><option>system_filter_user</option></entry>
27862 <entry>Use: <emphasis>main</emphasis></entry>
27863 <entry>Type: <emphasis>string</emphasis></entry>
27864 <entry>Default: <emphasis>unset</emphasis></entry>
27865 </row>
27866 </tbody>
27867 </tgroup>
27868 </informaltable>
27869 <para revisionflag="changed">
27870 <indexterm role="concept">
27871 <primary>uid (user id)</primary>
27872 <secondary>system filter</secondary>
27873 </indexterm>
27874 If this option is set to root, the system filter is run in the main Exim
27875 delivery process, as root.  Otherwise, the system filter runs in a separate
27876 process, as the given user, defaulting to the Exim run-time user.
27877 Unless the string consists entirely of digits, it
27878 is looked up in the password data. Failure to find the named user causes a
27879 configuration error. The gid is either taken from the password data, or
27880 specified by <option>system_filter_group</option>. When the uid is specified numerically,
27881 <option>system_filter_group</option> is required to be set.
27882 </para>
27883 <para revisionflag="changed">
27884 If the system filter generates any pipe, file, or reply deliveries, the uid
27885 under which the filter is run is used when transporting them, unless a
27886 transport option overrides.
27887 </para>
27888 <para>
27889 <indexterm role="option">
27890 <primary><option>tcp_nodelay</option></primary>
27891 </indexterm>
27892 </para>
27893 <informaltable frame="all">
27894 <tgroup cols="4" colsep="0" rowsep="0">
27895 <colspec colwidth="8*" align="left"/>
27896 <colspec colwidth="6*" align="center"/>
27897 <colspec colwidth="6*" align="center"/>
27898 <colspec colwidth="6*" align="right"/>
27899 <tbody>
27900 <row>
27901 <entry><option>tcp_nodelay</option></entry>
27902 <entry>Use: <emphasis>main</emphasis></entry>
27903 <entry>Type: <emphasis>boolean</emphasis></entry>
27904 <entry>Default: <emphasis>true</emphasis></entry>
27905 </row>
27906 </tbody>
27907 </tgroup>
27908 </informaltable>
27909 <para>
27910 <indexterm role="concept">
27911 <primary>daemon</primary>
27912 <secondary>TCP_NODELAY on sockets</secondary>
27913 </indexterm>
27914 <indexterm role="concept">
27915 <primary>Nagle algorithm</primary>
27916 </indexterm>
27917 <indexterm role="concept">
27918 <primary>TCP_NODELAY on listening sockets</primary>
27919 </indexterm>
27920 If this option is set false, it stops the Exim daemon setting the
27921 TCP_NODELAY option on its listening sockets. Setting TCP_NODELAY
27922 turns off the <quote>Nagle algorithm</quote>, which is a way of improving network
27923 performance in interactive (character-by-character) situations. Turning it off
27924 should improve Exim&#x2019;s performance a bit, so that is what happens by default.
27925 However, it appears that some broken clients cannot cope, and time out. Hence
27926 this option. It affects only those sockets that are set up for listening by the
27927 daemon. Sockets created by the smtp transport for delivering mail always set
27928 TCP_NODELAY.
27929 </para>
27930 <para>
27931 <indexterm role="option">
27932 <primary><option>timeout_frozen_after</option></primary>
27933 </indexterm>
27934 </para>
27935 <informaltable frame="all">
27936 <tgroup cols="4" colsep="0" rowsep="0">
27937 <colspec colwidth="8*" align="left"/>
27938 <colspec colwidth="6*" align="center"/>
27939 <colspec colwidth="6*" align="center"/>
27940 <colspec colwidth="6*" align="right"/>
27941 <tbody>
27942 <row>
27943 <entry><option>timeout_frozen_after</option></entry>
27944 <entry>Use: <emphasis>main</emphasis></entry>
27945 <entry>Type: <emphasis>time</emphasis></entry>
27946 <entry>Default: <emphasis>0s</emphasis></entry>
27947 </row>
27948 </tbody>
27949 </tgroup>
27950 </informaltable>
27951 <para>
27952 <indexterm role="concept">
27953 <primary>frozen messages</primary>
27954 <secondary>timing out</secondary>
27955 </indexterm>
27956 <indexterm role="concept">
27957 <primary>timeout</primary>
27958 <secondary>frozen messages</secondary>
27959 </indexterm>
27960 If <option>timeout_frozen_after</option> is set to a time greater than zero, a frozen
27961 message of any kind that has been on the queue for longer than the given time
27962 is automatically cancelled at the next queue run. If the frozen message is a
27963 bounce message, it is just discarded; otherwise, a bounce is sent to the
27964 sender, in a similar manner to cancellation by the <option>-Mg</option> command line option.
27965 If you want to timeout frozen bounce messages earlier than other kinds of
27966 frozen message, see <option>ignore_bounce_errors_after</option>.
27967 </para>
27968 <para>
27969 <emphasis role="bold">Note:</emphasis> the default value of zero means no timeouts; with this setting,
27970 frozen messages remain on the queue forever (except for any frozen bounce
27971 messages that are released by <option>ignore_bounce_errors_after</option>).
27972 </para>
27973 <para>
27974 <indexterm role="option">
27975 <primary><option>timezone</option></primary>
27976 </indexterm>
27977 </para>
27978 <informaltable frame="all">
27979 <tgroup cols="4" colsep="0" rowsep="0">
27980 <colspec colwidth="8*" align="left"/>
27981 <colspec colwidth="6*" align="center"/>
27982 <colspec colwidth="6*" align="center"/>
27983 <colspec colwidth="6*" align="right"/>
27984 <tbody>
27985 <row>
27986 <entry><option>timezone</option></entry>
27987 <entry>Use: <emphasis>main</emphasis></entry>
27988 <entry>Type: <emphasis>string</emphasis></entry>
27989 <entry>Default: <emphasis>unset</emphasis></entry>
27990 </row>
27991 </tbody>
27992 </tgroup>
27993 </informaltable>
27994 <para>
27995 <indexterm role="concept">
27996 <primary>timezone, setting</primary>
27997 </indexterm>
27998 The value of <option>timezone</option> is used to set the environment variable TZ while
27999 running Exim (if it is different on entry). This ensures that all timestamps
28000 created by Exim are in the required timezone. If you want all your timestamps
28001 to be in UTC (aka GMT) you should set
28002 </para>
28003 <literallayout class="monospaced">
28004 timezone = UTC
28005 </literallayout>
28006 <para>
28007 The default value is taken from TIMEZONE_DEFAULT in <filename>Local/Makefile</filename>,
28008 or, if that is not set, from the value of the TZ environment variable when Exim
28009 is built. If <option>timezone</option> is set to the empty string, either at build or run
28010 time, any existing TZ variable is removed from the environment when Exim
28011 runs. This is appropriate behaviour for obtaining wall-clock time on some, but
28012 unfortunately not all, operating systems.
28013 </para>
28014 <para>
28015 <indexterm role="option">
28016 <primary><option>tls_advertise_hosts</option></primary>
28017 </indexterm>
28018 </para>
28019 <informaltable frame="all">
28020 <tgroup cols="4" colsep="0" rowsep="0">
28021 <colspec colwidth="8*" align="left"/>
28022 <colspec colwidth="6*" align="center"/>
28023 <colspec colwidth="6*" align="center"/>
28024 <colspec colwidth="6*" align="right"/>
28025 <tbody>
28026 <row>
28027 <entry><option>tls_advertise_hosts</option></entry>
28028 <entry>Use: <emphasis>main</emphasis></entry>
28029 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
28030 <entry>Default: <emphasis>unset</emphasis></entry>
28031 </row>
28032 </tbody>
28033 </tgroup>
28034 </informaltable>
28035 <para>
28036 <indexterm role="concept">
28037 <primary>TLS</primary>
28038 <secondary>advertising</secondary>
28039 </indexterm>
28040 <indexterm role="concept">
28041 <primary>encryption</primary>
28042 <secondary>on SMTP connection</secondary>
28043 </indexterm>
28044 <indexterm role="concept">
28045 <primary>SMTP</primary>
28046 <secondary>encrypted connection</secondary>
28047 </indexterm>
28048 When Exim is built with support for TLS encrypted connections, the availability
28049 of the STARTTLS command to set up an encrypted session is advertised in
28050 response to EHLO only to those client hosts that match this option. See
28051 chapter <xref linkend="CHAPTLS"/> for details of Exim&#x2019;s support for TLS.
28052 </para>
28053 <para>
28054 <indexterm role="option">
28055 <primary><option>tls_certificate</option></primary>
28056 </indexterm>
28057 </para>
28058 <informaltable frame="all">
28059 <tgroup cols="4" colsep="0" rowsep="0">
28060 <colspec colwidth="8*" align="left"/>
28061 <colspec colwidth="6*" align="center"/>
28062 <colspec colwidth="6*" align="center"/>
28063 <colspec colwidth="6*" align="right"/>
28064 <tbody>
28065 <row>
28066 <entry><option>tls_certificate</option></entry>
28067 <entry>Use: <emphasis>main</emphasis></entry>
28068 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
28069 <entry>Default: <emphasis>unset</emphasis></entry>
28070 </row>
28071 </tbody>
28072 </tgroup>
28073 </informaltable>
28074 <para>
28075 <indexterm role="concept">
28076 <primary>TLS</primary>
28077 <secondary>server certificate; location of</secondary>
28078 </indexterm>
28079 <indexterm role="concept">
28080 <primary>certificate</primary>
28081 <secondary>server, location of</secondary>
28082 </indexterm>
28083 The value of this option is expanded, and must then be the absolute path to a
28084 file which contains the server&#x2019;s certificates. The server&#x2019;s private key is also
28085 assumed to be in this file if <option>tls_privatekey</option> is unset. See chapter
28086 <xref linkend="CHAPTLS"/> for further details.
28087 </para>
28088 <para>
28089 <emphasis role="bold">Note</emphasis>: The certificates defined by this option are used only when Exim is
28090 receiving incoming messages as a server. If you want to supply certificates for
28091 use when sending messages as a client, you must set the <option>tls_certificate</option>
28092 option in the relevant <command>smtp</command> transport.
28093 </para>
28094 <para>
28095 <indexterm role="option">
28096 <primary><option>tls_crl</option></primary>
28097 </indexterm>
28098 </para>
28099 <informaltable frame="all">
28100 <tgroup cols="4" colsep="0" rowsep="0">
28101 <colspec colwidth="8*" align="left"/>
28102 <colspec colwidth="6*" align="center"/>
28103 <colspec colwidth="6*" align="center"/>
28104 <colspec colwidth="6*" align="right"/>
28105 <tbody>
28106 <row>
28107 <entry><option>tls_crl</option></entry>
28108 <entry>Use: <emphasis>main</emphasis></entry>
28109 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
28110 <entry>Default: <emphasis>unset</emphasis></entry>
28111 </row>
28112 </tbody>
28113 </tgroup>
28114 </informaltable>
28115 <para>
28116 <indexterm role="concept">
28117 <primary>TLS</primary>
28118 <secondary>server certificate revocation list</secondary>
28119 </indexterm>
28120 <indexterm role="concept">
28121 <primary>certificate</primary>
28122 <secondary>revocation list for server</secondary>
28123 </indexterm>
28124 This option specifies a certificate revocation list. The expanded value must
28125 be the name of a file that contains a CRL in PEM format.
28126 </para>
28127 <para>
28128 <indexterm role="option">
28129 <primary><option>tls_dhparam</option></primary>
28130 </indexterm>
28131 </para>
28132 <informaltable frame="all">
28133 <tgroup cols="4" colsep="0" rowsep="0">
28134 <colspec colwidth="8*" align="left"/>
28135 <colspec colwidth="6*" align="center"/>
28136 <colspec colwidth="6*" align="center"/>
28137 <colspec colwidth="6*" align="right"/>
28138 <tbody>
28139 <row>
28140 <entry><option>tls_dhparam</option></entry>
28141 <entry>Use: <emphasis>main</emphasis></entry>
28142 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
28143 <entry>Default: <emphasis>unset</emphasis></entry>
28144 </row>
28145 </tbody>
28146 </tgroup>
28147 </informaltable>
28148 <para>
28149 <indexterm role="concept">
28150 <primary>TLS</primary>
28151 <secondary>D-H parameters for server</secondary>
28152 </indexterm>
28153 The value of this option is expanded, and must then be the absolute path to
28154 a file which contains the server&#x2019;s DH parameter values.
28155 This is used only for OpenSSL. When Exim is linked with GnuTLS, this option is
28156 ignored. See section <xref linkend="SECTopenvsgnu"/> for further details.
28157 </para>
28158 <para>
28159 <indexterm role="option">
28160 <primary><option>tls_on_connect_ports</option></primary>
28161 </indexterm>
28162 </para>
28163 <informaltable frame="all">
28164 <tgroup cols="4" colsep="0" rowsep="0">
28165 <colspec colwidth="8*" align="left"/>
28166 <colspec colwidth="6*" align="center"/>
28167 <colspec colwidth="6*" align="center"/>
28168 <colspec colwidth="6*" align="right"/>
28169 <tbody>
28170 <row>
28171 <entry><option>tls_on_connect_ports</option></entry>
28172 <entry>Use: <emphasis>main</emphasis></entry>
28173 <entry>Type: <emphasis>string list</emphasis></entry>
28174 <entry>Default: <emphasis>unset</emphasis></entry>
28175 </row>
28176 </tbody>
28177 </tgroup>
28178 </informaltable>
28179 <para>
28180 This option specifies a list of incoming SSMTP (aka SMTPS) ports that should
28181 operate the obsolete SSMTP (SMTPS) protocol, where a TLS session is immediately
28182 set up without waiting for the client to issue a STARTTLS command. For
28183 further details, see section <xref linkend="SECTsupobssmt"/>.
28184 </para>
28185 <para>
28186 <indexterm role="option">
28187 <primary><option>tls_privatekey</option></primary>
28188 </indexterm>
28189 </para>
28190 <informaltable frame="all">
28191 <tgroup cols="4" colsep="0" rowsep="0">
28192 <colspec colwidth="8*" align="left"/>
28193 <colspec colwidth="6*" align="center"/>
28194 <colspec colwidth="6*" align="center"/>
28195 <colspec colwidth="6*" align="right"/>
28196 <tbody>
28197 <row>
28198 <entry><option>tls_privatekey</option></entry>
28199 <entry>Use: <emphasis>main</emphasis></entry>
28200 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
28201 <entry>Default: <emphasis>unset</emphasis></entry>
28202 </row>
28203 </tbody>
28204 </tgroup>
28205 </informaltable>
28206 <para>
28207 <indexterm role="concept">
28208 <primary>TLS</primary>
28209 <secondary>server private key; location of</secondary>
28210 </indexterm>
28211 The value of this option is expanded, and must then be the absolute path to a
28212 file which contains the server&#x2019;s private key. If this option is unset, or if
28213 the expansion is forced to fail, or the result is an empty string, the private
28214 key is assumed to be in the same file as the server&#x2019;s certificates. See chapter
28215 <xref linkend="CHAPTLS"/> for further details.
28216 </para>
28217 <para>
28218 <indexterm role="option">
28219 <primary><option>tls_remember_esmtp</option></primary>
28220 </indexterm>
28221 </para>
28222 <informaltable frame="all">
28223 <tgroup cols="4" colsep="0" rowsep="0">
28224 <colspec colwidth="8*" align="left"/>
28225 <colspec colwidth="6*" align="center"/>
28226 <colspec colwidth="6*" align="center"/>
28227 <colspec colwidth="6*" align="right"/>
28228 <tbody>
28229 <row>
28230 <entry><option>tls_remember_esmtp</option></entry>
28231 <entry>Use: <emphasis>main</emphasis></entry>
28232 <entry>Type: <emphasis>boolean</emphasis></entry>
28233 <entry>Default: <emphasis>false</emphasis></entry>
28234 </row>
28235 </tbody>
28236 </tgroup>
28237 </informaltable>
28238 <para>
28239 <indexterm role="concept">
28240 <primary>TLS</primary>
28241 <secondary>esmtp state; remembering</secondary>
28242 </indexterm>
28243 <indexterm role="concept">
28244 <primary>TLS</primary>
28245 <secondary>broken clients</secondary>
28246 </indexterm>
28247 If this option is set true, Exim violates the RFCs by remembering that it is in
28248 <quote>esmtp</quote> state after successfully negotiating a TLS session. This provides
28249 support for broken clients that fail to send a new EHLO after starting a
28250 TLS session.
28251 </para>
28252 <para>
28253 <indexterm role="option">
28254 <primary><option>tls_require_ciphers</option></primary>
28255 </indexterm>
28256 </para>
28257 <informaltable frame="all">
28258 <tgroup cols="4" colsep="0" rowsep="0">
28259 <colspec colwidth="8*" align="left"/>
28260 <colspec colwidth="6*" align="center"/>
28261 <colspec colwidth="6*" align="center"/>
28262 <colspec colwidth="6*" align="right"/>
28263 <tbody>
28264 <row>
28265 <entry><option>tls_require_ciphers</option></entry>
28266 <entry>Use: <emphasis>main</emphasis></entry>
28267 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
28268 <entry>Default: <emphasis>unset</emphasis></entry>
28269 </row>
28270 </tbody>
28271 </tgroup>
28272 </informaltable>
28273 <para>
28274 <indexterm role="concept">
28275 <primary>TLS</primary>
28276 <secondary>requiring specific ciphers</secondary>
28277 </indexterm>
28278 <indexterm role="concept">
28279 <primary>cipher</primary>
28280 <secondary>requiring specific</secondary>
28281 </indexterm>
28282 This option controls which ciphers can be used for incoming TLS connections.
28283 The <command>smtp</command> transport has an option of the same name for controlling outgoing
28284 connections. This option is expanded for each connection, so can be varied for
28285 different clients if required. The value of this option must be a list of
28286 permitted cipher suites. The OpenSSL and GnuTLS libraries handle cipher control
28287 in somewhat different ways. If GnuTLS is being used, the client controls the
28288 preference order of the available ciphers. Details are given in sections
28289 <xref linkend="SECTreqciphssl"/> and <xref linkend="SECTreqciphgnu"/>.
28290 </para>
28291 <para>
28292 <indexterm role="option">
28293 <primary><option>tls_try_verify_hosts</option></primary>
28294 </indexterm>
28295 </para>
28296 <informaltable frame="all">
28297 <tgroup cols="4" colsep="0" rowsep="0">
28298 <colspec colwidth="8*" align="left"/>
28299 <colspec colwidth="6*" align="center"/>
28300 <colspec colwidth="6*" align="center"/>
28301 <colspec colwidth="6*" align="right"/>
28302 <tbody>
28303 <row>
28304 <entry><option>tls_try_verify_hosts</option></entry>
28305 <entry>Use: <emphasis>main</emphasis></entry>
28306 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
28307 <entry>Default: <emphasis>unset</emphasis></entry>
28308 </row>
28309 </tbody>
28310 </tgroup>
28311 </informaltable>
28312 <para>
28313 <indexterm role="concept">
28314 <primary>TLS</primary>
28315 <secondary>client certificate verification</secondary>
28316 </indexterm>
28317 <indexterm role="concept">
28318 <primary>certificate</primary>
28319 <secondary>verification of client</secondary>
28320 </indexterm>
28321 See <option>tls_verify_hosts</option> below.
28322 </para>
28323 <para>
28324 <indexterm role="option">
28325 <primary><option>tls_verify_certificates</option></primary>
28326 </indexterm>
28327 </para>
28328 <informaltable frame="all">
28329 <tgroup cols="4" colsep="0" rowsep="0">
28330 <colspec colwidth="8*" align="left"/>
28331 <colspec colwidth="6*" align="center"/>
28332 <colspec colwidth="6*" align="center"/>
28333 <colspec colwidth="6*" align="right"/>
28334 <tbody>
28335 <row>
28336 <entry><option>tls_verify_certificates</option></entry>
28337 <entry>Use: <emphasis>main</emphasis></entry>
28338 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
28339 <entry>Default: <emphasis>unset</emphasis></entry>
28340 </row>
28341 </tbody>
28342 </tgroup>
28343 </informaltable>
28344 <para>
28345 <indexterm role="concept">
28346 <primary>TLS</primary>
28347 <secondary>client certificate verification</secondary>
28348 </indexterm>
28349 <indexterm role="concept">
28350 <primary>certificate</primary>
28351 <secondary>verification of client</secondary>
28352 </indexterm>
28353 The value of this option is expanded, and must then be the absolute path to
28354 a file containing permitted certificates for clients that
28355 match <option>tls_verify_hosts</option> or <option>tls_try_verify_hosts</option>. Alternatively, if you
28356 are using OpenSSL, you can set <option>tls_verify_certificates</option> to the name of a
28357 directory containing certificate files. This does not work with GnuTLS; the
28358 option must be set to the name of a single file if you are using GnuTLS.
28359 </para>
28360 <para revisionflag="changed">
28361 These certificates should be for the certificate authorities trusted, rather
28362 than the public cert of individual clients.  With both OpenSSL and GnuTLS, if
28363 the value is a file then the certificates are sent by Exim as a server to
28364 connecting clients, defining the list of accepted certificate authorities.
28365 Thus the values defined should be considered public data.  To avoid this,
28366 use OpenSSL with a directory.
28367 </para>
28368 <para>
28369 <indexterm role="option">
28370 <primary><option>tls_verify_hosts</option></primary>
28371 </indexterm>
28372 </para>
28373 <informaltable frame="all">
28374 <tgroup cols="4" colsep="0" rowsep="0">
28375 <colspec colwidth="8*" align="left"/>
28376 <colspec colwidth="6*" align="center"/>
28377 <colspec colwidth="6*" align="center"/>
28378 <colspec colwidth="6*" align="right"/>
28379 <tbody>
28380 <row>
28381 <entry><option>tls_verify_hosts</option></entry>
28382 <entry>Use: <emphasis>main</emphasis></entry>
28383 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
28384 <entry>Default: <emphasis>unset</emphasis></entry>
28385 </row>
28386 </tbody>
28387 </tgroup>
28388 </informaltable>
28389 <para>
28390 <indexterm role="concept">
28391 <primary>TLS</primary>
28392 <secondary>client certificate verification</secondary>
28393 </indexterm>
28394 <indexterm role="concept">
28395 <primary>certificate</primary>
28396 <secondary>verification of client</secondary>
28397 </indexterm>
28398 This option, along with <option>tls_try_verify_hosts</option>, controls the checking of
28399 certificates from clients. The expected certificates are defined by
28400 <option>tls_verify_certificates</option>, which must be set. A configuration error occurs if
28401 either <option>tls_verify_hosts</option> or <option>tls_try_verify_hosts</option> is set and
28402 <option>tls_verify_certificates</option> is not set.
28403 </para>
28404 <para>
28405 Any client that matches <option>tls_verify_hosts</option> is constrained by
28406 <option>tls_verify_certificates</option>. When the client initiates a TLS session, it must
28407 present one of the listed certificates. If it does not, the connection is
28408 aborted. <emphasis role="bold">Warning</emphasis>: Including a host in <option>tls_verify_hosts</option> does not require
28409 the host to use TLS. It can still send SMTP commands through unencrypted
28410 connections. Forcing a client to use TLS has to be done separately using an
28411 ACL to reject inappropriate commands when the connection is not encrypted.
28412 </para>
28413 <para>
28414 A weaker form of checking is provided by <option>tls_try_verify_hosts</option>. If a client
28415 matches this option (but not <option>tls_verify_hosts</option>), Exim requests a
28416 certificate and checks it against <option>tls_verify_certificates</option>, but does not
28417 abort the connection if there is no certificate or if it does not match. This
28418 state can be detected in an ACL, which makes it possible to implement policies
28419 such as <quote>accept for relay only if a verified certificate has been received,
28420 but accept for local delivery if encrypted, even without a verified
28421 certificate</quote>.
28422 </para>
28423 <para>
28424 Client hosts that match neither of these lists are not asked to present
28425 certificates.
28426 </para>
28427 <para>
28428 <indexterm role="option">
28429 <primary><option>trusted_groups</option></primary>
28430 </indexterm>
28431 </para>
28432 <informaltable frame="all">
28433 <tgroup cols="4" colsep="0" rowsep="0">
28434 <colspec colwidth="8*" align="left"/>
28435 <colspec colwidth="6*" align="center"/>
28436 <colspec colwidth="6*" align="center"/>
28437 <colspec colwidth="6*" align="right"/>
28438 <tbody>
28439 <row>
28440 <entry><option>trusted_groups</option></entry>
28441 <entry>Use: <emphasis>main</emphasis></entry>
28442 <entry>Type: <emphasis>string list</emphasis>&dagger;<emphasis></emphasis></entry>
28443 <entry>Default: <emphasis>unset</emphasis></entry>
28444 </row>
28445 </tbody>
28446 </tgroup>
28447 </informaltable>
28448 <para>
28449 <indexterm role="concept">
28450 <primary>trusted groups</primary>
28451 </indexterm>
28452 <indexterm role="concept">
28453 <primary>groups</primary>
28454 <secondary>trusted</secondary>
28455 </indexterm>
28456 This option is expanded just once, at the start of Exim&#x2019;s processing. If this
28457 option is set, any process that is running in one of the listed groups, or
28458 which has one of them as a supplementary group, is trusted. The groups can be
28459 specified numerically or by name. See section <xref linkend="SECTtrustedadmin"/> for
28460 details of what trusted callers are permitted to do. If neither
28461 <option>trusted_groups</option> nor <option>trusted_users</option> is set, only root and the Exim user
28462 are trusted.
28463 </para>
28464 <para>
28465 <indexterm role="option">
28466 <primary><option>trusted_users</option></primary>
28467 </indexterm>
28468 </para>
28469 <informaltable frame="all">
28470 <tgroup cols="4" colsep="0" rowsep="0">
28471 <colspec colwidth="8*" align="left"/>
28472 <colspec colwidth="6*" align="center"/>
28473 <colspec colwidth="6*" align="center"/>
28474 <colspec colwidth="6*" align="right"/>
28475 <tbody>
28476 <row>
28477 <entry><option>trusted_users</option></entry>
28478 <entry>Use: <emphasis>main</emphasis></entry>
28479 <entry>Type: <emphasis>string list</emphasis>&dagger;<emphasis></emphasis></entry>
28480 <entry>Default: <emphasis>unset</emphasis></entry>
28481 </row>
28482 </tbody>
28483 </tgroup>
28484 </informaltable>
28485 <para>
28486 <indexterm role="concept">
28487 <primary>trusted users</primary>
28488 </indexterm>
28489 <indexterm role="concept">
28490 <primary>user</primary>
28491 <secondary>trusted</secondary>
28492 </indexterm>
28493 This option is expanded just once, at the start of Exim&#x2019;s processing. If this
28494 option is set, any process that is running as one of the listed users is
28495 trusted. The users can be specified numerically or by name. See section
28496 <xref linkend="SECTtrustedadmin"/> for details of what trusted callers are permitted to do.
28497 If neither <option>trusted_groups</option> nor <option>trusted_users</option> is set, only root and the
28498 Exim user are trusted.
28499 </para>
28500 <para>
28501 <indexterm role="option">
28502 <primary><option>unknown_login</option></primary>
28503 </indexterm>
28504 </para>
28505 <informaltable frame="all">
28506 <tgroup cols="4" colsep="0" rowsep="0">
28507 <colspec colwidth="8*" align="left"/>
28508 <colspec colwidth="6*" align="center"/>
28509 <colspec colwidth="6*" align="center"/>
28510 <colspec colwidth="6*" align="right"/>
28511 <tbody>
28512 <row>
28513 <entry><option>unknown_login</option></entry>
28514 <entry>Use: <emphasis>main</emphasis></entry>
28515 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
28516 <entry>Default: <emphasis>unset</emphasis></entry>
28517 </row>
28518 </tbody>
28519 </tgroup>
28520 </informaltable>
28521 <para>
28522 <indexterm role="concept">
28523 <primary>uid (user id)</primary>
28524 <secondary>unknown caller</secondary>
28525 </indexterm>
28526 <indexterm role="variable">
28527 <primary><varname>$caller_uid</varname></primary>
28528 </indexterm>
28529 This is a specialized feature for use in unusual configurations. By default, if
28530 the uid of the caller of Exim cannot be looked up using <function>getpwuid()</function>, Exim
28531 gives up. The <option>unknown_login</option> option can be used to set a login name to be
28532 used in this circumstance. It is expanded, so values like <option>user$caller_uid</option>
28533 can be set. When <option>unknown_login</option> is used, the value of <option>unknown_username</option>
28534 is used for the user&#x2019;s real name (gecos field), unless this has been set by the
28535 <option>-F</option> option.
28536 </para>
28537 <para>
28538 <indexterm role="option">
28539 <primary><option>unknown_username</option></primary>
28540 </indexterm>
28541 </para>
28542 <informaltable frame="all">
28543 <tgroup cols="4" colsep="0" rowsep="0">
28544 <colspec colwidth="8*" align="left"/>
28545 <colspec colwidth="6*" align="center"/>
28546 <colspec colwidth="6*" align="center"/>
28547 <colspec colwidth="6*" align="right"/>
28548 <tbody>
28549 <row>
28550 <entry><option>unknown_username</option></entry>
28551 <entry>Use: <emphasis>main</emphasis></entry>
28552 <entry>Type: <emphasis>string</emphasis></entry>
28553 <entry>Default: <emphasis>unset</emphasis></entry>
28554 </row>
28555 </tbody>
28556 </tgroup>
28557 </informaltable>
28558 <para>
28559 See <option>unknown_login</option>.
28560 </para>
28561 <para>
28562 <indexterm role="option">
28563 <primary><option>untrusted_set_sender</option></primary>
28564 </indexterm>
28565 </para>
28566 <informaltable frame="all">
28567 <tgroup cols="4" colsep="0" rowsep="0">
28568 <colspec colwidth="8*" align="left"/>
28569 <colspec colwidth="6*" align="center"/>
28570 <colspec colwidth="6*" align="center"/>
28571 <colspec colwidth="6*" align="right"/>
28572 <tbody>
28573 <row>
28574 <entry><option>untrusted_set_sender</option></entry>
28575 <entry>Use: <emphasis>main</emphasis></entry>
28576 <entry>Type: <emphasis>address list</emphasis>&dagger;<emphasis></emphasis></entry>
28577 <entry>Default: <emphasis>unset</emphasis></entry>
28578 </row>
28579 </tbody>
28580 </tgroup>
28581 </informaltable>
28582 <para>
28583 <indexterm role="concept">
28584 <primary>trusted users</primary>
28585 </indexterm>
28586 <indexterm role="concept">
28587 <primary>sender</primary>
28588 <secondary>setting by untrusted user</secondary>
28589 </indexterm>
28590 <indexterm role="concept">
28591 <primary>untrusted user setting sender</primary>
28592 </indexterm>
28593 <indexterm role="concept">
28594 <primary>user</primary>
28595 <secondary>untrusted setting sender</secondary>
28596 </indexterm>
28597 <indexterm role="concept">
28598 <primary>envelope sender</primary>
28599 </indexterm>
28600 When an untrusted user submits a message to Exim using the standard input, Exim
28601 normally creates an envelope sender address from the user&#x2019;s login and the
28602 default qualification domain. Data from the <option>-f</option> option (for setting envelope
28603 senders on non-SMTP messages) or the SMTP MAIL command (if <option>-bs</option> or <option>-bS</option>
28604 is used) is ignored.
28605 </para>
28606 <para>
28607 However, untrusted users are permitted to set an empty envelope sender address,
28608 to declare that a message should never generate any bounces. For example:
28609 </para>
28610 <literallayout class="monospaced">
28611 exim -f '&lt;&gt;' user@domain.example
28612 </literallayout>
28613 <para>
28614 <indexterm role="variable">
28615 <primary><varname>$sender_ident</varname></primary>
28616 </indexterm>
28617 The <option>untrusted_set_sender</option> option allows you to permit untrusted users to set
28618 other envelope sender addresses in a controlled way. When it is set, untrusted
28619 users are allowed to set envelope sender addresses that match any of the
28620 patterns in the list. Like all address lists, the string is expanded. The
28621 identity of the user is in <varname>$sender_ident</varname>, so you can, for example, restrict
28622 users to setting senders that start with their login ids
28623 followed by a hyphen
28624 by a setting like this:
28625 </para>
28626 <literallayout class="monospaced">
28627 untrusted_set_sender = ^$sender_ident-
28628 </literallayout>
28629 <para>
28630 If you want to allow untrusted users to set envelope sender addresses without
28631 restriction, you can use
28632 </para>
28633 <literallayout class="monospaced">
28634 untrusted_set_sender = *
28635 </literallayout>
28636 <para>
28637 The <option>untrusted_set_sender</option> option applies to all forms of local input, but
28638 only to the setting of the envelope sender. It does not permit untrusted users
28639 to use the other options which trusted user can use to override message
28640 parameters. Furthermore, it does not stop Exim from removing an existing
28641 <emphasis>Sender:</emphasis> header in the message, or from adding a <emphasis>Sender:</emphasis> header if
28642 necessary. See <option>local_sender_retain</option> and <option>local_from_check</option> for ways of
28643 overriding these actions. The handling of the <emphasis>Sender:</emphasis> header is also
28644 described in section <xref linkend="SECTthesenhea"/>.
28645 </para>
28646 <para>
28647 The log line for a message&#x2019;s arrival shows the envelope sender following
28648 <quote>&lt;=</quote>. For local messages, the user&#x2019;s login always follows, after <quote>U=</quote>. In
28649 <option>-bp</option> displays, and in the Exim monitor, if an untrusted user sets an
28650 envelope sender address, the user&#x2019;s login is shown in parentheses after the
28651 sender address.
28652 </para>
28653 <para>
28654 <indexterm role="option">
28655 <primary><option>uucp_from_pattern</option></primary>
28656 </indexterm>
28657 </para>
28658 <informaltable frame="all">
28659 <tgroup cols="4" colsep="0" rowsep="0">
28660 <colspec colwidth="8*" align="left"/>
28661 <colspec colwidth="6*" align="center"/>
28662 <colspec colwidth="6*" align="center"/>
28663 <colspec colwidth="6*" align="right"/>
28664 <tbody>
28665 <row>
28666 <entry><option>uucp_from_pattern</option></entry>
28667 <entry>Use: <emphasis>main</emphasis></entry>
28668 <entry>Type: <emphasis>string</emphasis></entry>
28669 <entry>Default: <emphasis>see below</emphasis></entry>
28670 </row>
28671 </tbody>
28672 </tgroup>
28673 </informaltable>
28674 <para>
28675 <indexterm role="concept">
28676 <primary><quote>From</quote> line</primary>
28677 </indexterm>
28678 <indexterm role="concept">
28679 <primary>UUCP</primary>
28680 <secondary><quote>From</quote> line</secondary>
28681 </indexterm>
28682 Some applications that pass messages to an MTA via a command line interface use
28683 an initial line starting with <quote>From&nbsp;</quote> to pass the envelope sender. In
28684 particular, this is used by UUCP software. Exim recognizes such a line by means
28685 of a regular expression that is set in <option>uucp_from_pattern</option>. When the pattern
28686 matches, the sender address is constructed by expanding the contents of
28687 <option>uucp_from_sender</option>, provided that the caller of Exim is a trusted user. The
28688 default pattern recognizes lines in the following two forms:
28689 </para>
28690 <literallayout class="monospaced">
28691 From ph10 Fri Jan  5 12:35 GMT 1996
28692 From ph10 Fri, 7 Jan 97 14:00:00 GMT
28693 </literallayout>
28694 <para>
28695 The pattern can be seen by running
28696 </para>
28697 <literallayout class="monospaced">
28698 exim -bP uucp_from_pattern
28699 </literallayout>
28700 <para>
28701 It checks only up to the hours and minutes, and allows for a 2-digit or 4-digit
28702 year in the second case. The first word after <quote>From&nbsp;</quote> is matched in the
28703 regular expression by a parenthesized subpattern. The default value for
28704 <option>uucp_from_sender</option> is <quote>$1</quote>, which therefore just uses this first word
28705 (<quote>ph10</quote> in the example above) as the message&#x2019;s sender. See also
28706 <option>ignore_fromline_hosts</option>.
28707 </para>
28708 <para>
28709 <indexterm role="option">
28710 <primary><option>uucp_from_sender</option></primary>
28711 </indexterm>
28712 </para>
28713 <informaltable frame="all">
28714 <tgroup cols="4" colsep="0" rowsep="0">
28715 <colspec colwidth="8*" align="left"/>
28716 <colspec colwidth="6*" align="center"/>
28717 <colspec colwidth="6*" align="center"/>
28718 <colspec colwidth="6*" align="right"/>
28719 <tbody>
28720 <row>
28721 <entry><option>uucp_from_sender</option></entry>
28722 <entry>Use: <emphasis>main</emphasis></entry>
28723 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
28724 <entry>Default: <emphasis><literal>$1</literal></emphasis></entry>
28725 </row>
28726 </tbody>
28727 </tgroup>
28728 </informaltable>
28729 <para>
28730 See <option>uucp_from_pattern</option> above.
28731 </para>
28732 <para>
28733 <indexterm role="option">
28734 <primary><option>warn_message_file</option></primary>
28735 </indexterm>
28736 </para>
28737 <informaltable frame="all">
28738 <tgroup cols="4" colsep="0" rowsep="0">
28739 <colspec colwidth="8*" align="left"/>
28740 <colspec colwidth="6*" align="center"/>
28741 <colspec colwidth="6*" align="center"/>
28742 <colspec colwidth="6*" align="right"/>
28743 <tbody>
28744 <row>
28745 <entry><option>warn_message_file</option></entry>
28746 <entry>Use: <emphasis>main</emphasis></entry>
28747 <entry>Type: <emphasis>string</emphasis></entry>
28748 <entry>Default: <emphasis>unset</emphasis></entry>
28749 </row>
28750 </tbody>
28751 </tgroup>
28752 </informaltable>
28753 <para>
28754 <indexterm role="concept">
28755 <primary>warning of delay</primary>
28756 <secondary>customizing the message</secondary>
28757 </indexterm>
28758 <indexterm role="concept">
28759 <primary>customizing</primary>
28760 <secondary>warning message</secondary>
28761 </indexterm>
28762 This option defines a template file containing paragraphs of text to be used
28763 for constructing the warning message which is sent by Exim when a message has
28764 been on the queue for a specified amount of time, as specified by
28765 <option>delay_warning</option>. Details of the file&#x2019;s contents are given in chapter
28766 <xref linkend="CHAPemsgcust"/>. See also <option>bounce_message_file</option>.
28767 </para>
28768 <para>
28769 <indexterm role="option">
28770 <primary><option>write_rejectlog</option></primary>
28771 </indexterm>
28772 </para>
28773 <informaltable frame="all">
28774 <tgroup cols="4" colsep="0" rowsep="0">
28775 <colspec colwidth="8*" align="left"/>
28776 <colspec colwidth="6*" align="center"/>
28777 <colspec colwidth="6*" align="center"/>
28778 <colspec colwidth="6*" align="right"/>
28779 <tbody>
28780 <row>
28781 <entry><option>write_rejectlog</option></entry>
28782 <entry>Use: <emphasis>main</emphasis></entry>
28783 <entry>Type: <emphasis>boolean</emphasis></entry>
28784 <entry>Default: <emphasis>true</emphasis></entry>
28785 </row>
28786 </tbody>
28787 </tgroup>
28788 </informaltable>
28789 <para>
28790 <indexterm role="concept">
28791 <primary>reject log</primary>
28792 <secondary>disabling</secondary>
28793 </indexterm>
28794 If this option is set false, Exim no longer writes anything to the reject log.
28795 See chapter <xref linkend="CHAPlog"/> for details of what Exim writes to its logs.
28796 <indexterm role="concept" startref="IIDconfima" class="endofrange"/>
28797 <indexterm role="concept" startref="IIDmaiconf" class="endofrange"/>
28798 </para>
28799 </section>
28800 </chapter>
28801
28802 <chapter id="CHAProutergeneric">
28803 <title>Generic options for routers</title>
28804 <para>
28805 <indexterm role="concept" id="IIDgenoprou1" class="startofrange">
28806 <primary>options</primary>
28807 <secondary>generic; for routers</secondary>
28808 </indexterm>
28809 <indexterm role="concept" id="IIDgenoprou2" class="startofrange">
28810 <primary>generic options</primary>
28811 <secondary>router</secondary>
28812 </indexterm>
28813 This chapter describes the generic options that apply to all routers.
28814 Those that are preconditions are marked with &Dagger; in the <quote>use</quote> field.
28815 </para>
28816 <para>
28817 For a general description of how a router operates, see sections
28818 <xref linkend="SECTrunindrou"/> and <xref linkend="SECTrouprecon"/>. The latter specifies the order in
28819 which the preconditions are tested. The order of expansion of the options that
28820 provide data for a transport is: <option>errors_to</option>, <option>headers_add</option>,
28821 <option>headers_remove</option>, <option>transport</option>.
28822 </para>
28823 <para>
28824 <indexterm role="option">
28825 <primary><option>address_data</option></primary>
28826 </indexterm>
28827 </para>
28828 <informaltable frame="all">
28829 <tgroup cols="4" colsep="0" rowsep="0">
28830 <colspec colwidth="8*" align="left"/>
28831 <colspec colwidth="6*" align="center"/>
28832 <colspec colwidth="6*" align="center"/>
28833 <colspec colwidth="6*" align="right"/>
28834 <tbody>
28835 <row>
28836 <entry><option>address_data</option></entry>
28837 <entry>Use: <emphasis>routers</emphasis></entry>
28838 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
28839 <entry>Default: <emphasis>unset</emphasis></entry>
28840 </row>
28841 </tbody>
28842 </tgroup>
28843 </informaltable>
28844 <para>
28845 <indexterm role="concept">
28846 <primary>router</primary>
28847 <secondary>data attached to address</secondary>
28848 </indexterm>
28849 The string is expanded just before the router is run, that is, after all the
28850 precondition tests have succeeded. If the expansion is forced to fail, the
28851 router declines, the value of <option>address_data</option> remains unchanged, and the
28852 <option>more</option> option controls what happens next. Other expansion failures cause
28853 delivery of the address to be deferred.
28854 </para>
28855 <para>
28856 <indexterm role="variable">
28857 <primary><varname>$address_data</varname></primary>
28858 </indexterm>
28859 When the expansion succeeds, the value is retained with the address, and can be
28860 accessed using the variable <varname>$address_data</varname> in the current router, subsequent
28861 routers, and the eventual transport.
28862 </para>
28863 <para>
28864 <emphasis role="bold">Warning</emphasis>: If the current or any subsequent router is a <command>redirect</command> router
28865 that runs a user&#x2019;s filter file, the contents of <varname>$address_data</varname> are accessible
28866 in the filter. This is not normally a problem, because such data is usually
28867 either not confidential or it <quote>belongs</quote> to the current user, but if you do
28868 put confidential data into <varname>$address_data</varname> you need to remember this point.
28869 </para>
28870 <para>
28871 Even if the router declines or passes, the value of <varname>$address_data</varname> remains
28872 with the address, though it can be changed by another <option>address_data</option> setting
28873 on a subsequent router. If a router generates child addresses, the value of
28874 <varname>$address_data</varname> propagates to them. This also applies to the special kind of
28875 <quote>child</quote> that is generated by a router with the <option>unseen</option> option.
28876 </para>
28877 <para>
28878 The idea of <option>address_data</option> is that you can use it to look up a lot of data
28879 for the address once, and then pick out parts of the data later. For example,
28880 you could use a single LDAP lookup to return a string of the form
28881 </para>
28882 <literallayout class="monospaced">
28883 uid=1234 gid=5678 mailbox=/mail/xyz forward=/home/xyz/.forward
28884 </literallayout>
28885 <para>
28886 In the transport you could pick out the mailbox by a setting such as
28887 </para>
28888 <literallayout class="monospaced">
28889 file = ${extract{mailbox}{$address_data}}
28890 </literallayout>
28891 <para>
28892 This makes the configuration file less messy, and also reduces the number of
28893 lookups (though Exim does cache lookups).
28894 </para>
28895 <para>
28896 <indexterm role="variable">
28897 <primary><varname>$sender_address_data</varname></primary>
28898 </indexterm>
28899 <indexterm role="variable">
28900 <primary><varname>$address_data</varname></primary>
28901 </indexterm>
28902 The <option>address_data</option> facility is also useful as a means of passing information
28903 from one router to another, and from a router to a transport. In addition, if
28904 <varname>$address_data</varname> is set by a router when verifying a recipient address from an
28905 ACL, it remains available for use in the rest of the ACL statement. After
28906 verifying a sender, the value is transferred to <varname>$sender_address_data</varname>.
28907 </para>
28908 <para>
28909 <indexterm role="option">
28910 <primary><option>address_test</option></primary>
28911 </indexterm>
28912 </para>
28913 <informaltable frame="all">
28914 <tgroup cols="4" colsep="0" rowsep="0">
28915 <colspec colwidth="8*" align="left"/>
28916 <colspec colwidth="6*" align="center"/>
28917 <colspec colwidth="6*" align="center"/>
28918 <colspec colwidth="6*" align="right"/>
28919 <tbody>
28920 <row>
28921 <entry><option>address_test</option></entry>
28922 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
28923 <entry>Type: <emphasis>boolean</emphasis></entry>
28924 <entry>Default: <emphasis>true</emphasis></entry>
28925 </row>
28926 </tbody>
28927 </tgroup>
28928 </informaltable>
28929 <para>
28930 <indexterm role="option">
28931 <primary><option>-bt</option></primary>
28932 </indexterm>
28933 <indexterm role="concept">
28934 <primary>router</primary>
28935 <secondary>skipping when address testing</secondary>
28936 </indexterm>
28937 If this option is set false, the router is skipped when routing is being tested
28938 by means of the <option>-bt</option> command line option. This can be a convenience when
28939 your first router sends messages to an external scanner, because it saves you
28940 having to set the <quote>already scanned</quote> indicator when testing real address
28941 routing.
28942 </para>
28943 <para>
28944 <indexterm role="option">
28945 <primary><option>cannot_route_message</option></primary>
28946 </indexterm>
28947 </para>
28948 <informaltable frame="all">
28949 <tgroup cols="4" colsep="0" rowsep="0">
28950 <colspec colwidth="8*" align="left"/>
28951 <colspec colwidth="6*" align="center"/>
28952 <colspec colwidth="6*" align="center"/>
28953 <colspec colwidth="6*" align="right"/>
28954 <tbody>
28955 <row>
28956 <entry><option>cannot_route_message</option></entry>
28957 <entry>Use: <emphasis>routers</emphasis></entry>
28958 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
28959 <entry>Default: <emphasis>unset</emphasis></entry>
28960 </row>
28961 </tbody>
28962 </tgroup>
28963 </informaltable>
28964 <para>
28965 <indexterm role="concept">
28966 <primary>router</primary>
28967 <secondary>customizing <quote>cannot route</quote> message</secondary>
28968 </indexterm>
28969 <indexterm role="concept">
28970 <primary>customizing</primary>
28971 <secondary><quote>cannot route</quote> message</secondary>
28972 </indexterm>
28973 This option specifies a text message that is used when an address cannot be
28974 routed because Exim has run out of routers. The default message is
28975 <quote>Unrouteable address</quote>. This option is useful only on routers that have
28976 <option>more</option> set false, or on the very last router in a configuration, because the
28977 value that is used is taken from the last router that is considered. This
28978 includes a router that is skipped because its preconditions are not met, as
28979 well as a router that declines. For example, using the default configuration,
28980 you could put:
28981 </para>
28982 <literallayout class="monospaced">
28983 cannot_route_message = Remote domain not found in DNS
28984 </literallayout>
28985 <para>
28986 on the first router, which is a <command>dnslookup</command> router with <option>more</option> set false,
28987 and
28988 </para>
28989 <literallayout class="monospaced">
28990 cannot_route_message = Unknown local user
28991 </literallayout>
28992 <para>
28993 on the final router that checks for local users. If string expansion fails for
28994 this option, the default message is used. Unless the expansion failure was
28995 explicitly forced, a message about the failure is written to the main and panic
28996 logs, in addition to the normal message about the routing failure.
28997 </para>
28998 <para>
28999 <indexterm role="option">
29000 <primary><option>caseful_local_part</option></primary>
29001 </indexterm>
29002 </para>
29003 <informaltable frame="all">
29004 <tgroup cols="4" colsep="0" rowsep="0">
29005 <colspec colwidth="8*" align="left"/>
29006 <colspec colwidth="6*" align="center"/>
29007 <colspec colwidth="6*" align="center"/>
29008 <colspec colwidth="6*" align="right"/>
29009 <tbody>
29010 <row>
29011 <entry><option>caseful_local_part</option></entry>
29012 <entry>Use: <emphasis>routers</emphasis></entry>
29013 <entry>Type: <emphasis>boolean</emphasis></entry>
29014 <entry>Default: <emphasis>false</emphasis></entry>
29015 </row>
29016 </tbody>
29017 </tgroup>
29018 </informaltable>
29019 <para>
29020 <indexterm role="concept">
29021 <primary>case of local parts</primary>
29022 </indexterm>
29023 <indexterm role="concept">
29024 <primary>router</primary>
29025 <secondary>case of local parts</secondary>
29026 </indexterm>
29027 By default, routers handle the local parts of addresses in a case-insensitive
29028 manner, though the actual case is preserved for transmission with the message.
29029 If you want the case of letters to be significant in a router, you must set
29030 this option true. For individual router options that contain address or local
29031 part lists (for example, <option>local_parts</option>), case-sensitive matching can be
29032 turned on by <quote>+caseful</quote> as a list item. See section <xref linkend="SECTcasletadd"/> for
29033 more details.
29034 </para>
29035 <para>
29036 <indexterm role="variable">
29037 <primary><varname>$local_part</varname></primary>
29038 </indexterm>
29039 <indexterm role="variable">
29040 <primary><varname>$original_local_part</varname></primary>
29041 </indexterm>
29042 <indexterm role="variable">
29043 <primary><varname>$parent_local_part</varname></primary>
29044 </indexterm>
29045 The value of the <varname>$local_part</varname> variable is forced to lower case while a
29046 router is running unless <option>caseful_local_part</option> is set. When a router assigns
29047 an address to a transport, the value of <varname>$local_part</varname> when the transport runs
29048 is the same as it was in the router. Similarly, when a router generates child
29049 addresses by aliasing or forwarding, the values of <varname>$original_local_part</varname>
29050 and <varname>$parent_local_part</varname> are those that were used by the redirecting router.
29051 </para>
29052 <para>
29053 This option applies to the processing of an address by a router. When a
29054 recipient address is being processed in an ACL, there is a separate <option>control</option>
29055 modifier that can be used to specify case-sensitive processing within the ACL
29056 (see section <xref linkend="SECTcontrols"/>).
29057 </para>
29058 <para>
29059 <indexterm role="option">
29060 <primary><option>check_local_user</option></primary>
29061 </indexterm>
29062 </para>
29063 <informaltable frame="all">
29064 <tgroup cols="4" colsep="0" rowsep="0">
29065 <colspec colwidth="8*" align="left"/>
29066 <colspec colwidth="6*" align="center"/>
29067 <colspec colwidth="6*" align="center"/>
29068 <colspec colwidth="6*" align="right"/>
29069 <tbody>
29070 <row>
29071 <entry><option>check_local_user</option></entry>
29072 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
29073 <entry>Type: <emphasis>boolean</emphasis></entry>
29074 <entry>Default: <emphasis>false</emphasis></entry>
29075 </row>
29076 </tbody>
29077 </tgroup>
29078 </informaltable>
29079 <para>
29080 <indexterm role="concept">
29081 <primary>local user, checking in router</primary>
29082 </indexterm>
29083 <indexterm role="concept">
29084 <primary>router</primary>
29085 <secondary>checking for local user</secondary>
29086 </indexterm>
29087 <indexterm role="concept">
29088 <primary><filename>/etc/passwd</filename></primary>
29089 </indexterm>
29090 <indexterm role="variable">
29091 <primary><varname>$home</varname></primary>
29092 </indexterm>
29093 When this option is true, Exim checks that the local part of the recipient
29094 address (with affixes removed if relevant) is the name of an account on the
29095 local system. The check is done by calling the <function>getpwnam()</function> function rather
29096 than trying to read <filename>/etc/passwd</filename> directly. This means that other methods of
29097 holding password data (such as NIS) are supported. If the local part is a local
29098 user, <varname>$home</varname> is set from the password data, and can be tested in other
29099 preconditions that are evaluated after this one (the order of evaluation is
29100 given in section <xref linkend="SECTrouprecon"/>). However, the value of <varname>$home</varname> can be
29101 overridden by <option>router_home_directory</option>. If the local part is not a local user,
29102 the router is skipped.
29103 </para>
29104 <para>
29105 If you want to check that the local part is either the name of a local user
29106 or matches something else, you cannot combine <option>check_local_user</option> with a
29107 setting of <option>local_parts</option>, because that specifies the logical <emphasis>and</emphasis> of the
29108 two conditions. However, you can use a <command>passwd</command> lookup in a <option>local_parts</option>
29109 setting to achieve this. For example:
29110 </para>
29111 <literallayout class="monospaced">
29112 local_parts = passwd;$local_part : lsearch;/etc/other/users
29113 </literallayout>
29114 <para>
29115 Note, however, that the side effects of <option>check_local_user</option> (such as setting
29116 up a home directory) do not occur when a <command>passwd</command> lookup is used in a
29117 <option>local_parts</option> (or any other) precondition.
29118 </para>
29119 <para>
29120 <indexterm role="option">
29121 <primary><option>condition</option></primary>
29122 </indexterm>
29123 </para>
29124 <informaltable frame="all">
29125 <tgroup cols="4" colsep="0" rowsep="0">
29126 <colspec colwidth="8*" align="left"/>
29127 <colspec colwidth="6*" align="center"/>
29128 <colspec colwidth="6*" align="center"/>
29129 <colspec colwidth="6*" align="right"/>
29130 <tbody>
29131 <row>
29132 <entry><option>condition</option></entry>
29133 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
29134 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
29135 <entry>Default: <emphasis>unset</emphasis></entry>
29136 </row>
29137 </tbody>
29138 </tgroup>
29139 </informaltable>
29140 <para>
29141 <indexterm role="concept">
29142 <primary>router</primary>
29143 <secondary>customized precondition</secondary>
29144 </indexterm>
29145 This option specifies a general precondition test that has to succeed for the
29146 router to be called. The <option>condition</option> option is the last precondition to be
29147 evaluated (see section <xref linkend="SECTrouprecon"/>). The string is expanded, and if the
29148 result is a forced failure, or an empty string, or one of the strings <quote>0</quote> or
29149 <quote>no</quote> or <quote>false</quote> (checked without regard to the case of the letters), the
29150 router is skipped, and the address is offered to the next one.
29151 </para>
29152 <para>
29153 If the result is any other value, the router is run (as this is the last
29154 precondition to be evaluated, all the other preconditions must be true).
29155 </para>
29156 <para revisionflag="changed">
29157 This option is unique in that multiple <option>condition</option> options may be present.
29158 All <option>condition</option> options must succeed.
29159 </para>
29160 <para revisionflag="changed">
29161 The <option>condition</option> option provides a means of applying custom conditions to the
29162 running of routers. Note that in the case of a simple conditional expansion,
29163 the default expansion values are exactly what is wanted. For example:
29164 </para>
29165 <literallayout class="monospaced" revisionflag="changed">
29166 condition = ${if &gt;{$message_age}{600}}
29167 </literallayout>
29168 <para revisionflag="changed">
29169 Because of the default behaviour of the string expansion, this is equivalent to
29170 </para>
29171 <literallayout class="monospaced" revisionflag="changed">
29172 condition = ${if &gt;{$message_age}{600}{true}{}}
29173 </literallayout>
29174 <para revisionflag="changed">
29175 A multiple condition example, which succeeds:
29176 </para>
29177 <literallayout class="monospaced" revisionflag="changed">
29178 condition = ${if &gt;{$message_age}{600}}
29179 condition = ${if !eq{${lc:$local_part}}{postmaster}}
29180 condition = foobar
29181 </literallayout>
29182 <para revisionflag="changed">
29183 If the expansion fails (other than forced failure) delivery is deferred. Some
29184 of the other precondition options are common special cases that could in fact
29185 be specified using <option>condition</option>.
29186 </para>
29187 <para>
29188 <indexterm role="option">
29189 <primary><option>debug_print</option></primary>
29190 </indexterm>
29191 </para>
29192 <informaltable frame="all">
29193 <tgroup cols="4" colsep="0" rowsep="0">
29194 <colspec colwidth="8*" align="left"/>
29195 <colspec colwidth="6*" align="center"/>
29196 <colspec colwidth="6*" align="center"/>
29197 <colspec colwidth="6*" align="right"/>
29198 <tbody>
29199 <row>
29200 <entry><option>debug_print</option></entry>
29201 <entry>Use: <emphasis>routers</emphasis></entry>
29202 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
29203 <entry>Default: <emphasis>unset</emphasis></entry>
29204 </row>
29205 </tbody>
29206 </tgroup>
29207 </informaltable>
29208 <para>
29209 <indexterm role="concept">
29210 <primary>testing</primary>
29211 <secondary>variables in drivers</secondary>
29212 </indexterm>
29213 If this option is set and debugging is enabled (see the <option>-d</option> command line
29214 option), the string is expanded and included in the debugging output.
29215 If expansion of the string fails, the error message is written to the debugging
29216 output, and Exim carries on processing.
29217 This option is provided to help with checking out the values of variables and
29218 so on when debugging router configurations. For example, if a <option>condition</option>
29219 option appears not to be working, <option>debug_print</option> can be used to output the
29220 variables it references. The output happens after checks for <option>domains</option>,
29221 <option>local_parts</option>, and <option>check_local_user</option> but before any other preconditions
29222 are tested. A newline is added to the text if it does not end with one.
29223 </para>
29224 <para>
29225 <indexterm role="option">
29226 <primary><option>disable_logging</option></primary>
29227 </indexterm>
29228 </para>
29229 <informaltable frame="all">
29230 <tgroup cols="4" colsep="0" rowsep="0">
29231 <colspec colwidth="8*" align="left"/>
29232 <colspec colwidth="6*" align="center"/>
29233 <colspec colwidth="6*" align="center"/>
29234 <colspec colwidth="6*" align="right"/>
29235 <tbody>
29236 <row>
29237 <entry><option>disable_logging</option></entry>
29238 <entry>Use: <emphasis>routers</emphasis></entry>
29239 <entry>Type: <emphasis>boolean</emphasis></entry>
29240 <entry>Default: <emphasis>false</emphasis></entry>
29241 </row>
29242 </tbody>
29243 </tgroup>
29244 </informaltable>
29245 <para>
29246 If this option is set true, nothing is logged for any routing errors
29247 or for any deliveries caused by this router. You should not set this option
29248 unless you really, really know what you are doing. See also the generic
29249 transport option of the same name.
29250 </para>
29251 <para>
29252 <indexterm role="option">
29253 <primary><option>domains</option></primary>
29254 </indexterm>
29255 </para>
29256 <informaltable frame="all">
29257 <tgroup cols="4" colsep="0" rowsep="0">
29258 <colspec colwidth="8*" align="left"/>
29259 <colspec colwidth="6*" align="center"/>
29260 <colspec colwidth="6*" align="center"/>
29261 <colspec colwidth="6*" align="right"/>
29262 <tbody>
29263 <row>
29264 <entry><option>domains</option></entry>
29265 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
29266 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
29267 <entry>Default: <emphasis>unset</emphasis></entry>
29268 </row>
29269 </tbody>
29270 </tgroup>
29271 </informaltable>
29272 <para>
29273 <indexterm role="concept">
29274 <primary>router</primary>
29275 <secondary>restricting to specific domains</secondary>
29276 </indexterm>
29277 <indexterm role="variable">
29278 <primary><varname>$domain_data</varname></primary>
29279 </indexterm>
29280 If this option is set, the router is skipped unless the current domain matches
29281 the list. If the match is achieved by means of a file lookup, the data that the
29282 lookup returned for the domain is placed in <varname>$domain_data</varname> for use in string
29283 expansions of the driver&#x2019;s private options. See section <xref linkend="SECTrouprecon"/> for
29284 a list of the order in which preconditions are evaluated.
29285 </para>
29286 <para>
29287 <indexterm role="option">
29288 <primary><option>driver</option></primary>
29289 </indexterm>
29290 </para>
29291 <informaltable frame="all">
29292 <tgroup cols="4" colsep="0" rowsep="0">
29293 <colspec colwidth="8*" align="left"/>
29294 <colspec colwidth="6*" align="center"/>
29295 <colspec colwidth="6*" align="center"/>
29296 <colspec colwidth="6*" align="right"/>
29297 <tbody>
29298 <row>
29299 <entry><option>driver</option></entry>
29300 <entry>Use: <emphasis>routers</emphasis></entry>
29301 <entry>Type: <emphasis>string</emphasis></entry>
29302 <entry>Default: <emphasis>unset</emphasis></entry>
29303 </row>
29304 </tbody>
29305 </tgroup>
29306 </informaltable>
29307 <para>
29308 This option must always be set. It specifies which of the available routers is
29309 to be used.
29310 </para>
29311 <para>
29312 <indexterm role="option">
29313 <primary><option>errors_to</option></primary>
29314 </indexterm>
29315 </para>
29316 <informaltable frame="all">
29317 <tgroup cols="4" colsep="0" rowsep="0">
29318 <colspec colwidth="8*" align="left"/>
29319 <colspec colwidth="6*" align="center"/>
29320 <colspec colwidth="6*" align="center"/>
29321 <colspec colwidth="6*" align="right"/>
29322 <tbody>
29323 <row>
29324 <entry><option>errors_to</option></entry>
29325 <entry>Use: <emphasis>routers</emphasis></entry>
29326 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
29327 <entry>Default: <emphasis>unset</emphasis></entry>
29328 </row>
29329 </tbody>
29330 </tgroup>
29331 </informaltable>
29332 <para>
29333 <indexterm role="concept">
29334 <primary>envelope sender</primary>
29335 </indexterm>
29336 <indexterm role="concept">
29337 <primary>router</primary>
29338 <secondary>changing address for errors</secondary>
29339 </indexterm>
29340 If a router successfully handles an address, it may assign the address to a
29341 transport for delivery or it may generate child addresses. In both cases, if
29342 there is a delivery problem during later processing, the resulting bounce
29343 message is sent to the address that results from expanding this string,
29344 provided that the address verifies successfully. The <option>errors_to</option> option is
29345 expanded before <option>headers_add</option>, <option>headers_remove</option>, and <option>transport</option>.
29346 </para>
29347 <para>
29348 The <option>errors_to</option> setting associated with an address can be overridden if it
29349 subsequently passes through other routers that have their own <option>errors_to</option>
29350 settings, or if the message is delivered by a transport with a <option>return_path</option>
29351 setting.
29352 </para>
29353 <para>
29354 If <option>errors_to</option> is unset, or the expansion is forced to fail, or the result of
29355 the expansion fails to verify, the errors address associated with the incoming
29356 address is used. At top level, this is the envelope sender. A non-forced
29357 expansion failure causes delivery to be deferred.
29358 </para>
29359 <para>
29360 If an address for which <option>errors_to</option> has been set ends up being delivered over
29361 SMTP, the envelope sender for that delivery is the <option>errors_to</option> value, so that
29362 any bounces that are generated by other MTAs on the delivery route are also
29363 sent there. You can set <option>errors_to</option> to the empty string by either of these
29364 settings:
29365 </para>
29366 <literallayout class="monospaced">
29367 errors_to =
29368 errors_to = ""
29369 </literallayout>
29370 <para>
29371 An expansion item that yields an empty string has the same effect. If you do
29372 this, a locally detected delivery error for addresses processed by this router
29373 no longer gives rise to a bounce message; the error is discarded. If the
29374 address is delivered to a remote host, the return path is set to <literal>&lt;&gt;</literal>, unless
29375 overridden by the <option>return_path</option> option on the transport.
29376 </para>
29377 <para>
29378 <indexterm role="variable">
29379 <primary><varname>$address_data</varname></primary>
29380 </indexterm>
29381 If for some reason you want to discard local errors, but use a non-empty
29382 MAIL command for remote delivery, you can preserve the original return
29383 path in <varname>$address_data</varname> in the router, and reinstate it in the transport by
29384 setting <option>return_path</option>.
29385 </para>
29386 <para>
29387 The most common use of <option>errors_to</option> is to direct mailing list bounces to the
29388 manager of the list, as described in section <xref linkend="SECTmailinglists"/>, or to
29389 implement VERP (Variable Envelope Return Paths) (see section <xref linkend="SECTverp"/>).
29390 </para>
29391 <para>
29392 <indexterm role="option">
29393 <primary><option>expn</option></primary>
29394 </indexterm>
29395 </para>
29396 <informaltable frame="all">
29397 <tgroup cols="4" colsep="0" rowsep="0">
29398 <colspec colwidth="8*" align="left"/>
29399 <colspec colwidth="6*" align="center"/>
29400 <colspec colwidth="6*" align="center"/>
29401 <colspec colwidth="6*" align="right"/>
29402 <tbody>
29403 <row>
29404 <entry><option>expn</option></entry>
29405 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
29406 <entry>Type: <emphasis>boolean</emphasis></entry>
29407 <entry>Default: <emphasis>true</emphasis></entry>
29408 </row>
29409 </tbody>
29410 </tgroup>
29411 </informaltable>
29412 <para>
29413 <indexterm role="concept">
29414 <primary>address</primary>
29415 <secondary>testing</secondary>
29416 </indexterm>
29417 <indexterm role="concept">
29418 <primary>testing</primary>
29419 <secondary>addresses</secondary>
29420 </indexterm>
29421 <indexterm role="concept">
29422 <primary>EXPN</primary>
29423 <secondary>router skipping</secondary>
29424 </indexterm>
29425 <indexterm role="concept">
29426 <primary>router</primary>
29427 <secondary>skipping for EXPN</secondary>
29428 </indexterm>
29429 If this option is turned off, the router is skipped when testing an address
29430 as a result of processing an SMTP EXPN command. You might, for example,
29431 want to turn it off on a router for users&#x2019; <filename>.forward</filename> files, while leaving it
29432 on for the system alias file.
29433 See section <xref linkend="SECTrouprecon"/> for a list of the order in which preconditions
29434 are evaluated.
29435 </para>
29436 <para>
29437 The use of the SMTP EXPN command is controlled by an ACL (see chapter
29438 <xref linkend="CHAPACL"/>). When Exim is running an EXPN command, it is similar to testing
29439 an address with <option>-bt</option>. Compare VRFY, whose counterpart is <option>-bv</option>.
29440 </para>
29441 <para>
29442 <indexterm role="option">
29443 <primary><option>fail_verify</option></primary>
29444 </indexterm>
29445 </para>
29446 <informaltable frame="all">
29447 <tgroup cols="4" colsep="0" rowsep="0">
29448 <colspec colwidth="8*" align="left"/>
29449 <colspec colwidth="6*" align="center"/>
29450 <colspec colwidth="6*" align="center"/>
29451 <colspec colwidth="6*" align="right"/>
29452 <tbody>
29453 <row>
29454 <entry><option>fail_verify</option></entry>
29455 <entry>Use: <emphasis>routers</emphasis></entry>
29456 <entry>Type: <emphasis>boolean</emphasis></entry>
29457 <entry>Default: <emphasis>false</emphasis></entry>
29458 </row>
29459 </tbody>
29460 </tgroup>
29461 </informaltable>
29462 <para>
29463 <indexterm role="concept">
29464 <primary>router</primary>
29465 <secondary>forcing verification failure</secondary>
29466 </indexterm>
29467 Setting this option has the effect of setting both <option>fail_verify_sender</option> and
29468 <option>fail_verify_recipient</option> to the same value.
29469 </para>
29470 <para>
29471 <indexterm role="option">
29472 <primary><option>fail_verify_recipient</option></primary>
29473 </indexterm>
29474 </para>
29475 <informaltable frame="all">
29476 <tgroup cols="4" colsep="0" rowsep="0">
29477 <colspec colwidth="8*" align="left"/>
29478 <colspec colwidth="6*" align="center"/>
29479 <colspec colwidth="6*" align="center"/>
29480 <colspec colwidth="6*" align="right"/>
29481 <tbody>
29482 <row>
29483 <entry><option>fail_verify_recipient</option></entry>
29484 <entry>Use: <emphasis>routers</emphasis></entry>
29485 <entry>Type: <emphasis>boolean</emphasis></entry>
29486 <entry>Default: <emphasis>false</emphasis></entry>
29487 </row>
29488 </tbody>
29489 </tgroup>
29490 </informaltable>
29491 <para>
29492 If this option is true and an address is accepted by this router when
29493 verifying a recipient, verification fails.
29494 </para>
29495 <para>
29496 <indexterm role="option">
29497 <primary><option>fail_verify_sender</option></primary>
29498 </indexterm>
29499 </para>
29500 <informaltable frame="all">
29501 <tgroup cols="4" colsep="0" rowsep="0">
29502 <colspec colwidth="8*" align="left"/>
29503 <colspec colwidth="6*" align="center"/>
29504 <colspec colwidth="6*" align="center"/>
29505 <colspec colwidth="6*" align="right"/>
29506 <tbody>
29507 <row>
29508 <entry><option>fail_verify_sender</option></entry>
29509 <entry>Use: <emphasis>routers</emphasis></entry>
29510 <entry>Type: <emphasis>boolean</emphasis></entry>
29511 <entry>Default: <emphasis>false</emphasis></entry>
29512 </row>
29513 </tbody>
29514 </tgroup>
29515 </informaltable>
29516 <para>
29517 If this option is true and an address is accepted by this router when
29518 verifying a sender, verification fails.
29519 </para>
29520 <para>
29521 <indexterm role="option">
29522 <primary><option>fallback_hosts</option></primary>
29523 </indexterm>
29524 </para>
29525 <informaltable frame="all">
29526 <tgroup cols="4" colsep="0" rowsep="0">
29527 <colspec colwidth="8*" align="left"/>
29528 <colspec colwidth="6*" align="center"/>
29529 <colspec colwidth="6*" align="center"/>
29530 <colspec colwidth="6*" align="right"/>
29531 <tbody>
29532 <row>
29533 <entry><option>fallback_hosts</option></entry>
29534 <entry>Use: <emphasis>routers</emphasis></entry>
29535 <entry>Type: <emphasis>string list</emphasis></entry>
29536 <entry>Default: <emphasis>unset</emphasis></entry>
29537 </row>
29538 </tbody>
29539 </tgroup>
29540 </informaltable>
29541 <para>
29542 <indexterm role="concept">
29543 <primary>router</primary>
29544 <secondary>fallback hosts</secondary>
29545 </indexterm>
29546 <indexterm role="concept">
29547 <primary>fallback</primary>
29548 <secondary>hosts specified on router</secondary>
29549 </indexterm>
29550 String expansion is not applied to this option. The argument must be a
29551 colon-separated list of host names or IP addresses. The list separator can be
29552 changed (see section <xref linkend="SECTlistconstruct"/>), and a port can be specified with
29553 each name or address. In fact, the format of each item is exactly the same as
29554 defined for the list of hosts in a <command>manualroute</command> router (see section
29555 <xref linkend="SECTformatonehostitem"/>).
29556 </para>
29557 <para>
29558 If a router queues an address for a remote transport, this host list is
29559 associated with the address, and used instead of the transport&#x2019;s fallback host
29560 list. If <option>hosts_randomize</option> is set on the transport, the order of the list is
29561 randomized for each use. See the <option>fallback_hosts</option> option of the <command>smtp</command>
29562 transport for further details.
29563 </para>
29564 <para>
29565 <indexterm role="option">
29566 <primary><option>group</option></primary>
29567 </indexterm>
29568 </para>
29569 <informaltable frame="all">
29570 <tgroup cols="4" colsep="0" rowsep="0">
29571 <colspec colwidth="8*" align="left"/>
29572 <colspec colwidth="6*" align="center"/>
29573 <colspec colwidth="6*" align="center"/>
29574 <colspec colwidth="6*" align="right"/>
29575 <tbody>
29576 <row>
29577 <entry><option>group</option></entry>
29578 <entry>Use: <emphasis>routers</emphasis></entry>
29579 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
29580 <entry>Default: <emphasis>see below</emphasis></entry>
29581 </row>
29582 </tbody>
29583 </tgroup>
29584 </informaltable>
29585 <para>
29586 <indexterm role="concept">
29587 <primary>gid (group id)</primary>
29588 <secondary>local delivery</secondary>
29589 </indexterm>
29590 <indexterm role="concept">
29591 <primary>local transports</primary>
29592 <secondary>uid and gid</secondary>
29593 </indexterm>
29594 <indexterm role="concept">
29595 <primary>transport</primary>
29596 <secondary>local</secondary>
29597 </indexterm>
29598 <indexterm role="concept">
29599 <primary>router</primary>
29600 <secondary>setting group</secondary>
29601 </indexterm>
29602 When a router queues an address for a transport, and the transport does not
29603 specify a group, the group given here is used when running the delivery
29604 process.
29605 The group may be specified numerically or by name. If expansion fails, the
29606 error is logged and delivery is deferred.
29607 The default is unset, unless <option>check_local_user</option> is set, when the default
29608 is taken from the password information. See also <option>initgroups</option> and <option>user</option>
29609 and the discussion in chapter <xref linkend="CHAPenvironment"/>.
29610 </para>
29611 <para>
29612 <indexterm role="option">
29613 <primary><option>headers_add</option></primary>
29614 </indexterm>
29615 </para>
29616 <informaltable frame="all">
29617 <tgroup cols="4" colsep="0" rowsep="0">
29618 <colspec colwidth="8*" align="left"/>
29619 <colspec colwidth="6*" align="center"/>
29620 <colspec colwidth="6*" align="center"/>
29621 <colspec colwidth="6*" align="right"/>
29622 <tbody>
29623 <row>
29624 <entry><option>headers_add</option></entry>
29625 <entry>Use: <emphasis>routers</emphasis></entry>
29626 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
29627 <entry>Default: <emphasis>unset</emphasis></entry>
29628 </row>
29629 </tbody>
29630 </tgroup>
29631 </informaltable>
29632 <para>
29633 <indexterm role="concept">
29634 <primary>header lines</primary>
29635 <secondary>adding</secondary>
29636 </indexterm>
29637 <indexterm role="concept">
29638 <primary>router</primary>
29639 <secondary>adding header lines</secondary>
29640 </indexterm>
29641 This option specifies a string of text that is expanded at routing time, and
29642 associated with any addresses that are accepted by the router. However, this
29643 option has no effect when an address is just being verified. The way in which
29644 the text is used to add header lines at transport time is described in section
29645 <xref linkend="SECTheadersaddrem"/>. New header lines are not actually added until the
29646 message is in the process of being transported. This means that references to
29647 header lines in string expansions in the transport&#x2019;s configuration do not
29648 <quote>see</quote> the added header lines.
29649 </para>
29650 <para>
29651 The <option>headers_add</option> option is expanded after <option>errors_to</option>, but before
29652 <option>headers_remove</option> and <option>transport</option>. If the expanded string is empty, or if
29653 the expansion is forced to fail, the option has no effect. Other expansion
29654 failures are treated as configuration errors.
29655 </para>
29656 <para>
29657 <emphasis role="bold">Warning 1</emphasis>: The <option>headers_add</option> option cannot be used for a <command>redirect</command>
29658 router that has the <option>one_time</option> option set.
29659 </para>
29660 <para>
29661 <indexterm role="concept">
29662 <primary>duplicate addresses</primary>
29663 </indexterm>
29664 <indexterm role="option">
29665 <primary><option>unseen</option></primary>
29666 </indexterm>
29667 <emphasis role="bold">Warning 2</emphasis>: If the <option>unseen</option> option is set on the router, all header
29668 additions are deleted when the address is passed on to subsequent routers.
29669 For a <option>redirect</option> router, if a generated address is the same as the incoming
29670 address, this can lead to duplicate addresses with different header
29671 modifications. Exim does not do duplicate deliveries (except, in certain
29672 circumstances, to pipes -- see section <xref linkend="SECTdupaddr"/>), but it is undefined
29673 which of the duplicates is discarded, so this ambiguous situation should be
29674 avoided. The <option>repeat_use</option> option of the <option>redirect</option> router may be of help.
29675 </para>
29676 <para>
29677 <indexterm role="option">
29678 <primary><option>headers_remove</option></primary>
29679 </indexterm>
29680 </para>
29681 <informaltable frame="all">
29682 <tgroup cols="4" colsep="0" rowsep="0">
29683 <colspec colwidth="8*" align="left"/>
29684 <colspec colwidth="6*" align="center"/>
29685 <colspec colwidth="6*" align="center"/>
29686 <colspec colwidth="6*" align="right"/>
29687 <tbody>
29688 <row>
29689 <entry><option>headers_remove</option></entry>
29690 <entry>Use: <emphasis>routers</emphasis></entry>
29691 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
29692 <entry>Default: <emphasis>unset</emphasis></entry>
29693 </row>
29694 </tbody>
29695 </tgroup>
29696 </informaltable>
29697 <para>
29698 <indexterm role="concept">
29699 <primary>header lines</primary>
29700 <secondary>removing</secondary>
29701 </indexterm>
29702 <indexterm role="concept">
29703 <primary>router</primary>
29704 <secondary>removing header lines</secondary>
29705 </indexterm>
29706 This option specifies a string of text that is expanded at routing time, and
29707 associated with any addresses that are accepted by the router. However, this
29708 option has no effect when an address is just being verified. The way in which
29709 the text is used to remove header lines at transport time is described in
29710 section <xref linkend="SECTheadersaddrem"/>. Header lines are not actually removed until
29711 the message is in the process of being transported. This means that references
29712 to header lines in string expansions in the transport&#x2019;s configuration still
29713 <quote>see</quote> the original header lines.
29714 </para>
29715 <para>
29716 The <option>headers_remove</option> option is expanded after <option>errors_to</option> and
29717 <option>headers_add</option>, but before <option>transport</option>. If the expansion is forced to fail,
29718 the option has no effect. Other expansion failures are treated as configuration
29719 errors.
29720 </para>
29721 <para>
29722 <emphasis role="bold">Warning 1</emphasis>: The <option>headers_remove</option> option cannot be used for a <command>redirect</command>
29723 router that has the <option>one_time</option> option set.
29724 </para>
29725 <para>
29726 <emphasis role="bold">Warning 2</emphasis>: If the <option>unseen</option> option is set on the router, all header
29727 removal requests are deleted when the address is passed on to subsequent
29728 routers, and this can lead to problems with duplicates -- see the similar
29729 warning for <option>headers_add</option> above.
29730 </para>
29731 <para>
29732 <indexterm role="option">
29733 <primary><option>ignore_target_hosts</option></primary>
29734 </indexterm>
29735 </para>
29736 <informaltable frame="all">
29737 <tgroup cols="4" colsep="0" rowsep="0">
29738 <colspec colwidth="8*" align="left"/>
29739 <colspec colwidth="6*" align="center"/>
29740 <colspec colwidth="6*" align="center"/>
29741 <colspec colwidth="6*" align="right"/>
29742 <tbody>
29743 <row>
29744 <entry><option>ignore_target_hosts</option></entry>
29745 <entry>Use: <emphasis>routers</emphasis></entry>
29746 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
29747 <entry>Default: <emphasis>unset</emphasis></entry>
29748 </row>
29749 </tbody>
29750 </tgroup>
29751 </informaltable>
29752 <para>
29753 <indexterm role="concept">
29754 <primary>IP address</primary>
29755 <secondary>discarding</secondary>
29756 </indexterm>
29757 <indexterm role="concept">
29758 <primary>router</primary>
29759 <secondary>discarding IP addresses</secondary>
29760 </indexterm>
29761 Although this option is a host list, it should normally contain IP address
29762 entries rather than names. If any host that is looked up by the router has an
29763 IP address that matches an item in this list, Exim behaves as if that IP
29764 address did not exist. This option allows you to cope with rogue DNS entries
29765 like
29766 </para>
29767 <literallayout class="monospaced">
29768 remote.domain.example.  A  127.0.0.1
29769 </literallayout>
29770 <para>
29771 by setting
29772 </para>
29773 <literallayout class="monospaced">
29774 ignore_target_hosts = 127.0.0.1
29775 </literallayout>
29776 <para>
29777 on the relevant router. If all the hosts found by a <command>dnslookup</command> router are
29778 discarded in this way, the router declines. In a conventional configuration, an
29779 attempt to mail to such a domain would normally provoke the <quote>unrouteable
29780 domain</quote> error, and an attempt to verify an address in the domain would fail.
29781 Similarly, if <option>ignore_target_hosts</option> is set on an <command>ipliteral</command> router, the
29782 router declines if presented with one of the listed addresses.
29783 </para>
29784 <para>
29785 You can use this option to disable the use of IPv4 or IPv6 for mail delivery by
29786 means of the first or the second of the following settings, respectively:
29787 </para>
29788 <literallayout class="monospaced">
29789 ignore_target_hosts = 0.0.0.0/0
29790 ignore_target_hosts = &lt;; 0::0/0
29791 </literallayout>
29792 <para>
29793 The pattern in the first line matches all IPv4 addresses, whereas the pattern
29794 in the second line matches all IPv6 addresses.
29795 </para>
29796 <para>
29797 This option may also be useful for ignoring link-local and site-local IPv6
29798 addresses. Because, like all host lists, the value of <option>ignore_target_hosts</option>
29799 is expanded before use as a list, it is possible to make it dependent on the
29800 domain that is being routed.
29801 </para>
29802 <para>
29803 <indexterm role="variable">
29804 <primary><varname>$host_address</varname></primary>
29805 </indexterm>
29806 During its expansion, <varname>$host_address</varname> is set to the IP address that is being
29807 checked.
29808 </para>
29809 <para>
29810 <indexterm role="option">
29811 <primary><option>initgroups</option></primary>
29812 </indexterm>
29813 </para>
29814 <informaltable frame="all">
29815 <tgroup cols="4" colsep="0" rowsep="0">
29816 <colspec colwidth="8*" align="left"/>
29817 <colspec colwidth="6*" align="center"/>
29818 <colspec colwidth="6*" align="center"/>
29819 <colspec colwidth="6*" align="right"/>
29820 <tbody>
29821 <row>
29822 <entry><option>initgroups</option></entry>
29823 <entry>Use: <emphasis>routers</emphasis></entry>
29824 <entry>Type: <emphasis>boolean</emphasis></entry>
29825 <entry>Default: <emphasis>false</emphasis></entry>
29826 </row>
29827 </tbody>
29828 </tgroup>
29829 </informaltable>
29830 <para>
29831 <indexterm role="concept">
29832 <primary>additional groups</primary>
29833 </indexterm>
29834 <indexterm role="concept">
29835 <primary>groups</primary>
29836 <secondary>additional</secondary>
29837 </indexterm>
29838 <indexterm role="concept">
29839 <primary>local transports</primary>
29840 <secondary>uid and gid</secondary>
29841 </indexterm>
29842 <indexterm role="concept">
29843 <primary>transport</primary>
29844 <secondary>local</secondary>
29845 </indexterm>
29846 If the router queues an address for a transport, and this option is true, and
29847 the uid supplied by the router is not overridden by the transport, the
29848 <function>initgroups()</function> function is called when running the transport to ensure that
29849 any additional groups associated with the uid are set up. See also <option>group</option>
29850 and <option>user</option> and the discussion in chapter <xref linkend="CHAPenvironment"/>.
29851 </para>
29852 <para>
29853 <indexterm role="option">
29854 <primary><option>local_part_prefix</option></primary>
29855 </indexterm>
29856 </para>
29857 <informaltable frame="all">
29858 <tgroup cols="4" colsep="0" rowsep="0">
29859 <colspec colwidth="8*" align="left"/>
29860 <colspec colwidth="6*" align="center"/>
29861 <colspec colwidth="6*" align="center"/>
29862 <colspec colwidth="6*" align="right"/>
29863 <tbody>
29864 <row>
29865 <entry><option>local_part_prefix</option></entry>
29866 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
29867 <entry>Type: <emphasis>string list</emphasis></entry>
29868 <entry>Default: <emphasis>unset</emphasis></entry>
29869 </row>
29870 </tbody>
29871 </tgroup>
29872 </informaltable>
29873 <para>
29874 <indexterm role="concept">
29875 <primary>router</primary>
29876 <secondary>prefix for local part</secondary>
29877 </indexterm>
29878 <indexterm role="concept">
29879 <primary>prefix</primary>
29880 <secondary>for local part, used in router</secondary>
29881 </indexterm>
29882 If this option is set, the router is skipped unless the local part starts with
29883 one of the given strings, or <option>local_part_prefix_optional</option> is true. See
29884 section <xref linkend="SECTrouprecon"/> for a list of the order in which preconditions are
29885 evaluated.
29886 </para>
29887 <para>
29888 The list is scanned from left to right, and the first prefix that matches is
29889 used. A limited form of wildcard is available; if the prefix begins with an
29890 asterisk, it matches the longest possible sequence of arbitrary characters at
29891 the start of the local part. An asterisk should therefore always be followed by
29892 some character that does not occur in normal local parts.
29893 <indexterm role="concept">
29894 <primary>multiple mailboxes</primary>
29895 </indexterm>
29896 <indexterm role="concept">
29897 <primary>mailbox</primary>
29898 <secondary>multiple</secondary>
29899 </indexterm>
29900 Wildcarding can be used to set up multiple user mailboxes, as described in
29901 section <xref linkend="SECTmulbox"/>.
29902 </para>
29903 <para>
29904 <indexterm role="variable">
29905 <primary><varname>$local_part</varname></primary>
29906 </indexterm>
29907 <indexterm role="variable">
29908 <primary><varname>$local_part_prefix</varname></primary>
29909 </indexterm>
29910 During the testing of the <option>local_parts</option> option, and while the router is
29911 running, the prefix is removed from the local part, and is available in the
29912 expansion variable <varname>$local_part_prefix</varname>. When a message is being delivered, if
29913 the router accepts the address, this remains true during subsequent delivery by
29914 a transport. In particular, the local part that is transmitted in the RCPT
29915 command for LMTP, SMTP, and BSMTP deliveries has the prefix removed by default.
29916 This behaviour can be overridden by setting <option>rcpt_include_affixes</option> true on
29917 the relevant transport.
29918 </para>
29919 <para>
29920 When an address is being verified, <option>local_part_prefix</option> affects only the
29921 behaviour of the router. If the callout feature of verification is in use, this
29922 means that the full address, including the prefix, will be used during the
29923 callout.
29924 </para>
29925 <para>
29926 The prefix facility is commonly used to handle local parts of the form
29927 <option>owner-something</option>. Another common use is to support local parts of the form
29928 <option>real-username</option> to bypass a user&#x2019;s <filename>.forward</filename> file &ndash; helpful when trying
29929 to tell a user their forwarding is broken &ndash; by placing a router like this one
29930 immediately before the router that handles <filename>.forward</filename> files:
29931 </para>
29932 <literallayout class="monospaced">
29933 real_localuser:
29934   driver = accept
29935   local_part_prefix = real-
29936   check_local_user
29937   transport = local_delivery
29938 </literallayout>
29939 <para>
29940 For security, it would probably be a good idea to restrict the use of this
29941 router to locally-generated messages, using a condition such as this:
29942 </para>
29943 <literallayout class="monospaced">
29944   condition = ${if match {$sender_host_address}\
29945                          {\N^(|127\.0\.0\.1)$\N}}
29946 </literallayout>
29947 <para>
29948 If both <option>local_part_prefix</option> and <option>local_part_suffix</option> are set for a router,
29949 both conditions must be met if not optional. Care must be taken if wildcards
29950 are used in both a prefix and a suffix on the same router. Different
29951 separator characters must be used to avoid ambiguity.
29952 </para>
29953 <para>
29954 <indexterm role="option">
29955 <primary><option>local_part_prefix_optional</option></primary>
29956 </indexterm>
29957 </para>
29958 <informaltable frame="all">
29959 <tgroup cols="4" colsep="0" rowsep="0">
29960 <colspec colwidth="8*" align="left"/>
29961 <colspec colwidth="6*" align="center"/>
29962 <colspec colwidth="6*" align="center"/>
29963 <colspec colwidth="6*" align="right"/>
29964 <tbody>
29965 <row>
29966 <entry><option>local_part_prefix_optional</option></entry>
29967 <entry>Use: <emphasis>routers</emphasis></entry>
29968 <entry>Type: <emphasis>boolean</emphasis></entry>
29969 <entry>Default: <emphasis>false</emphasis></entry>
29970 </row>
29971 </tbody>
29972 </tgroup>
29973 </informaltable>
29974 <para>
29975 See <option>local_part_prefix</option> above.
29976 </para>
29977 <para>
29978 <indexterm role="option">
29979 <primary><option>local_part_suffix</option></primary>
29980 </indexterm>
29981 </para>
29982 <informaltable frame="all">
29983 <tgroup cols="4" colsep="0" rowsep="0">
29984 <colspec colwidth="8*" align="left"/>
29985 <colspec colwidth="6*" align="center"/>
29986 <colspec colwidth="6*" align="center"/>
29987 <colspec colwidth="6*" align="right"/>
29988 <tbody>
29989 <row>
29990 <entry><option>local_part_suffix</option></entry>
29991 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
29992 <entry>Type: <emphasis>string list</emphasis></entry>
29993 <entry>Default: <emphasis>unset</emphasis></entry>
29994 </row>
29995 </tbody>
29996 </tgroup>
29997 </informaltable>
29998 <para>
29999 <indexterm role="concept">
30000 <primary>router</primary>
30001 <secondary>suffix for local part</secondary>
30002 </indexterm>
30003 <indexterm role="concept">
30004 <primary>suffix for local part</primary>
30005 <secondary>used in router</secondary>
30006 </indexterm>
30007 This option operates in the same way as <option>local_part_prefix</option>, except that the
30008 local part must end (rather than start) with the given string, the
30009 <option>local_part_suffix_optional</option> option determines whether the suffix is
30010 mandatory, and the wildcard * character, if present, must be the last
30011 character of the suffix. This option facility is commonly used to handle local
30012 parts of the form <option>something-request</option> and multiple user mailboxes of the form
30013 <option>username-foo</option>.
30014 </para>
30015 <para>
30016 <indexterm role="option">
30017 <primary><option>local_part_suffix_optional</option></primary>
30018 </indexterm>
30019 </para>
30020 <informaltable frame="all">
30021 <tgroup cols="4" colsep="0" rowsep="0">
30022 <colspec colwidth="8*" align="left"/>
30023 <colspec colwidth="6*" align="center"/>
30024 <colspec colwidth="6*" align="center"/>
30025 <colspec colwidth="6*" align="right"/>
30026 <tbody>
30027 <row>
30028 <entry><option>local_part_suffix_optional</option></entry>
30029 <entry>Use: <emphasis>routers</emphasis></entry>
30030 <entry>Type: <emphasis>boolean</emphasis></entry>
30031 <entry>Default: <emphasis>false</emphasis></entry>
30032 </row>
30033 </tbody>
30034 </tgroup>
30035 </informaltable>
30036 <para>
30037 See <option>local_part_suffix</option> above.
30038 </para>
30039 <para>
30040 <indexterm role="option">
30041 <primary><option>local_parts</option></primary>
30042 </indexterm>
30043 </para>
30044 <informaltable frame="all">
30045 <tgroup cols="4" colsep="0" rowsep="0">
30046 <colspec colwidth="8*" align="left"/>
30047 <colspec colwidth="6*" align="center"/>
30048 <colspec colwidth="6*" align="center"/>
30049 <colspec colwidth="6*" align="right"/>
30050 <tbody>
30051 <row>
30052 <entry><option>local_parts</option></entry>
30053 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
30054 <entry>Type: <emphasis>local part list</emphasis>&dagger;<emphasis></emphasis></entry>
30055 <entry>Default: <emphasis>unset</emphasis></entry>
30056 </row>
30057 </tbody>
30058 </tgroup>
30059 </informaltable>
30060 <para>
30061 <indexterm role="concept">
30062 <primary>router</primary>
30063 <secondary>restricting to specific local parts</secondary>
30064 </indexterm>
30065 <indexterm role="concept">
30066 <primary>local part</primary>
30067 <secondary>checking in router</secondary>
30068 </indexterm>
30069 The router is run only if the local part of the address matches the list.
30070 See section <xref linkend="SECTrouprecon"/> for a list of the order in which preconditions
30071 are evaluated, and
30072 section <xref linkend="SECTlocparlis"/> for a discussion of local part lists. Because the
30073 string is expanded, it is possible to make it depend on the domain, for
30074 example:
30075 </para>
30076 <literallayout class="monospaced">
30077 local_parts = dbm;/usr/local/specials/$domain
30078 </literallayout>
30079 <para>
30080 <indexterm role="variable">
30081 <primary><varname>$local_part_data</varname></primary>
30082 </indexterm>
30083 If the match is achieved by a lookup, the data that the lookup returned
30084 for the local part is placed in the variable <varname>$local_part_data</varname> for use in
30085 expansions of the router&#x2019;s private options. You might use this option, for
30086 example, if you have a large number of local virtual domains, and you want to
30087 send all postmaster mail to the same place without having to set up an alias in
30088 each virtual domain:
30089 </para>
30090 <literallayout class="monospaced">
30091 postmaster:
30092   driver = redirect
30093   local_parts = postmaster
30094   data = postmaster@real.domain.example
30095 </literallayout>
30096 <para>
30097 <indexterm role="option">
30098 <primary><option>log_as_local</option></primary>
30099 </indexterm>
30100 </para>
30101 <informaltable frame="all">
30102 <tgroup cols="4" colsep="0" rowsep="0">
30103 <colspec colwidth="8*" align="left"/>
30104 <colspec colwidth="6*" align="center"/>
30105 <colspec colwidth="6*" align="center"/>
30106 <colspec colwidth="6*" align="right"/>
30107 <tbody>
30108 <row>
30109 <entry><option>log_as_local</option></entry>
30110 <entry>Use: <emphasis>routers</emphasis></entry>
30111 <entry>Type: <emphasis>boolean</emphasis></entry>
30112 <entry>Default: <emphasis>see below</emphasis></entry>
30113 </row>
30114 </tbody>
30115 </tgroup>
30116 </informaltable>
30117 <para>
30118 <indexterm role="concept">
30119 <primary>log</primary>
30120 <secondary>delivery line</secondary>
30121 </indexterm>
30122 <indexterm role="concept">
30123 <primary>delivery</primary>
30124 <secondary>log line format</secondary>
30125 </indexterm>
30126 Exim has two logging styles for delivery, the idea being to make local
30127 deliveries stand out more visibly from remote ones. In the <quote>local</quote> style, the
30128 recipient address is given just as the local part, without a domain. The use of
30129 this style is controlled by this option. It defaults to true for the <command>accept</command>
30130 router, and false for all the others. This option applies only when a
30131 router assigns an address to a transport. It has no effect on routers that
30132 redirect addresses.
30133 </para>
30134 <para>
30135 <indexterm role="option">
30136 <primary><option>more</option></primary>
30137 </indexterm>
30138 </para>
30139 <informaltable frame="all">
30140 <tgroup cols="4" colsep="0" rowsep="0">
30141 <colspec colwidth="8*" align="left"/>
30142 <colspec colwidth="6*" align="center"/>
30143 <colspec colwidth="6*" align="center"/>
30144 <colspec colwidth="6*" align="right"/>
30145 <tbody>
30146 <row>
30147 <entry><option>more</option></entry>
30148 <entry>Use: <emphasis>routers</emphasis></entry>
30149 <entry>Type: <emphasis>boolean</emphasis>&dagger;<emphasis></emphasis></entry>
30150 <entry>Default: <emphasis>true</emphasis></entry>
30151 </row>
30152 </tbody>
30153 </tgroup>
30154 </informaltable>
30155 <para>
30156 The result of string expansion for this option must be a valid boolean value,
30157 that is, one of the strings <quote>yes</quote>, <quote>no</quote>, <quote>true</quote>, or <quote>false</quote>. Any other
30158 result causes an error, and delivery is deferred. If the expansion is forced to
30159 fail, the default value for the option (true) is used. Other failures cause
30160 delivery to be deferred.
30161 </para>
30162 <para>
30163 If this option is set false, and the router declines to handle the address, no
30164 further routers are tried, routing fails, and the address is bounced.
30165 <indexterm role="option">
30166 <primary><option>self</option></primary>
30167 </indexterm>
30168 However, if the router explicitly passes an address to the following router by
30169 means of the setting
30170 </para>
30171 <literallayout class="monospaced">
30172 self = pass
30173 </literallayout>
30174 <para>
30175 or otherwise, the setting of <option>more</option> is ignored. Also, the setting of <option>more</option>
30176 does not affect the behaviour if one of the precondition tests fails. In that
30177 case, the address is always passed to the next router.
30178 </para>
30179 <para>
30180 Note that <option>address_data</option> is not considered to be a precondition. If its
30181 expansion is forced to fail, the router declines, and the value of <option>more</option>
30182 controls what happens next.
30183 </para>
30184 <para>
30185 <indexterm role="option">
30186 <primary><option>pass_on_timeout</option></primary>
30187 </indexterm>
30188 </para>
30189 <informaltable frame="all">
30190 <tgroup cols="4" colsep="0" rowsep="0">
30191 <colspec colwidth="8*" align="left"/>
30192 <colspec colwidth="6*" align="center"/>
30193 <colspec colwidth="6*" align="center"/>
30194 <colspec colwidth="6*" align="right"/>
30195 <tbody>
30196 <row>
30197 <entry><option>pass_on_timeout</option></entry>
30198 <entry>Use: <emphasis>routers</emphasis></entry>
30199 <entry>Type: <emphasis>boolean</emphasis></entry>
30200 <entry>Default: <emphasis>false</emphasis></entry>
30201 </row>
30202 </tbody>
30203 </tgroup>
30204 </informaltable>
30205 <para>
30206 <indexterm role="concept">
30207 <primary>timeout</primary>
30208 <secondary>of router</secondary>
30209 </indexterm>
30210 <indexterm role="concept">
30211 <primary>router</primary>
30212 <secondary>timeout</secondary>
30213 </indexterm>
30214 If a router times out during a host lookup, it normally causes deferral of the
30215 address. If <option>pass_on_timeout</option> is set, the address is passed on to the next
30216 router, overriding <option>no_more</option>. This may be helpful for systems that are
30217 intermittently connected to the Internet, or those that want to pass to a smart
30218 host any messages that cannot immediately be delivered.
30219 </para>
30220 <para>
30221 There are occasional other temporary errors that can occur while doing DNS
30222 lookups. They are treated in the same way as a timeout, and this option
30223 applies to all of them.
30224 </para>
30225 <para>
30226 <indexterm role="option">
30227 <primary><option>pass_router</option></primary>
30228 </indexterm>
30229 </para>
30230 <informaltable frame="all">
30231 <tgroup cols="4" colsep="0" rowsep="0">
30232 <colspec colwidth="8*" align="left"/>
30233 <colspec colwidth="6*" align="center"/>
30234 <colspec colwidth="6*" align="center"/>
30235 <colspec colwidth="6*" align="right"/>
30236 <tbody>
30237 <row>
30238 <entry><option>pass_router</option></entry>
30239 <entry>Use: <emphasis>routers</emphasis></entry>
30240 <entry>Type: <emphasis>string</emphasis></entry>
30241 <entry>Default: <emphasis>unset</emphasis></entry>
30242 </row>
30243 </tbody>
30244 </tgroup>
30245 </informaltable>
30246 <para>
30247 <indexterm role="concept">
30248 <primary>router</primary>
30249 <secondary>go to after <quote>pass</quote></secondary>
30250 </indexterm>
30251 Routers that recognize the generic <option>self</option> option (<command>dnslookup</command>,
30252 <command>ipliteral</command>, and <command>manualroute</command>) are able to return <quote>pass</quote>, forcing
30253 routing to continue, and overriding a false setting of <option>more</option>. When one of
30254 these routers returns <quote>pass</quote>, the address is normally handed on to the next
30255 router in sequence. This can be changed by setting <option>pass_router</option> to the name
30256 of another router. However (unlike <option>redirect_router</option>) the named router must
30257 be below the current router, to avoid loops. Note that this option applies only
30258 to the special case of <quote>pass</quote>. It does not apply when a router returns
30259 <quote>decline</quote> because it cannot handle an address.
30260 </para>
30261 <para>
30262 <indexterm role="option">
30263 <primary><option>redirect_router</option></primary>
30264 </indexterm>
30265 </para>
30266 <informaltable frame="all">
30267 <tgroup cols="4" colsep="0" rowsep="0">
30268 <colspec colwidth="8*" align="left"/>
30269 <colspec colwidth="6*" align="center"/>
30270 <colspec colwidth="6*" align="center"/>
30271 <colspec colwidth="6*" align="right"/>
30272 <tbody>
30273 <row>
30274 <entry><option>redirect_router</option></entry>
30275 <entry>Use: <emphasis>routers</emphasis></entry>
30276 <entry>Type: <emphasis>string</emphasis></entry>
30277 <entry>Default: <emphasis>unset</emphasis></entry>
30278 </row>
30279 </tbody>
30280 </tgroup>
30281 </informaltable>
30282 <para>
30283 <indexterm role="concept">
30284 <primary>router</primary>
30285 <secondary>start at after redirection</secondary>
30286 </indexterm>
30287 Sometimes an administrator knows that it is pointless to reprocess addresses
30288 generated from alias or forward files with the same router again. For
30289 example, if an alias file translates real names into login ids there is no
30290 point searching the alias file a second time, especially if it is a large file.
30291 </para>
30292 <para>
30293 The <option>redirect_router</option> option can be set to the name of any router instance.
30294 It causes the routing of any generated addresses to start at the named router
30295 instead of at the first router. This option has no effect if the router in
30296 which it is set does not generate new addresses.
30297 </para>
30298 <para>
30299 <indexterm role="option">
30300 <primary><option>require_files</option></primary>
30301 </indexterm>
30302 </para>
30303 <informaltable frame="all">
30304 <tgroup cols="4" colsep="0" rowsep="0">
30305 <colspec colwidth="8*" align="left"/>
30306 <colspec colwidth="6*" align="center"/>
30307 <colspec colwidth="6*" align="center"/>
30308 <colspec colwidth="6*" align="right"/>
30309 <tbody>
30310 <row>
30311 <entry><option>require_files</option></entry>
30312 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
30313 <entry>Type: <emphasis>string list</emphasis>&dagger;<emphasis></emphasis></entry>
30314 <entry>Default: <emphasis>unset</emphasis></entry>
30315 </row>
30316 </tbody>
30317 </tgroup>
30318 </informaltable>
30319 <para>
30320 <indexterm role="concept">
30321 <primary>file</primary>
30322 <secondary>requiring for router</secondary>
30323 </indexterm>
30324 <indexterm role="concept">
30325 <primary>router</primary>
30326 <secondary>requiring file existence</secondary>
30327 </indexterm>
30328 This option provides a general mechanism for predicating the running of a
30329 router on the existence or non-existence of certain files or directories.
30330 Before running a router, as one of its precondition tests, Exim works its way
30331 through the <option>require_files</option> list, expanding each item separately.
30332 </para>
30333 <para>
30334 Because the list is split before expansion, any colons in expansion items must
30335 be doubled, or the facility for using a different list separator must be used.
30336 If any expansion is forced to fail, the item is ignored. Other expansion
30337 failures cause routing of the address to be deferred.
30338 </para>
30339 <para>
30340 If any expanded string is empty, it is ignored. Otherwise, except as described
30341 below, each string must be a fully qualified file path, optionally preceded by
30342 <quote>!</quote>. The paths are passed to the <function>stat()</function> function to test for the
30343 existence of the files or directories. The router is skipped if any paths not
30344 preceded by <quote>!</quote> do not exist, or if any paths preceded by <quote>!</quote> do exist.
30345 </para>
30346 <para>
30347 <indexterm role="concept">
30348 <primary>NFS</primary>
30349 </indexterm>
30350 If <function>stat()</function> cannot determine whether a file exists or not, delivery of
30351 the message is deferred. This can happen when NFS-mounted filesystems are
30352 unavailable.
30353 </para>
30354 <para>
30355 This option is checked after the <option>domains</option>, <option>local_parts</option>, and <option>senders</option>
30356 options, so you cannot use it to check for the existence of a file in which to
30357 look up a domain, local part, or sender. (See section <xref linkend="SECTrouprecon"/> for a
30358 full list of the order in which preconditions are evaluated.) However, as
30359 these options are all expanded, you can use the <option>exists</option> expansion condition
30360 to make such tests. The <option>require_files</option> option is intended for checking files
30361 that the router may be going to use internally, or which are needed by a
30362 transport (for example <filename>.procmailrc</filename>).
30363 </para>
30364 <para>
30365 During delivery, the <function>stat()</function> function is run as root, but there is a
30366 facility for some checking of the accessibility of a file by another user.
30367 This is not a proper permissions check, but just a <quote>rough</quote> check that
30368 operates as follows:
30369 </para>
30370 <para>
30371 If an item in a <option>require_files</option> list does not contain any forward slash
30372 characters, it is taken to be the user (and optional group, separated by a
30373 comma) to be checked for subsequent files in the list. If no group is specified
30374 but the user is specified symbolically, the gid associated with the uid is
30375 used. For example:
30376 </para>
30377 <literallayout class="monospaced">
30378 require_files = mail:/some/file
30379 require_files = $local_part:$home/.procmailrc
30380 </literallayout>
30381 <para>
30382 If a user or group name in a <option>require_files</option> list does not exist, the
30383 <option>require_files</option> condition fails.
30384 </para>
30385 <para>
30386 Exim performs the check by scanning along the components of the file path, and
30387 checking the access for the given uid and gid. It checks for <quote>x</quote> access on
30388 directories, and <quote>r</quote> access on the final file. Note that this means that file
30389 access control lists, if the operating system has them, are ignored.
30390 </para>
30391 <para>
30392 <emphasis role="bold">Warning 1</emphasis>: When the router is being run to verify addresses for an
30393 incoming SMTP message, Exim is not running as root, but under its own uid. This
30394 may affect the result of a <option>require_files</option> check. In particular, <function>stat()</function>
30395 may yield the error EACCES (<quote>Permission denied</quote>). This means that the Exim
30396 user is not permitted to read one of the directories on the file&#x2019;s path.
30397 </para>
30398 <para>
30399 <emphasis role="bold">Warning 2</emphasis>: Even when Exim is running as root while delivering a message,
30400 <function>stat()</function> can yield EACCES for a file in an NFS directory that is mounted
30401 without root access. In this case, if a check for access by a particular user
30402 is requested, Exim creates a subprocess that runs as that user, and tries the
30403 check again in that process.
30404 </para>
30405 <para>
30406 The default action for handling an unresolved EACCES is to consider it to
30407 be caused by a configuration error, and routing is deferred because the
30408 existence or non-existence of the file cannot be determined. However, in some
30409 circumstances it may be desirable to treat this condition as if the file did
30410 not exist. If the file name (or the exclamation mark that precedes the file
30411 name for non-existence) is preceded by a plus sign, the EACCES error is treated
30412 as if the file did not exist. For example:
30413 </para>
30414 <literallayout class="monospaced">
30415 require_files = +/some/file
30416 </literallayout>
30417 <para>
30418 If the router is not an essential part of verification (for example, it
30419 handles users&#x2019; <filename>.forward</filename> files), another solution is to set the <option>verify</option>
30420 option false so that the router is skipped when verifying.
30421 </para>
30422 <para>
30423 <indexterm role="option">
30424 <primary><option>retry_use_local_part</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>retry_use_local_part</option></entry>
30436 <entry>Use: <emphasis>routers</emphasis></entry>
30437 <entry>Type: <emphasis>boolean</emphasis></entry>
30438 <entry>Default: <emphasis>see below</emphasis></entry>
30439 </row>
30440 </tbody>
30441 </tgroup>
30442 </informaltable>
30443 <para>
30444 <indexterm role="concept">
30445 <primary>hints database</primary>
30446 <secondary>retry keys</secondary>
30447 </indexterm>
30448 <indexterm role="concept">
30449 <primary>local part</primary>
30450 <secondary>in retry keys</secondary>
30451 </indexterm>
30452 When a delivery suffers a temporary routing failure, a retry record is created
30453 in Exim&#x2019;s hints database. For addresses whose routing depends only on the
30454 domain, the key for the retry record should not involve the local part, but for
30455 other addresses, both the domain and the local part should be included.
30456 Usually, remote routing is of the former kind, and local routing is of the
30457 latter kind.
30458 </para>
30459 <para>
30460 This option controls whether the local part is used to form the key for retry
30461 hints for addresses that suffer temporary errors while being handled by this
30462 router. The default value is true for any router that has <option>check_local_user</option>
30463 set, and false otherwise. Note that this option does not apply to hints keys
30464 for transport delays; they are controlled by a generic transport option of the
30465 same name.
30466 </para>
30467 <para>
30468 The setting of <option>retry_use_local_part</option> applies only to the router on which it
30469 appears. If the router generates child addresses, they are routed
30470 independently; this setting does not become attached to them.
30471 </para>
30472 <para>
30473 <indexterm role="option">
30474 <primary><option>router_home_directory</option></primary>
30475 </indexterm>
30476 </para>
30477 <informaltable frame="all">
30478 <tgroup cols="4" colsep="0" rowsep="0">
30479 <colspec colwidth="8*" align="left"/>
30480 <colspec colwidth="6*" align="center"/>
30481 <colspec colwidth="6*" align="center"/>
30482 <colspec colwidth="6*" align="right"/>
30483 <tbody>
30484 <row>
30485 <entry><option>router_home_directory</option></entry>
30486 <entry>Use: <emphasis>routers</emphasis></entry>
30487 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
30488 <entry>Default: <emphasis>unset</emphasis></entry>
30489 </row>
30490 </tbody>
30491 </tgroup>
30492 </informaltable>
30493 <para>
30494 <indexterm role="concept">
30495 <primary>router</primary>
30496 <secondary>home directory for</secondary>
30497 </indexterm>
30498 <indexterm role="concept">
30499 <primary>home directory</primary>
30500 <secondary>for router</secondary>
30501 </indexterm>
30502 <indexterm role="variable">
30503 <primary><varname>$home</varname></primary>
30504 </indexterm>
30505 This option sets a home directory for use while the router is running. (Compare
30506 <option>transport_home_directory</option>, which sets a home directory for later
30507 transporting.) In particular, if used on a <command>redirect</command> router, this option
30508 sets a value for <varname>$home</varname> while a filter is running. The value is expanded;
30509 forced expansion failure causes the option to be ignored &ndash; other failures
30510 cause the router to defer.
30511 </para>
30512 <para>
30513 Expansion of <option>router_home_directory</option> happens immediately after the
30514 <option>check_local_user</option> test (if configured), before any further expansions take
30515 place.
30516 (See section <xref linkend="SECTrouprecon"/> for a list of the order in which preconditions
30517 are evaluated.)
30518 While the router is running, <option>router_home_directory</option> overrides the value of
30519 <varname>$home</varname> that came from <option>check_local_user</option>.
30520 </para>
30521 <para>
30522 When a router accepts an address and assigns it to a local transport (including
30523 the cases when a <command>redirect</command> router generates a pipe, file, or autoreply
30524 delivery), the home directory setting for the transport is taken from the first
30525 of these values that is set:
30526 </para>
30527 <itemizedlist>
30528 <listitem>
30529 <para>
30530 The <option>home_directory</option> option on the transport;
30531 </para>
30532 </listitem>
30533 <listitem>
30534 <para>
30535 The <option>transport_home_directory</option> option on the router;
30536 </para>
30537 </listitem>
30538 <listitem>
30539 <para>
30540 The password data if <option>check_local_user</option> is set on the router;
30541 </para>
30542 </listitem>
30543 <listitem>
30544 <para>
30545 The <option>router_home_directory</option> option on the router.
30546 </para>
30547 </listitem>
30548 </itemizedlist>
30549 <para>
30550 In other words, <option>router_home_directory</option> overrides the password data for the
30551 router, but not for the transport.
30552 </para>
30553 <para>
30554 <indexterm role="option">
30555 <primary><option>self</option></primary>
30556 </indexterm>
30557 </para>
30558 <informaltable frame="all">
30559 <tgroup cols="4" colsep="0" rowsep="0">
30560 <colspec colwidth="8*" align="left"/>
30561 <colspec colwidth="6*" align="center"/>
30562 <colspec colwidth="6*" align="center"/>
30563 <colspec colwidth="6*" align="right"/>
30564 <tbody>
30565 <row>
30566 <entry><option>self</option></entry>
30567 <entry>Use: <emphasis>routers</emphasis></entry>
30568 <entry>Type: <emphasis>string</emphasis></entry>
30569 <entry>Default: <emphasis>freeze</emphasis></entry>
30570 </row>
30571 </tbody>
30572 </tgroup>
30573 </informaltable>
30574 <para>
30575 <indexterm role="concept">
30576 <primary>MX record</primary>
30577 <secondary>pointing to local host</secondary>
30578 </indexterm>
30579 <indexterm role="concept">
30580 <primary>local host</primary>
30581 <secondary>MX pointing to</secondary>
30582 </indexterm>
30583 This option applies to those routers that use a recipient address to find a
30584 list of remote hosts. Currently, these are the <command>dnslookup</command>, <command>ipliteral</command>,
30585 and <command>manualroute</command> routers.
30586 Certain configurations of the <command>queryprogram</command> router can also specify a list
30587 of remote hosts.
30588 Usually such routers are configured to send the message to a remote host via an
30589 <command>smtp</command> transport. The <option>self</option> option specifies what happens when the first
30590 host on the list turns out to be the local host.
30591 The way in which Exim checks for the local host is described in section
30592 <xref linkend="SECTreclocipadd"/>.
30593 </para>
30594 <para>
30595 Normally this situation indicates either an error in Exim&#x2019;s configuration (for
30596 example, the router should be configured not to process this domain), or an
30597 error in the DNS (for example, the MX should not point to this host). For this
30598 reason, the default action is to log the incident, defer the address, and
30599 freeze the message. The following alternatives are provided for use in special
30600 cases:
30601 </para>
30602 <variablelist>
30603 <varlistentry>
30604 <term><option>defer</option></term>
30605 <listitem>
30606 <para>
30607 Delivery of the message is tried again later, but the message is not frozen.
30608 </para>
30609 </listitem></varlistentry>
30610 <varlistentry>
30611 <term><option>reroute</option>: &lt;<emphasis>domain</emphasis>&gt;</term>
30612 <listitem>
30613 <para>
30614 The domain is changed to the given domain, and the address is passed back to
30615 be reprocessed by the routers. No rewriting of headers takes place. This
30616 behaviour is essentially a redirection.
30617 </para>
30618 </listitem></varlistentry>
30619 <varlistentry>
30620 <term><option>reroute: rewrite:</option> &lt;<emphasis>domain</emphasis>&gt;</term>
30621 <listitem>
30622 <para>
30623 The domain is changed to the given domain, and the address is passed back to be
30624 reprocessed by the routers. Any headers that contain the original domain are
30625 rewritten.
30626 </para>
30627 </listitem></varlistentry>
30628 <varlistentry>
30629 <term><option>pass</option></term>
30630 <listitem>
30631 <para>
30632 <indexterm role="option">
30633 <primary><option>more</option></primary>
30634 </indexterm>
30635 <indexterm role="variable">
30636 <primary><varname>$self_hostname</varname></primary>
30637 </indexterm>
30638 The router passes the address to the next router, or to the router named in the
30639 <option>pass_router</option> option if it is set. This overrides <option>no_more</option>. During
30640 subsequent routing and delivery, the variable <varname>$self_hostname</varname> contains the
30641 name of the local host that the router encountered. This can be used to
30642 distinguish between different cases for hosts with multiple names. The
30643 combination
30644 </para>
30645 <literallayout class="monospaced">
30646 self = pass
30647 no_more
30648 </literallayout>
30649 <para>
30650 ensures that only those addresses that routed to the local host are passed on.
30651 Without <option>no_more</option>, addresses that were declined for other reasons would also
30652 be passed to the next router.
30653 </para>
30654 </listitem></varlistentry>
30655 <varlistentry>
30656 <term><option>fail</option></term>
30657 <listitem>
30658 <para>
30659 Delivery fails and an error report is generated.
30660 </para>
30661 </listitem></varlistentry>
30662 <varlistentry>
30663 <term><option>send</option></term>
30664 <listitem>
30665 <para>
30666 <indexterm role="concept">
30667 <primary>local host</primary>
30668 <secondary>sending to</secondary>
30669 </indexterm>
30670 The anomaly is ignored and the address is queued for the transport. This
30671 setting should be used with extreme caution. For an <command>smtp</command> transport, it
30672 makes sense only in cases where the program that is listening on the SMTP port
30673 is not this version of Exim. That is, it must be some other MTA, or Exim with a
30674 different configuration file that handles the domain in another way.
30675 </para>
30676 </listitem></varlistentry>
30677 </variablelist>
30678 <para>
30679 <indexterm role="option">
30680 <primary><option>senders</option></primary>
30681 </indexterm>
30682 </para>
30683 <informaltable frame="all">
30684 <tgroup cols="4" colsep="0" rowsep="0">
30685 <colspec colwidth="8*" align="left"/>
30686 <colspec colwidth="6*" align="center"/>
30687 <colspec colwidth="6*" align="center"/>
30688 <colspec colwidth="6*" align="right"/>
30689 <tbody>
30690 <row>
30691 <entry><option>senders</option></entry>
30692 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
30693 <entry>Type: <emphasis>address list</emphasis>&dagger;<emphasis></emphasis></entry>
30694 <entry>Default: <emphasis>unset</emphasis></entry>
30695 </row>
30696 </tbody>
30697 </tgroup>
30698 </informaltable>
30699 <para>
30700 <indexterm role="concept">
30701 <primary>router</primary>
30702 <secondary>checking senders</secondary>
30703 </indexterm>
30704 If this option is set, the router is skipped unless the message&#x2019;s sender
30705 address matches something on the list.
30706 See section <xref linkend="SECTrouprecon"/> for a list of the order in which preconditions
30707 are evaluated.
30708 </para>
30709 <para>
30710 There are issues concerning verification when the running of routers is
30711 dependent on the sender. When Exim is verifying the address in an <option>errors_to</option>
30712 setting, it sets the sender to the null string. When using the <option>-bt</option> option
30713 to check a configuration file, it is necessary also to use the <option>-f</option> option to
30714 set an appropriate sender. For incoming mail, the sender is unset when
30715 verifying the sender, but is available when verifying any recipients. If the
30716 SMTP VRFY command is enabled, it must be used after MAIL if the sender address
30717 matters.
30718 </para>
30719 <para>
30720 <indexterm role="option">
30721 <primary><option>translate_ip_address</option></primary>
30722 </indexterm>
30723 </para>
30724 <informaltable frame="all">
30725 <tgroup cols="4" colsep="0" rowsep="0">
30726 <colspec colwidth="8*" align="left"/>
30727 <colspec colwidth="6*" align="center"/>
30728 <colspec colwidth="6*" align="center"/>
30729 <colspec colwidth="6*" align="right"/>
30730 <tbody>
30731 <row>
30732 <entry><option>translate_ip_address</option></entry>
30733 <entry>Use: <emphasis>routers</emphasis></entry>
30734 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
30735 <entry>Default: <emphasis>unset</emphasis></entry>
30736 </row>
30737 </tbody>
30738 </tgroup>
30739 </informaltable>
30740 <para>
30741 <indexterm role="concept">
30742 <primary>IP address</primary>
30743 <secondary>translating</secondary>
30744 </indexterm>
30745 <indexterm role="concept">
30746 <primary>packet radio</primary>
30747 </indexterm>
30748 <indexterm role="concept">
30749 <primary>router</primary>
30750 <secondary>IP address translation</secondary>
30751 </indexterm>
30752 There exist some rare networking situations (for example, packet radio) where
30753 it is helpful to be able to translate IP addresses generated by normal routing
30754 mechanisms into other IP addresses, thus performing a kind of manual IP
30755 routing. This should be done only if the normal IP routing of the TCP/IP stack
30756 is inadequate or broken. Because this is an extremely uncommon requirement, the
30757 code to support this option is not included in the Exim binary unless
30758 SUPPORT_TRANSLATE_IP_ADDRESS=yes is set in <filename>Local/Makefile</filename>.
30759 </para>
30760 <para>
30761 <indexterm role="variable">
30762 <primary><varname>$host_address</varname></primary>
30763 </indexterm>
30764 The <option>translate_ip_address</option> string is expanded for every IP address generated
30765 by the router, with the generated address set in <varname>$host_address</varname>. If the
30766 expansion is forced to fail, no action is taken.
30767 For any other expansion error, delivery of the message is deferred.
30768 If the result of the expansion is an IP address, that replaces the original
30769 address; otherwise the result is assumed to be a host name &ndash; this is looked
30770 up using <function>gethostbyname()</function> (or <function>getipnodebyname()</function> when available) to
30771 produce one or more replacement IP addresses. For example, to subvert all IP
30772 addresses in some specific networks, this could be added to a router:
30773 </para>
30774 <literallayout class="monospaced">
30775 translate_ip_address = \
30776   ${lookup{${mask:$host_address/26}}lsearch{/some/file}\
30777     {$value}fail}}
30778 </literallayout>
30779 <para>
30780 The file would contain lines like
30781 </para>
30782 <literallayout class="monospaced">
30783 10.2.3.128/26    some.host
30784 10.8.4.34/26     10.44.8.15
30785 </literallayout>
30786 <para>
30787 You should not make use of this facility unless you really understand what you
30788 are doing.
30789 </para>
30790 <para>
30791 <indexterm role="option">
30792 <primary><option>transport</option></primary>
30793 </indexterm>
30794 </para>
30795 <informaltable frame="all">
30796 <tgroup cols="4" colsep="0" rowsep="0">
30797 <colspec colwidth="8*" align="left"/>
30798 <colspec colwidth="6*" align="center"/>
30799 <colspec colwidth="6*" align="center"/>
30800 <colspec colwidth="6*" align="right"/>
30801 <tbody>
30802 <row>
30803 <entry><option>transport</option></entry>
30804 <entry>Use: <emphasis>routers</emphasis></entry>
30805 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
30806 <entry>Default: <emphasis>unset</emphasis></entry>
30807 </row>
30808 </tbody>
30809 </tgroup>
30810 </informaltable>
30811 <para>
30812 This option specifies the transport to be used when a router accepts an address
30813 and sets it up for delivery. A transport is never needed if a router is used
30814 only for verification. The value of the option is expanded at routing time,
30815 after the expansion of <option>errors_to</option>, <option>headers_add</option>, and <option>headers_remove</option>,
30816 and result must be the name of one of the configured transports. If it is not,
30817 delivery is deferred.
30818 </para>
30819 <para>
30820 The <option>transport</option> option is not used by the <command>redirect</command> router, but it does
30821 have some private options that set up transports for pipe and file deliveries
30822 (see chapter <xref linkend="CHAPredirect"/>).
30823 </para>
30824 <para>
30825 <indexterm role="option">
30826 <primary><option>transport_current_directory</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>transport_current_directory</option></entry>
30838 <entry>Use: <emphasis>routers</emphasis></entry>
30839 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
30840 <entry>Default: <emphasis>unset</emphasis></entry>
30841 </row>
30842 </tbody>
30843 </tgroup>
30844 </informaltable>
30845 <para>
30846 <indexterm role="concept">
30847 <primary>current directory for local transport</primary>
30848 </indexterm>
30849 This option associates a current directory with any address that is routed
30850 to a local transport. This can happen either because a transport is
30851 explicitly configured for the router, or because it generates a delivery to a
30852 file or a pipe. During the delivery process (that is, at transport time), this
30853 option string is expanded and is set as the current directory, unless
30854 overridden by a setting on the transport.
30855 If the expansion fails for any reason, including forced failure, an error is
30856 logged, and delivery is deferred.
30857 See chapter <xref linkend="CHAPenvironment"/> for details of the local delivery
30858 environment.
30859 </para>
30860 <para>
30861 <indexterm role="option">
30862 <primary><option>transport_home_directory</option></primary>
30863 </indexterm>
30864 </para>
30865 <informaltable frame="all">
30866 <tgroup cols="4" colsep="0" rowsep="0">
30867 <colspec colwidth="8*" align="left"/>
30868 <colspec colwidth="6*" align="center"/>
30869 <colspec colwidth="6*" align="center"/>
30870 <colspec colwidth="6*" align="right"/>
30871 <tbody>
30872 <row>
30873 <entry><option>transport_home_directory</option></entry>
30874 <entry>Use: <emphasis>routers</emphasis></entry>
30875 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
30876 <entry>Default: <emphasis>see below</emphasis></entry>
30877 </row>
30878 </tbody>
30879 </tgroup>
30880 </informaltable>
30881 <para>
30882 <indexterm role="concept">
30883 <primary>home directory</primary>
30884 <secondary>for local transport</secondary>
30885 </indexterm>
30886 This option associates a home directory with any address that is routed to a
30887 local transport. This can happen either because a transport is explicitly
30888 configured for the router, or because it generates a delivery to a file or a
30889 pipe. During the delivery process (that is, at transport time), the option
30890 string is expanded and is set as the home directory, unless overridden by a
30891 setting of <option>home_directory</option> on the transport.
30892 If the expansion fails for any reason, including forced failure, an error is
30893 logged, and delivery is deferred.
30894 </para>
30895 <para>
30896 If the transport does not specify a home directory, and
30897 <option>transport_home_directory</option> is not set for the router, the home directory for
30898 the transport is taken from the password data if <option>check_local_user</option> is set for
30899 the router. Otherwise it is taken from <option>router_home_directory</option> if that option
30900 is set; if not, no home directory is set for the transport.
30901 </para>
30902 <para>
30903 See chapter <xref linkend="CHAPenvironment"/> for further details of the local delivery
30904 environment.
30905 </para>
30906 <para>
30907 <indexterm role="option">
30908 <primary><option>unseen</option></primary>
30909 </indexterm>
30910 </para>
30911 <informaltable frame="all">
30912 <tgroup cols="4" colsep="0" rowsep="0">
30913 <colspec colwidth="8*" align="left"/>
30914 <colspec colwidth="6*" align="center"/>
30915 <colspec colwidth="6*" align="center"/>
30916 <colspec colwidth="6*" align="right"/>
30917 <tbody>
30918 <row>
30919 <entry><option>unseen</option></entry>
30920 <entry>Use: <emphasis>routers</emphasis></entry>
30921 <entry>Type: <emphasis>boolean</emphasis>&dagger;<emphasis></emphasis></entry>
30922 <entry>Default: <emphasis>false</emphasis></entry>
30923 </row>
30924 </tbody>
30925 </tgroup>
30926 </informaltable>
30927 <para>
30928 <indexterm role="concept">
30929 <primary>router</primary>
30930 <secondary>carrying on after success</secondary>
30931 </indexterm>
30932 The result of string expansion for this option must be a valid boolean value,
30933 that is, one of the strings <quote>yes</quote>, <quote>no</quote>, <quote>true</quote>, or <quote>false</quote>. Any other
30934 result causes an error, and delivery is deferred. If the expansion is forced to
30935 fail, the default value for the option (false) is used. Other failures cause
30936 delivery to be deferred.
30937 </para>
30938 <para>
30939 When this option is set true, routing does not cease if the router accepts the
30940 address. Instead, a copy of the incoming address is passed to the next router,
30941 overriding a false setting of <option>more</option>. There is little point in setting
30942 <option>more</option> false if <option>unseen</option> is always true, but it may be useful in cases when
30943 the value of <option>unseen</option> contains expansion items (and therefore, presumably, is
30944 sometimes true and sometimes false).
30945 </para>
30946 <para>
30947 <indexterm role="concept">
30948 <primary>copy of message (<option>unseen</option> option)</primary>
30949 </indexterm>
30950 Setting the <option>unseen</option> option has a similar effect to the <option>unseen</option> command
30951 qualifier in filter files. It can be used to cause copies of messages to be
30952 delivered to some other destination, while also carrying out a normal delivery.
30953 In effect, the current address is made into a <quote>parent</quote> that has two children
30954 &ndash; one that is delivered as specified by this router, and a clone that goes on
30955 to be routed further. For this reason, <option>unseen</option> may not be combined with the
30956 <option>one_time</option> option in a <command>redirect</command> router.
30957 </para>
30958 <para>
30959 <emphasis role="bold">Warning</emphasis>: Header lines added to the address (or specified for removal) by
30960 this router or by previous routers affect the <quote>unseen</quote> copy of the message
30961 only. The clone that continues to be processed by further routers starts with
30962 no added headers and none specified for removal. For a <option>redirect</option> router, if
30963 a generated address is the same as the incoming address, this can lead to
30964 duplicate addresses with different header modifications. Exim does not do
30965 duplicate deliveries (except, in certain circumstances, to pipes -- see section
30966 <xref linkend="SECTdupaddr"/>), but it is undefined which of the duplicates is discarded,
30967 so this ambiguous situation should be avoided. The <option>repeat_use</option> option of the
30968 <option>redirect</option> router may be of help.
30969 </para>
30970 <para>
30971 Unlike the handling of header modifications, any data that was set by the
30972 <option>address_data</option> option in the current or previous routers <emphasis>is</emphasis> passed on to
30973 subsequent routers.
30974 </para>
30975 <para>
30976 <indexterm role="option">
30977 <primary><option>user</option></primary>
30978 </indexterm>
30979 </para>
30980 <informaltable frame="all">
30981 <tgroup cols="4" colsep="0" rowsep="0">
30982 <colspec colwidth="8*" align="left"/>
30983 <colspec colwidth="6*" align="center"/>
30984 <colspec colwidth="6*" align="center"/>
30985 <colspec colwidth="6*" align="right"/>
30986 <tbody>
30987 <row>
30988 <entry><option>user</option></entry>
30989 <entry>Use: <emphasis>routers</emphasis></entry>
30990 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
30991 <entry>Default: <emphasis>see below</emphasis></entry>
30992 </row>
30993 </tbody>
30994 </tgroup>
30995 </informaltable>
30996 <para>
30997 <indexterm role="concept">
30998 <primary>uid (user id)</primary>
30999 <secondary>local delivery</secondary>
31000 </indexterm>
31001 <indexterm role="concept">
31002 <primary>local transports</primary>
31003 <secondary>uid and gid</secondary>
31004 </indexterm>
31005 <indexterm role="concept">
31006 <primary>transport</primary>
31007 <secondary>local</secondary>
31008 </indexterm>
31009 <indexterm role="concept">
31010 <primary>router</primary>
31011 <secondary>user for filter processing</secondary>
31012 </indexterm>
31013 <indexterm role="concept">
31014 <primary>filter</primary>
31015 <secondary>user for processing</secondary>
31016 </indexterm>
31017 When a router queues an address for a transport, and the transport does not
31018 specify a user, the user given here is used when running the delivery process.
31019 The user may be specified numerically or by name. If expansion fails, the
31020 error is logged and delivery is deferred.
31021 This user is also used by the <command>redirect</command> router when running a filter file.
31022 The default is unset, except when <option>check_local_user</option> is set. In this case,
31023 the default is taken from the password information. If the user is specified as
31024 a name, and <option>group</option> is not set, the group associated with the user is used.
31025 See also <option>initgroups</option> and <option>group</option> and the discussion in chapter
31026 <xref linkend="CHAPenvironment"/>.
31027 </para>
31028 <para>
31029 <indexterm role="option">
31030 <primary><option>verify</option></primary>
31031 </indexterm>
31032 </para>
31033 <informaltable frame="all">
31034 <tgroup cols="4" colsep="0" rowsep="0">
31035 <colspec colwidth="8*" align="left"/>
31036 <colspec colwidth="6*" align="center"/>
31037 <colspec colwidth="6*" align="center"/>
31038 <colspec colwidth="6*" align="right"/>
31039 <tbody>
31040 <row>
31041 <entry><option>verify</option></entry>
31042 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
31043 <entry>Type: <emphasis>boolean</emphasis></entry>
31044 <entry>Default: <emphasis>true</emphasis></entry>
31045 </row>
31046 </tbody>
31047 </tgroup>
31048 </informaltable>
31049 <para>
31050 Setting this option has the effect of setting <option>verify_sender</option> and
31051 <option>verify_recipient</option> to the same value.
31052 </para>
31053 <para>
31054 <indexterm role="option">
31055 <primary><option>verify_only</option></primary>
31056 </indexterm>
31057 </para>
31058 <informaltable frame="all">
31059 <tgroup cols="4" colsep="0" rowsep="0">
31060 <colspec colwidth="8*" align="left"/>
31061 <colspec colwidth="6*" align="center"/>
31062 <colspec colwidth="6*" align="center"/>
31063 <colspec colwidth="6*" align="right"/>
31064 <tbody>
31065 <row>
31066 <entry><option>verify_only</option></entry>
31067 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
31068 <entry>Type: <emphasis>boolean</emphasis></entry>
31069 <entry>Default: <emphasis>false</emphasis></entry>
31070 </row>
31071 </tbody>
31072 </tgroup>
31073 </informaltable>
31074 <para>
31075 <indexterm role="concept">
31076 <primary>EXPN</primary>
31077 <secondary>with <option>verify_only</option></secondary>
31078 </indexterm>
31079 <indexterm role="option">
31080 <primary><option>-bv</option></primary>
31081 </indexterm>
31082 <indexterm role="concept">
31083 <primary>router</primary>
31084 <secondary>used only when verifying</secondary>
31085 </indexterm>
31086 If this option is set, the router is used only when verifying an address or
31087 testing with the <option>-bv</option> option, not when actually doing a delivery, testing
31088 with the <option>-bt</option> option, or running the SMTP EXPN command. It can be further
31089 restricted to verifying only senders or recipients by means of
31090 <option>verify_sender</option> and <option>verify_recipient</option>.
31091 </para>
31092 <para>
31093 <emphasis role="bold">Warning</emphasis>: When the router is being run to verify addresses for an incoming
31094 SMTP message, Exim is not running as root, but under its own uid. If the router
31095 accesses any files, you need to make sure that they are accessible to the Exim
31096 user or group.
31097 </para>
31098 <para>
31099 <indexterm role="option">
31100 <primary><option>verify_recipient</option></primary>
31101 </indexterm>
31102 </para>
31103 <informaltable frame="all">
31104 <tgroup cols="4" colsep="0" rowsep="0">
31105 <colspec colwidth="8*" align="left"/>
31106 <colspec colwidth="6*" align="center"/>
31107 <colspec colwidth="6*" align="center"/>
31108 <colspec colwidth="6*" align="right"/>
31109 <tbody>
31110 <row>
31111 <entry><option>verify_recipient</option></entry>
31112 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
31113 <entry>Type: <emphasis>boolean</emphasis></entry>
31114 <entry>Default: <emphasis>true</emphasis></entry>
31115 </row>
31116 </tbody>
31117 </tgroup>
31118 </informaltable>
31119 <para>
31120 If this option is false, the router is skipped when verifying recipient
31121 addresses
31122 or testing recipient verification using <option>-bv</option>.
31123 See section <xref linkend="SECTrouprecon"/> for a list of the order in which preconditions
31124 are evaluated.
31125 </para>
31126 <para>
31127 <indexterm role="option">
31128 <primary><option>verify_sender</option></primary>
31129 </indexterm>
31130 </para>
31131 <informaltable frame="all">
31132 <tgroup cols="4" colsep="0" rowsep="0">
31133 <colspec colwidth="8*" align="left"/>
31134 <colspec colwidth="6*" align="center"/>
31135 <colspec colwidth="6*" align="center"/>
31136 <colspec colwidth="6*" align="right"/>
31137 <tbody>
31138 <row>
31139 <entry><option>verify_sender</option></entry>
31140 <entry>Use: <emphasis>routers</emphasis>&Dagger;<emphasis></emphasis></entry>
31141 <entry>Type: <emphasis>boolean</emphasis></entry>
31142 <entry>Default: <emphasis>true</emphasis></entry>
31143 </row>
31144 </tbody>
31145 </tgroup>
31146 </informaltable>
31147 <para>
31148 If this option is false, the router is skipped when verifying sender addresses
31149 or testing sender verification using <option>-bvs</option>.
31150 See section <xref linkend="SECTrouprecon"/> for a list of the order in which preconditions
31151 are evaluated.
31152 <indexterm role="concept" startref="IIDgenoprou1" class="endofrange"/>
31153 <indexterm role="concept" startref="IIDgenoprou2" class="endofrange"/>
31154 </para>
31155 </chapter>
31156
31157 <chapter id="CHID4">
31158 <title>The accept router</title>
31159 <para>
31160 <indexterm role="concept">
31161 <primary><command>accept</command> router</primary>
31162 </indexterm>
31163 <indexterm role="concept">
31164 <primary>routers</primary>
31165 <secondary><command>accept</command></secondary>
31166 </indexterm>
31167 The <command>accept</command> router has no private options of its own. Unless it is being
31168 used purely for verification (see <option>verify_only</option>) a transport is required to
31169 be defined by the generic <option>transport</option> option. If the preconditions that are
31170 specified by generic options are met, the router accepts the address and queues
31171 it for the given transport. The most common use of this router is for setting
31172 up deliveries to local mailboxes. For example:
31173 </para>
31174 <literallayout class="monospaced">
31175 localusers:
31176   driver = accept
31177   domains = mydomain.example
31178   check_local_user
31179   transport = local_delivery
31180 </literallayout>
31181 <para>
31182 The <option>domains</option> condition in this example checks the domain of the address, and
31183 <option>check_local_user</option> checks that the local part is the login of a local user.
31184 When both preconditions are met, the <command>accept</command> router runs, and queues the
31185 address for the <command>local_delivery</command> transport.
31186 </para>
31187 </chapter>
31188
31189 <chapter id="CHAPdnslookup">
31190 <title>The dnslookup router</title>
31191 <para>
31192 <indexterm role="concept" id="IIDdnsrou1" class="startofrange">
31193 <primary><command>dnslookup</command> router</primary>
31194 </indexterm>
31195 <indexterm role="concept" id="IIDdnsrou2" class="startofrange">
31196 <primary>routers</primary>
31197 <secondary><command>dnslookup</command></secondary>
31198 </indexterm>
31199 The <command>dnslookup</command> router looks up the hosts that handle mail for the
31200 recipient&#x2019;s domain in the DNS. A transport must always be set for this router,
31201 unless <option>verify_only</option> is set.
31202 </para>
31203 <para>
31204 If SRV support is configured (see <option>check_srv</option> below), Exim first searches for
31205 SRV records. If none are found, or if SRV support is not configured,
31206 MX records are looked up. If no MX records exist, address records are sought.
31207 However, <option>mx_domains</option> can be set to disable the direct use of address
31208 records.
31209 </para>
31210 <para>
31211 MX records of equal priority are sorted by Exim into a random order. Exim then
31212 looks for address records for the host names obtained from MX or SRV records.
31213 When a host has more than one IP address, they are sorted into a random order,
31214 except that IPv6 addresses are always sorted before IPv4 addresses. If all the
31215 IP addresses found are discarded by a setting of the <option>ignore_target_hosts</option>
31216 generic option, the router declines.
31217 </para>
31218 <para>
31219 Unless they have the highest priority (lowest MX value), MX records that point
31220 to the local host, or to any host name that matches <option>hosts_treat_as_local</option>,
31221 are discarded, together with any other MX records of equal or lower priority.
31222 </para>
31223 <para>
31224 <indexterm role="concept">
31225 <primary>MX record</primary>
31226 <secondary>pointing to local host</secondary>
31227 </indexterm>
31228 <indexterm role="concept">
31229 <primary>local host</primary>
31230 <secondary>MX pointing to</secondary>
31231 </indexterm>
31232 <indexterm role="option">
31233 <primary><option>self</option></primary>
31234 <secondary>in <command>dnslookup</command> router</secondary>
31235 </indexterm>
31236 If the host pointed to by the highest priority MX record, or looked up as an
31237 address record, is the local host, or matches <option>hosts_treat_as_local</option>, what
31238 happens is controlled by the generic <option>self</option> option.
31239 </para>
31240 <section id="SECTprowitdnsloo">
31241 <title>Problems with DNS lookups</title>
31242 <para>
31243 There have been problems with DNS servers when SRV records are looked up.
31244 Some mis-behaving servers return a DNS error or timeout when a non-existent
31245 SRV record is sought. Similar problems have in the past been reported for
31246 MX records. The global <option>dns_again_means_nonexist</option> option can help with this
31247 problem, but it is heavy-handed because it is a global option.
31248 </para>
31249 <para>
31250 For this reason, there are two options, <option>srv_fail_domains</option> and
31251 <option>mx_fail_domains</option>, that control what happens when a DNS lookup in a
31252 <command>dnslookup</command> router results in a DNS failure or a <quote>try again</quote> response. If
31253 an attempt to look up an SRV or MX record causes one of these results, and the
31254 domain matches the relevant list, Exim behaves as if the DNS had responded <quote>no
31255 such record</quote>. In the case of an SRV lookup, this means that the router
31256 proceeds to look for MX records; in the case of an MX lookup, it proceeds to
31257 look for A or AAAA records, unless the domain matches <option>mx_domains</option>, in which
31258 case routing fails.
31259 </para>
31260 </section>
31261 <section id="SECID118">
31262 <title>Private options for dnslookup</title>
31263 <para>
31264 <indexterm role="concept">
31265 <primary>options</primary>
31266 <secondary><command>dnslookup</command> router</secondary>
31267 </indexterm>
31268 The private options for the <command>dnslookup</command> router are as follows:
31269 </para>
31270 <para>
31271 <indexterm role="option">
31272 <primary><option>check_secondary_mx</option></primary>
31273 </indexterm>
31274 </para>
31275 <informaltable frame="all">
31276 <tgroup cols="4" colsep="0" rowsep="0">
31277 <colspec colwidth="8*" align="left"/>
31278 <colspec colwidth="6*" align="center"/>
31279 <colspec colwidth="6*" align="center"/>
31280 <colspec colwidth="6*" align="right"/>
31281 <tbody>
31282 <row>
31283 <entry><option>check_secondary_mx</option></entry>
31284 <entry>Use: <emphasis>dnslookup</emphasis></entry>
31285 <entry>Type: <emphasis>boolean</emphasis></entry>
31286 <entry>Default: <emphasis>false</emphasis></entry>
31287 </row>
31288 </tbody>
31289 </tgroup>
31290 </informaltable>
31291 <para>
31292 <indexterm role="concept">
31293 <primary>MX record</primary>
31294 <secondary>checking for secondary</secondary>
31295 </indexterm>
31296 If this option is set, the router declines unless the local host is found in
31297 (and removed from) the list of hosts obtained by MX lookup. This can be used to
31298 process domains for which the local host is a secondary mail exchanger
31299 differently to other domains. The way in which Exim decides whether a host is
31300 the local host is described in section <xref linkend="SECTreclocipadd"/>.
31301 </para>
31302 <para>
31303 <indexterm role="option">
31304 <primary><option>check_srv</option></primary>
31305 </indexterm>
31306 </para>
31307 <informaltable frame="all">
31308 <tgroup cols="4" colsep="0" rowsep="0">
31309 <colspec colwidth="8*" align="left"/>
31310 <colspec colwidth="6*" align="center"/>
31311 <colspec colwidth="6*" align="center"/>
31312 <colspec colwidth="6*" align="right"/>
31313 <tbody>
31314 <row>
31315 <entry><option>check_srv</option></entry>
31316 <entry>Use: <emphasis>dnslookup</emphasis></entry>
31317 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
31318 <entry>Default: <emphasis>unset</emphasis></entry>
31319 </row>
31320 </tbody>
31321 </tgroup>
31322 </informaltable>
31323 <para>
31324 <indexterm role="concept">
31325 <primary>SRV record</primary>
31326 <secondary>enabling use of</secondary>
31327 </indexterm>
31328 The <command>dnslookup</command> router supports the use of SRV records (see RFC 2782) in
31329 addition to MX and address records. The support is disabled by default. To
31330 enable SRV support, set the <option>check_srv</option> option to the name of the service
31331 required. For example,
31332 </para>
31333 <literallayout class="monospaced">
31334 check_srv = smtp
31335 </literallayout>
31336 <para>
31337 looks for SRV records that refer to the normal smtp service. The option is
31338 expanded, so the service name can vary from message to message or address
31339 to address. This might be helpful if SRV records are being used for a
31340 submission service. If the expansion is forced to fail, the <option>check_srv</option>
31341 option is ignored, and the router proceeds to look for MX records in the
31342 normal way.
31343 </para>
31344 <para>
31345 When the expansion succeeds, the router searches first for SRV records for
31346 the given service (it assumes TCP protocol). A single SRV record with a
31347 host name that consists of just a single dot indicates <quote>no such service for
31348 this domain</quote>; if this is encountered, the router declines. If other kinds of
31349 SRV record are found, they are used to construct a host list for delivery
31350 according to the rules of RFC 2782. MX records are not sought in this case.
31351 </para>
31352 <para>
31353 When no SRV records are found, MX records (and address records) are sought in
31354 the traditional way. In other words, SRV records take precedence over MX
31355 records, just as MX records take precedence over address records. Note that
31356 this behaviour is not sanctioned by RFC 2782, though a previous draft RFC
31357 defined it. It is apparently believed that MX records are sufficient for email
31358 and that SRV records should not be used for this purpose. However, SRV records
31359 have an additional <quote>weight</quote> feature which some people might find useful when
31360 trying to split an SMTP load between hosts of different power.
31361 </para>
31362 <para>
31363 See section <xref linkend="SECTprowitdnsloo"/> above for a discussion of Exim&#x2019;s behaviour
31364 when there is a DNS lookup error.
31365 </para>
31366 <para>
31367 <indexterm role="option">
31368 <primary><option>mx_domains</option></primary>
31369 </indexterm>
31370 </para>
31371 <informaltable frame="all">
31372 <tgroup cols="4" colsep="0" rowsep="0">
31373 <colspec colwidth="8*" align="left"/>
31374 <colspec colwidth="6*" align="center"/>
31375 <colspec colwidth="6*" align="center"/>
31376 <colspec colwidth="6*" align="right"/>
31377 <tbody>
31378 <row>
31379 <entry><option>mx_domains</option></entry>
31380 <entry>Use: <emphasis>dnslookup</emphasis></entry>
31381 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
31382 <entry>Default: <emphasis>unset</emphasis></entry>
31383 </row>
31384 </tbody>
31385 </tgroup>
31386 </informaltable>
31387 <para>
31388 <indexterm role="concept">
31389 <primary>MX record</primary>
31390 <secondary>required to exist</secondary>
31391 </indexterm>
31392 <indexterm role="concept">
31393 <primary>SRV record</primary>
31394 <secondary>required to exist</secondary>
31395 </indexterm>
31396 A domain that matches <option>mx_domains</option> is required to have either an MX or an SRV
31397 record in order to be recognized. (The name of this option could be improved.)
31398 For example, if all the mail hosts in <emphasis>fict.example</emphasis> are known to have MX
31399 records, except for those in <emphasis>discworld.fict.example</emphasis>, you could use this
31400 setting:
31401 </para>
31402 <literallayout class="monospaced">
31403 mx_domains = ! *.discworld.fict.example : *.fict.example
31404 </literallayout>
31405 <para>
31406 This specifies that messages addressed to a domain that matches the list but
31407 has no MX record should be bounced immediately instead of being routed using
31408 the address record.
31409 </para>
31410 <para>
31411 <indexterm role="option">
31412 <primary><option>mx_fail_domains</option></primary>
31413 </indexterm>
31414 </para>
31415 <informaltable frame="all">
31416 <tgroup cols="4" colsep="0" rowsep="0">
31417 <colspec colwidth="8*" align="left"/>
31418 <colspec colwidth="6*" align="center"/>
31419 <colspec colwidth="6*" align="center"/>
31420 <colspec colwidth="6*" align="right"/>
31421 <tbody>
31422 <row>
31423 <entry><option>mx_fail_domains</option></entry>
31424 <entry>Use: <emphasis>dnslookup</emphasis></entry>
31425 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
31426 <entry>Default: <emphasis>unset</emphasis></entry>
31427 </row>
31428 </tbody>
31429 </tgroup>
31430 </informaltable>
31431 <para>
31432 If the DNS lookup for MX records for one of the domains in this list causes a
31433 DNS lookup error, Exim behaves as if no MX records were found. See section
31434 <xref linkend="SECTprowitdnsloo"/> for more discussion.
31435 </para>
31436 <para>
31437 <indexterm role="option">
31438 <primary><option>qualify_single</option></primary>
31439 </indexterm>
31440 </para>
31441 <informaltable frame="all">
31442 <tgroup cols="4" colsep="0" rowsep="0">
31443 <colspec colwidth="8*" align="left"/>
31444 <colspec colwidth="6*" align="center"/>
31445 <colspec colwidth="6*" align="center"/>
31446 <colspec colwidth="6*" align="right"/>
31447 <tbody>
31448 <row>
31449 <entry><option>qualify_single</option></entry>
31450 <entry>Use: <emphasis>dnslookup</emphasis></entry>
31451 <entry>Type: <emphasis>boolean</emphasis></entry>
31452 <entry>Default: <emphasis>true</emphasis></entry>
31453 </row>
31454 </tbody>
31455 </tgroup>
31456 </informaltable>
31457 <para>
31458 <indexterm role="concept">
31459 <primary>DNS</primary>
31460 <secondary>resolver options</secondary>
31461 </indexterm>
31462 <indexterm role="concept">
31463 <primary>DNS</primary>
31464 <secondary>qualifying single-component names</secondary>
31465 </indexterm>
31466 When this option is true, the resolver option RES_DEFNAMES is set for DNS
31467 lookups. Typically, but not standardly, this causes the resolver to qualify
31468 single-component names with the default domain. For example, on a machine
31469 called <emphasis>dictionary.ref.example</emphasis>, the domain <emphasis>thesaurus</emphasis> would be changed to
31470 <emphasis>thesaurus.ref.example</emphasis> inside the resolver. For details of what your
31471 resolver actually does, consult your man pages for <emphasis>resolver</emphasis> and
31472 <emphasis>resolv.conf</emphasis>.
31473 </para>
31474 <para>
31475 <indexterm role="option">
31476 <primary><option>rewrite_headers</option></primary>
31477 </indexterm>
31478 </para>
31479 <informaltable frame="all">
31480 <tgroup cols="4" colsep="0" rowsep="0">
31481 <colspec colwidth="8*" align="left"/>
31482 <colspec colwidth="6*" align="center"/>
31483 <colspec colwidth="6*" align="center"/>
31484 <colspec colwidth="6*" align="right"/>
31485 <tbody>
31486 <row>
31487 <entry><option>rewrite_headers</option></entry>
31488 <entry>Use: <emphasis>dnslookup</emphasis></entry>
31489 <entry>Type: <emphasis>boolean</emphasis></entry>
31490 <entry>Default: <emphasis>true</emphasis></entry>
31491 </row>
31492 </tbody>
31493 </tgroup>
31494 </informaltable>
31495 <para>
31496 <indexterm role="concept">
31497 <primary>rewriting</primary>
31498 <secondary>header lines</secondary>
31499 </indexterm>
31500 <indexterm role="concept">
31501 <primary>header lines</primary>
31502 <secondary>rewriting</secondary>
31503 </indexterm>
31504 If the domain name in the address that is being processed is not fully
31505 qualified, it may be expanded to its full form by a DNS lookup. For example, if
31506 an address is specified as <emphasis>dormouse@teaparty</emphasis>, the domain might be
31507 expanded to <emphasis>teaparty.wonderland.fict.example</emphasis>. Domain expansion can also
31508 occur as a result of setting the <option>widen_domains</option> option. If
31509 <option>rewrite_headers</option> is true, all occurrences of the abbreviated domain name in
31510 any <emphasis>Bcc:</emphasis>, <emphasis>Cc:</emphasis>, <emphasis>From:</emphasis>, <emphasis>Reply-to:</emphasis>, <emphasis>Sender:</emphasis>, and <emphasis>To:</emphasis>
31511 header lines of the message are rewritten with the full domain name.
31512 </para>
31513 <para>
31514 This option should be turned off only when it is known that no message is
31515 ever going to be sent outside an environment where the abbreviation makes
31516 sense.
31517 </para>
31518 <para>
31519 When an MX record is looked up in the DNS and matches a wildcard record, name
31520 servers normally return a record containing the name that has been looked up,
31521 making it impossible to detect whether a wildcard was present or not. However,
31522 some name servers have recently been seen to return the wildcard entry. If the
31523 name returned by a DNS lookup begins with an asterisk, it is not used for
31524 header rewriting.
31525 </para>
31526 <para>
31527 <indexterm role="option">
31528 <primary><option>same_domain_copy_routing</option></primary>
31529 </indexterm>
31530 </para>
31531 <informaltable frame="all">
31532 <tgroup cols="4" colsep="0" rowsep="0">
31533 <colspec colwidth="8*" align="left"/>
31534 <colspec colwidth="6*" align="center"/>
31535 <colspec colwidth="6*" align="center"/>
31536 <colspec colwidth="6*" align="right"/>
31537 <tbody>
31538 <row>
31539 <entry><option>same_domain_copy_routing</option></entry>
31540 <entry>Use: <emphasis>dnslookup</emphasis></entry>
31541 <entry>Type: <emphasis>boolean</emphasis></entry>
31542 <entry>Default: <emphasis>false</emphasis></entry>
31543 </row>
31544 </tbody>
31545 </tgroup>
31546 </informaltable>
31547 <para>
31548 <indexterm role="concept">
31549 <primary>address</primary>
31550 <secondary>copying routing</secondary>
31551 </indexterm>
31552 Addresses with the same domain are normally routed by the <command>dnslookup</command> router
31553 to the same list of hosts. However, this cannot be presumed, because the router
31554 options and preconditions may refer to the local part of the address. By
31555 default, therefore, Exim routes each address in a message independently. DNS
31556 servers run caches, so repeated DNS lookups are not normally expensive, and in
31557 any case, personal messages rarely have more than a few recipients.
31558 </para>
31559 <para>
31560 If you are running mailing lists with large numbers of subscribers at the same
31561 domain, and you are using a <command>dnslookup</command> router which is independent of the
31562 local part, you can set <option>same_domain_copy_routing</option> to bypass repeated DNS
31563 lookups for identical domains in one message. In this case, when <command>dnslookup</command>
31564 routes an address to a remote transport, any other unrouted addresses in the
31565 message that have the same domain are automatically given the same routing
31566 without processing them independently,
31567 provided the following conditions are met:
31568 </para>
31569 <itemizedlist>
31570 <listitem>
31571 <para>
31572 No router that processed the address specified <option>headers_add</option> or
31573 <option>headers_remove</option>.
31574 </para>
31575 </listitem>
31576 <listitem>
31577 <para>
31578 The router did not change the address in any way, for example, by <quote>widening</quote>
31579 the domain.
31580 </para>
31581 </listitem>
31582 </itemizedlist>
31583 <para>
31584 <indexterm role="option">
31585 <primary><option>search_parents</option></primary>
31586 </indexterm>
31587 </para>
31588 <informaltable frame="all">
31589 <tgroup cols="4" colsep="0" rowsep="0">
31590 <colspec colwidth="8*" align="left"/>
31591 <colspec colwidth="6*" align="center"/>
31592 <colspec colwidth="6*" align="center"/>
31593 <colspec colwidth="6*" align="right"/>
31594 <tbody>
31595 <row>
31596 <entry><option>search_parents</option></entry>
31597 <entry>Use: <emphasis>dnslookup</emphasis></entry>
31598 <entry>Type: <emphasis>boolean</emphasis></entry>
31599 <entry>Default: <emphasis>false</emphasis></entry>
31600 </row>
31601 </tbody>
31602 </tgroup>
31603 </informaltable>
31604 <para>
31605 <indexterm role="concept">
31606 <primary>DNS</primary>
31607 <secondary>resolver options</secondary>
31608 </indexterm>
31609 When this option is true, the resolver option RES_DNSRCH is set for DNS
31610 lookups. This is different from the <option>qualify_single</option> option in that it
31611 applies to domains containing dots. Typically, but not standardly, it causes
31612 the resolver to search for the name in the current domain and in parent
31613 domains. For example, on a machine in the <emphasis>fict.example</emphasis> domain, if looking
31614 up <emphasis>teaparty.wonderland</emphasis> failed, the resolver would try
31615 <emphasis>teaparty.wonderland.fict.example</emphasis>. For details of what your resolver
31616 actually does, consult your man pages for <emphasis>resolver</emphasis> and <emphasis>resolv.conf</emphasis>.
31617 </para>
31618 <para>
31619 Setting this option true can cause problems in domains that have a wildcard MX
31620 record, because any domain that does not have its own MX record matches the
31621 local wildcard.
31622 </para>
31623 <para>
31624 <indexterm role="option">
31625 <primary><option>srv_fail_domains</option></primary>
31626 </indexterm>
31627 </para>
31628 <informaltable frame="all">
31629 <tgroup cols="4" colsep="0" rowsep="0">
31630 <colspec colwidth="8*" align="left"/>
31631 <colspec colwidth="6*" align="center"/>
31632 <colspec colwidth="6*" align="center"/>
31633 <colspec colwidth="6*" align="right"/>
31634 <tbody>
31635 <row>
31636 <entry><option>srv_fail_domains</option></entry>
31637 <entry>Use: <emphasis>dnslookup</emphasis></entry>
31638 <entry>Type: <emphasis>domain list</emphasis>&dagger;<emphasis></emphasis></entry>
31639 <entry>Default: <emphasis>unset</emphasis></entry>
31640 </row>
31641 </tbody>
31642 </tgroup>
31643 </informaltable>
31644 <para>
31645 If the DNS lookup for SRV records for one of the domains in this list causes a
31646 DNS lookup error, Exim behaves as if no SRV records were found. See section
31647 <xref linkend="SECTprowitdnsloo"/> for more discussion.
31648 </para>
31649 <para>
31650 <indexterm role="option">
31651 <primary><option>widen_domains</option></primary>
31652 </indexterm>
31653 </para>
31654 <informaltable frame="all">
31655 <tgroup cols="4" colsep="0" rowsep="0">
31656 <colspec colwidth="8*" align="left"/>
31657 <colspec colwidth="6*" align="center"/>
31658 <colspec colwidth="6*" align="center"/>
31659 <colspec colwidth="6*" align="right"/>
31660 <tbody>
31661 <row>
31662 <entry><option>widen_domains</option></entry>
31663 <entry>Use: <emphasis>dnslookup</emphasis></entry>
31664 <entry>Type: <emphasis>string list</emphasis></entry>
31665 <entry>Default: <emphasis>unset</emphasis></entry>
31666 </row>
31667 </tbody>
31668 </tgroup>
31669 </informaltable>
31670 <para>
31671 <indexterm role="concept">
31672 <primary>domain</primary>
31673 <secondary>partial; widening</secondary>
31674 </indexterm>
31675 If a DNS lookup fails and this option is set, each of its strings in turn is
31676 added onto the end of the domain, and the lookup is tried again. For example,
31677 if
31678 </para>
31679 <literallayout class="monospaced">
31680 widen_domains = fict.example:ref.example
31681 </literallayout>
31682 <para>
31683 is set and a lookup of <emphasis>klingon.dictionary</emphasis> fails,
31684 <emphasis>klingon.dictionary.fict.example</emphasis> is looked up, and if this fails,
31685 <emphasis>klingon.dictionary.ref.example</emphasis> is tried. Note that the <option>qualify_single</option>
31686 and <option>search_parents</option> options can cause some widening to be undertaken inside
31687 the DNS resolver. <option>widen_domains</option> is not applied to sender addresses
31688 when verifying, unless <option>rewrite_headers</option> is false (not the default).
31689 </para>
31690 </section>
31691 <section id="SECID119">
31692 <title>Effect of qualify_single and search_parents</title>
31693 <para>
31694 When a domain from an envelope recipient is changed by the resolver as a result
31695 of the <option>qualify_single</option> or <option>search_parents</option> options, Exim rewrites the
31696 corresponding address in the message&#x2019;s header lines unless <option>rewrite_headers</option>
31697 is set false. Exim then re-routes the address, using the full domain.
31698 </para>
31699 <para>
31700 These two options affect only the DNS lookup that takes place inside the router
31701 for the domain of the address that is being routed. They do not affect lookups
31702 such as that implied by
31703 </para>
31704 <literallayout class="monospaced">
31705 domains = @mx_any
31706 </literallayout>
31707 <para>
31708 that may happen while processing a router precondition before the router is
31709 entered. No widening ever takes place for these lookups.
31710 <indexterm role="concept" startref="IIDdnsrou1" class="endofrange"/>
31711 <indexterm role="concept" startref="IIDdnsrou2" class="endofrange"/>
31712 </para>
31713 </section>
31714 </chapter>
31715
31716 <chapter id="CHID5">
31717 <title>The ipliteral router</title>
31718 <para>
31719 <indexterm role="concept">
31720 <primary><command>ipliteral</command> router</primary>
31721 </indexterm>
31722 <indexterm role="concept">
31723 <primary>domain literal</primary>
31724 <secondary>routing</secondary>
31725 </indexterm>
31726 <indexterm role="concept">
31727 <primary>routers</primary>
31728 <secondary><command>ipliteral</command></secondary>
31729 </indexterm>
31730 This router has no private options. Unless it is being used purely for
31731 verification (see <option>verify_only</option>) a transport is required to be defined by the
31732 generic <option>transport</option> option. The router accepts the address if its domain part
31733 takes the form of an RFC 2822 domain literal. For example, the <command>ipliteral</command>
31734 router handles the address
31735 </para>
31736 <literallayout class="monospaced">
31737 root@[192.168.1.1]
31738 </literallayout>
31739 <para>
31740 by setting up delivery to the host with that IP address. IPv4 domain literals
31741 consist of an IPv4 address enclosed in square brackets. IPv6 domain literals
31742 are similar, but the address is preceded by <literal>ipv6:</literal>. For example:
31743 </para>
31744 <literallayout class="monospaced">
31745 postmaster@[ipv6:fe80::a00:20ff:fe86:a061.5678]
31746 </literallayout>
31747 <para>
31748 Exim allows <literal>ipv4:</literal> before IPv4 addresses, for consistency, and on the
31749 grounds that sooner or later somebody will try it.
31750 </para>
31751 <para>
31752 <indexterm role="option">
31753 <primary><option>self</option></primary>
31754 <secondary>in <command>ipliteral</command> router</secondary>
31755 </indexterm>
31756 If the IP address matches something in <option>ignore_target_hosts</option>, the router
31757 declines. If an IP literal turns out to refer to the local host, the generic
31758 <option>self</option> option determines what happens.
31759 </para>
31760 <para>
31761 The RFCs require support for domain literals; however, their use is
31762 controversial in today&#x2019;s Internet. If you want to use this router, you must
31763 also set the main configuration option <option>allow_domain_literals</option>. Otherwise,
31764 Exim will not recognize the domain literal syntax in addresses.
31765 </para>
31766 </chapter>
31767
31768 <chapter id="CHID6">
31769 <title>The iplookup router</title>
31770 <para>
31771 <indexterm role="concept">
31772 <primary><command>iplookup</command> router</primary>
31773 </indexterm>
31774 <indexterm role="concept">
31775 <primary>routers</primary>
31776 <secondary><command>iplookup</command></secondary>
31777 </indexterm>
31778 The <command>iplookup</command> router was written to fulfil a specific requirement in
31779 Cambridge University (which in fact no longer exists). For this reason, it is
31780 not included in the binary of Exim by default. If you want to include it, you
31781 must set
31782 </para>
31783 <literallayout class="monospaced">
31784 ROUTER_IPLOOKUP=yes
31785 </literallayout>
31786 <para>
31787 in your <filename>Local/Makefile</filename> configuration file.
31788 </para>
31789 <para>
31790 The <command>iplookup</command> router routes an address by sending it over a TCP or UDP
31791 connection to one or more specific hosts. The host can then return the same or
31792 a different address &ndash; in effect rewriting the recipient address in the
31793 message&#x2019;s envelope. The new address is then passed on to subsequent routers. If
31794 this process fails, the address can be passed on to other routers, or delivery
31795 can be deferred. Since <command>iplookup</command> is just a rewriting router, a transport
31796 must not be specified for it.
31797 </para>
31798 <para>
31799 <indexterm role="concept">
31800 <primary>options</primary>
31801 <secondary><command>iplookup</command> router</secondary>
31802 </indexterm>
31803 <indexterm role="option">
31804 <primary><option>hosts</option></primary>
31805 </indexterm>
31806 </para>
31807 <informaltable frame="all">
31808 <tgroup cols="4" colsep="0" rowsep="0">
31809 <colspec colwidth="8*" align="left"/>
31810 <colspec colwidth="6*" align="center"/>
31811 <colspec colwidth="6*" align="center"/>
31812 <colspec colwidth="6*" align="right"/>
31813 <tbody>
31814 <row>
31815 <entry><option>hosts</option></entry>
31816 <entry>Use: <emphasis>iplookup</emphasis></entry>
31817 <entry>Type: <emphasis>string</emphasis></entry>
31818 <entry>Default: <emphasis>unset</emphasis></entry>
31819 </row>
31820 </tbody>
31821 </tgroup>
31822 </informaltable>
31823 <para>
31824 This option must be supplied. Its value is a colon-separated list of host
31825 names. The hosts are looked up using <function>gethostbyname()</function>
31826 (or <function>getipnodebyname()</function> when available)
31827 and are tried in order until one responds to the query. If none respond, what
31828 happens is controlled by <option>optional</option>.
31829 </para>
31830 <para>
31831 <indexterm role="option">
31832 <primary><option>optional</option></primary>
31833 </indexterm>
31834 </para>
31835 <informaltable frame="all">
31836 <tgroup cols="4" colsep="0" rowsep="0">
31837 <colspec colwidth="8*" align="left"/>
31838 <colspec colwidth="6*" align="center"/>
31839 <colspec colwidth="6*" align="center"/>
31840 <colspec colwidth="6*" align="right"/>
31841 <tbody>
31842 <row>
31843 <entry><option>optional</option></entry>
31844 <entry>Use: <emphasis>iplookup</emphasis></entry>
31845 <entry>Type: <emphasis>boolean</emphasis></entry>
31846 <entry>Default: <emphasis>false</emphasis></entry>
31847 </row>
31848 </tbody>
31849 </tgroup>
31850 </informaltable>
31851 <para>
31852 If <option>optional</option> is true, if no response is obtained from any host, the address
31853 is passed to the next router, overriding <option>no_more</option>. If <option>optional</option> is false,
31854 delivery to the address is deferred.
31855 </para>
31856 <para>
31857 <indexterm role="option">
31858 <primary><option>port</option></primary>
31859 </indexterm>
31860 </para>
31861 <informaltable frame="all">
31862 <tgroup cols="4" colsep="0" rowsep="0">
31863 <colspec colwidth="8*" align="left"/>
31864 <colspec colwidth="6*" align="center"/>
31865 <colspec colwidth="6*" align="center"/>
31866 <colspec colwidth="6*" align="right"/>
31867 <tbody>
31868 <row>
31869 <entry><option>port</option></entry>
31870 <entry>Use: <emphasis>iplookup</emphasis></entry>
31871 <entry>Type: <emphasis>integer</emphasis></entry>
31872 <entry>Default: <emphasis>0</emphasis></entry>
31873 </row>
31874 </tbody>
31875 </tgroup>
31876 </informaltable>
31877 <para>
31878 <indexterm role="concept">
31879 <primary>port</primary>
31880 <secondary><command>iplookup</command> router</secondary>
31881 </indexterm>
31882 This option must be supplied. It specifies the port number for the TCP or UDP
31883 call.
31884 </para>
31885 <para>
31886 <indexterm role="option">
31887 <primary><option>protocol</option></primary>
31888 </indexterm>
31889 </para>
31890 <informaltable frame="all">
31891 <tgroup cols="4" colsep="0" rowsep="0">
31892 <colspec colwidth="8*" align="left"/>
31893 <colspec colwidth="6*" align="center"/>
31894 <colspec colwidth="6*" align="center"/>
31895 <colspec colwidth="6*" align="right"/>
31896 <tbody>
31897 <row>
31898 <entry><option>protocol</option></entry>
31899 <entry>Use: <emphasis>iplookup</emphasis></entry>
31900 <entry>Type: <emphasis>string</emphasis></entry>
31901 <entry>Default: <emphasis>udp</emphasis></entry>
31902 </row>
31903 </tbody>
31904 </tgroup>
31905 </informaltable>
31906 <para>
31907 This option can be set to <quote>udp</quote> or <quote>tcp</quote> to specify which of the two
31908 protocols is to be used.
31909 </para>
31910 <para>
31911 <indexterm role="option">
31912 <primary><option>query</option></primary>
31913 </indexterm>
31914 </para>
31915 <informaltable frame="all">
31916 <tgroup cols="4" colsep="0" rowsep="0">
31917 <colspec colwidth="8*" align="left"/>
31918 <colspec colwidth="6*" align="center"/>
31919 <colspec colwidth="6*" align="center"/>
31920 <colspec colwidth="6*" align="right"/>
31921 <tbody>
31922 <row>
31923 <entry><option>query</option></entry>
31924 <entry>Use: <emphasis>iplookup</emphasis></entry>
31925 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
31926 <entry>Default: <emphasis>see below</emphasis></entry>
31927 </row>
31928 </tbody>
31929 </tgroup>
31930 </informaltable>
31931 <para>
31932 This defines the content of the query that is sent to the remote hosts. The
31933 default value is:
31934 </para>
31935 <literallayout class="monospaced">
31936 $local_part@$domain $local_part@$domain
31937 </literallayout>
31938 <para>
31939 The repetition serves as a way of checking that a response is to the correct
31940 query in the default case (see <option>response_pattern</option> below).
31941 </para>
31942 <para>
31943 <indexterm role="option">
31944 <primary><option>reroute</option></primary>
31945 </indexterm>
31946 </para>
31947 <informaltable frame="all">
31948 <tgroup cols="4" colsep="0" rowsep="0">
31949 <colspec colwidth="8*" align="left"/>
31950 <colspec colwidth="6*" align="center"/>
31951 <colspec colwidth="6*" align="center"/>
31952 <colspec colwidth="6*" align="right"/>
31953 <tbody>
31954 <row>
31955 <entry><option>reroute</option></entry>
31956 <entry>Use: <emphasis>iplookup</emphasis></entry>
31957 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
31958 <entry>Default: <emphasis>unset</emphasis></entry>
31959 </row>
31960 </tbody>
31961 </tgroup>
31962 </informaltable>
31963 <para>
31964 If this option is not set, the rerouted address is precisely the byte string
31965 returned by the remote host, up to the first white space, if any. If set, the
31966 string is expanded to form the rerouted address. It can include parts matched
31967 in the response by <option>response_pattern</option> by means of numeric variables such as
31968 <varname>$1</varname>, <varname>$2</varname>, etc. The variable <varname>$0</varname> refers to the entire input string,
31969 whether or not a pattern is in use. In all cases, the rerouted address must end
31970 up in the form <emphasis>local_part@domain</emphasis>.
31971 </para>
31972 <para>
31973 <indexterm role="option">
31974 <primary><option>response_pattern</option></primary>
31975 </indexterm>
31976 </para>
31977 <informaltable frame="all">
31978 <tgroup cols="4" colsep="0" rowsep="0">
31979 <colspec colwidth="8*" align="left"/>
31980 <colspec colwidth="6*" align="center"/>
31981 <colspec colwidth="6*" align="center"/>
31982 <colspec colwidth="6*" align="right"/>
31983 <tbody>
31984 <row>
31985 <entry><option>response_pattern</option></entry>
31986 <entry>Use: <emphasis>iplookup</emphasis></entry>
31987 <entry>Type: <emphasis>string</emphasis></entry>
31988 <entry>Default: <emphasis>unset</emphasis></entry>
31989 </row>
31990 </tbody>
31991 </tgroup>
31992 </informaltable>
31993 <para>
31994 This option can be set to a regular expression that is applied to the string
31995 returned from the remote host. If the pattern does not match the response, the
31996 router declines. If <option>response_pattern</option> is not set, no checking of the
31997 response is done, unless the query was defaulted, in which case there is a
31998 check that the text returned after the first white space is the original
31999 address. This checks that the answer that has been received is in response to
32000 the correct question. For example, if the response is just a new domain, the
32001 following could be used:
32002 </para>
32003 <literallayout class="monospaced">
32004 response_pattern = ^([^@]+)$
32005 reroute = $local_part@$1
32006 </literallayout>
32007 <para>
32008 <indexterm role="option">
32009 <primary><option>timeout</option></primary>
32010 </indexterm>
32011 </para>
32012 <informaltable frame="all">
32013 <tgroup cols="4" colsep="0" rowsep="0">
32014 <colspec colwidth="8*" align="left"/>
32015 <colspec colwidth="6*" align="center"/>
32016 <colspec colwidth="6*" align="center"/>
32017 <colspec colwidth="6*" align="right"/>
32018 <tbody>
32019 <row>
32020 <entry><option>timeout</option></entry>
32021 <entry>Use: <emphasis>iplookup</emphasis></entry>
32022 <entry>Type: <emphasis>time</emphasis></entry>
32023 <entry>Default: <emphasis>5s</emphasis></entry>
32024 </row>
32025 </tbody>
32026 </tgroup>
32027 </informaltable>
32028 <para>
32029 This specifies the amount of time to wait for a response from the remote
32030 machine. The same timeout is used for the <function>connect()</function> function for a TCP
32031 call. It does not apply to UDP.
32032 </para>
32033 </chapter>
32034
32035 <chapter id="CHID7">
32036 <title>The manualroute router</title>
32037 <para>
32038 <indexterm role="concept" id="IIDmanrou1" class="startofrange">
32039 <primary><command>manualroute</command> router</primary>
32040 </indexterm>
32041 <indexterm role="concept" id="IIDmanrou2" class="startofrange">
32042 <primary>routers</primary>
32043 <secondary><command>manualroute</command></secondary>
32044 </indexterm>
32045 <indexterm role="concept">
32046 <primary>domain</primary>
32047 <secondary>manually routing</secondary>
32048 </indexterm>
32049 The <command>manualroute</command> router is so-called because it provides a way of manually
32050 routing an address according to its domain. It is mainly used when you want to
32051 route addresses to remote hosts according to your own rules, bypassing the
32052 normal DNS routing that looks up MX records. However, <command>manualroute</command> can also
32053 route to local transports, a facility that may be useful if you want to save
32054 messages for dial-in hosts in local files.
32055 </para>
32056 <para>
32057 The <command>manualroute</command> router compares a list of domain patterns with the domain
32058 it is trying to route. If there is no match, the router declines. Each pattern
32059 has associated with it a list of hosts and some other optional data, which may
32060 include a transport. The combination of a pattern and its data is called a
32061 <quote>routing rule</quote>. For patterns that do not have an associated transport, the
32062 generic <option>transport</option> option must specify a transport, unless the router is
32063 being used purely for verification (see <option>verify_only</option>).
32064 </para>
32065 <para>
32066 <indexterm role="variable">
32067 <primary><varname>$host</varname></primary>
32068 </indexterm>
32069 In the case of verification, matching the domain pattern is sufficient for the
32070 router to accept the address. When actually routing an address for delivery,
32071 an address that matches a domain pattern is queued for the associated
32072 transport. If the transport is not a local one, a host list must be associated
32073 with the pattern; IP addresses are looked up for the hosts, and these are
32074 passed to the transport along with the mail address. For local transports, a
32075 host list is optional. If it is present, it is passed in <varname>$host</varname> as a single
32076 text string.
32077 </para>
32078 <para>
32079 The list of routing rules can be provided as an inline string in
32080 <option>route_list</option>, or the data can be obtained by looking up the domain in a file
32081 or database by setting <option>route_data</option>. Only one of these settings may appear in
32082 any one instance of <command>manualroute</command>. The format of routing rules is described
32083 below, following the list of private options.
32084 </para>
32085 <section id="SECTprioptman">
32086 <title>Private options for manualroute</title>
32087 <para>
32088 <indexterm role="concept">
32089 <primary>options</primary>
32090 <secondary><command>manualroute</command> router</secondary>
32091 </indexterm>
32092 The private options for the <command>manualroute</command> router are as follows:
32093 </para>
32094 <para>
32095 <indexterm role="option">
32096 <primary><option>host_all_ignored</option></primary>
32097 </indexterm>
32098 </para>
32099 <informaltable frame="all">
32100 <tgroup cols="4" colsep="0" rowsep="0">
32101 <colspec colwidth="8*" align="left"/>
32102 <colspec colwidth="6*" align="center"/>
32103 <colspec colwidth="6*" align="center"/>
32104 <colspec colwidth="6*" align="right"/>
32105 <tbody>
32106 <row>
32107 <entry><option>host_all_ignored</option></entry>
32108 <entry>Use: <emphasis>manualroute</emphasis></entry>
32109 <entry>Type: <emphasis>string</emphasis></entry>
32110 <entry>Default: <emphasis>defer</emphasis></entry>
32111 </row>
32112 </tbody>
32113 </tgroup>
32114 </informaltable>
32115 <para>
32116 See <option>host_find_failed</option>.
32117 </para>
32118 <para>
32119 <indexterm role="option">
32120 <primary><option>host_find_failed</option></primary>
32121 </indexterm>
32122 </para>
32123 <informaltable frame="all">
32124 <tgroup cols="4" colsep="0" rowsep="0">
32125 <colspec colwidth="8*" align="left"/>
32126 <colspec colwidth="6*" align="center"/>
32127 <colspec colwidth="6*" align="center"/>
32128 <colspec colwidth="6*" align="right"/>
32129 <tbody>
32130 <row>
32131 <entry><option>host_find_failed</option></entry>
32132 <entry>Use: <emphasis>manualroute</emphasis></entry>
32133 <entry>Type: <emphasis>string</emphasis></entry>
32134 <entry>Default: <emphasis>freeze</emphasis></entry>
32135 </row>
32136 </tbody>
32137 </tgroup>
32138 </informaltable>
32139 <para>
32140 This option controls what happens when <command>manualroute</command> tries to find an IP
32141 address for a host, and the host does not exist. The option can be set to one
32142 of the following values:
32143 </para>
32144 <literallayout class="monospaced">
32145 decline
32146 defer
32147 fail
32148 freeze
32149 ignore
32150 pass
32151 </literallayout>
32152 <para>
32153 The default (<quote>freeze</quote>) assumes that this state is a serious configuration
32154 error. The difference between <quote>pass</quote> and <quote>decline</quote> is that the former
32155 forces the address to be passed to the next router (or the router defined by
32156 <option>pass_router</option>),
32157 <indexterm role="option">
32158 <primary><option>more</option></primary>
32159 </indexterm>
32160 overriding <option>no_more</option>, whereas the latter passes the address to the next
32161 router only if <option>more</option> is true.
32162 </para>
32163 <para>
32164 The value <quote>ignore</quote> causes Exim to completely ignore a host whose IP address
32165 cannot be found. If all the hosts in the list are ignored, the behaviour is
32166 controlled by the <option>host_all_ignored</option> option. This takes the same values
32167 as <option>host_find_failed</option>, except that it cannot be set to <quote>ignore</quote>.
32168 </para>
32169 <para>
32170 The <option>host_find_failed</option> option applies only to a definite <quote>does not exist</quote>
32171 state; if a host lookup gets a temporary error, delivery is deferred unless the
32172 generic <option>pass_on_timeout</option> option is set.
32173 </para>
32174 <para>
32175 <indexterm role="option">
32176 <primary><option>hosts_randomize</option></primary>
32177 </indexterm>
32178 </para>
32179 <informaltable frame="all">
32180 <tgroup cols="4" colsep="0" rowsep="0">
32181 <colspec colwidth="8*" align="left"/>
32182 <colspec colwidth="6*" align="center"/>
32183 <colspec colwidth="6*" align="center"/>
32184 <colspec colwidth="6*" align="right"/>
32185 <tbody>
32186 <row>
32187 <entry><option>hosts_randomize</option></entry>
32188 <entry>Use: <emphasis>manualroute</emphasis></entry>
32189 <entry>Type: <emphasis>boolean</emphasis></entry>
32190 <entry>Default: <emphasis>false</emphasis></entry>
32191 </row>
32192 </tbody>
32193 </tgroup>
32194 </informaltable>
32195 <para>
32196 <indexterm role="concept">
32197 <primary>randomized host list</primary>
32198 </indexterm>
32199 <indexterm role="concept">
32200 <primary>host</primary>
32201 <secondary>list of; randomized</secondary>
32202 </indexterm>
32203 If this option is set, the order of the items in a host list in a routing rule
32204 is randomized each time the list is used, unless an option in the routing rule
32205 overrides (see below). Randomizing the order of a host list can be used to do
32206 crude load sharing. However, if more than one mail address is routed by the
32207 same router to the same host list, the host lists are considered to be the same
32208 (even though they may be randomized into different orders) for the purpose of
32209 deciding whether to batch the deliveries into a single SMTP transaction.
32210 </para>
32211 <para>
32212 When <option>hosts_randomize</option> is true, a host list may be split
32213 into groups whose order is separately randomized. This makes it possible to
32214 set up MX-like behaviour. The boundaries between groups are indicated by an
32215 item that is just <literal>+</literal> in the host list. For example:
32216 </para>
32217 <literallayout class="monospaced">
32218 route_list = * host1:host2:host3:+:host4:host5
32219 </literallayout>
32220 <para>
32221 The order of the first three hosts and the order of the last two hosts is
32222 randomized for each use, but the first three always end up before the last two.
32223 If <option>hosts_randomize</option> is not set, a <literal>+</literal> item in the list is ignored. If a
32224 randomized host list is passed to an <command>smtp</command> transport that also has
32225 <option>hosts_randomize set</option>, the list is not re-randomized.
32226 </para>
32227 <para>
32228 <indexterm role="option">
32229 <primary><option>route_data</option></primary>
32230 </indexterm>
32231 </para>
32232 <informaltable frame="all">
32233 <tgroup cols="4" colsep="0" rowsep="0">
32234 <colspec colwidth="8*" align="left"/>
32235 <colspec colwidth="6*" align="center"/>
32236 <colspec colwidth="6*" align="center"/>
32237 <colspec colwidth="6*" align="right"/>
32238 <tbody>
32239 <row>
32240 <entry><option>route_data</option></entry>
32241 <entry>Use: <emphasis>manualroute</emphasis></entry>
32242 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
32243 <entry>Default: <emphasis>unset</emphasis></entry>
32244 </row>
32245 </tbody>
32246 </tgroup>
32247 </informaltable>
32248 <para>
32249 If this option is set, it must expand to yield the data part of a routing rule.
32250 Typically, the expansion string includes a lookup based on the domain. For
32251 example:
32252 </para>
32253 <literallayout class="monospaced">
32254 route_data = ${lookup{$domain}dbm{/etc/routes}}
32255 </literallayout>
32256 <para>
32257 If the expansion is forced to fail, or the result is an empty string, the
32258 router declines. Other kinds of expansion failure cause delivery to be
32259 deferred.
32260 </para>
32261 <para>
32262 <indexterm role="option">
32263 <primary><option>route_list</option></primary>
32264 </indexterm>
32265 </para>
32266 <informaltable frame="all">
32267 <tgroup cols="4" colsep="0" rowsep="0">
32268 <colspec colwidth="8*" align="left"/>
32269 <colspec colwidth="6*" align="center"/>
32270 <colspec colwidth="6*" align="center"/>
32271 <colspec colwidth="6*" align="right"/>
32272 <tbody>
32273 <row>
32274 <entry><option>route_list</option></entry>
32275 <entry>Use: <emphasis>manualroute</emphasis></entry>
32276 <entry>Type: <emphasis>string list</emphasis></entry>
32277 <entry>Default: <emphasis>unset</emphasis></entry>
32278 </row>
32279 </tbody>
32280 </tgroup>
32281 </informaltable>
32282 <para>
32283 This string is a list of routing rules, in the form defined below. Note that,
32284 unlike most string lists, the items are separated by semicolons. This is so
32285 that they may contain colon-separated host lists.
32286 </para>
32287 <para>
32288 <indexterm role="option">
32289 <primary><option>same_domain_copy_routing</option></primary>
32290 </indexterm>
32291 </para>
32292 <informaltable frame="all">
32293 <tgroup cols="4" colsep="0" rowsep="0">
32294 <colspec colwidth="8*" align="left"/>
32295 <colspec colwidth="6*" align="center"/>
32296 <colspec colwidth="6*" align="center"/>
32297 <colspec colwidth="6*" align="right"/>
32298 <tbody>
32299 <row>
32300 <entry><option>same_domain_copy_routing</option></entry>
32301 <entry>Use: <emphasis>manualroute</emphasis></entry>
32302 <entry>Type: <emphasis>boolean</emphasis></entry>
32303 <entry>Default: <emphasis>false</emphasis></entry>
32304 </row>
32305 </tbody>
32306 </tgroup>
32307 </informaltable>
32308 <para>
32309 <indexterm role="concept">
32310 <primary>address</primary>
32311 <secondary>copying routing</secondary>
32312 </indexterm>
32313 Addresses with the same domain are normally routed by the <command>manualroute</command>
32314 router to the same list of hosts. However, this cannot be presumed, because the
32315 router options and preconditions may refer to the local part of the address. By
32316 default, therefore, Exim routes each address in a message independently. DNS
32317 servers run caches, so repeated DNS lookups are not normally expensive, and in
32318 any case, personal messages rarely have more than a few recipients.
32319 </para>
32320 <para>
32321 If you are running mailing lists with large numbers of subscribers at the same
32322 domain, and you are using a <command>manualroute</command> router which is independent of the
32323 local part, you can set <option>same_domain_copy_routing</option> to bypass repeated DNS
32324 lookups for identical domains in one message. In this case, when
32325 <command>manualroute</command> routes an address to a remote transport, any other unrouted
32326 addresses in the message that have the same domain are automatically given the
32327 same routing without processing them independently. However, this is only done
32328 if <option>headers_add</option> and <option>headers_remove</option> are unset.
32329 </para>
32330 </section>
32331 <section id="SECID120">
32332 <title>Routing rules in route_list</title>
32333 <para>
32334 The value of <option>route_list</option> is a string consisting of a sequence of routing
32335 rules, separated by semicolons. If a semicolon is needed in a rule, it can be
32336 entered as two semicolons. Alternatively, the list separator can be changed as
32337 described (for colon-separated lists) in section <xref linkend="SECTlistconstruct"/>.
32338 Empty rules are ignored. The format of each rule is
32339 </para>
32340 <literallayout>
32341 &lt;<emphasis>domain pattern</emphasis>&gt;  &lt;<emphasis>list of hosts</emphasis>&gt;  &lt;<emphasis>options</emphasis>&gt;
32342 </literallayout>
32343 <para>
32344 The following example contains two rules, each with a simple domain pattern and
32345 no options:
32346 </para>
32347 <literallayout class="monospaced">
32348 route_list = \
32349   dict.ref.example  mail-1.ref.example:mail-2.ref.example ; \
32350   thes.ref.example  mail-3.ref.example:mail-4.ref.example
32351 </literallayout>
32352 <para>
32353 The three parts of a rule are separated by white space. The pattern and the
32354 list of hosts can be enclosed in quotes if necessary, and if they are, the
32355 usual quoting rules apply. Each rule in a <option>route_list</option> must start with a
32356 single domain pattern, which is the only mandatory item in the rule. The
32357 pattern is in the same format as one item in a domain list (see section
32358 <xref linkend="SECTdomainlist"/>),
32359 except that it may not be the name of an interpolated file.
32360 That is, it may be wildcarded, or a regular expression, or a file or database
32361 lookup (with semicolons doubled, because of the use of semicolon as a separator
32362 in a <option>route_list</option>).
32363 </para>
32364 <para>
32365 The rules in <option>route_list</option> are searched in order until one of the patterns
32366 matches the domain that is being routed. The list of hosts and then options are
32367 then used as described below. If there is no match, the router declines. When
32368 <option>route_list</option> is set, <option>route_data</option> must not be set.
32369 </para>
32370 </section>
32371 <section id="SECID121">
32372 <title>Routing rules in route_data</title>
32373 <para>
32374 The use of <option>route_list</option> is convenient when there are only a small number of
32375 routing rules. For larger numbers, it is easier to use a file or database to
32376 hold the routing information, and use the <option>route_data</option> option instead.
32377 The value of <option>route_data</option> is a list of hosts, followed by (optional) options.
32378 Most commonly, <option>route_data</option> is set as a string that contains an
32379 expansion lookup. For example, suppose we place two routing rules in a file
32380 like this:
32381 </para>
32382 <literallayout class="monospaced">
32383 dict.ref.example:  mail-1.ref.example:mail-2.ref.example
32384 thes.ref.example:  mail-3.ref.example:mail-4.ref.example
32385 </literallayout>
32386 <para>
32387 This data can be accessed by setting
32388 </para>
32389 <literallayout class="monospaced">
32390 route_data = ${lookup{$domain}lsearch{/the/file/name}}
32391 </literallayout>
32392 <para>
32393 Failure of the lookup results in an empty string, causing the router to
32394 decline. However, you do not have to use a lookup in <option>route_data</option>. The only
32395 requirement is that the result of expanding the string is a list of hosts,
32396 possibly followed by options, separated by white space. The list of hosts must
32397 be enclosed in quotes if it contains white space.
32398 </para>
32399 </section>
32400 <section id="SECID122">
32401 <title>Format of the list of hosts</title>
32402 <para>
32403 A list of hosts, whether obtained via <option>route_data</option> or <option>route_list</option>, is
32404 always separately expanded before use. If the expansion fails, the router
32405 declines. The result of the expansion must be a colon-separated list of names
32406 and/or IP addresses, optionally also including ports. The format of each item
32407 in the list is described in the next section. The list separator can be changed
32408 as described in section <xref linkend="SECTlistconstruct"/>.
32409 </para>
32410 <para>
32411 If the list of hosts was obtained from a <option>route_list</option> item, the following
32412 variables are set during its expansion:
32413 </para>
32414 <itemizedlist>
32415 <listitem>
32416 <para>
32417 <indexterm role="concept">
32418 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname>  etc)</primary>
32419 <secondary>in <command>manualroute</command> router</secondary>
32420 </indexterm>
32421 If the domain was matched against a regular expression, the numeric variables
32422 <varname>$1</varname>, <varname>$2</varname>, etc. may be set. For example:
32423 </para>
32424 <literallayout class="monospaced">
32425 route_list = ^domain(\d+)   host-$1.text.example
32426 </literallayout>
32427 </listitem>
32428 <listitem>
32429 <para>
32430 <varname>$0</varname> is always set to the entire domain.
32431 </para>
32432 </listitem>
32433 <listitem>
32434 <para>
32435 <varname>$1</varname> is also set when partial matching is done in a file lookup.
32436 </para>
32437 </listitem>
32438 <listitem>
32439 <para>
32440 <indexterm role="variable">
32441 <primary><varname>$value</varname></primary>
32442 </indexterm>
32443 If the pattern that matched the domain was a lookup item, the data that was
32444 looked up is available in the expansion variable <varname>$value</varname>. For example:
32445 </para>
32446 <literallayout class="monospaced">
32447 route_list = lsearch;;/some/file.routes  $value
32448 </literallayout>
32449 </listitem>
32450 </itemizedlist>
32451 <para>
32452 Note the doubling of the semicolon in the pattern that is necessary because
32453 semicolon is the default route list separator.
32454 </para>
32455 </section>
32456 <section id="SECTformatonehostitem">
32457 <title>Format of one host item</title>
32458 <para>
32459 Each item in the list of hosts is either a host name or an IP address,
32460 optionally with an attached port number. When no port is given, an IP address
32461 is not enclosed in brackets. When a port is specified, it overrides the port
32462 specification on the transport. The port is separated from the name or address
32463 by a colon. This leads to some complications:
32464 </para>
32465 <itemizedlist>
32466 <listitem>
32467 <para>
32468 Because colon is the default separator for the list of hosts, either
32469 the colon that specifies a port must be doubled, or the list separator must
32470 be changed. The following two examples have the same effect:
32471 </para>
32472 <literallayout class="monospaced">
32473 route_list = * "host1.tld::1225 : host2.tld::1226"
32474 route_list = * "&lt;+ host1.tld:1225 + host2.tld:1226"
32475 </literallayout>
32476 </listitem>
32477 <listitem>
32478 <para>
32479 When IPv6 addresses are involved, it gets worse, because they contain
32480 colons of their own. To make this case easier, it is permitted to
32481 enclose an IP address (either v4 or v6) in square brackets if a port
32482 number follows. For example:
32483 </para>
32484 <literallayout class="monospaced">
32485 route_list = * "&lt;/ [10.1.1.1]:1225 / [::1]:1226"
32486 </literallayout>
32487 </listitem>
32488 </itemizedlist>
32489 </section>
32490 <section id="SECThostshowused">
32491 <title>How the list of hosts is used</title>
32492 <para>
32493 When an address is routed to an <command>smtp</command> transport by <command>manualroute</command>, each of
32494 the hosts is tried, in the order specified, when carrying out the SMTP
32495 delivery. However, the order can be changed by setting the <option>hosts_randomize</option>
32496 option, either on the router (see section <xref linkend="SECTprioptman"/> above), or on the
32497 transport.
32498 </para>
32499 <para>
32500 Hosts may be listed by name or by IP address. An unadorned name in the list of
32501 hosts is interpreted as a host name. A name that is followed by <literal>/MX</literal> is
32502 interpreted as an indirection to a sublist of hosts obtained by looking up MX
32503 records in the DNS. For example:
32504 </para>
32505 <literallayout class="monospaced">
32506 route_list = *  x.y.z:p.q.r/MX:e.f.g
32507 </literallayout>
32508 <para>
32509 If this feature is used with a port specifier, the port must come last. For
32510 example:
32511 </para>
32512 <literallayout class="monospaced">
32513 route_list = *  dom1.tld/mx::1225
32514 </literallayout>
32515 <para>
32516 If the <option>hosts_randomize</option> option is set, the order of the items in the list is
32517 randomized before any lookups are done. Exim then scans the list; for any name
32518 that is not followed by <literal>/MX</literal> it looks up an IP address. If this turns out to
32519 be an interface on the local host and the item is not the first in the list,
32520 Exim discards it and any subsequent items. If it is the first item, what
32521 happens is controlled by the
32522 <indexterm role="option">
32523 <primary><option>self</option></primary>
32524 <secondary>in <command>manualroute</command> router</secondary>
32525 </indexterm>
32526 <option>self</option> option of the router.
32527 </para>
32528 <para>
32529 A name on the list that is followed by <literal>/MX</literal> is replaced with the list of
32530 hosts obtained by looking up MX records for the name. This is always a DNS
32531 lookup; the <option>bydns</option> and <option>byname</option> options (see section <xref linkend="SECThowoptused"/>
32532 below) are not relevant here. The order of these hosts is determined by the
32533 preference values in the MX records, according to the usual rules. Because
32534 randomizing happens before the MX lookup, it does not affect the order that is
32535 defined by MX preferences.
32536 </para>
32537 <para>
32538 If the local host is present in the sublist obtained from MX records, but is
32539 not the most preferred host in that list, it and any equally or less
32540 preferred hosts are removed before the sublist is inserted into the main list.
32541 </para>
32542 <para>
32543 If the local host is the most preferred host in the MX list, what happens
32544 depends on where in the original list of hosts the <literal>/MX</literal> item appears. If it
32545 is not the first item (that is, there are previous hosts in the main list),
32546 Exim discards this name and any subsequent items in the main list.
32547 </para>
32548 <para>
32549 If the MX item is first in the list of hosts, and the local host is the
32550 most preferred host, what happens is controlled by the <option>self</option> option of the
32551 router.
32552 </para>
32553 <para>
32554 DNS failures when lookup up the MX records are treated in the same way as DNS
32555 failures when looking up IP addresses: <option>pass_on_timeout</option> and
32556 <option>host_find_failed</option> are used when relevant.
32557 </para>
32558 <para>
32559 The generic <option>ignore_target_hosts</option> option applies to all hosts in the list,
32560 whether obtained from an MX lookup or not.
32561 </para>
32562 </section>
32563 <section id="SECThowoptused">
32564 <title>How the options are used</title>
32565 <para>
32566 The options are a sequence of words; in practice no more than three are ever
32567 present. One of the words can be the name of a transport; this overrides the
32568 <option>transport</option> option on the router for this particular routing rule only. The
32569 other words (if present) control randomization of the list of hosts on a
32570 per-rule basis, and how the IP addresses of the hosts are to be found when
32571 routing to a remote transport. These options are as follows:
32572 </para>
32573 <itemizedlist>
32574 <listitem>
32575 <para>
32576 <option>randomize</option>: randomize the order of the hosts in this list, overriding the
32577 setting of <option>hosts_randomize</option> for this routing rule only.
32578 </para>
32579 </listitem>
32580 <listitem>
32581 <para>
32582 <option>no_randomize</option>: do not randomize the order of the hosts in this list,
32583 overriding the setting of <option>hosts_randomize</option> for this routing rule only.
32584 </para>
32585 </listitem>
32586 <listitem>
32587 <para>
32588 <option>byname</option>: use <function>getipnodebyname()</function> (<function>gethostbyname()</function> on older systems) to
32589 find IP addresses. This function may ultimately cause a DNS lookup, but it may
32590 also look in <filename>/etc/hosts</filename> or other sources of information.
32591 </para>
32592 </listitem>
32593 <listitem>
32594 <para>
32595 <option>bydns</option>: look up address records for the hosts directly in the DNS; fail if
32596 no address records are found. If there is a temporary DNS error (such as a
32597 timeout), delivery is deferred.
32598 </para>
32599 </listitem>
32600 </itemizedlist>
32601 <para>
32602 For example:
32603 </para>
32604 <literallayout class="monospaced">
32605 route_list = domain1  host1:host2:host3  randomize bydns;\
32606              domain2  host4:host5
32607 </literallayout>
32608 <para>
32609 If neither <option>byname</option> nor <option>bydns</option> is given, Exim behaves as follows: First, a
32610 DNS lookup is done. If this yields anything other than HOST_NOT_FOUND, that
32611 result is used. Otherwise, Exim goes on to try a call to <function>getipnodebyname()</function>
32612 or <function>gethostbyname()</function>, and the result of the lookup is the result of that
32613 call.
32614 </para>
32615 <para>
32616 <emphasis role="bold">Warning</emphasis>: It has been discovered that on some systems, if a DNS lookup
32617 called via <function>getipnodebyname()</function> times out, HOST_NOT_FOUND is returned
32618 instead of TRY_AGAIN. That is why the default action is to try a DNS
32619 lookup first. Only if that gives a definite <quote>no such host</quote> is the local
32620 function called.
32621 </para>
32622 <para>
32623 If no IP address for a host can be found, what happens is controlled by the
32624 <option>host_find_failed</option> option.
32625 </para>
32626 <para>
32627 <indexterm role="variable">
32628 <primary><varname>$host</varname></primary>
32629 </indexterm>
32630 When an address is routed to a local transport, IP addresses are not looked up.
32631 The host list is passed to the transport in the <varname>$host</varname> variable.
32632 </para>
32633 </section>
32634 <section id="SECID123">
32635 <title>Manualroute examples</title>
32636 <para>
32637 In some of the examples that follow, the presence of the <option>remote_smtp</option>
32638 transport, as defined in the default configuration file, is assumed:
32639 </para>
32640 <itemizedlist>
32641 <listitem>
32642 <para>
32643 <indexterm role="concept">
32644 <primary>smart host</primary>
32645 <secondary>example router</secondary>
32646 </indexterm>
32647 The <command>manualroute</command> router can be used to forward all external mail to a
32648 <emphasis>smart host</emphasis>. If you have set up, in the main part of the configuration, a
32649 named domain list that contains your local domains, for example:
32650 </para>
32651 <literallayout class="monospaced">
32652 domainlist local_domains = my.domain.example
32653 </literallayout>
32654 <para>
32655 You can arrange for all other domains to be routed to a smart host by making
32656 your first router something like this:
32657 </para>
32658 <literallayout class="monospaced">
32659 smart_route:
32660   driver = manualroute
32661   domains = !+local_domains
32662   transport = remote_smtp
32663   route_list = * smarthost.ref.example
32664 </literallayout>
32665 <para>
32666 This causes all non-local addresses to be sent to the single host
32667 <emphasis>smarthost.ref.example</emphasis>. If a colon-separated list of smart hosts is given,
32668 they are tried in order
32669 (but you can use <option>hosts_randomize</option> to vary the order each time).
32670 Another way of configuring the same thing is this:
32671 </para>
32672 <literallayout class="monospaced">
32673 smart_route:
32674   driver = manualroute
32675   transport = remote_smtp
32676   route_list = !+local_domains  smarthost.ref.example
32677 </literallayout>
32678 <para>
32679 There is no difference in behaviour between these two routers as they stand.
32680 However, they behave differently if <option>no_more</option> is added to them. In the first
32681 example, the router is skipped if the domain does not match the <option>domains</option>
32682 precondition; the following router is always tried. If the router runs, it
32683 always matches the domain and so can never decline. Therefore, <option>no_more</option>
32684 would have no effect. In the second case, the router is never skipped; it
32685 always runs. However, if it doesn&#x2019;t match the domain, it declines. In this case
32686 <option>no_more</option> would prevent subsequent routers from running.
32687 </para>
32688 </listitem>
32689 <listitem>
32690 <para>
32691 <indexterm role="concept">
32692 <primary>mail hub example</primary>
32693 </indexterm>
32694 A <emphasis>mail hub</emphasis> is a host which receives mail for a number of domains via MX
32695 records in the DNS and delivers it via its own private routing mechanism. Often
32696 the final destinations are behind a firewall, with the mail hub being the one
32697 machine that can connect to machines both inside and outside the firewall. The
32698 <command>manualroute</command> router is usually used on a mail hub to route incoming messages
32699 to the correct hosts. For a small number of domains, the routing can be inline,
32700 using the <option>route_list</option> option, but for a larger number a file or database
32701 lookup is easier to manage.
32702 </para>
32703 <para>
32704 If the domain names are in fact the names of the machines to which the mail is
32705 to be sent by the mail hub, the configuration can be quite simple. For
32706 example:
32707 </para>
32708 <literallayout class="monospaced">
32709 hub_route:
32710   driver = manualroute
32711   transport = remote_smtp
32712   route_list = *.rhodes.tvs.example  $domain
32713 </literallayout>
32714 <para>
32715 This configuration routes domains that match <literal>*.rhodes.tvs.example</literal> to hosts
32716 whose names are the same as the mail domains. A similar approach can be taken
32717 if the host name can be obtained from the domain name by a string manipulation
32718 that the expansion facilities can handle. Otherwise, a lookup based on the
32719 domain can be used to find the host:
32720 </para>
32721 <literallayout class="monospaced">
32722 through_firewall:
32723   driver = manualroute
32724   transport = remote_smtp
32725   route_data = ${lookup {$domain} cdb {/internal/host/routes}}
32726 </literallayout>
32727 <para>
32728 The result of the lookup must be the name or IP address of the host (or
32729 hosts) to which the address is to be routed. If the lookup fails, the route
32730 data is empty, causing the router to decline. The address then passes to the
32731 next router.
32732 </para>
32733 </listitem>
32734 <listitem>
32735 <para>
32736 <indexterm role="concept">
32737 <primary>batched SMTP output example</primary>
32738 </indexterm>
32739 <indexterm role="concept">
32740 <primary>SMTP</primary>
32741 <secondary>batched outgoing; example</secondary>
32742 </indexterm>
32743 You can use <command>manualroute</command> to deliver messages to pipes or files in batched
32744 SMTP format for onward transportation by some other means. This is one way of
32745 storing mail for a dial-up host when it is not connected. The route list entry
32746 can be as simple as a single domain name in a configuration like this:
32747 </para>
32748 <literallayout class="monospaced">
32749 save_in_file:
32750   driver = manualroute
32751   transport = batchsmtp_appendfile
32752   route_list = saved.domain.example
32753 </literallayout>
32754 <para>
32755 though often a pattern is used to pick up more than one domain. If there are
32756 several domains or groups of domains with different transport requirements,
32757 different transports can be listed in the routing information:
32758 </para>
32759 <literallayout class="monospaced">
32760 save_in_file:
32761   driver = manualroute
32762   route_list = \
32763     *.saved.domain1.example  $domain  batch_appendfile; \
32764     *.saved.domain2.example  \
32765       ${lookup{$domain}dbm{/domain2/hosts}{$value}fail} \
32766       batch_pipe
32767 </literallayout>
32768 <para>
32769 <indexterm role="variable">
32770 <primary><varname>$domain</varname></primary>
32771 </indexterm>
32772 <indexterm role="variable">
32773 <primary><varname>$host</varname></primary>
32774 </indexterm>
32775 The first of these just passes the domain in the <varname>$host</varname> variable, which
32776 doesn&#x2019;t achieve much (since it is also in <varname>$domain</varname>), but the second does a
32777 file lookup to find a value to pass, causing the router to decline to handle
32778 the address if the lookup fails.
32779 </para>
32780 </listitem>
32781 <listitem>
32782 <para>
32783 <indexterm role="concept">
32784 <primary>UUCP</primary>
32785 <secondary>example of router for</secondary>
32786 </indexterm>
32787 Routing mail directly to UUCP software is a specific case of the use of
32788 <command>manualroute</command> in a gateway to another mail environment. This is an example of
32789 one way it can be done:
32790 </para>
32791 <literallayout class="monospaced">
32792 # Transport
32793 uucp:
32794   driver = pipe
32795   user = nobody
32796   command = /usr/local/bin/uux -r - \
32797     ${substr_-5:$host}!rmail ${local_part}
32798   return_fail_output = true
32799
32800 # Router
32801 uucphost:
32802   transport = uucp
32803   driver = manualroute
32804   route_data = \
32805     ${lookup{$domain}lsearch{/usr/local/exim/uucphosts}}
32806 </literallayout>
32807 <para>
32808 The file <filename>/usr/local/exim/uucphosts</filename> contains entries like
32809 </para>
32810 <literallayout class="monospaced">
32811 darksite.ethereal.example:           darksite.UUCP
32812 </literallayout>
32813 <para>
32814 It can be set up more simply without adding and removing <quote>.UUCP</quote> but this way
32815 makes clear the distinction between the domain name
32816 <emphasis>darksite.ethereal.example</emphasis> and the UUCP host name <emphasis>darksite</emphasis>.
32817 </para>
32818 </listitem>
32819 </itemizedlist>
32820 <para>
32821 <indexterm role="concept" startref="IIDmanrou1" class="endofrange"/>
32822 <indexterm role="concept" startref="IIDmanrou2" class="endofrange"/>
32823 </para>
32824 </section>
32825 </chapter>
32826
32827 <chapter id="CHAPdriverlast">
32828 <title>The queryprogram router</title>
32829 <para>
32830 <indexterm role="concept" id="IIDquerou1" class="startofrange">
32831 <primary><command>queryprogram</command> router</primary>
32832 </indexterm>
32833 <indexterm role="concept" id="IIDquerou2" class="startofrange">
32834 <primary>routers</primary>
32835 <secondary><command>queryprogram</command></secondary>
32836 </indexterm>
32837 <indexterm role="concept">
32838 <primary>routing</primary>
32839 <secondary>by external program</secondary>
32840 </indexterm>
32841 The <command>queryprogram</command> router routes an address by running an external command
32842 and acting on its output. This is an expensive way to route, and is intended
32843 mainly for use in lightly-loaded systems, or for performing experiments.
32844 However, if it is possible to use the precondition options (<option>domains</option>,
32845 <option>local_parts</option>, etc) to skip this router for most addresses, it could sensibly
32846 be used in special cases, even on a busy host. There are the following private
32847 options:
32848 <indexterm role="concept">
32849 <primary>options</primary>
32850 <secondary><command>queryprogram</command> router</secondary>
32851 </indexterm>
32852 </para>
32853 <para>
32854 <indexterm role="option">
32855 <primary><option>command</option></primary>
32856 </indexterm>
32857 </para>
32858 <informaltable frame="all">
32859 <tgroup cols="4" colsep="0" rowsep="0">
32860 <colspec colwidth="8*" align="left"/>
32861 <colspec colwidth="6*" align="center"/>
32862 <colspec colwidth="6*" align="center"/>
32863 <colspec colwidth="6*" align="right"/>
32864 <tbody>
32865 <row>
32866 <entry><option>command</option></entry>
32867 <entry>Use: <emphasis>queryprogram</emphasis></entry>
32868 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
32869 <entry>Default: <emphasis>unset</emphasis></entry>
32870 </row>
32871 </tbody>
32872 </tgroup>
32873 </informaltable>
32874 <para>
32875 This option must be set. It specifies the command that is to be run. The
32876 command is split up into a command name and arguments, and then each is
32877 expanded separately (exactly as for a <command>pipe</command> transport, described in chapter
32878 <xref linkend="CHAPpipetransport"/>).
32879 </para>
32880 <para>
32881 <indexterm role="option">
32882 <primary><option>command_group</option></primary>
32883 </indexterm>
32884 </para>
32885 <informaltable frame="all">
32886 <tgroup cols="4" colsep="0" rowsep="0">
32887 <colspec colwidth="8*" align="left"/>
32888 <colspec colwidth="6*" align="center"/>
32889 <colspec colwidth="6*" align="center"/>
32890 <colspec colwidth="6*" align="right"/>
32891 <tbody>
32892 <row>
32893 <entry><option>command_group</option></entry>
32894 <entry>Use: <emphasis>queryprogram</emphasis></entry>
32895 <entry>Type: <emphasis>string</emphasis></entry>
32896 <entry>Default: <emphasis>unset</emphasis></entry>
32897 </row>
32898 </tbody>
32899 </tgroup>
32900 </informaltable>
32901 <para>
32902 <indexterm role="concept">
32903 <primary>gid (group id)</primary>
32904 <secondary>in <command>queryprogram</command> router</secondary>
32905 </indexterm>
32906 This option specifies a gid to be set when running the command while routing an
32907 address for deliver. It must be set if <option>command_user</option> specifies a numerical
32908 uid. If it begins with a digit, it is interpreted as the numerical value of the
32909 gid. Otherwise it is looked up using <function>getgrnam()</function>.
32910 </para>
32911 <para>
32912 <indexterm role="option">
32913 <primary><option>command_user</option></primary>
32914 </indexterm>
32915 </para>
32916 <informaltable frame="all">
32917 <tgroup cols="4" colsep="0" rowsep="0">
32918 <colspec colwidth="8*" align="left"/>
32919 <colspec colwidth="6*" align="center"/>
32920 <colspec colwidth="6*" align="center"/>
32921 <colspec colwidth="6*" align="right"/>
32922 <tbody>
32923 <row>
32924 <entry><option>command_user</option></entry>
32925 <entry>Use: <emphasis>queryprogram</emphasis></entry>
32926 <entry>Type: <emphasis>string</emphasis></entry>
32927 <entry>Default: <emphasis>unset</emphasis></entry>
32928 </row>
32929 </tbody>
32930 </tgroup>
32931 </informaltable>
32932 <para>
32933 <indexterm role="concept">
32934 <primary>uid (user id)</primary>
32935 <secondary>for <command>queryprogram</command></secondary>
32936 </indexterm>
32937 This option must be set. It specifies the uid which is set when running the
32938 command while routing an address for delivery. If the value begins with a digit,
32939 it is interpreted as the numerical value of the uid. Otherwise, it is looked up
32940 using <function>getpwnam()</function> to obtain a value for the uid and, if <option>command_group</option> is
32941 not set, a value for the gid also.
32942 </para>
32943 <para>
32944 <emphasis role="bold">Warning:</emphasis> Changing uid and gid is possible only when Exim is running as
32945 root, which it does during a normal delivery in a conventional configuration.
32946 However, when an address is being verified during message reception, Exim is
32947 usually running as the Exim user, not as root. If the <command>queryprogram</command> router
32948 is called from a non-root process, Exim cannot change uid or gid before running
32949 the command. In this circumstance the command runs under the current uid and
32950 gid.
32951 </para>
32952 <para>
32953 <indexterm role="option">
32954 <primary><option>current_directory</option></primary>
32955 </indexterm>
32956 </para>
32957 <informaltable frame="all">
32958 <tgroup cols="4" colsep="0" rowsep="0">
32959 <colspec colwidth="8*" align="left"/>
32960 <colspec colwidth="6*" align="center"/>
32961 <colspec colwidth="6*" align="center"/>
32962 <colspec colwidth="6*" align="right"/>
32963 <tbody>
32964 <row>
32965 <entry><option>current_directory</option></entry>
32966 <entry>Use: <emphasis>queryprogram</emphasis></entry>
32967 <entry>Type: <emphasis>string</emphasis></entry>
32968 <entry>Default: <emphasis>/</emphasis></entry>
32969 </row>
32970 </tbody>
32971 </tgroup>
32972 </informaltable>
32973 <para>
32974 This option specifies an absolute path which is made the current directory
32975 before running the command.
32976 </para>
32977 <para>
32978 <indexterm role="option">
32979 <primary><option>timeout</option></primary>
32980 </indexterm>
32981 </para>
32982 <informaltable frame="all">
32983 <tgroup cols="4" colsep="0" rowsep="0">
32984 <colspec colwidth="8*" align="left"/>
32985 <colspec colwidth="6*" align="center"/>
32986 <colspec colwidth="6*" align="center"/>
32987 <colspec colwidth="6*" align="right"/>
32988 <tbody>
32989 <row>
32990 <entry><option>timeout</option></entry>
32991 <entry>Use: <emphasis>queryprogram</emphasis></entry>
32992 <entry>Type: <emphasis>time</emphasis></entry>
32993 <entry>Default: <emphasis>1h</emphasis></entry>
32994 </row>
32995 </tbody>
32996 </tgroup>
32997 </informaltable>
32998 <para>
32999 If the command does not complete within the timeout period, its process group
33000 is killed and the message is frozen. A value of zero time specifies no
33001 timeout.
33002 </para>
33003 <para>
33004 The standard output of the command is connected to a pipe, which is read when
33005 the command terminates. It should consist of a single line of output,
33006 containing up to five fields, separated by white space. The maximum length of
33007 the line is 1023 characters. Longer lines are silently truncated. The first
33008 field is one of the following words (case-insensitive):
33009 </para>
33010 <itemizedlist>
33011 <listitem>
33012 <para>
33013 <emphasis>Accept</emphasis>: routing succeeded; the remaining fields specify what to do (see
33014 below).
33015 </para>
33016 </listitem>
33017 <listitem>
33018 <para>
33019 <emphasis>Decline</emphasis>: the router declines; pass the address to the next router, unless
33020 <option>no_more</option> is set.
33021 </para>
33022 </listitem>
33023 <listitem>
33024 <para>
33025 <emphasis>Fail</emphasis>: routing failed; do not pass the address to any more routers. Any
33026 subsequent text on the line is an error message. If the router is run as part
33027 of address verification during an incoming SMTP message, the message is
33028 included in the SMTP response.
33029 </para>
33030 </listitem>
33031 <listitem>
33032 <para>
33033 <emphasis>Defer</emphasis>: routing could not be completed at this time; try again later. Any
33034 subsequent text on the line is an error message which is logged. It is not
33035 included in any SMTP response.
33036 </para>
33037 </listitem>
33038 <listitem>
33039 <para>
33040 <emphasis>Freeze</emphasis>: the same as <emphasis>defer</emphasis>, except that the message is frozen.
33041 </para>
33042 </listitem>
33043 <listitem>
33044 <para>
33045 <emphasis>Pass</emphasis>: pass the address to the next router (or the router specified by
33046 <option>pass_router</option>), overriding <option>no_more</option>.
33047 </para>
33048 </listitem>
33049 <listitem>
33050 <para>
33051 <emphasis>Redirect</emphasis>: the message is redirected. The remainder of the line is a list of
33052 new addresses, which are routed independently, starting with the first router,
33053 or the router specified by <option>redirect_router</option>, if set.
33054 </para>
33055 </listitem>
33056 </itemizedlist>
33057 <para>
33058 When the first word is <emphasis>accept</emphasis>, the remainder of the line consists of a
33059 number of keyed data values, as follows (split into two lines here, to fit on
33060 the page):
33061 </para>
33062 <literallayout class="monospaced">
33063 ACCEPT TRANSPORT=&lt;transport&gt; HOSTS=&lt;list of hosts&gt;
33064 LOOKUP=byname|bydns DATA=&lt;text&gt;
33065 </literallayout>
33066 <para>
33067 The data items can be given in any order, and all are optional. If no transport
33068 is included, the transport specified by the generic <option>transport</option> option is
33069 used. The list of hosts and the lookup type are needed only if the transport is
33070 an <command>smtp</command> transport that does not itself supply a list of hosts.
33071 </para>
33072 <para>
33073 The format of the list of hosts is the same as for the <command>manualroute</command> router.
33074 As well as host names and IP addresses with optional port numbers, as described
33075 in section <xref linkend="SECTformatonehostitem"/>, it may contain names followed by
33076 <literal>/MX</literal> to specify sublists of hosts that are obtained by looking up MX records
33077 (see section <xref linkend="SECThostshowused"/>).
33078 </para>
33079 <para>
33080 If the lookup type is not specified, Exim behaves as follows when trying to
33081 find an IP address for each host: First, a DNS lookup is done. If this yields
33082 anything other than HOST_NOT_FOUND, that result is used. Otherwise, Exim
33083 goes on to try a call to <function>getipnodebyname()</function> or <function>gethostbyname()</function>, and the
33084 result of the lookup is the result of that call.
33085 </para>
33086 <para>
33087 <indexterm role="variable">
33088 <primary><varname>$address_data</varname></primary>
33089 </indexterm>
33090 If the DATA field is set, its value is placed in the <varname>$address_data</varname>
33091 variable. For example, this return line
33092 </para>
33093 <literallayout class="monospaced">
33094 accept hosts=x1.y.example:x2.y.example data="rule1"
33095 </literallayout>
33096 <para>
33097 routes the address to the default transport, passing a list of two hosts. When
33098 the transport runs, the string <quote>rule1</quote> is in <varname>$address_data</varname>.
33099 <indexterm role="concept" startref="IIDquerou1" class="endofrange"/>
33100 <indexterm role="concept" startref="IIDquerou2" class="endofrange"/>
33101 </para>
33102 </chapter>
33103
33104 <chapter id="CHAPredirect">
33105 <title>The redirect router</title>
33106 <para>
33107 <indexterm role="concept" id="IIDredrou1" class="startofrange">
33108 <primary><command>redirect</command> router</primary>
33109 </indexterm>
33110 <indexterm role="concept" id="IIDredrou2" class="startofrange">
33111 <primary>routers</primary>
33112 <secondary><command>redirect</command></secondary>
33113 </indexterm>
33114 <indexterm role="concept">
33115 <primary>alias file</primary>
33116 <secondary>in a <command>redirect</command> router</secondary>
33117 </indexterm>
33118 <indexterm role="concept">
33119 <primary>address redirection</primary>
33120 <secondary><command>redirect</command> router</secondary>
33121 </indexterm>
33122 The <command>redirect</command> router handles several kinds of address redirection. Its most
33123 common uses are for resolving local part aliases from a central alias file
33124 (usually called <filename>/etc/aliases</filename>) and for handling users&#x2019; personal <filename>.forward</filename>
33125 files, but it has many other potential uses. The incoming address can be
33126 redirected in several different ways:
33127 </para>
33128 <itemizedlist>
33129 <listitem>
33130 <para>
33131 It can be replaced by one or more new addresses which are themselves routed
33132 independently.
33133 </para>
33134 </listitem>
33135 <listitem>
33136 <para>
33137 It can be routed to be delivered to a given file or directory.
33138 </para>
33139 </listitem>
33140 <listitem>
33141 <para>
33142 It can be routed to be delivered to a specified pipe command.
33143 </para>
33144 </listitem>
33145 <listitem>
33146 <para>
33147 It can cause an automatic reply to be generated.
33148 </para>
33149 </listitem>
33150 <listitem>
33151 <para>
33152 It can be forced to fail, optionally with a custom error message.
33153 </para>
33154 </listitem>
33155 <listitem>
33156 <para>
33157 It can be temporarily deferred, optionally with a custom message.
33158 </para>
33159 </listitem>
33160 <listitem>
33161 <para>
33162 It can be discarded.
33163 </para>
33164 </listitem>
33165 </itemizedlist>
33166 <para>
33167 The generic <option>transport</option> option must not be set for <command>redirect</command> routers.
33168 However, there are some private options which define transports for delivery to
33169 files and pipes, and for generating autoreplies. See the <option>file_transport</option>,
33170 <option>pipe_transport</option> and <option>reply_transport</option> descriptions below.
33171 </para>
33172 <section id="SECID124">
33173 <title>Redirection data</title>
33174 <para>
33175 The router operates by interpreting a text string which it obtains either by
33176 expanding the contents of the <option>data</option> option, or by reading the entire
33177 contents of a file whose name is given in the <option>file</option> option. These two
33178 options are mutually exclusive. The first is commonly used for handling system
33179 aliases, in a configuration like this:
33180 </para>
33181 <literallayout class="monospaced">
33182 system_aliases:
33183   driver = redirect
33184   data = ${lookup{$local_part}lsearch{/etc/aliases}}
33185 </literallayout>
33186 <para>
33187 If the lookup fails, the expanded string in this example is empty. When the
33188 expansion of <option>data</option> results in an empty string, the router declines. A forced
33189 expansion failure also causes the router to decline; other expansion failures
33190 cause delivery to be deferred.
33191 </para>
33192 <para>
33193 A configuration using <option>file</option> is commonly used for handling users&#x2019;
33194 <filename>.forward</filename> files, like this:
33195 </para>
33196 <literallayout class="monospaced">
33197 userforward:
33198   driver = redirect
33199   check_local_user
33200   file = $home/.forward
33201   no_verify
33202 </literallayout>
33203 <para>
33204 If the file does not exist, or causes no action to be taken (for example, it is
33205 empty or consists only of comments), the router declines. <emphasis role="bold">Warning</emphasis>: This
33206 is not the case when the file contains syntactically valid items that happen to
33207 yield empty addresses, for example, items containing only RFC 2822 address
33208 comments.
33209 </para>
33210 </section>
33211 <section id="SECID125">
33212 <title>Forward files and address verification</title>
33213 <para>
33214 <indexterm role="concept">
33215 <primary>address redirection</primary>
33216 <secondary>while verifying</secondary>
33217 </indexterm>
33218 It is usual to set <option>no_verify</option> on <command>redirect</command> routers which handle users&#x2019;
33219 <filename>.forward</filename> files, as in the example above. There are two reasons for this:
33220 </para>
33221 <itemizedlist>
33222 <listitem>
33223 <para>
33224 When Exim is receiving an incoming SMTP message from a remote host, it is
33225 running under the Exim uid, not as root. Exim is unable to change uid to read
33226 the file as the user, and it may not be able to read it as the Exim user. So in
33227 practice the router may not be able to operate.
33228 </para>
33229 </listitem>
33230 <listitem>
33231 <para>
33232 However, even when the router can operate, the existence of a <filename>.forward</filename> file
33233 is unimportant when verifying an address. What should be checked is whether the
33234 local part is a valid user name or not. Cutting out the redirection processing
33235 saves some resources.
33236 </para>
33237 </listitem>
33238 </itemizedlist>
33239 </section>
33240 <section id="SECID126">
33241 <title>Interpreting redirection data</title>
33242 <para>
33243 <indexterm role="concept">
33244 <primary>Sieve filter</primary>
33245 <secondary>specifying in redirection data</secondary>
33246 </indexterm>
33247 <indexterm role="concept">
33248 <primary>filter</primary>
33249 <secondary>specifying in redirection data</secondary>
33250 </indexterm>
33251 The contents of the data string, whether obtained from <option>data</option> or <option>file</option>,
33252 can be interpreted in two different ways:
33253 </para>
33254 <itemizedlist>
33255 <listitem>
33256 <para>
33257 If the <option>allow_filter</option> option is set true, and the data begins with the text
33258 <quote>#Exim filter</quote> or <quote>#Sieve filter</quote>, it is interpreted as a list of
33259 <emphasis>filtering</emphasis> instructions in the form of an Exim or Sieve filter file,
33260 respectively. Details of the syntax and semantics of filter files are described
33261 in a separate document entitled <emphasis>Exim&#x2019;s interfaces to mail filtering</emphasis>; this
33262 document is intended for use by end users.
33263 </para>
33264 </listitem>
33265 <listitem>
33266 <para>
33267 Otherwise, the data must be a comma-separated list of redirection items, as
33268 described in the next section.
33269 </para>
33270 </listitem>
33271 </itemizedlist>
33272 <para>
33273 When a message is redirected to a file (a <quote>mail folder</quote>), the file name given
33274 in a non-filter redirection list must always be an absolute path. A filter may
33275 generate a relative path &ndash; how this is handled depends on the transport&#x2019;s
33276 configuration. See section <xref linkend="SECTfildiropt"/> for a discussion of this issue
33277 for the <command>appendfile</command> transport.
33278 </para>
33279 </section>
33280 <section id="SECTitenonfilred">
33281 <title>Items in a non-filter redirection list</title>
33282 <para>
33283 <indexterm role="concept">
33284 <primary>address redirection</primary>
33285 <secondary>non-filter list items</secondary>
33286 </indexterm>
33287 When the redirection data is not an Exim or Sieve filter, for example, if it
33288 comes from a conventional alias or forward file, it consists of a list of
33289 addresses, file names, pipe commands, or certain special items (see section
33290 <xref linkend="SECTspecitredli"/> below). The special items can be individually enabled or
33291 disabled by means of options whose names begin with <option>allow_</option> or <option>forbid_</option>,
33292 depending on their default values. The items in the list are separated by
33293 commas or newlines.
33294 If a comma is required in an item, the entire item must be enclosed in double
33295 quotes.
33296 </para>
33297 <para>
33298 Lines starting with a # character are comments, and are ignored, and # may
33299 also appear following a comma, in which case everything between the # and the
33300 next newline character is ignored.
33301 </para>
33302 <para>
33303 If an item is entirely enclosed in double quotes, these are removed. Otherwise
33304 double quotes are retained because some forms of mail address require their use
33305 (but never to enclose the entire address). In the following description,
33306 <quote>item</quote> refers to what remains after any surrounding double quotes have been
33307 removed.
33308 </para>
33309 <para>
33310 <indexterm role="variable">
33311 <primary><varname>$local_part</varname></primary>
33312 </indexterm>
33313 <emphasis role="bold">Warning</emphasis>: If you use an Exim expansion to construct a redirection address,
33314 and the expansion contains a reference to <varname>$local_part</varname>, you should make use
33315 of the <option>quote_local_part</option> expansion operator, in case the local part contains
33316 special characters. For example, to redirect all mail for the domain
33317 <emphasis>obsolete.example</emphasis>, retaining the existing local part, you could use this
33318 setting:
33319 </para>
33320 <literallayout class="monospaced">
33321 data = ${quote_local_part:$local_part}@newdomain.example
33322 </literallayout>
33323 </section>
33324 <section id="SECTredlocmai">
33325 <title>Redirecting to a local mailbox</title>
33326 <para>
33327 <indexterm role="concept">
33328 <primary>routing</primary>
33329 <secondary>loops in</secondary>
33330 </indexterm>
33331 <indexterm role="concept">
33332 <primary>loop</primary>
33333 <secondary>while routing, avoidance of</secondary>
33334 </indexterm>
33335 <indexterm role="concept">
33336 <primary>address redirection</primary>
33337 <secondary>to local mailbox</secondary>
33338 </indexterm>
33339 A redirection item may safely be the same as the address currently under
33340 consideration. This does not cause a routing loop, because a router is
33341 automatically skipped if any ancestor of the address that is being processed
33342 is the same as the current address and was processed by the current router.
33343 Such an address is therefore passed to the following routers, so it is handled
33344 as if there were no redirection. When making this loop-avoidance test, the
33345 complete local part, including any prefix or suffix, is used.
33346 </para>
33347 <para>
33348 <indexterm role="concept">
33349 <primary>address redirection</primary>
33350 <secondary>local part without domain</secondary>
33351 </indexterm>
33352 Specifying the same local part without a domain is a common usage in personal
33353 filter files when the user wants to have messages delivered to the local
33354 mailbox and also forwarded elsewhere. For example, the user whose login is
33355 <emphasis>cleo</emphasis> might have a <filename>.forward</filename> file containing this:
33356 </para>
33357 <literallayout class="monospaced">
33358 cleo, cleopatra@egypt.example
33359 </literallayout>
33360 <para>
33361 <indexterm role="concept">
33362 <primary>backslash in alias file</primary>
33363 </indexterm>
33364 <indexterm role="concept">
33365 <primary>alias file</primary>
33366 <secondary>backslash in</secondary>
33367 </indexterm>
33368 For compatibility with other MTAs, such unqualified local parts may be
33369 preceded by <quote>\</quote>, but this is not a requirement for loop prevention. However,
33370 it does make a difference if more than one domain is being handled
33371 synonymously.
33372 </para>
33373 <para>
33374 If an item begins with <quote>\</quote> and the rest of the item parses as a valid RFC
33375 2822 address that does not include a domain, the item is qualified using the
33376 domain of the incoming address. In the absence of a leading <quote>\</quote>, unqualified
33377 addresses are qualified using the value in <option>qualify_recipient</option>, but you can
33378 force the incoming domain to be used by setting <option>qualify_preserve_domain</option>.
33379 </para>
33380 <para>
33381 Care must be taken if there are alias names for local users.
33382 Consider an MTA handling a single local domain where the system alias file
33383 contains:
33384 </para>
33385 <literallayout class="monospaced">
33386 Sam.Reman: spqr
33387 </literallayout>
33388 <para>
33389 Now suppose that Sam (whose login id is <emphasis>spqr</emphasis>) wants to save copies of
33390 messages in the local mailbox, and also forward copies elsewhere. He creates
33391 this forward file:
33392 </para>
33393 <literallayout class="monospaced">
33394 Sam.Reman, spqr@reme.elsewhere.example
33395 </literallayout>
33396 <para>
33397 With these settings, an incoming message addressed to <emphasis>Sam.Reman</emphasis> fails. The
33398 <command>redirect</command> router for system aliases does not process <emphasis>Sam.Reman</emphasis> the
33399 second time round, because it has previously routed it,
33400 and the following routers presumably cannot handle the alias. The forward file
33401 should really contain
33402 </para>
33403 <literallayout class="monospaced">
33404 spqr, spqr@reme.elsewhere.example
33405 </literallayout>
33406 <para>
33407 but because this is such a common error, the <option>check_ancestor</option> option (see
33408 below) exists to provide a way to get round it. This is normally set on a
33409 <command>redirect</command> router that is handling users&#x2019; <filename>.forward</filename> files.
33410 </para>
33411 </section>
33412 <section id="SECTspecitredli">
33413 <title>Special items in redirection lists</title>
33414 <para>
33415 In addition to addresses, the following types of item may appear in redirection
33416 lists (that is, in non-filter redirection data):
33417 </para>
33418 <itemizedlist>
33419 <listitem>
33420 <para>
33421 <indexterm role="concept">
33422 <primary>pipe</primary>
33423 <secondary>in redirection list</secondary>
33424 </indexterm>
33425 <indexterm role="concept">
33426 <primary>address redirection</primary>
33427 <secondary>to pipe</secondary>
33428 </indexterm>
33429 An item is treated as a pipe command if it begins with <quote>|</quote> and does not parse
33430 as a valid RFC 2822 address that includes a domain. A transport for running the
33431 command must be specified by the <option>pipe_transport</option> option.
33432 Normally, either the router or the transport specifies a user and a group under
33433 which to run the delivery. The default is to use the Exim user and group.
33434 </para>
33435 <para>
33436 Single or double quotes can be used for enclosing the individual arguments of
33437 the pipe command; no interpretation of escapes is done for single quotes. If
33438 the command contains a comma character, it is necessary to put the whole item
33439 in double quotes, for example:
33440 </para>
33441 <literallayout class="monospaced">
33442 "|/some/command ready,steady,go"
33443 </literallayout>
33444 <para>
33445 since items in redirection lists are terminated by commas. Do not, however,
33446 quote just the command. An item such as
33447 </para>
33448 <literallayout class="monospaced">
33449 |"/some/command ready,steady,go"
33450 </literallayout>
33451 <para>
33452 is interpreted as a pipe with a rather strange command name, and no arguments.
33453 </para>
33454 </listitem>
33455 <listitem>
33456 <para>
33457 <indexterm role="concept">
33458 <primary>file</primary>
33459 <secondary>in redirection list</secondary>
33460 </indexterm>
33461 <indexterm role="concept">
33462 <primary>address redirection</primary>
33463 <secondary>to file</secondary>
33464 </indexterm>
33465 An item is interpreted as a path name if it begins with <quote>/</quote> and does not
33466 parse as a valid RFC 2822 address that includes a domain. For example,
33467 </para>
33468 <literallayout class="monospaced">
33469 /home/world/minbari
33470 </literallayout>
33471 <para>
33472 is treated as a file name, but
33473 </para>
33474 <literallayout class="monospaced">
33475 /s=molari/o=babylon/@x400gate.way
33476 </literallayout>
33477 <para>
33478 is treated as an address. For a file name, a transport must be specified using
33479 the <option>file_transport</option> option. However, if the generated path name ends with a
33480 forward slash character, it is interpreted as a directory name rather than a
33481 file name, and <option>directory_transport</option> is used instead.
33482 </para>
33483 <para>
33484 Normally, either the router or the transport specifies a user and a group under
33485 which to run the delivery. The default is to use the Exim user and group.
33486 </para>
33487 <para>
33488 <indexterm role="concept">
33489 <primary><filename>/dev/null</filename></primary>
33490 </indexterm>
33491 However, if a redirection item is the path <filename>/dev/null</filename>, delivery to it is
33492 bypassed at a high level, and the log entry shows <quote>**bypassed**</quote>
33493 instead of a transport name. In this case the user and group are not used.
33494 </para>
33495 </listitem>
33496 <listitem>
33497 <para>
33498 <indexterm role="concept">
33499 <primary>included address list</primary>
33500 </indexterm>
33501 <indexterm role="concept">
33502 <primary>address redirection</primary>
33503 <secondary>included external list</secondary>
33504 </indexterm>
33505 If an item is of the form
33506 </para>
33507 <literallayout class="monospaced">
33508 :include:&lt;path name&gt;
33509 </literallayout>
33510 <para>
33511 a list of further items is taken from the given file and included at that
33512 point. <emphasis role="bold">Note</emphasis>: Such a file can not be a filter file; it is just an
33513 out-of-line addition to the list. The items in the included list are separated
33514 by commas or newlines and are not subject to expansion. If this is the first
33515 item in an alias list in an <command>lsearch</command> file, a colon must be used to terminate
33516 the alias name. This example is incorrect:
33517 </para>
33518 <literallayout class="monospaced">
33519 list1    :include:/opt/lists/list1
33520 </literallayout>
33521 <para>
33522 It must be given as
33523 </para>
33524 <literallayout class="monospaced">
33525 list1:   :include:/opt/lists/list1
33526 </literallayout>
33527 </listitem>
33528 <listitem>
33529 <para>
33530 <indexterm role="concept">
33531 <primary>address redirection</primary>
33532 <secondary>to black hole</secondary>
33533 </indexterm>
33534 Sometimes you want to throw away mail to a particular local part. Making the
33535 <option>data</option> option expand to an empty string does not work, because that causes
33536 the router to decline. Instead, the alias item
33537 <indexterm role="concept">
33538 <primary>black hole</primary>
33539 </indexterm>
33540 <indexterm role="concept">
33541 <primary>abandoning mail</primary>
33542 </indexterm>
33543 <emphasis>:blackhole:</emphasis> can be used. It does what its name implies. No delivery is
33544 done, and no error message is generated. This has the same effect as specifing
33545 <filename>/dev/null</filename> as a destination, but it can be independently disabled.
33546 </para>
33547 <para>
33548 <emphasis role="bold">Warning</emphasis>: If <emphasis>:blackhole:</emphasis> appears anywhere in a redirection list, no
33549 delivery is done for the original local part, even if other redirection items
33550 are present. If you are generating a multi-item list (for example, by reading a
33551 database) and need the ability to provide a no-op item, you must use
33552 <filename>/dev/null</filename>.
33553 </para>
33554 </listitem>
33555 <listitem>
33556 <para>
33557 <indexterm role="concept">
33558 <primary>delivery</primary>
33559 <secondary>forcing failure</secondary>
33560 </indexterm>
33561 <indexterm role="concept">
33562 <primary>delivery</primary>
33563 <secondary>forcing deferral</secondary>
33564 </indexterm>
33565 <indexterm role="concept">
33566 <primary>failing delivery</primary>
33567 <secondary>forcing</secondary>
33568 </indexterm>
33569 <indexterm role="concept">
33570 <primary>deferred delivery, forcing</primary>
33571 </indexterm>
33572 <indexterm role="concept">
33573 <primary>customizing</primary>
33574 <secondary>failure message</secondary>
33575 </indexterm>
33576 An attempt to deliver a particular address can be deferred or forced to fail by
33577 redirection items of the form
33578 </para>
33579 <literallayout class="monospaced">
33580 :defer:
33581 :fail:
33582 </literallayout>
33583 <para>
33584 respectively. When a redirection list contains such an item, it applies
33585 to the entire redirection; any other items in the list are ignored. Any
33586 text following <emphasis>:fail:</emphasis> or <emphasis>:defer:</emphasis> is placed in the error text
33587 associated with the failure. For example, an alias file might contain:
33588 </para>
33589 <literallayout class="monospaced">
33590 X.Employee:  :fail: Gone away, no forwarding address
33591 </literallayout>
33592 <para>
33593 In the case of an address that is being verified from an ACL or as the subject
33594 of a
33595 <indexterm role="concept">
33596 <primary>VRFY</primary>
33597 <secondary>error text, display of</secondary>
33598 </indexterm>
33599 VRFY command, the text is included in the SMTP error response by
33600 default.
33601 <indexterm role="concept">
33602 <primary>EXPN</primary>
33603 <secondary>error text, display of</secondary>
33604 </indexterm>
33605 The text is not included in the response to an EXPN command. In non-SMTP cases
33606 the text is included in the error message that Exim generates.
33607 </para>
33608 <para>
33609 <indexterm role="concept">
33610 <primary>SMTP</primary>
33611 <secondary>error codes</secondary>
33612 </indexterm>
33613 By default, Exim sends a 451 SMTP code for a <emphasis>:defer:</emphasis>, and 550 for
33614 <emphasis>:fail:</emphasis>. However, if the message starts with three digits followed by a
33615 space, optionally followed by an extended code of the form <emphasis>n.n.n</emphasis>, also
33616 followed by a space, and the very first digit is the same as the default error
33617 code, the code from the message is used instead. If the very first digit is
33618 incorrect, a panic error is logged, and the default code is used. You can
33619 suppress the use of the supplied code in a redirect router by setting the
33620 <option>forbid_smtp_code</option> option true. In this case, any SMTP code is quietly
33621 ignored.
33622 </para>
33623 <para>
33624 <indexterm role="variable">
33625 <primary><varname>$acl_verify_message</varname></primary>
33626 </indexterm>
33627 In an ACL, an explicitly provided message overrides the default, but the
33628 default message is available in the variable <varname>$acl_verify_message</varname> and can
33629 therefore be included in a custom message if this is desired.
33630 </para>
33631 <para>
33632 Normally the error text is the rest of the redirection list &ndash; a comma does
33633 not terminate it &ndash; but a newline does act as a terminator. Newlines are not
33634 normally present in alias expansions. In <command>lsearch</command> lookups they are removed
33635 as part of the continuation process, but they may exist in other kinds of
33636 lookup and in <emphasis>:include:</emphasis> files.
33637 </para>
33638 <para>
33639 During routing for message delivery (as opposed to verification), a redirection
33640 containing <emphasis>:fail:</emphasis> causes an immediate failure of the incoming address,
33641 whereas <emphasis>:defer:</emphasis> causes the message to remain on the queue so that a
33642 subsequent delivery attempt can happen at a later time. If an address is
33643 deferred for too long, it will ultimately fail, because the normal retry
33644 rules still apply.
33645 </para>
33646 </listitem>
33647 <listitem>
33648 <para>
33649 <indexterm role="concept">
33650 <primary>alias file</primary>
33651 <secondary>exception to default</secondary>
33652 </indexterm>
33653 Sometimes it is useful to use a single-key search type with a default (see
33654 chapter <xref linkend="CHAPfdlookup"/>) to look up aliases. However, there may be a need
33655 for exceptions to the default. These can be handled by aliasing them to
33656 <emphasis>:unknown:</emphasis>. This differs from <emphasis>:fail:</emphasis> in that it causes the <command>redirect</command>
33657 router to decline, whereas <emphasis>:fail:</emphasis> forces routing to fail. A lookup which
33658 results in an empty redirection list has the same effect.
33659 </para>
33660 </listitem>
33661 </itemizedlist>
33662 </section>
33663 <section id="SECTdupaddr">
33664 <title>Duplicate addresses</title>
33665 <para>
33666 <indexterm role="concept">
33667 <primary>duplicate addresses</primary>
33668 </indexterm>
33669 <indexterm role="concept">
33670 <primary>address duplicate, discarding</primary>
33671 </indexterm>
33672 <indexterm role="concept">
33673 <primary>pipe</primary>
33674 <secondary>duplicated</secondary>
33675 </indexterm>
33676 Exim removes duplicate addresses from the list to which it is delivering, so as
33677 to deliver just one copy to each address. This does not apply to deliveries
33678 routed to pipes by different immediate parent addresses, but an indirect
33679 aliasing scheme of the type
33680 </para>
33681 <literallayout class="monospaced">
33682 pipe:       |/some/command $local_part
33683 localpart1: pipe
33684 localpart2: pipe
33685 </literallayout>
33686 <para>
33687 does not work with a message that is addressed to both local parts, because
33688 when the second is aliased to the intermediate local part <quote>pipe</quote> it gets
33689 discarded as being the same as a previously handled address. However, a scheme
33690 such as
33691 </para>
33692 <literallayout class="monospaced">
33693 localpart1: |/some/command $local_part
33694 localpart2: |/some/command $local_part
33695 </literallayout>
33696 <para>
33697 does result in two different pipe deliveries, because the immediate parents of
33698 the pipes are distinct.
33699 </para>
33700 </section>
33701 <section id="SECID128">
33702 <title>Repeated redirection expansion</title>
33703 <para>
33704 <indexterm role="concept">
33705 <primary>repeated redirection expansion</primary>
33706 </indexterm>
33707 <indexterm role="concept">
33708 <primary>address redirection</primary>
33709 <secondary>repeated for each delivery attempt</secondary>
33710 </indexterm>
33711 When a message cannot be delivered to all of its recipients immediately,
33712 leading to two or more delivery attempts, redirection expansion is carried out
33713 afresh each time for those addresses whose children were not all previously
33714 delivered. If redirection is being used as a mailing list, this can lead to new
33715 members of the list receiving copies of old messages. The <option>one_time</option> option
33716 can be used to avoid this.
33717 </para>
33718 </section>
33719 <section id="SECID129">
33720 <title>Errors in redirection lists</title>
33721 <para>
33722 <indexterm role="concept">
33723 <primary>address redirection</primary>
33724 <secondary>errors</secondary>
33725 </indexterm>
33726 If <option>skip_syntax_errors</option> is set, a malformed address that causes a parsing
33727 error is skipped, and an entry is written to the main log. This may be useful
33728 for mailing lists that are automatically managed. Otherwise, if an error is
33729 detected while generating the list of new addresses, the original address is
33730 deferred. See also <option>syntax_errors_to</option>.
33731 </para>
33732 </section>
33733 <section id="SECID130">
33734 <title>Private options for the redirect router</title>
33735 <para>
33736 <indexterm role="concept">
33737 <primary>options</primary>
33738 <secondary><command>redirect</command> router</secondary>
33739 </indexterm>
33740 The private options for the <command>redirect</command> router are as follows:
33741 </para>
33742 <para>
33743 <indexterm role="option">
33744 <primary><option>allow_defer</option></primary>
33745 </indexterm>
33746 </para>
33747 <informaltable frame="all">
33748 <tgroup cols="4" colsep="0" rowsep="0">
33749 <colspec colwidth="8*" align="left"/>
33750 <colspec colwidth="6*" align="center"/>
33751 <colspec colwidth="6*" align="center"/>
33752 <colspec colwidth="6*" align="right"/>
33753 <tbody>
33754 <row>
33755 <entry><option>allow_defer</option></entry>
33756 <entry>Use: <emphasis>redirect</emphasis></entry>
33757 <entry>Type: <emphasis>boolean</emphasis></entry>
33758 <entry>Default: <emphasis>false</emphasis></entry>
33759 </row>
33760 </tbody>
33761 </tgroup>
33762 </informaltable>
33763 <para>
33764 Setting this option allows the use of <emphasis>:defer:</emphasis> in non-filter redirection
33765 data, or the <option>defer</option> command in an Exim filter file.
33766 </para>
33767 <para>
33768 <indexterm role="option">
33769 <primary><option>allow_fail</option></primary>
33770 </indexterm>
33771 </para>
33772 <informaltable frame="all">
33773 <tgroup cols="4" colsep="0" rowsep="0">
33774 <colspec colwidth="8*" align="left"/>
33775 <colspec colwidth="6*" align="center"/>
33776 <colspec colwidth="6*" align="center"/>
33777 <colspec colwidth="6*" align="right"/>
33778 <tbody>
33779 <row>
33780 <entry><option>allow_fail</option></entry>
33781 <entry>Use: <emphasis>redirect</emphasis></entry>
33782 <entry>Type: <emphasis>boolean</emphasis></entry>
33783 <entry>Default: <emphasis>false</emphasis></entry>
33784 </row>
33785 </tbody>
33786 </tgroup>
33787 </informaltable>
33788 <para>
33789 <indexterm role="concept">
33790 <primary>failing delivery</primary>
33791 <secondary>from filter</secondary>
33792 </indexterm>
33793 If this option is true, the <emphasis>:fail:</emphasis> item can be used in a redirection list,
33794 and the <option>fail</option> command may be used in an Exim filter file.
33795 </para>
33796 <para>
33797 <indexterm role="option">
33798 <primary><option>allow_filter</option></primary>
33799 </indexterm>
33800 </para>
33801 <informaltable frame="all">
33802 <tgroup cols="4" colsep="0" rowsep="0">
33803 <colspec colwidth="8*" align="left"/>
33804 <colspec colwidth="6*" align="center"/>
33805 <colspec colwidth="6*" align="center"/>
33806 <colspec colwidth="6*" align="right"/>
33807 <tbody>
33808 <row>
33809 <entry><option>allow_filter</option></entry>
33810 <entry>Use: <emphasis>redirect</emphasis></entry>
33811 <entry>Type: <emphasis>boolean</emphasis></entry>
33812 <entry>Default: <emphasis>false</emphasis></entry>
33813 </row>
33814 </tbody>
33815 </tgroup>
33816 </informaltable>
33817 <para>
33818 <indexterm role="concept">
33819 <primary>filter</primary>
33820 <secondary>enabling use of</secondary>
33821 </indexterm>
33822 <indexterm role="concept">
33823 <primary>Sieve filter</primary>
33824 <secondary>enabling use of</secondary>
33825 </indexterm>
33826 Setting this option allows Exim to interpret redirection data that starts with
33827 <quote>#Exim filter</quote> or <quote>#Sieve filter</quote> as a set of filtering instructions. There
33828 are some features of Exim filter files that some administrators may wish to
33829 lock out; see the <option>forbid_filter_</option><emphasis>xxx</emphasis> options below.
33830 </para>
33831 <para>
33832 It is also possible to lock out Exim filters or Sieve filters while allowing
33833 the other type; see <option>forbid_exim_filter</option> and <option>forbid_sieve_filter</option>.
33834 </para>
33835 <para>
33836 The filter is run using the uid and gid set by the generic <option>user</option> and
33837 <option>group</option> options. These take their defaults from the password data if
33838 <option>check_local_user</option> is set, so in the normal case of users&#x2019; personal filter
33839 files, the filter is run as the relevant user. When <option>allow_filter</option> is set
33840 true, Exim insists that either <option>check_local_user</option> or <option>user</option> is set.
33841 </para>
33842 <para>
33843 <indexterm role="option">
33844 <primary><option>allow_freeze</option></primary>
33845 </indexterm>
33846 </para>
33847 <informaltable frame="all">
33848 <tgroup cols="4" colsep="0" rowsep="0">
33849 <colspec colwidth="8*" align="left"/>
33850 <colspec colwidth="6*" align="center"/>
33851 <colspec colwidth="6*" align="center"/>
33852 <colspec colwidth="6*" align="right"/>
33853 <tbody>
33854 <row>
33855 <entry><option>allow_freeze</option></entry>
33856 <entry>Use: <emphasis>redirect</emphasis></entry>
33857 <entry>Type: <emphasis>boolean</emphasis></entry>
33858 <entry>Default: <emphasis>false</emphasis></entry>
33859 </row>
33860 </tbody>
33861 </tgroup>
33862 </informaltable>
33863 <para>
33864 <indexterm role="concept">
33865 <primary>freezing messages</primary>
33866 <secondary>allowing in filter</secondary>
33867 </indexterm>
33868 Setting this option allows the use of the <option>freeze</option> command in an Exim filter.
33869 This command is more normally encountered in system filters, and is disabled by
33870 default for redirection filters because it isn&#x2019;t something you usually want to
33871 let ordinary users do.
33872 </para>
33873 <para>
33874 <indexterm role="option">
33875 <primary><option>check_ancestor</option></primary>
33876 </indexterm>
33877 </para>
33878 <informaltable frame="all">
33879 <tgroup cols="4" colsep="0" rowsep="0">
33880 <colspec colwidth="8*" align="left"/>
33881 <colspec colwidth="6*" align="center"/>
33882 <colspec colwidth="6*" align="center"/>
33883 <colspec colwidth="6*" align="right"/>
33884 <tbody>
33885 <row>
33886 <entry><option>check_ancestor</option></entry>
33887 <entry>Use: <emphasis>redirect</emphasis></entry>
33888 <entry>Type: <emphasis>boolean</emphasis></entry>
33889 <entry>Default: <emphasis>false</emphasis></entry>
33890 </row>
33891 </tbody>
33892 </tgroup>
33893 </informaltable>
33894 <para>
33895 This option is concerned with handling generated addresses that are the same
33896 as some address in the list of redirection ancestors of the current address.
33897 Although it is turned off by default in the code, it is set in the default
33898 configuration file for handling users&#x2019; <filename>.forward</filename> files. It is recommended
33899 for this use of the <command>redirect</command> router.
33900 </para>
33901 <para>
33902 When <option>check_ancestor</option> is set, if a generated address (including the domain)
33903 is the same as any ancestor of the current address, it is replaced by a copy of
33904 the current address. This helps in the case where local part A is aliased to B,
33905 and B has a <filename>.forward</filename> file pointing back to A. For example, within a single
33906 domain, the local part <quote>Joe.Bloggs</quote> is aliased to <quote>jb</quote> and
33907 <filename>&nbsp;jb/.forward</filename> contains:
33908 </para>
33909 <literallayout class="monospaced">
33910 \Joe.Bloggs, &lt;other item(s)&gt;
33911 </literallayout>
33912 <para>
33913 Without the <option>check_ancestor</option> setting, either local part (<quote>jb</quote> or
33914 <quote>joe.bloggs</quote>) gets processed once by each router and so ends up as it was
33915 originally. If <quote>jb</quote> is the real mailbox name, mail to <quote>jb</quote> gets delivered
33916 (having been turned into <quote>joe.bloggs</quote> by the <filename>.forward</filename> file and back to
33917 <quote>jb</quote> by the alias), but mail to <quote>joe.bloggs</quote> fails. Setting
33918 <option>check_ancestor</option> on the <command>redirect</command> router that handles the <filename>.forward</filename>
33919 file prevents it from turning <quote>jb</quote> back into <quote>joe.bloggs</quote> when that was the
33920 original address. See also the <option>repeat_use</option> option below.
33921 </para>
33922 <para>
33923 <indexterm role="option">
33924 <primary><option>check_group</option></primary>
33925 </indexterm>
33926 </para>
33927 <informaltable frame="all">
33928 <tgroup cols="4" colsep="0" rowsep="0">
33929 <colspec colwidth="8*" align="left"/>
33930 <colspec colwidth="6*" align="center"/>
33931 <colspec colwidth="6*" align="center"/>
33932 <colspec colwidth="6*" align="right"/>
33933 <tbody>
33934 <row>
33935 <entry><option>check_group</option></entry>
33936 <entry>Use: <emphasis>redirect</emphasis></entry>
33937 <entry>Type: <emphasis>boolean</emphasis></entry>
33938 <entry>Default: <emphasis>see below</emphasis></entry>
33939 </row>
33940 </tbody>
33941 </tgroup>
33942 </informaltable>
33943 <para>
33944 When the <option>file</option> option is used, the group owner of the file is checked only
33945 when this option is set. The permitted groups are those listed in the
33946 <option>owngroups</option> option, together with the user&#x2019;s default group if
33947 <option>check_local_user</option> is set. If the file has the wrong group, routing is
33948 deferred. The default setting for this option is true if <option>check_local_user</option>
33949 is set and the <option>modemask</option> option permits the group write bit, or if the
33950 <option>owngroups</option> option is set. Otherwise it is false, and no group check occurs.
33951 </para>
33952 <para>
33953 <indexterm role="option">
33954 <primary><option>check_owner</option></primary>
33955 </indexterm>
33956 </para>
33957 <informaltable frame="all">
33958 <tgroup cols="4" colsep="0" rowsep="0">
33959 <colspec colwidth="8*" align="left"/>
33960 <colspec colwidth="6*" align="center"/>
33961 <colspec colwidth="6*" align="center"/>
33962 <colspec colwidth="6*" align="right"/>
33963 <tbody>
33964 <row>
33965 <entry><option>check_owner</option></entry>
33966 <entry>Use: <emphasis>redirect</emphasis></entry>
33967 <entry>Type: <emphasis>boolean</emphasis></entry>
33968 <entry>Default: <emphasis>see below</emphasis></entry>
33969 </row>
33970 </tbody>
33971 </tgroup>
33972 </informaltable>
33973 <para>
33974 When the <option>file</option> option is used, the owner of the file is checked only when
33975 this option is set. If <option>check_local_user</option> is set, the local user is
33976 permitted; otherwise the owner must be one of those listed in the <option>owners</option>
33977 option. The default value for this option is true if <option>check_local_user</option> or
33978 <option>owners</option> is set. Otherwise the default is false, and no owner check occurs.
33979 </para>
33980 <para>
33981 <indexterm role="option">
33982 <primary><option>data</option></primary>
33983 </indexterm>
33984 </para>
33985 <informaltable frame="all">
33986 <tgroup cols="4" colsep="0" rowsep="0">
33987 <colspec colwidth="8*" align="left"/>
33988 <colspec colwidth="6*" align="center"/>
33989 <colspec colwidth="6*" align="center"/>
33990 <colspec colwidth="6*" align="right"/>
33991 <tbody>
33992 <row>
33993 <entry><option>data</option></entry>
33994 <entry>Use: <emphasis>redirect</emphasis></entry>
33995 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
33996 <entry>Default: <emphasis>unset</emphasis></entry>
33997 </row>
33998 </tbody>
33999 </tgroup>
34000 </informaltable>
34001 <para>
34002 This option is mutually exclusive with <option>file</option>. One or other of them must be
34003 set, but not both. The contents of <option>data</option> are expanded, and then used as the
34004 list of forwarding items, or as a set of filtering instructions. If the
34005 expansion is forced to fail, or the result is an empty string or a string that
34006 has no effect (consists entirely of comments), the router declines.
34007 </para>
34008 <para>
34009 When filtering instructions are used, the string must begin with <quote>#Exim
34010 filter</quote>, and all comments in the string, including this initial one, must be
34011 terminated with newline characters. For example:
34012 </para>
34013 <literallayout class="monospaced">
34014 data = #Exim filter\n\
34015        if $h_to: contains Exim then save $home/mail/exim endif
34016 </literallayout>
34017 <para>
34018 If you are reading the data from a database where newlines cannot be included,
34019 you can use the <varname>${sg}</varname> expansion item to turn the escape string of your
34020 choice into a newline.
34021 </para>
34022 <para>
34023 <indexterm role="option">
34024 <primary><option>directory_transport</option></primary>
34025 </indexterm>
34026 </para>
34027 <informaltable frame="all">
34028 <tgroup cols="4" colsep="0" rowsep="0">
34029 <colspec colwidth="8*" align="left"/>
34030 <colspec colwidth="6*" align="center"/>
34031 <colspec colwidth="6*" align="center"/>
34032 <colspec colwidth="6*" align="right"/>
34033 <tbody>
34034 <row>
34035 <entry><option>directory_transport</option></entry>
34036 <entry>Use: <emphasis>redirect</emphasis></entry>
34037 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
34038 <entry>Default: <emphasis>unset</emphasis></entry>
34039 </row>
34040 </tbody>
34041 </tgroup>
34042 </informaltable>
34043 <para>
34044 A <command>redirect</command> router sets up a direct delivery to a directory when a path name
34045 ending with a slash is specified as a new <quote>address</quote>. The transport used is
34046 specified by this option, which, after expansion, must be the name of a
34047 configured transport. This should normally be an <command>appendfile</command> transport.
34048 </para>
34049 <para>
34050 <indexterm role="option">
34051 <primary><option>file</option></primary>
34052 </indexterm>
34053 </para>
34054 <informaltable frame="all">
34055 <tgroup cols="4" colsep="0" rowsep="0">
34056 <colspec colwidth="8*" align="left"/>
34057 <colspec colwidth="6*" align="center"/>
34058 <colspec colwidth="6*" align="center"/>
34059 <colspec colwidth="6*" align="right"/>
34060 <tbody>
34061 <row>
34062 <entry><option>file</option></entry>
34063 <entry>Use: <emphasis>redirect</emphasis></entry>
34064 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
34065 <entry>Default: <emphasis>unset</emphasis></entry>
34066 </row>
34067 </tbody>
34068 </tgroup>
34069 </informaltable>
34070 <para>
34071 This option specifies the name of a file that contains the redirection data. It
34072 is mutually exclusive with the <option>data</option> option. The string is expanded before
34073 use; if the expansion is forced to fail, the router declines. Other expansion
34074 failures cause delivery to be deferred. The result of a successful expansion
34075 must be an absolute path. The entire file is read and used as the redirection
34076 data. If the data is an empty string or a string that has no effect (consists
34077 entirely of comments), the router declines.
34078 </para>
34079 <para>
34080 <indexterm role="concept">
34081 <primary>NFS</primary>
34082 <secondary>checking for file existence</secondary>
34083 </indexterm>
34084 If the attempt to open the file fails with a <quote>does not exist</quote> error, Exim
34085 runs a check on the containing directory,
34086 unless <option>ignore_enotdir</option> is true (see below).
34087 If the directory does not appear to exist, delivery is deferred. This can
34088 happen when users&#x2019; <filename>.forward</filename> files are in NFS-mounted directories, and there
34089 is a mount problem. If the containing directory does exist, but the file does
34090 not, the router declines.
34091 </para>
34092 <para>
34093 <indexterm role="option">
34094 <primary><option>file_transport</option></primary>
34095 </indexterm>
34096 </para>
34097 <informaltable frame="all">
34098 <tgroup cols="4" colsep="0" rowsep="0">
34099 <colspec colwidth="8*" align="left"/>
34100 <colspec colwidth="6*" align="center"/>
34101 <colspec colwidth="6*" align="center"/>
34102 <colspec colwidth="6*" align="right"/>
34103 <tbody>
34104 <row>
34105 <entry><option>file_transport</option></entry>
34106 <entry>Use: <emphasis>redirect</emphasis></entry>
34107 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
34108 <entry>Default: <emphasis>unset</emphasis></entry>
34109 </row>
34110 </tbody>
34111 </tgroup>
34112 </informaltable>
34113 <para>
34114 <indexterm role="variable">
34115 <primary><varname>$address_file</varname></primary>
34116 </indexterm>
34117 A <command>redirect</command> router sets up a direct delivery to a file when a path name not
34118 ending in a slash is specified as a new <quote>address</quote>. The transport used is
34119 specified by this option, which, after expansion, must be the name of a
34120 configured transport. This should normally be an <command>appendfile</command> transport. When
34121 it is running, the file name is in <varname>$address_file</varname>.
34122 </para>
34123 <para>
34124 <indexterm role="option">
34125 <primary><option>filter_prepend_home</option></primary>
34126 </indexterm>
34127 </para>
34128 <informaltable frame="all">
34129 <tgroup cols="4" colsep="0" rowsep="0">
34130 <colspec colwidth="8*" align="left"/>
34131 <colspec colwidth="6*" align="center"/>
34132 <colspec colwidth="6*" align="center"/>
34133 <colspec colwidth="6*" align="right"/>
34134 <tbody>
34135 <row>
34136 <entry><option>filter_prepend_home</option></entry>
34137 <entry>Use: <emphasis>redirect</emphasis></entry>
34138 <entry>Type: <emphasis>boolean</emphasis></entry>
34139 <entry>Default: <emphasis>true</emphasis></entry>
34140 </row>
34141 </tbody>
34142 </tgroup>
34143 </informaltable>
34144 <para>
34145 When this option is true, if a <command>save</command> command in an Exim filter specifies a
34146 relative path, and <varname>$home</varname> is defined, it is automatically prepended to the
34147 relative path. If this option is set false, this action does not happen. The
34148 relative path is then passed to the transport unmodified.
34149 </para>
34150 <para>
34151 <indexterm role="option">
34152 <primary><option>forbid_blackhole</option></primary>
34153 </indexterm>
34154 </para>
34155 <informaltable frame="all">
34156 <tgroup cols="4" colsep="0" rowsep="0">
34157 <colspec colwidth="8*" align="left"/>
34158 <colspec colwidth="6*" align="center"/>
34159 <colspec colwidth="6*" align="center"/>
34160 <colspec colwidth="6*" align="right"/>
34161 <tbody>
34162 <row>
34163 <entry><option>forbid_blackhole</option></entry>
34164 <entry>Use: <emphasis>redirect</emphasis></entry>
34165 <entry>Type: <emphasis>boolean</emphasis></entry>
34166 <entry>Default: <emphasis>false</emphasis></entry>
34167 </row>
34168 </tbody>
34169 </tgroup>
34170 </informaltable>
34171 <para>
34172 If this option is true, the <emphasis>:blackhole:</emphasis> item may not appear in a
34173 redirection list.
34174 </para>
34175 <para>
34176 <indexterm role="option">
34177 <primary><option>forbid_exim_filter</option></primary>
34178 </indexterm>
34179 </para>
34180 <informaltable frame="all">
34181 <tgroup cols="4" colsep="0" rowsep="0">
34182 <colspec colwidth="8*" align="left"/>
34183 <colspec colwidth="6*" align="center"/>
34184 <colspec colwidth="6*" align="center"/>
34185 <colspec colwidth="6*" align="right"/>
34186 <tbody>
34187 <row>
34188 <entry><option>forbid_exim_filter</option></entry>
34189 <entry>Use: <emphasis>redirect</emphasis></entry>
34190 <entry>Type: <emphasis>boolean</emphasis></entry>
34191 <entry>Default: <emphasis>false</emphasis></entry>
34192 </row>
34193 </tbody>
34194 </tgroup>
34195 </informaltable>
34196 <para>
34197 If this option is set true, only Sieve filters are permitted when
34198 <option>allow_filter</option> is true.
34199 </para>
34200 <para>
34201 <indexterm role="option">
34202 <primary><option>forbid_file</option></primary>
34203 </indexterm>
34204 </para>
34205 <informaltable frame="all">
34206 <tgroup cols="4" colsep="0" rowsep="0">
34207 <colspec colwidth="8*" align="left"/>
34208 <colspec colwidth="6*" align="center"/>
34209 <colspec colwidth="6*" align="center"/>
34210 <colspec colwidth="6*" align="right"/>
34211 <tbody>
34212 <row>
34213 <entry><option>forbid_file</option></entry>
34214 <entry>Use: <emphasis>redirect</emphasis></entry>
34215 <entry>Type: <emphasis>boolean</emphasis></entry>
34216 <entry>Default: <emphasis>false</emphasis></entry>
34217 </row>
34218 </tbody>
34219 </tgroup>
34220 </informaltable>
34221 <para>
34222 <indexterm role="concept">
34223 <primary>delivery</primary>
34224 <secondary>to file; forbidding</secondary>
34225 </indexterm>
34226 <indexterm role="concept">
34227 <primary>Sieve filter</primary>
34228 <secondary>forbidding delivery to a file</secondary>
34229 </indexterm>
34230 <indexterm role="concept">
34231 <primary>Sieve filter</primary>
34232 <secondary><quote>keep</quote> facility; disabling</secondary>
34233 </indexterm>
34234 If this option is true, this router may not generate a new address that
34235 specifies delivery to a local file or directory, either from a filter or from a
34236 conventional forward file. This option is forced to be true if <option>one_time</option> is
34237 set. It applies to Sieve filters as well as to Exim filters, but if true, it
34238 locks out the Sieve&#x2019;s <quote>keep</quote> facility.
34239 </para>
34240 <para>
34241 <indexterm role="option">
34242 <primary><option>forbid_filter_dlfunc</option></primary>
34243 </indexterm>
34244 </para>
34245 <informaltable frame="all">
34246 <tgroup cols="4" colsep="0" rowsep="0">
34247 <colspec colwidth="8*" align="left"/>
34248 <colspec colwidth="6*" align="center"/>
34249 <colspec colwidth="6*" align="center"/>
34250 <colspec colwidth="6*" align="right"/>
34251 <tbody>
34252 <row>
34253 <entry><option>forbid_filter_dlfunc</option></entry>
34254 <entry>Use: <emphasis>redirect</emphasis></entry>
34255 <entry>Type: <emphasis>boolean</emphasis></entry>
34256 <entry>Default: <emphasis>false</emphasis></entry>
34257 </row>
34258 </tbody>
34259 </tgroup>
34260 </informaltable>
34261 <para>
34262 <indexterm role="concept">
34263 <primary>filter</primary>
34264 <secondary>locking out certain features</secondary>
34265 </indexterm>
34266 If this option is true, string expansions in Exim filters are not allowed to
34267 make use of the <option>dlfunc</option> expansion facility to run dynamically loaded
34268 functions.
34269 </para>
34270 <para>
34271 <indexterm role="option">
34272 <primary><option>forbid_filter_existstest</option></primary>
34273 </indexterm>
34274 </para>
34275 <informaltable frame="all">
34276 <tgroup cols="4" colsep="0" rowsep="0">
34277 <colspec colwidth="8*" align="left"/>
34278 <colspec colwidth="6*" align="center"/>
34279 <colspec colwidth="6*" align="center"/>
34280 <colspec colwidth="6*" align="right"/>
34281 <tbody>
34282 <row>
34283 <entry><option>forbid_filter_existstest</option></entry>
34284 <entry>Use: <emphasis>redirect</emphasis></entry>
34285 <entry>Type: <emphasis>boolean</emphasis></entry>
34286 <entry>Default: <emphasis>false</emphasis></entry>
34287 </row>
34288 </tbody>
34289 </tgroup>
34290 </informaltable>
34291 <para>
34292 <indexterm role="concept">
34293 <primary>expansion</primary>
34294 <secondary>statting a file</secondary>
34295 </indexterm>
34296 If this option is true, string expansions in Exim filters are not allowed to
34297 make use of the <option>exists</option> condition or the <option>stat</option> expansion item.
34298 </para>
34299 <para>
34300 <indexterm role="option">
34301 <primary><option>forbid_filter_logwrite</option></primary>
34302 </indexterm>
34303 </para>
34304 <informaltable frame="all">
34305 <tgroup cols="4" colsep="0" rowsep="0">
34306 <colspec colwidth="8*" align="left"/>
34307 <colspec colwidth="6*" align="center"/>
34308 <colspec colwidth="6*" align="center"/>
34309 <colspec colwidth="6*" align="right"/>
34310 <tbody>
34311 <row>
34312 <entry><option>forbid_filter_logwrite</option></entry>
34313 <entry>Use: <emphasis>redirect</emphasis></entry>
34314 <entry>Type: <emphasis>boolean</emphasis></entry>
34315 <entry>Default: <emphasis>false</emphasis></entry>
34316 </row>
34317 </tbody>
34318 </tgroup>
34319 </informaltable>
34320 <para>
34321 If this option is true, use of the logging facility in Exim filters is not
34322 permitted. Logging is in any case available only if the filter is being run
34323 under some unprivileged uid (which is normally the case for ordinary users&#x2019;
34324 <filename>.forward</filename> files).
34325 </para>
34326 <para>
34327 <indexterm role="option">
34328 <primary><option>forbid_filter_lookup</option></primary>
34329 </indexterm>
34330 </para>
34331 <informaltable frame="all">
34332 <tgroup cols="4" colsep="0" rowsep="0">
34333 <colspec colwidth="8*" align="left"/>
34334 <colspec colwidth="6*" align="center"/>
34335 <colspec colwidth="6*" align="center"/>
34336 <colspec colwidth="6*" align="right"/>
34337 <tbody>
34338 <row>
34339 <entry><option>forbid_filter_lookup</option></entry>
34340 <entry>Use: <emphasis>redirect</emphasis></entry>
34341 <entry>Type: <emphasis>boolean</emphasis></entry>
34342 <entry>Default: <emphasis>false</emphasis></entry>
34343 </row>
34344 </tbody>
34345 </tgroup>
34346 </informaltable>
34347 <para>
34348 If this option is true, string expansions in Exim filter files are not allowed
34349 to make use of <option>lookup</option> items.
34350 </para>
34351 <para>
34352 <indexterm role="option">
34353 <primary><option>forbid_filter_perl</option></primary>
34354 </indexterm>
34355 </para>
34356 <informaltable frame="all">
34357 <tgroup cols="4" colsep="0" rowsep="0">
34358 <colspec colwidth="8*" align="left"/>
34359 <colspec colwidth="6*" align="center"/>
34360 <colspec colwidth="6*" align="center"/>
34361 <colspec colwidth="6*" align="right"/>
34362 <tbody>
34363 <row>
34364 <entry><option>forbid_filter_perl</option></entry>
34365 <entry>Use: <emphasis>redirect</emphasis></entry>
34366 <entry>Type: <emphasis>boolean</emphasis></entry>
34367 <entry>Default: <emphasis>false</emphasis></entry>
34368 </row>
34369 </tbody>
34370 </tgroup>
34371 </informaltable>
34372 <para>
34373 This option has an effect only if Exim is built with embedded Perl support. If
34374 it is true, string expansions in Exim filter files are not allowed to make use
34375 of the embedded Perl support.
34376 </para>
34377 <para>
34378 <indexterm role="option">
34379 <primary><option>forbid_filter_readfile</option></primary>
34380 </indexterm>
34381 </para>
34382 <informaltable frame="all">
34383 <tgroup cols="4" colsep="0" rowsep="0">
34384 <colspec colwidth="8*" align="left"/>
34385 <colspec colwidth="6*" align="center"/>
34386 <colspec colwidth="6*" align="center"/>
34387 <colspec colwidth="6*" align="right"/>
34388 <tbody>
34389 <row>
34390 <entry><option>forbid_filter_readfile</option></entry>
34391 <entry>Use: <emphasis>redirect</emphasis></entry>
34392 <entry>Type: <emphasis>boolean</emphasis></entry>
34393 <entry>Default: <emphasis>false</emphasis></entry>
34394 </row>
34395 </tbody>
34396 </tgroup>
34397 </informaltable>
34398 <para>
34399 If this option is true, string expansions in Exim filter files are not allowed
34400 to make use of <option>readfile</option> items.
34401 </para>
34402 <para>
34403 <indexterm role="option">
34404 <primary><option>forbid_filter_readsocket</option></primary>
34405 </indexterm>
34406 </para>
34407 <informaltable frame="all">
34408 <tgroup cols="4" colsep="0" rowsep="0">
34409 <colspec colwidth="8*" align="left"/>
34410 <colspec colwidth="6*" align="center"/>
34411 <colspec colwidth="6*" align="center"/>
34412 <colspec colwidth="6*" align="right"/>
34413 <tbody>
34414 <row>
34415 <entry><option>forbid_filter_readsocket</option></entry>
34416 <entry>Use: <emphasis>redirect</emphasis></entry>
34417 <entry>Type: <emphasis>boolean</emphasis></entry>
34418 <entry>Default: <emphasis>false</emphasis></entry>
34419 </row>
34420 </tbody>
34421 </tgroup>
34422 </informaltable>
34423 <para>
34424 If this option is true, string expansions in Exim filter files are not allowed
34425 to make use of <option>readsocket</option> items.
34426 </para>
34427 <para>
34428 <indexterm role="option">
34429 <primary><option>forbid_filter_reply</option></primary>
34430 </indexterm>
34431 </para>
34432 <informaltable frame="all">
34433 <tgroup cols="4" colsep="0" rowsep="0">
34434 <colspec colwidth="8*" align="left"/>
34435 <colspec colwidth="6*" align="center"/>
34436 <colspec colwidth="6*" align="center"/>
34437 <colspec colwidth="6*" align="right"/>
34438 <tbody>
34439 <row>
34440 <entry><option>forbid_filter_reply</option></entry>
34441 <entry>Use: <emphasis>redirect</emphasis></entry>
34442 <entry>Type: <emphasis>boolean</emphasis></entry>
34443 <entry>Default: <emphasis>false</emphasis></entry>
34444 </row>
34445 </tbody>
34446 </tgroup>
34447 </informaltable>
34448 <para>
34449 If this option is true, this router may not generate an automatic reply
34450 message. Automatic replies can be generated only from Exim or Sieve filter
34451 files, not from traditional forward files. This option is forced to be true if
34452 <option>one_time</option> is set.
34453 </para>
34454 <para>
34455 <indexterm role="option">
34456 <primary><option>forbid_filter_run</option></primary>
34457 </indexterm>
34458 </para>
34459 <informaltable frame="all">
34460 <tgroup cols="4" colsep="0" rowsep="0">
34461 <colspec colwidth="8*" align="left"/>
34462 <colspec colwidth="6*" align="center"/>
34463 <colspec colwidth="6*" align="center"/>
34464 <colspec colwidth="6*" align="right"/>
34465 <tbody>
34466 <row>
34467 <entry><option>forbid_filter_run</option></entry>
34468 <entry>Use: <emphasis>redirect</emphasis></entry>
34469 <entry>Type: <emphasis>boolean</emphasis></entry>
34470 <entry>Default: <emphasis>false</emphasis></entry>
34471 </row>
34472 </tbody>
34473 </tgroup>
34474 </informaltable>
34475 <para>
34476 If this option is true, string expansions in Exim filter files are not allowed
34477 to make use of <option>run</option> items.
34478 </para>
34479 <para>
34480 <indexterm role="option">
34481 <primary><option>forbid_include</option></primary>
34482 </indexterm>
34483 </para>
34484 <informaltable frame="all">
34485 <tgroup cols="4" colsep="0" rowsep="0">
34486 <colspec colwidth="8*" align="left"/>
34487 <colspec colwidth="6*" align="center"/>
34488 <colspec colwidth="6*" align="center"/>
34489 <colspec colwidth="6*" align="right"/>
34490 <tbody>
34491 <row>
34492 <entry><option>forbid_include</option></entry>
34493 <entry>Use: <emphasis>redirect</emphasis></entry>
34494 <entry>Type: <emphasis>boolean</emphasis></entry>
34495 <entry>Default: <emphasis>false</emphasis></entry>
34496 </row>
34497 </tbody>
34498 </tgroup>
34499 </informaltable>
34500 <para>
34501 If this option is true, items of the form
34502 </para>
34503 <literallayout class="monospaced">
34504 :include:&lt;path name&gt;
34505 </literallayout>
34506 <para>
34507 are not permitted in non-filter redirection lists.
34508 </para>
34509 <para>
34510 <indexterm role="option">
34511 <primary><option>forbid_pipe</option></primary>
34512 </indexterm>
34513 </para>
34514 <informaltable frame="all">
34515 <tgroup cols="4" colsep="0" rowsep="0">
34516 <colspec colwidth="8*" align="left"/>
34517 <colspec colwidth="6*" align="center"/>
34518 <colspec colwidth="6*" align="center"/>
34519 <colspec colwidth="6*" align="right"/>
34520 <tbody>
34521 <row>
34522 <entry><option>forbid_pipe</option></entry>
34523 <entry>Use: <emphasis>redirect</emphasis></entry>
34524 <entry>Type: <emphasis>boolean</emphasis></entry>
34525 <entry>Default: <emphasis>false</emphasis></entry>
34526 </row>
34527 </tbody>
34528 </tgroup>
34529 </informaltable>
34530 <para>
34531 <indexterm role="concept">
34532 <primary>delivery</primary>
34533 <secondary>to pipe; forbidding</secondary>
34534 </indexterm>
34535 If this option is true, this router may not generate a new address which
34536 specifies delivery to a pipe, either from an Exim filter or from a conventional
34537 forward file. This option is forced to be true if <option>one_time</option> is set.
34538 </para>
34539 <para>
34540 <indexterm role="option">
34541 <primary><option>forbid_sieve_filter</option></primary>
34542 </indexterm>
34543 </para>
34544 <informaltable frame="all">
34545 <tgroup cols="4" colsep="0" rowsep="0">
34546 <colspec colwidth="8*" align="left"/>
34547 <colspec colwidth="6*" align="center"/>
34548 <colspec colwidth="6*" align="center"/>
34549 <colspec colwidth="6*" align="right"/>
34550 <tbody>
34551 <row>
34552 <entry><option>forbid_sieve_filter</option></entry>
34553 <entry>Use: <emphasis>redirect</emphasis></entry>
34554 <entry>Type: <emphasis>boolean</emphasis></entry>
34555 <entry>Default: <emphasis>false</emphasis></entry>
34556 </row>
34557 </tbody>
34558 </tgroup>
34559 </informaltable>
34560 <para>
34561 If this option is set true, only Exim filters are permitted when
34562 <option>allow_filter</option> is true.
34563 </para>
34564 <para>
34565 <indexterm role="concept">
34566 <primary>SMTP</primary>
34567 <secondary>error codes</secondary>
34568 </indexterm>
34569 <indexterm role="option">
34570 <primary><option>forbid_smtp_code</option></primary>
34571 </indexterm>
34572 </para>
34573 <informaltable frame="all">
34574 <tgroup cols="4" colsep="0" rowsep="0">
34575 <colspec colwidth="8*" align="left"/>
34576 <colspec colwidth="6*" align="center"/>
34577 <colspec colwidth="6*" align="center"/>
34578 <colspec colwidth="6*" align="right"/>
34579 <tbody>
34580 <row>
34581 <entry><option>forbid_smtp_code</option></entry>
34582 <entry>Use: <emphasis>redirect</emphasis></entry>
34583 <entry>Type: <emphasis>boolean</emphasis></entry>
34584 <entry>Default: <emphasis>false</emphasis></entry>
34585 </row>
34586 </tbody>
34587 </tgroup>
34588 </informaltable>
34589 <para>
34590 If this option is set true, any SMTP error codes that are present at the start
34591 of messages specified for <literal>:defer:</literal> or <literal>:fail:</literal> are quietly ignored, and
34592 the default codes (451 and 550, respectively) are always used.
34593 </para>
34594 <para>
34595 <indexterm role="option">
34596 <primary><option>hide_child_in_errmsg</option></primary>
34597 </indexterm>
34598 </para>
34599 <informaltable frame="all">
34600 <tgroup cols="4" colsep="0" rowsep="0">
34601 <colspec colwidth="8*" align="left"/>
34602 <colspec colwidth="6*" align="center"/>
34603 <colspec colwidth="6*" align="center"/>
34604 <colspec colwidth="6*" align="right"/>
34605 <tbody>
34606 <row>
34607 <entry><option>hide_child_in_errmsg</option></entry>
34608 <entry>Use: <emphasis>redirect</emphasis></entry>
34609 <entry>Type: <emphasis>boolean</emphasis></entry>
34610 <entry>Default: <emphasis>false</emphasis></entry>
34611 </row>
34612 </tbody>
34613 </tgroup>
34614 </informaltable>
34615 <para>
34616 <indexterm role="concept">
34617 <primary>bounce message</primary>
34618 <secondary>redirection details; suppressing</secondary>
34619 </indexterm>
34620 If this option is true, it prevents Exim from quoting a child address if it
34621 generates a bounce or delay message for it. Instead it says <quote>an address
34622 generated from &lt;<emphasis>the top level address</emphasis>&gt;</quote>. Of course, this applies only to
34623 bounces generated locally. If a message is forwarded to another host, <emphasis>its</emphasis>
34624 bounce may well quote the generated address.
34625 </para>
34626 <para>
34627 <indexterm role="option">
34628 <primary><option>ignore_eacces</option></primary>
34629 </indexterm>
34630 </para>
34631 <informaltable frame="all">
34632 <tgroup cols="4" colsep="0" rowsep="0">
34633 <colspec colwidth="8*" align="left"/>
34634 <colspec colwidth="6*" align="center"/>
34635 <colspec colwidth="6*" align="center"/>
34636 <colspec colwidth="6*" align="right"/>
34637 <tbody>
34638 <row>
34639 <entry><option>ignore_eacces</option></entry>
34640 <entry>Use: <emphasis>redirect</emphasis></entry>
34641 <entry>Type: <emphasis>boolean</emphasis></entry>
34642 <entry>Default: <emphasis>false</emphasis></entry>
34643 </row>
34644 </tbody>
34645 </tgroup>
34646 </informaltable>
34647 <para>
34648 <indexterm role="concept">
34649 <primary>EACCES</primary>
34650 </indexterm>
34651 If this option is set and an attempt to open a redirection file yields the
34652 EACCES error (permission denied), the <command>redirect</command> router behaves as if the
34653 file did not exist.
34654 </para>
34655 <para>
34656 <indexterm role="option">
34657 <primary><option>ignore_enotdir</option></primary>
34658 </indexterm>
34659 </para>
34660 <informaltable frame="all">
34661 <tgroup cols="4" colsep="0" rowsep="0">
34662 <colspec colwidth="8*" align="left"/>
34663 <colspec colwidth="6*" align="center"/>
34664 <colspec colwidth="6*" align="center"/>
34665 <colspec colwidth="6*" align="right"/>
34666 <tbody>
34667 <row>
34668 <entry><option>ignore_enotdir</option></entry>
34669 <entry>Use: <emphasis>redirect</emphasis></entry>
34670 <entry>Type: <emphasis>boolean</emphasis></entry>
34671 <entry>Default: <emphasis>false</emphasis></entry>
34672 </row>
34673 </tbody>
34674 </tgroup>
34675 </informaltable>
34676 <para>
34677 <indexterm role="concept">
34678 <primary>ENOTDIR</primary>
34679 </indexterm>
34680 If this option is set and an attempt to open a redirection file yields the
34681 ENOTDIR error (something on the path is not a directory), the <command>redirect</command>
34682 router behaves as if the file did not exist.
34683 </para>
34684 <para>
34685 Setting <option>ignore_enotdir</option> has another effect as well: When a <command>redirect</command>
34686 router that has the <option>file</option> option set discovers that the file does not exist
34687 (the ENOENT error), it tries to <function>stat()</function> the parent directory, as a check
34688 against unmounted NFS directories. If the parent can not be statted, delivery
34689 is deferred. However, it seems wrong to do this check when <option>ignore_enotdir</option>
34690 is set, because that option tells Exim to ignore <quote>something on the path is not
34691 a directory</quote> (the ENOTDIR error). This is a confusing area, because it seems
34692 that some operating systems give ENOENT where others give ENOTDIR.
34693 </para>
34694 <para>
34695 <indexterm role="option">
34696 <primary><option>include_directory</option></primary>
34697 </indexterm>
34698 </para>
34699 <informaltable frame="all">
34700 <tgroup cols="4" colsep="0" rowsep="0">
34701 <colspec colwidth="8*" align="left"/>
34702 <colspec colwidth="6*" align="center"/>
34703 <colspec colwidth="6*" align="center"/>
34704 <colspec colwidth="6*" align="right"/>
34705 <tbody>
34706 <row>
34707 <entry><option>include_directory</option></entry>
34708 <entry>Use: <emphasis>redirect</emphasis></entry>
34709 <entry>Type: <emphasis>string</emphasis></entry>
34710 <entry>Default: <emphasis>unset</emphasis></entry>
34711 </row>
34712 </tbody>
34713 </tgroup>
34714 </informaltable>
34715 <para>
34716 If this option is set, the path names of any <emphasis>:include:</emphasis> items in a
34717 redirection list must start with this directory.
34718 </para>
34719 <para>
34720 <indexterm role="option">
34721 <primary><option>modemask</option></primary>
34722 </indexterm>
34723 </para>
34724 <informaltable frame="all">
34725 <tgroup cols="4" colsep="0" rowsep="0">
34726 <colspec colwidth="8*" align="left"/>
34727 <colspec colwidth="6*" align="center"/>
34728 <colspec colwidth="6*" align="center"/>
34729 <colspec colwidth="6*" align="right"/>
34730 <tbody>
34731 <row>
34732 <entry><option>modemask</option></entry>
34733 <entry>Use: <emphasis>redirect</emphasis></entry>
34734 <entry>Type: <emphasis>octal integer</emphasis></entry>
34735 <entry>Default: <emphasis>022</emphasis></entry>
34736 </row>
34737 </tbody>
34738 </tgroup>
34739 </informaltable>
34740 <para>
34741 This specifies mode bits which must not be set for a file specified by the
34742 <option>file</option> option. If any of the forbidden bits are set, delivery is deferred.
34743 </para>
34744 <para>
34745 <indexterm role="option">
34746 <primary><option>one_time</option></primary>
34747 </indexterm>
34748 </para>
34749 <informaltable frame="all">
34750 <tgroup cols="4" colsep="0" rowsep="0">
34751 <colspec colwidth="8*" align="left"/>
34752 <colspec colwidth="6*" align="center"/>
34753 <colspec colwidth="6*" align="center"/>
34754 <colspec colwidth="6*" align="right"/>
34755 <tbody>
34756 <row>
34757 <entry><option>one_time</option></entry>
34758 <entry>Use: <emphasis>redirect</emphasis></entry>
34759 <entry>Type: <emphasis>boolean</emphasis></entry>
34760 <entry>Default: <emphasis>false</emphasis></entry>
34761 </row>
34762 </tbody>
34763 </tgroup>
34764 </informaltable>
34765 <para>
34766 <indexterm role="concept">
34767 <primary>one-time aliasing/forwarding expansion</primary>
34768 </indexterm>
34769 <indexterm role="concept">
34770 <primary>alias file</primary>
34771 <secondary>one-time expansion</secondary>
34772 </indexterm>
34773 <indexterm role="concept">
34774 <primary>forward file</primary>
34775 <secondary>one-time expansion</secondary>
34776 </indexterm>
34777 <indexterm role="concept">
34778 <primary>mailing lists</primary>
34779 <secondary>one-time expansion</secondary>
34780 </indexterm>
34781 <indexterm role="concept">
34782 <primary>address redirection</primary>
34783 <secondary>one-time expansion</secondary>
34784 </indexterm>
34785 Sometimes the fact that Exim re-evaluates aliases and reprocesses redirection
34786 files each time it tries to deliver a message causes a problem when one or more
34787 of the generated addresses fails be delivered at the first attempt. The problem
34788 is not one of duplicate delivery &ndash; Exim is clever enough to handle that &ndash;
34789 but of what happens when the redirection list changes during the time that the
34790 message is on Exim&#x2019;s queue. This is particularly true in the case of mailing
34791 lists, where new subscribers might receive copies of messages that were posted
34792 before they subscribed.
34793 </para>
34794 <para>
34795 If <option>one_time</option> is set and any addresses generated by the router fail to
34796 deliver at the first attempt, the failing addresses are added to the message as
34797 <quote>top level</quote> addresses, and the parent address that generated them is marked
34798 <quote>delivered</quote>. Thus, redirection does not happen again at the next delivery
34799 attempt.
34800 </para>
34801 <para>
34802 <emphasis role="bold">Warning 1</emphasis>: Any header line addition or removal that is specified by this
34803 router would be lost if delivery did not succeed at the first attempt. For this
34804 reason, the <option>headers_add</option> and <option>headers_remove</option> generic options are not
34805 permitted when <option>one_time</option> is set.
34806 </para>
34807 <para>
34808 <emphasis role="bold">Warning 2</emphasis>: To ensure that the router generates only addresses (as opposed
34809 to pipe or file deliveries or auto-replies) <option>forbid_file</option>, <option>forbid_pipe</option>,
34810 and <option>forbid_filter_reply</option> are forced to be true when <option>one_time</option> is set.
34811 </para>
34812 <para>
34813 <emphasis role="bold">Warning 3</emphasis>: The <option>unseen</option> generic router option may not be set with
34814 <option>one_time</option>.
34815 </para>
34816 <para>
34817 The original top-level address is remembered with each of the generated
34818 addresses, and is output in any log messages. However, any intermediate parent
34819 addresses are not recorded. This makes a difference to the log only if
34820 <option>all_parents</option> log selector is set. It is expected that <option>one_time</option> will
34821 typically be used for mailing lists, where there is normally just one level of
34822 expansion.
34823 </para>
34824 <para>
34825 <indexterm role="option">
34826 <primary><option>owners</option></primary>
34827 </indexterm>
34828 </para>
34829 <informaltable frame="all">
34830 <tgroup cols="4" colsep="0" rowsep="0">
34831 <colspec colwidth="8*" align="left"/>
34832 <colspec colwidth="6*" align="center"/>
34833 <colspec colwidth="6*" align="center"/>
34834 <colspec colwidth="6*" align="right"/>
34835 <tbody>
34836 <row>
34837 <entry><option>owners</option></entry>
34838 <entry>Use: <emphasis>redirect</emphasis></entry>
34839 <entry>Type: <emphasis>string list</emphasis></entry>
34840 <entry>Default: <emphasis>unset</emphasis></entry>
34841 </row>
34842 </tbody>
34843 </tgroup>
34844 </informaltable>
34845 <para>
34846 <indexterm role="concept">
34847 <primary>ownership</primary>
34848 <secondary>alias file</secondary>
34849 </indexterm>
34850 <indexterm role="concept">
34851 <primary>ownership</primary>
34852 <secondary>forward file</secondary>
34853 </indexterm>
34854 <indexterm role="concept">
34855 <primary>alias file</primary>
34856 <secondary>ownership</secondary>
34857 </indexterm>
34858 <indexterm role="concept">
34859 <primary>forward file</primary>
34860 <secondary>ownership</secondary>
34861 </indexterm>
34862 This specifies a list of permitted owners for the file specified by <option>file</option>.
34863 This list is in addition to the local user when <option>check_local_user</option> is set.
34864 See <option>check_owner</option> above.
34865 </para>
34866 <para>
34867 <indexterm role="option">
34868 <primary><option>owngroups</option></primary>
34869 </indexterm>
34870 </para>
34871 <informaltable frame="all">
34872 <tgroup cols="4" colsep="0" rowsep="0">
34873 <colspec colwidth="8*" align="left"/>
34874 <colspec colwidth="6*" align="center"/>
34875 <colspec colwidth="6*" align="center"/>
34876 <colspec colwidth="6*" align="right"/>
34877 <tbody>
34878 <row>
34879 <entry><option>owngroups</option></entry>
34880 <entry>Use: <emphasis>redirect</emphasis></entry>
34881 <entry>Type: <emphasis>string list</emphasis></entry>
34882 <entry>Default: <emphasis>unset</emphasis></entry>
34883 </row>
34884 </tbody>
34885 </tgroup>
34886 </informaltable>
34887 <para>
34888 This specifies a list of permitted groups for the file specified by <option>file</option>.
34889 The list is in addition to the local user&#x2019;s primary group when
34890 <option>check_local_user</option> is set. See <option>check_group</option> above.
34891 </para>
34892 <para>
34893 <indexterm role="option">
34894 <primary><option>pipe_transport</option></primary>
34895 </indexterm>
34896 </para>
34897 <informaltable frame="all">
34898 <tgroup cols="4" colsep="0" rowsep="0">
34899 <colspec colwidth="8*" align="left"/>
34900 <colspec colwidth="6*" align="center"/>
34901 <colspec colwidth="6*" align="center"/>
34902 <colspec colwidth="6*" align="right"/>
34903 <tbody>
34904 <row>
34905 <entry><option>pipe_transport</option></entry>
34906 <entry>Use: <emphasis>redirect</emphasis></entry>
34907 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
34908 <entry>Default: <emphasis>unset</emphasis></entry>
34909 </row>
34910 </tbody>
34911 </tgroup>
34912 </informaltable>
34913 <para>
34914 <indexterm role="variable">
34915 <primary><varname>$address_pipe</varname></primary>
34916 </indexterm>
34917 A <command>redirect</command> router sets up a direct delivery to a pipe when a string
34918 starting with a vertical bar character is specified as a new <quote>address</quote>. The
34919 transport used is specified by this option, which, after expansion, must be the
34920 name of a configured transport. This should normally be a <command>pipe</command> transport.
34921 When the transport is run, the pipe command is in <varname>$address_pipe</varname>.
34922 </para>
34923 <para>
34924 <indexterm role="option">
34925 <primary><option>qualify_domain</option></primary>
34926 </indexterm>
34927 </para>
34928 <informaltable frame="all">
34929 <tgroup cols="4" colsep="0" rowsep="0">
34930 <colspec colwidth="8*" align="left"/>
34931 <colspec colwidth="6*" align="center"/>
34932 <colspec colwidth="6*" align="center"/>
34933 <colspec colwidth="6*" align="right"/>
34934 <tbody>
34935 <row>
34936 <entry><option>qualify_domain</option></entry>
34937 <entry>Use: <emphasis>redirect</emphasis></entry>
34938 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
34939 <entry>Default: <emphasis>unset</emphasis></entry>
34940 </row>
34941 </tbody>
34942 </tgroup>
34943 </informaltable>
34944 <para>
34945 <indexterm role="variable">
34946 <primary><varname>$qualify_recipient</varname></primary>
34947 </indexterm>
34948 If this option is set, and an unqualified address (one without a domain) is
34949 generated, and that address would normally be qualified by the global setting
34950 in <option>qualify_recipient</option>, it is instead qualified with the domain specified by
34951 expanding this string. If the expansion fails, the router declines. If you want
34952 to revert to the default, you can have the expansion generate
34953 <varname>$qualify_recipient</varname>.
34954 </para>
34955 <para>
34956 This option applies to all unqualified addresses generated by Exim filters,
34957 but for traditional <filename>.forward</filename> files, it applies only to addresses that are
34958 not preceded by a backslash. Sieve filters cannot generate unqualified
34959 addresses.
34960 </para>
34961 <para>
34962 <indexterm role="option">
34963 <primary><option>qualify_preserve_domain</option></primary>
34964 </indexterm>
34965 </para>
34966 <informaltable frame="all">
34967 <tgroup cols="4" colsep="0" rowsep="0">
34968 <colspec colwidth="8*" align="left"/>
34969 <colspec colwidth="6*" align="center"/>
34970 <colspec colwidth="6*" align="center"/>
34971 <colspec colwidth="6*" align="right"/>
34972 <tbody>
34973 <row>
34974 <entry><option>qualify_preserve_domain</option></entry>
34975 <entry>Use: <emphasis>redirect</emphasis></entry>
34976 <entry>Type: <emphasis>boolean</emphasis></entry>
34977 <entry>Default: <emphasis>false</emphasis></entry>
34978 </row>
34979 </tbody>
34980 </tgroup>
34981 </informaltable>
34982 <para>
34983 <indexterm role="concept">
34984 <primary>domain</primary>
34985 <secondary>in redirection; preserving</secondary>
34986 </indexterm>
34987 <indexterm role="concept">
34988 <primary>preserving domain in redirection</primary>
34989 </indexterm>
34990 <indexterm role="concept">
34991 <primary>address redirection</primary>
34992 <secondary>domain; preserving</secondary>
34993 </indexterm>
34994 If this option is set, the router&#x2019;s local <option>qualify_domain</option> option must not be
34995 set (a configuration error occurs if it is). If an unqualified address (one
34996 without a domain) is generated, it is qualified with the domain of the parent
34997 address (the immediately preceding ancestor) instead of the global
34998 <option>qualify_recipient</option> value. In the case of a traditional <filename>.forward</filename> file,
34999 this applies whether or not the address is preceded by a backslash.
35000 </para>
35001 <para>
35002 <indexterm role="option">
35003 <primary><option>repeat_use</option></primary>
35004 </indexterm>
35005 </para>
35006 <informaltable frame="all">
35007 <tgroup cols="4" colsep="0" rowsep="0">
35008 <colspec colwidth="8*" align="left"/>
35009 <colspec colwidth="6*" align="center"/>
35010 <colspec colwidth="6*" align="center"/>
35011 <colspec colwidth="6*" align="right"/>
35012 <tbody>
35013 <row>
35014 <entry><option>repeat_use</option></entry>
35015 <entry>Use: <emphasis>redirect</emphasis></entry>
35016 <entry>Type: <emphasis>boolean</emphasis></entry>
35017 <entry>Default: <emphasis>true</emphasis></entry>
35018 </row>
35019 </tbody>
35020 </tgroup>
35021 </informaltable>
35022 <para>
35023 If this option is set false, the router is skipped for a child address that has
35024 any ancestor that was routed by this router. This test happens before any of
35025 the other preconditions are tested. Exim&#x2019;s default anti-looping rules skip
35026 only when the ancestor is the same as the current address. See also
35027 <option>check_ancestor</option> above and the generic <option>redirect_router</option> option.
35028 </para>
35029 <para>
35030 <indexterm role="option">
35031 <primary><option>reply_transport</option></primary>
35032 </indexterm>
35033 </para>
35034 <informaltable frame="all">
35035 <tgroup cols="4" colsep="0" rowsep="0">
35036 <colspec colwidth="8*" align="left"/>
35037 <colspec colwidth="6*" align="center"/>
35038 <colspec colwidth="6*" align="center"/>
35039 <colspec colwidth="6*" align="right"/>
35040 <tbody>
35041 <row>
35042 <entry><option>reply_transport</option></entry>
35043 <entry>Use: <emphasis>redirect</emphasis></entry>
35044 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
35045 <entry>Default: <emphasis>unset</emphasis></entry>
35046 </row>
35047 </tbody>
35048 </tgroup>
35049 </informaltable>
35050 <para>
35051 A <command>redirect</command> router sets up an automatic reply when a <option>mail</option> or
35052 <option>vacation</option> command is used in a filter file. The transport used is specified
35053 by this option, which, after expansion, must be the name of a configured
35054 transport. This should normally be an <command>autoreply</command> transport. Other transports
35055 are unlikely to do anything sensible or useful.
35056 </para>
35057 <para>
35058 <indexterm role="option">
35059 <primary><option>rewrite</option></primary>
35060 </indexterm>
35061 </para>
35062 <informaltable frame="all">
35063 <tgroup cols="4" colsep="0" rowsep="0">
35064 <colspec colwidth="8*" align="left"/>
35065 <colspec colwidth="6*" align="center"/>
35066 <colspec colwidth="6*" align="center"/>
35067 <colspec colwidth="6*" align="right"/>
35068 <tbody>
35069 <row>
35070 <entry><option>rewrite</option></entry>
35071 <entry>Use: <emphasis>redirect</emphasis></entry>
35072 <entry>Type: <emphasis>boolean</emphasis></entry>
35073 <entry>Default: <emphasis>true</emphasis></entry>
35074 </row>
35075 </tbody>
35076 </tgroup>
35077 </informaltable>
35078 <para>
35079 <indexterm role="concept">
35080 <primary>address redirection</primary>
35081 <secondary>disabling rewriting</secondary>
35082 </indexterm>
35083 If this option is set false, addresses generated by the router are not
35084 subject to address rewriting. Otherwise, they are treated like new addresses
35085 and are rewritten according to the global rewriting rules.
35086 </para>
35087 <para>
35088 <indexterm role="option">
35089 <primary><option>sieve_subaddress</option></primary>
35090 </indexterm>
35091 </para>
35092 <informaltable frame="all">
35093 <tgroup cols="4" colsep="0" rowsep="0">
35094 <colspec colwidth="8*" align="left"/>
35095 <colspec colwidth="6*" align="center"/>
35096 <colspec colwidth="6*" align="center"/>
35097 <colspec colwidth="6*" align="right"/>
35098 <tbody>
35099 <row>
35100 <entry><option>sieve_subaddress</option></entry>
35101 <entry>Use: <emphasis>redirect</emphasis></entry>
35102 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
35103 <entry>Default: <emphasis>unset</emphasis></entry>
35104 </row>
35105 </tbody>
35106 </tgroup>
35107 </informaltable>
35108 <para>
35109 The value of this option is passed to a Sieve filter to specify the
35110 :subaddress part of an address.
35111 </para>
35112 <para>
35113 <indexterm role="option">
35114 <primary><option>sieve_useraddress</option></primary>
35115 </indexterm>
35116 </para>
35117 <informaltable frame="all">
35118 <tgroup cols="4" colsep="0" rowsep="0">
35119 <colspec colwidth="8*" align="left"/>
35120 <colspec colwidth="6*" align="center"/>
35121 <colspec colwidth="6*" align="center"/>
35122 <colspec colwidth="6*" align="right"/>
35123 <tbody>
35124 <row>
35125 <entry><option>sieve_useraddress</option></entry>
35126 <entry>Use: <emphasis>redirect</emphasis></entry>
35127 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
35128 <entry>Default: <emphasis>unset</emphasis></entry>
35129 </row>
35130 </tbody>
35131 </tgroup>
35132 </informaltable>
35133 <para>
35134 The value of this option is passed to a Sieve filter to specify the :user part
35135 of an address. However, if it is unset, the entire original local part
35136 (including any prefix or suffix) is used for :user.
35137 </para>
35138 <para>
35139 <indexterm role="option">
35140 <primary><option>sieve_vacation_directory</option></primary>
35141 </indexterm>
35142 </para>
35143 <informaltable frame="all">
35144 <tgroup cols="4" colsep="0" rowsep="0">
35145 <colspec colwidth="8*" align="left"/>
35146 <colspec colwidth="6*" align="center"/>
35147 <colspec colwidth="6*" align="center"/>
35148 <colspec colwidth="6*" align="right"/>
35149 <tbody>
35150 <row>
35151 <entry><option>sieve_vacation_directory</option></entry>
35152 <entry>Use: <emphasis>redirect</emphasis></entry>
35153 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
35154 <entry>Default: <emphasis>unset</emphasis></entry>
35155 </row>
35156 </tbody>
35157 </tgroup>
35158 </informaltable>
35159 <para>
35160 <indexterm role="concept">
35161 <primary>Sieve filter</primary>
35162 <secondary>vacation directory</secondary>
35163 </indexterm>
35164 To enable the <quote>vacation</quote> extension for Sieve filters, you must set
35165 <option>sieve_vacation_directory</option> to the directory where vacation databases are held
35166 (do not put anything else in that directory), and ensure that the
35167 <option>reply_transport</option> option refers to an <command>autoreply</command> transport. Each user
35168 needs their own directory; Exim will create it if necessary.
35169 </para>
35170 <para>
35171 <indexterm role="option">
35172 <primary><option>skip_syntax_errors</option></primary>
35173 </indexterm>
35174 </para>
35175 <informaltable frame="all">
35176 <tgroup cols="4" colsep="0" rowsep="0">
35177 <colspec colwidth="8*" align="left"/>
35178 <colspec colwidth="6*" align="center"/>
35179 <colspec colwidth="6*" align="center"/>
35180 <colspec colwidth="6*" align="right"/>
35181 <tbody>
35182 <row>
35183 <entry><option>skip_syntax_errors</option></entry>
35184 <entry>Use: <emphasis>redirect</emphasis></entry>
35185 <entry>Type: <emphasis>boolean</emphasis></entry>
35186 <entry>Default: <emphasis>false</emphasis></entry>
35187 </row>
35188 </tbody>
35189 </tgroup>
35190 </informaltable>
35191 <para>
35192 <indexterm role="concept">
35193 <primary>forward file</primary>
35194 <secondary>broken</secondary>
35195 </indexterm>
35196 <indexterm role="concept">
35197 <primary>address redirection</primary>
35198 <secondary>broken files</secondary>
35199 </indexterm>
35200 <indexterm role="concept">
35201 <primary>alias file</primary>
35202 <secondary>broken</secondary>
35203 </indexterm>
35204 <indexterm role="concept">
35205 <primary>broken alias or forward files</primary>
35206 </indexterm>
35207 <indexterm role="concept">
35208 <primary>ignoring faulty addresses</primary>
35209 </indexterm>
35210 <indexterm role="concept">
35211 <primary>skipping faulty addresses</primary>
35212 </indexterm>
35213 <indexterm role="concept">
35214 <primary>error</primary>
35215 <secondary>skipping bad syntax</secondary>
35216 </indexterm>
35217 If <option>skip_syntax_errors</option> is set, syntactically malformed addresses in
35218 non-filter redirection data are skipped, and each failing address is logged. If
35219 <option>syntax_errors_to</option> is set, a message is sent to the address it defines,
35220 giving details of the failures. If <option>syntax_errors_text</option> is set, its contents
35221 are expanded and placed at the head of the error message generated by
35222 <option>syntax_errors_to</option>. Usually it is appropriate to set <option>syntax_errors_to</option> to
35223 be the same address as the generic <option>errors_to</option> option. The
35224 <option>skip_syntax_errors</option> option is often used when handling mailing lists.
35225 </para>
35226 <para>
35227 If all the addresses in a redirection list are skipped because of syntax
35228 errors, the router declines to handle the original address, and it is passed to
35229 the following routers.
35230 </para>
35231 <para>
35232 If <option>skip_syntax_errors</option> is set when an Exim filter is interpreted, any syntax
35233 error in the filter causes filtering to be abandoned without any action being
35234 taken. The incident is logged, and the router declines to handle the address,
35235 so it is passed to the following routers.
35236 </para>
35237 <para>
35238 <indexterm role="concept">
35239 <primary>Sieve filter</primary>
35240 <secondary>syntax errors in</secondary>
35241 </indexterm>
35242 Syntax errors in a Sieve filter file cause the <quote>keep</quote> action to occur. This
35243 action is specified by RFC 3028. The values of <option>skip_syntax_errors</option>,
35244 <option>syntax_errors_to</option>, and <option>syntax_errors_text</option> are not used.
35245 </para>
35246 <para>
35247 <option>skip_syntax_errors</option> can be used to specify that errors in users&#x2019; forward
35248 lists or filter files should not prevent delivery. The <option>syntax_errors_to</option>
35249 option, used with an address that does not get redirected, can be used to
35250 notify users of these errors, by means of a router like this:
35251 </para>
35252 <literallayout class="monospaced">
35253 userforward:
35254   driver = redirect
35255   allow_filter
35256   check_local_user
35257   file = $home/.forward
35258   file_transport = address_file
35259   pipe_transport = address_pipe
35260   reply_transport = address_reply
35261   no_verify
35262   skip_syntax_errors
35263   syntax_errors_to = real-$local_part@$domain
35264   syntax_errors_text = \
35265    This is an automatically generated message. An error has\n\
35266    been found in your .forward file. Details of the error are\n\
35267    reported below. While this error persists, you will receive\n\
35268    a copy of this message for every message that is addressed\n\
35269    to you. If your .forward file is a filter file, or if it is\n\
35270    a non-filter file containing no valid forwarding addresses,\n\
35271    a copy of each incoming message will be put in your normal\n\
35272    mailbox. If a non-filter file contains at least one valid\n\
35273    forwarding address, forwarding to the valid addresses will\n\
35274    happen, and those will be the only deliveries that occur.
35275 </literallayout>
35276 <para>
35277 You also need a router to ensure that local addresses that are prefixed by
35278 <literal>real-</literal> are recognized, but not forwarded or filtered. For example, you could
35279 put this immediately before the <command>userforward</command> router:
35280 </para>
35281 <literallayout class="monospaced">
35282 real_localuser:
35283   driver = accept
35284   check_local_user
35285   local_part_prefix = real-
35286   transport = local_delivery
35287 </literallayout>
35288 <para>
35289 For security, it would probably be a good idea to restrict the use of this
35290 router to locally-generated messages, using a condition such as this:
35291 </para>
35292 <literallayout class="monospaced">
35293   condition = ${if match {$sender_host_address}\
35294                          {\N^(|127\.0\.0\.1)$\N}}
35295 </literallayout>
35296 <para>
35297 <indexterm role="option">
35298 <primary><option>syntax_errors_text</option></primary>
35299 </indexterm>
35300 </para>
35301 <informaltable frame="all">
35302 <tgroup cols="4" colsep="0" rowsep="0">
35303 <colspec colwidth="8*" align="left"/>
35304 <colspec colwidth="6*" align="center"/>
35305 <colspec colwidth="6*" align="center"/>
35306 <colspec colwidth="6*" align="right"/>
35307 <tbody>
35308 <row>
35309 <entry><option>syntax_errors_text</option></entry>
35310 <entry>Use: <emphasis>redirect</emphasis></entry>
35311 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
35312 <entry>Default: <emphasis>unset</emphasis></entry>
35313 </row>
35314 </tbody>
35315 </tgroup>
35316 </informaltable>
35317 <para>
35318 See <option>skip_syntax_errors</option> above.
35319 </para>
35320 <para>
35321 <indexterm role="option">
35322 <primary><option>syntax_errors_to</option></primary>
35323 </indexterm>
35324 </para>
35325 <informaltable frame="all">
35326 <tgroup cols="4" colsep="0" rowsep="0">
35327 <colspec colwidth="8*" align="left"/>
35328 <colspec colwidth="6*" align="center"/>
35329 <colspec colwidth="6*" align="center"/>
35330 <colspec colwidth="6*" align="right"/>
35331 <tbody>
35332 <row>
35333 <entry><option>syntax_errors_to</option></entry>
35334 <entry>Use: <emphasis>redirect</emphasis></entry>
35335 <entry>Type: <emphasis>string</emphasis></entry>
35336 <entry>Default: <emphasis>unset</emphasis></entry>
35337 </row>
35338 </tbody>
35339 </tgroup>
35340 </informaltable>
35341 <para>
35342 See <option>skip_syntax_errors</option> above.
35343 <indexterm role="concept" startref="IIDredrou1" class="endofrange"/>
35344 <indexterm role="concept" startref="IIDredrou2" class="endofrange"/>
35345 </para>
35346 </section>
35347 </chapter>
35348
35349 <chapter id="CHAPenvironment">
35350 <title>Environment for running local transports</title>
35351 <titleabbrev>Environment for local transports</titleabbrev>
35352 <para>
35353 <indexterm role="concept" id="IIDenvlotra1" class="startofrange">
35354 <primary>local transports</primary>
35355 <secondary>environment for</secondary>
35356 </indexterm>
35357 <indexterm role="concept" id="IIDenvlotra2" class="startofrange">
35358 <primary>environment for local transports</primary>
35359 </indexterm>
35360 <indexterm role="concept" id="IIDenvlotra3" class="startofrange">
35361 <primary>transport</primary>
35362 <secondary>local; environment for</secondary>
35363 </indexterm>
35364 Local transports handle deliveries to files and pipes. (The <command>autoreply</command>
35365 transport can be thought of as similar to a pipe.) Exim always runs transports
35366 in subprocesses, under specified uids and gids. Typical deliveries to local
35367 mailboxes run under the uid and gid of the local user.
35368 </para>
35369 <para>
35370 Exim also sets a specific current directory while running the transport; for
35371 some transports a home directory setting is also relevant. The <command>pipe</command>
35372 transport is the only one that sets up environment variables; see section
35373 <xref linkend="SECTpipeenv"/> for details.
35374 </para>
35375 <para>
35376 The values used for the uid, gid, and the directories may come from several
35377 different places. In many cases, the router that handles the address associates
35378 settings with that address as a result of its <option>check_local_user</option>, <option>group</option>,
35379 or <option>user</option> options. However, values may also be given in the transport&#x2019;s own
35380 configuration, and these override anything that comes from the router.
35381 </para>
35382 <section id="SECID131">
35383 <title>Concurrent deliveries</title>
35384 <para>
35385 <indexterm role="concept">
35386 <primary>concurrent deliveries</primary>
35387 </indexterm>
35388 <indexterm role="concept">
35389 <primary>simultaneous deliveries</primary>
35390 </indexterm>
35391 If two different messages for the same local recipient arrive more or less
35392 simultaneously, the two delivery processes are likely to run concurrently. When
35393 the <command>appendfile</command> transport is used to write to a file, Exim applies locking
35394 rules to stop concurrent processes from writing to the same file at the same
35395 time.
35396 </para>
35397 <para>
35398 However, when you use a <command>pipe</command> transport, it is up to you to arrange any
35399 locking that is needed. Here is a silly example:
35400 </para>
35401 <literallayout class="monospaced">
35402 my_transport:
35403   driver = pipe
35404   command = /bin/sh -c 'cat &gt;&gt;/some/file'
35405 </literallayout>
35406 <para>
35407 This is supposed to write the message at the end of the file. However, if two
35408 messages arrive at the same time, the file will be scrambled. You can use the
35409 <option>exim_lock</option> utility program (see section <xref linkend="SECTmailboxmaint"/>) to lock a
35410 file using the same algorithm that Exim itself uses.
35411 </para>
35412 </section>
35413 <section id="SECTenvuidgid">
35414 <title>Uids and gids</title>
35415 <para>
35416 <indexterm role="concept">
35417 <primary>local transports</primary>
35418 <secondary>uid and gid</secondary>
35419 </indexterm>
35420 <indexterm role="concept">
35421 <primary>transport</primary>
35422 <secondary>local; uid and gid</secondary>
35423 </indexterm>
35424 All transports have the options <option>group</option> and <option>user</option>. If <option>group</option> is set, it
35425 overrides any group that the router set in the address, even if <option>user</option> is not
35426 set for the transport. This makes it possible, for example, to run local mail
35427 delivery under the uid of the recipient (set by the router), but in a special
35428 group (set by the transport). For example:
35429 </para>
35430 <literallayout class="monospaced">
35431 # Routers ...
35432 # User/group are set by check_local_user in this router
35433 local_users:
35434   driver = accept
35435   check_local_user
35436   transport = group_delivery
35437
35438 # Transports ...
35439 # This transport overrides the group
35440 group_delivery:
35441   driver = appendfile
35442   file = /var/spool/mail/$local_part
35443   group = mail
35444 </literallayout>
35445 <para>
35446 If <option>user</option> is set for a transport, its value overrides what is set in the
35447 address by the router. If <option>user</option> is non-numeric and <option>group</option> is not set, the
35448 gid associated with the user is used. If <option>user</option> is numeric, <option>group</option> must be
35449 set.
35450 </para>
35451 <para>
35452 <indexterm role="option">
35453 <primary><option>initgroups</option></primary>
35454 </indexterm>
35455 When the uid is taken from the transport&#x2019;s configuration, the <function>initgroups()</function>
35456 function is called for the groups associated with that uid if the
35457 <option>initgroups</option> option is set for the transport. When the uid is not specified
35458 by the transport, but is associated with the address by a router, the option
35459 for calling <function>initgroups()</function> is taken from the router configuration.
35460 </para>
35461 <para>
35462 <indexterm role="concept">
35463 <primary><command>pipe</command> transport</primary>
35464 <secondary>uid for</secondary>
35465 </indexterm>
35466 The <command>pipe</command> transport contains the special option <option>pipe_as_creator</option>. If this
35467 is set and <option>user</option> is not set, the uid of the process that called Exim to
35468 receive the message is used, and if <option>group</option> is not set, the corresponding
35469 original gid is also used.
35470 </para>
35471 <para>
35472 This is the detailed preference order for obtaining a gid; the first of the
35473 following that is set is used:
35474 </para>
35475 <itemizedlist>
35476 <listitem>
35477 <para>
35478 A <option>group</option> setting of the transport;
35479 </para>
35480 </listitem>
35481 <listitem>
35482 <para>
35483 A <option>group</option> setting of the router;
35484 </para>
35485 </listitem>
35486 <listitem>
35487 <para>
35488 A gid associated with a user setting of the router, either as a result of
35489 <option>check_local_user</option> or an explicit non-numeric <option>user</option> setting;
35490 </para>
35491 </listitem>
35492 <listitem>
35493 <para>
35494 The group associated with a non-numeric <option>user</option> setting of the transport;
35495 </para>
35496 </listitem>
35497 <listitem>
35498 <para>
35499 In a <command>pipe</command> transport, the creator&#x2019;s gid if <option>deliver_as_creator</option> is set and
35500 the uid is the creator&#x2019;s uid;
35501 </para>
35502 </listitem>
35503 <listitem>
35504 <para>
35505 The Exim gid if the Exim uid is being used as a default.
35506 </para>
35507 </listitem>
35508 </itemizedlist>
35509 <para>
35510 If, for example, the user is specified numerically on the router and there are
35511 no group settings, no gid is available. In this situation, an error occurs.
35512 This is different for the uid, for which there always is an ultimate default.
35513 The first of the following that is set is used:
35514 </para>
35515 <itemizedlist>
35516 <listitem>
35517 <para>
35518 A <option>user</option> setting of the transport;
35519 </para>
35520 </listitem>
35521 <listitem>
35522 <para>
35523 In a <command>pipe</command> transport, the creator&#x2019;s uid if <option>deliver_as_creator</option> is set;
35524 </para>
35525 </listitem>
35526 <listitem>
35527 <para>
35528 A <option>user</option> setting of the router;
35529 </para>
35530 </listitem>
35531 <listitem>
35532 <para>
35533 A <option>check_local_user</option> setting of the router;
35534 </para>
35535 </listitem>
35536 <listitem>
35537 <para>
35538 The Exim uid.
35539 </para>
35540 </listitem>
35541 </itemizedlist>
35542 <para>
35543 Of course, an error will still occur if the uid that is chosen is on the
35544 <option>never_users</option> list.
35545 </para>
35546 </section>
35547 <section id="SECID132">
35548 <title>Current and home directories</title>
35549 <para>
35550 <indexterm role="concept">
35551 <primary>current directory for local transport</primary>
35552 </indexterm>
35553 <indexterm role="concept">
35554 <primary>home directory</primary>
35555 <secondary>for local transport</secondary>
35556 </indexterm>
35557 <indexterm role="concept">
35558 <primary>transport</primary>
35559 <secondary>local; home directory for</secondary>
35560 </indexterm>
35561 <indexterm role="concept">
35562 <primary>transport</primary>
35563 <secondary>local; current directory for</secondary>
35564 </indexterm>
35565 Routers may set current and home directories for local transports by means of
35566 the <option>transport_current_directory</option> and <option>transport_home_directory</option> options.
35567 However, if the transport&#x2019;s <option>current_directory</option> or <option>home_directory</option> options
35568 are set, they override the router&#x2019;s values. In detail, the home directory
35569 for a local transport is taken from the first of these values that is set:
35570 </para>
35571 <itemizedlist>
35572 <listitem>
35573 <para>
35574 The <option>home_directory</option> option on the transport;
35575 </para>
35576 </listitem>
35577 <listitem>
35578 <para>
35579 The <option>transport_home_directory</option> option on the router;
35580 </para>
35581 </listitem>
35582 <listitem>
35583 <para>
35584 The password data if <option>check_local_user</option> is set on the router;
35585 </para>
35586 </listitem>
35587 <listitem>
35588 <para>
35589 The <option>router_home_directory</option> option on the router.
35590 </para>
35591 </listitem>
35592 </itemizedlist>
35593 <para>
35594 The current directory is taken from the first of these values that is set:
35595 </para>
35596 <itemizedlist>
35597 <listitem>
35598 <para>
35599 The <option>current_directory</option> option on the transport;
35600 </para>
35601 </listitem>
35602 <listitem>
35603 <para>
35604 The <option>transport_current_directory</option> option on the router.
35605 </para>
35606 </listitem>
35607 </itemizedlist>
35608 <para>
35609 If neither the router nor the transport sets a current directory, Exim uses the
35610 value of the home directory, if it is set. Otherwise it sets the current
35611 directory to <filename>/</filename> before running a local transport.
35612 </para>
35613 </section>
35614 <section id="SECID133">
35615 <title>Expansion variables derived from the address</title>
35616 <para>
35617 <indexterm role="variable">
35618 <primary><varname>$domain</varname></primary>
35619 </indexterm>
35620 <indexterm role="variable">
35621 <primary><varname>$local_part</varname></primary>
35622 </indexterm>
35623 <indexterm role="variable">
35624 <primary><varname>$original_domain</varname></primary>
35625 </indexterm>
35626 Normally a local delivery is handling a single address, and in that case the
35627 variables such as <varname>$domain</varname> and <varname>$local_part</varname> are set during local
35628 deliveries. However, in some circumstances more than one address may be handled
35629 at once (for example, while writing batch SMTP for onward transmission by some
35630 other means). In this case, the variables associated with the local part are
35631 never set, <varname>$domain</varname> is set only if all the addresses have the same domain,
35632 and <varname>$original_domain</varname> is never set.
35633 <indexterm role="concept" startref="IIDenvlotra1" class="endofrange"/>
35634 <indexterm role="concept" startref="IIDenvlotra2" class="endofrange"/>
35635 <indexterm role="concept" startref="IIDenvlotra3" class="endofrange"/>
35636 </para>
35637 </section>
35638 </chapter>
35639
35640 <chapter id="CHAPtransportgeneric">
35641 <title>Generic options for transports</title>
35642 <para>
35643 <indexterm role="concept" id="IIDgenoptra1" class="startofrange">
35644 <primary>generic options</primary>
35645 <secondary>transport</secondary>
35646 </indexterm>
35647 <indexterm role="concept" id="IIDgenoptra2" class="startofrange">
35648 <primary>options</primary>
35649 <secondary>generic; for transports</secondary>
35650 </indexterm>
35651 <indexterm role="concept" id="IIDgenoptra3" class="startofrange">
35652 <primary>transport</primary>
35653 <secondary>generic options for</secondary>
35654 </indexterm>
35655 The following generic options apply to all transports:
35656 </para>
35657 <para>
35658 <indexterm role="option">
35659 <primary><option>body_only</option></primary>
35660 </indexterm>
35661 </para>
35662 <informaltable frame="all">
35663 <tgroup cols="4" colsep="0" rowsep="0">
35664 <colspec colwidth="8*" align="left"/>
35665 <colspec colwidth="6*" align="center"/>
35666 <colspec colwidth="6*" align="center"/>
35667 <colspec colwidth="6*" align="right"/>
35668 <tbody>
35669 <row>
35670 <entry><option>body_only</option></entry>
35671 <entry>Use: <emphasis>transports</emphasis></entry>
35672 <entry>Type: <emphasis>boolean</emphasis></entry>
35673 <entry>Default: <emphasis>false</emphasis></entry>
35674 </row>
35675 </tbody>
35676 </tgroup>
35677 </informaltable>
35678 <para>
35679 <indexterm role="concept">
35680 <primary>transport</primary>
35681 <secondary>body only</secondary>
35682 </indexterm>
35683 <indexterm role="concept">
35684 <primary>message</primary>
35685 <secondary>transporting body only</secondary>
35686 </indexterm>
35687 <indexterm role="concept">
35688 <primary>body of message</primary>
35689 <secondary>transporting</secondary>
35690 </indexterm>
35691 If this option is set, the message&#x2019;s headers are not transported. It is
35692 mutually exclusive with <option>headers_only</option>. If it is used with the <command>appendfile</command>
35693 or <command>pipe</command> transports, the settings of <option>message_prefix</option> and
35694 <option>message_suffix</option> should be checked, because this option does not
35695 automatically suppress them.
35696 </para>
35697 <para>
35698 <indexterm role="option">
35699 <primary><option>current_directory</option></primary>
35700 </indexterm>
35701 </para>
35702 <informaltable frame="all">
35703 <tgroup cols="4" colsep="0" rowsep="0">
35704 <colspec colwidth="8*" align="left"/>
35705 <colspec colwidth="6*" align="center"/>
35706 <colspec colwidth="6*" align="center"/>
35707 <colspec colwidth="6*" align="right"/>
35708 <tbody>
35709 <row>
35710 <entry><option>current_directory</option></entry>
35711 <entry>Use: <emphasis>transports</emphasis></entry>
35712 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
35713 <entry>Default: <emphasis>unset</emphasis></entry>
35714 </row>
35715 </tbody>
35716 </tgroup>
35717 </informaltable>
35718 <para>
35719 <indexterm role="concept">
35720 <primary>transport</primary>
35721 <secondary>current directory for</secondary>
35722 </indexterm>
35723 This specifies the current directory that is to be set while running the
35724 transport, overriding any value that may have been set by the router.
35725 If the expansion fails for any reason, including forced failure, an error is
35726 logged, and delivery is deferred.
35727 </para>
35728 <para>
35729 <indexterm role="option">
35730 <primary><option>disable_logging</option></primary>
35731 </indexterm>
35732 </para>
35733 <informaltable frame="all">
35734 <tgroup cols="4" colsep="0" rowsep="0">
35735 <colspec colwidth="8*" align="left"/>
35736 <colspec colwidth="6*" align="center"/>
35737 <colspec colwidth="6*" align="center"/>
35738 <colspec colwidth="6*" align="right"/>
35739 <tbody>
35740 <row>
35741 <entry><option>disable_logging</option></entry>
35742 <entry>Use: <emphasis>transports</emphasis></entry>
35743 <entry>Type: <emphasis>boolean</emphasis></entry>
35744 <entry>Default: <emphasis>false</emphasis></entry>
35745 </row>
35746 </tbody>
35747 </tgroup>
35748 </informaltable>
35749 <para>
35750 If this option is set true, nothing is logged for any
35751 deliveries by the transport or for any
35752 transport errors. You should not set this option unless you really, really know
35753 what you are doing.
35754 </para>
35755 <para>
35756 <indexterm role="option">
35757 <primary><option>debug_print</option></primary>
35758 </indexterm>
35759 </para>
35760 <informaltable frame="all">
35761 <tgroup cols="4" colsep="0" rowsep="0">
35762 <colspec colwidth="8*" align="left"/>
35763 <colspec colwidth="6*" align="center"/>
35764 <colspec colwidth="6*" align="center"/>
35765 <colspec colwidth="6*" align="right"/>
35766 <tbody>
35767 <row>
35768 <entry><option>debug_print</option></entry>
35769 <entry>Use: <emphasis>transports</emphasis></entry>
35770 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
35771 <entry>Default: <emphasis>unset</emphasis></entry>
35772 </row>
35773 </tbody>
35774 </tgroup>
35775 </informaltable>
35776 <para>
35777 <indexterm role="concept">
35778 <primary>testing</primary>
35779 <secondary>variables in drivers</secondary>
35780 </indexterm>
35781 If this option is set and debugging is enabled (see the <option>-d</option> command line
35782 option), the string is expanded and included in the debugging output when the
35783 transport is run.
35784 If expansion of the string fails, the error message is written to the debugging
35785 output, and Exim carries on processing.
35786 This facility is provided to help with checking out the values of variables and
35787 so on when debugging driver configurations. For example, if a <option>headers_add</option>
35788 option is not working properly, <option>debug_print</option> could be used to output the
35789 variables it references. A newline is added to the text if it does not end with
35790 one.
35791 </para>
35792 <para>
35793 <indexterm role="option">
35794 <primary><option>delivery_date_add</option></primary>
35795 </indexterm>
35796 </para>
35797 <informaltable frame="all">
35798 <tgroup cols="4" colsep="0" rowsep="0">
35799 <colspec colwidth="8*" align="left"/>
35800 <colspec colwidth="6*" align="center"/>
35801 <colspec colwidth="6*" align="center"/>
35802 <colspec colwidth="6*" align="right"/>
35803 <tbody>
35804 <row>
35805 <entry><option>delivery_date_add</option></entry>
35806 <entry>Use: <emphasis>transports</emphasis></entry>
35807 <entry>Type: <emphasis>boolean</emphasis></entry>
35808 <entry>Default: <emphasis>false</emphasis></entry>
35809 </row>
35810 </tbody>
35811 </tgroup>
35812 </informaltable>
35813 <para>
35814 <indexterm role="concept">
35815 <primary><emphasis>Delivery-date:</emphasis> header line</primary>
35816 </indexterm>
35817 If this option is true, a <emphasis>Delivery-date:</emphasis> header is added to the message.
35818 This gives the actual time the delivery was made. As this is not a standard
35819 header, Exim has a configuration option (<option>delivery_date_remove</option>) which
35820 requests its removal from incoming messages, so that delivered messages can
35821 safely be resent to other recipients.
35822 </para>
35823 <para>
35824 <indexterm role="option">
35825 <primary><option>driver</option></primary>
35826 </indexterm>
35827 </para>
35828 <informaltable frame="all">
35829 <tgroup cols="4" colsep="0" rowsep="0">
35830 <colspec colwidth="8*" align="left"/>
35831 <colspec colwidth="6*" align="center"/>
35832 <colspec colwidth="6*" align="center"/>
35833 <colspec colwidth="6*" align="right"/>
35834 <tbody>
35835 <row>
35836 <entry><option>driver</option></entry>
35837 <entry>Use: <emphasis>transports</emphasis></entry>
35838 <entry>Type: <emphasis>string</emphasis></entry>
35839 <entry>Default: <emphasis>unset</emphasis></entry>
35840 </row>
35841 </tbody>
35842 </tgroup>
35843 </informaltable>
35844 <para>
35845 This specifies which of the available transport drivers is to be used.
35846 There is no default, and this option must be set for every transport.
35847 </para>
35848 <para>
35849 <indexterm role="option">
35850 <primary><option>envelope_to_add</option></primary>
35851 </indexterm>
35852 </para>
35853 <informaltable frame="all">
35854 <tgroup cols="4" colsep="0" rowsep="0">
35855 <colspec colwidth="8*" align="left"/>
35856 <colspec colwidth="6*" align="center"/>
35857 <colspec colwidth="6*" align="center"/>
35858 <colspec colwidth="6*" align="right"/>
35859 <tbody>
35860 <row>
35861 <entry><option>envelope_to_add</option></entry>
35862 <entry>Use: <emphasis>transports</emphasis></entry>
35863 <entry>Type: <emphasis>boolean</emphasis></entry>
35864 <entry>Default: <emphasis>false</emphasis></entry>
35865 </row>
35866 </tbody>
35867 </tgroup>
35868 </informaltable>
35869 <para>
35870 <indexterm role="concept">
35871 <primary><emphasis>Envelope-to:</emphasis> header line</primary>
35872 </indexterm>
35873 If this option is true, an <emphasis>Envelope-to:</emphasis> header is added to the message.
35874 This gives the original address(es) in the incoming envelope that caused this
35875 delivery to happen. More than one address may be present if the transport is
35876 configured to handle several addresses at once, or if more than one original
35877 address was redirected to the same final address. As this is not a standard
35878 header, Exim has a configuration option (<option>envelope_to_remove</option>) which requests
35879 its removal from incoming messages, so that delivered messages can safely be
35880 resent to other recipients.
35881 </para>
35882 <para>
35883 <indexterm role="option">
35884 <primary><option>group</option></primary>
35885 </indexterm>
35886 </para>
35887 <informaltable frame="all">
35888 <tgroup cols="4" colsep="0" rowsep="0">
35889 <colspec colwidth="8*" align="left"/>
35890 <colspec colwidth="6*" align="center"/>
35891 <colspec colwidth="6*" align="center"/>
35892 <colspec colwidth="6*" align="right"/>
35893 <tbody>
35894 <row>
35895 <entry><option>group</option></entry>
35896 <entry>Use: <emphasis>transports</emphasis></entry>
35897 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
35898 <entry>Default: <emphasis>Exim group</emphasis></entry>
35899 </row>
35900 </tbody>
35901 </tgroup>
35902 </informaltable>
35903 <para>
35904 <indexterm role="concept">
35905 <primary>transport</primary>
35906 <secondary>group; specifying</secondary>
35907 </indexterm>
35908 This option specifies a gid for running the transport process, overriding any
35909 value that the router supplies, and also overriding any value associated with
35910 <option>user</option> (see below).
35911 </para>
35912 <para>
35913 <indexterm role="option">
35914 <primary><option>headers_add</option></primary>
35915 </indexterm>
35916 </para>
35917 <informaltable frame="all">
35918 <tgroup cols="4" colsep="0" rowsep="0">
35919 <colspec colwidth="8*" align="left"/>
35920 <colspec colwidth="6*" align="center"/>
35921 <colspec colwidth="6*" align="center"/>
35922 <colspec colwidth="6*" align="right"/>
35923 <tbody>
35924 <row>
35925 <entry><option>headers_add</option></entry>
35926 <entry>Use: <emphasis>transports</emphasis></entry>
35927 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
35928 <entry>Default: <emphasis>unset</emphasis></entry>
35929 </row>
35930 </tbody>
35931 </tgroup>
35932 </informaltable>
35933 <para>
35934 <indexterm role="concept">
35935 <primary>header lines</primary>
35936 <secondary>adding in transport</secondary>
35937 </indexterm>
35938 <indexterm role="concept">
35939 <primary>transport</primary>
35940 <secondary>header lines; adding</secondary>
35941 </indexterm>
35942 This option specifies a string of text that is expanded and added to the header
35943 portion of a message as it is transported, as described in section
35944 <xref linkend="SECTheadersaddrem"/>. Additional header lines can also be specified by
35945 routers. If the result of the expansion is an empty string, or if the expansion
35946 is forced to fail, no action is taken. Other expansion failures are treated as
35947 errors and cause the delivery to be deferred.
35948 </para>
35949 <para>
35950 <indexterm role="option">
35951 <primary><option>headers_only</option></primary>
35952 </indexterm>
35953 </para>
35954 <informaltable frame="all">
35955 <tgroup cols="4" colsep="0" rowsep="0">
35956 <colspec colwidth="8*" align="left"/>
35957 <colspec colwidth="6*" align="center"/>
35958 <colspec colwidth="6*" align="center"/>
35959 <colspec colwidth="6*" align="right"/>
35960 <tbody>
35961 <row>
35962 <entry><option>headers_only</option></entry>
35963 <entry>Use: <emphasis>transports</emphasis></entry>
35964 <entry>Type: <emphasis>boolean</emphasis></entry>
35965 <entry>Default: <emphasis>false</emphasis></entry>
35966 </row>
35967 </tbody>
35968 </tgroup>
35969 </informaltable>
35970 <para>
35971 <indexterm role="concept">
35972 <primary>transport</primary>
35973 <secondary>header lines only</secondary>
35974 </indexterm>
35975 <indexterm role="concept">
35976 <primary>message</primary>
35977 <secondary>transporting headers only</secondary>
35978 </indexterm>
35979 <indexterm role="concept">
35980 <primary>header lines</primary>
35981 <secondary>transporting</secondary>
35982 </indexterm>
35983 If this option is set, the message&#x2019;s body is not transported. It is mutually
35984 exclusive with <option>body_only</option>. If it is used with the <command>appendfile</command> or <command>pipe</command>
35985 transports, the settings of <option>message_prefix</option> and <option>message_suffix</option> should be
35986 checked, since this option does not automatically suppress them.
35987 </para>
35988 <para>
35989 <indexterm role="option">
35990 <primary><option>headers_remove</option></primary>
35991 </indexterm>
35992 </para>
35993 <informaltable frame="all">
35994 <tgroup cols="4" colsep="0" rowsep="0">
35995 <colspec colwidth="8*" align="left"/>
35996 <colspec colwidth="6*" align="center"/>
35997 <colspec colwidth="6*" align="center"/>
35998 <colspec colwidth="6*" align="right"/>
35999 <tbody>
36000 <row>
36001 <entry><option>headers_remove</option></entry>
36002 <entry>Use: <emphasis>transports</emphasis></entry>
36003 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
36004 <entry>Default: <emphasis>unset</emphasis></entry>
36005 </row>
36006 </tbody>
36007 </tgroup>
36008 </informaltable>
36009 <para>
36010 <indexterm role="concept">
36011 <primary>header lines</primary>
36012 <secondary>removing</secondary>
36013 </indexterm>
36014 <indexterm role="concept">
36015 <primary>transport</primary>
36016 <secondary>header lines; removing</secondary>
36017 </indexterm>
36018 This option specifies a string that is expanded into a list of header names;
36019 these headers are omitted from the message as it is transported, as described
36020 in section <xref linkend="SECTheadersaddrem"/>. Header removal can also be specified by
36021 routers. If the result of the expansion is an empty string, or if the expansion
36022 is forced to fail, no action is taken. Other expansion failures are treated as
36023 errors and cause the delivery to be deferred.
36024 </para>
36025 <para>
36026 <indexterm role="option">
36027 <primary><option>headers_rewrite</option></primary>
36028 </indexterm>
36029 </para>
36030 <informaltable frame="all">
36031 <tgroup cols="4" colsep="0" rowsep="0">
36032 <colspec colwidth="8*" align="left"/>
36033 <colspec colwidth="6*" align="center"/>
36034 <colspec colwidth="6*" align="center"/>
36035 <colspec colwidth="6*" align="right"/>
36036 <tbody>
36037 <row>
36038 <entry><option>headers_rewrite</option></entry>
36039 <entry>Use: <emphasis>transports</emphasis></entry>
36040 <entry>Type: <emphasis>string</emphasis></entry>
36041 <entry>Default: <emphasis>unset</emphasis></entry>
36042 </row>
36043 </tbody>
36044 </tgroup>
36045 </informaltable>
36046 <para>
36047 <indexterm role="concept">
36048 <primary>transport</primary>
36049 <secondary>header lines; rewriting</secondary>
36050 </indexterm>
36051 <indexterm role="concept">
36052 <primary>rewriting</primary>
36053 <secondary>at transport time</secondary>
36054 </indexterm>
36055 This option allows addresses in header lines to be rewritten at transport time,
36056 that is, as the message is being copied to its destination. The contents of the
36057 option are a colon-separated list of rewriting rules. Each rule is in exactly
36058 the same form as one of the general rewriting rules that are applied when a
36059 message is received. These are described in chapter <xref linkend="CHAPrewrite"/>. For
36060 example,
36061 </para>
36062 <literallayout class="monospaced">
36063 headers_rewrite = a@b c@d f : \
36064                   x@y w@z
36065 </literallayout>
36066 <para>
36067 changes <emphasis>a@b</emphasis> into <emphasis>c@d</emphasis> in <emphasis>From:</emphasis> header lines, and <emphasis>x@y</emphasis> into
36068 <emphasis>w@z</emphasis> in all address-bearing header lines. The rules are applied to the
36069 header lines just before they are written out at transport time, so they affect
36070 only those copies of the message that pass through the transport. However, only
36071 the message&#x2019;s original header lines, and any that were added by a system
36072 filter, are rewritten. If a router or transport adds header lines, they are not
36073 affected by this option. These rewriting rules are <emphasis>not</emphasis> applied to the
36074 envelope. You can change the return path using <option>return_path</option>, but you cannot
36075 change envelope recipients at this time.
36076 </para>
36077 <para>
36078 <indexterm role="option">
36079 <primary><option>home_directory</option></primary>
36080 </indexterm>
36081 </para>
36082 <informaltable frame="all">
36083 <tgroup cols="4" colsep="0" rowsep="0">
36084 <colspec colwidth="8*" align="left"/>
36085 <colspec colwidth="6*" align="center"/>
36086 <colspec colwidth="6*" align="center"/>
36087 <colspec colwidth="6*" align="right"/>
36088 <tbody>
36089 <row>
36090 <entry><option>home_directory</option></entry>
36091 <entry>Use: <emphasis>transports</emphasis></entry>
36092 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
36093 <entry>Default: <emphasis>unset</emphasis></entry>
36094 </row>
36095 </tbody>
36096 </tgroup>
36097 </informaltable>
36098 <para>
36099 <indexterm role="concept">
36100 <primary>transport</primary>
36101 <secondary>home directory for</secondary>
36102 </indexterm>
36103 <indexterm role="variable">
36104 <primary><varname>$home</varname></primary>
36105 </indexterm>
36106 This option specifies a home directory setting for a local transport,
36107 overriding any value that may be set by the router. The home directory is
36108 placed in <varname>$home</varname> while expanding the transport&#x2019;s private options. It is also
36109 used as the current directory if no current directory is set by the
36110 <option>current_directory</option> option on the transport or the
36111 <option>transport_current_directory</option> option on the router. If the expansion fails
36112 for any reason, including forced failure, an error is logged, and delivery is
36113 deferred.
36114 </para>
36115 <para>
36116 <indexterm role="option">
36117 <primary><option>initgroups</option></primary>
36118 </indexterm>
36119 </para>
36120 <informaltable frame="all">
36121 <tgroup cols="4" colsep="0" rowsep="0">
36122 <colspec colwidth="8*" align="left"/>
36123 <colspec colwidth="6*" align="center"/>
36124 <colspec colwidth="6*" align="center"/>
36125 <colspec colwidth="6*" align="right"/>
36126 <tbody>
36127 <row>
36128 <entry><option>initgroups</option></entry>
36129 <entry>Use: <emphasis>transports</emphasis></entry>
36130 <entry>Type: <emphasis>boolean</emphasis></entry>
36131 <entry>Default: <emphasis>false</emphasis></entry>
36132 </row>
36133 </tbody>
36134 </tgroup>
36135 </informaltable>
36136 <para>
36137 <indexterm role="concept">
36138 <primary>additional groups</primary>
36139 </indexterm>
36140 <indexterm role="concept">
36141 <primary>groups</primary>
36142 <secondary>additional</secondary>
36143 </indexterm>
36144 <indexterm role="concept">
36145 <primary>transport</primary>
36146 <secondary>group; additional</secondary>
36147 </indexterm>
36148 If this option is true and the uid for the delivery process is provided by the
36149 transport, the <function>initgroups()</function> function is called when running the transport
36150 to ensure that any additional groups associated with the uid are set up.
36151 </para>
36152 <para>
36153 <indexterm role="option">
36154 <primary><option>message_size_limit</option></primary>
36155 </indexterm>
36156 </para>
36157 <informaltable frame="all">
36158 <tgroup cols="4" colsep="0" rowsep="0">
36159 <colspec colwidth="8*" align="left"/>
36160 <colspec colwidth="6*" align="center"/>
36161 <colspec colwidth="6*" align="center"/>
36162 <colspec colwidth="6*" align="right"/>
36163 <tbody>
36164 <row>
36165 <entry><option>message_size_limit</option></entry>
36166 <entry>Use: <emphasis>transports</emphasis></entry>
36167 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
36168 <entry>Default: <emphasis>0</emphasis></entry>
36169 </row>
36170 </tbody>
36171 </tgroup>
36172 </informaltable>
36173 <para>
36174 <indexterm role="concept">
36175 <primary>limit</primary>
36176 <secondary>message size per transport</secondary>
36177 </indexterm>
36178 <indexterm role="concept">
36179 <primary>size</primary>
36180 <secondary>of message, limit</secondary>
36181 </indexterm>
36182 <indexterm role="concept">
36183 <primary>transport</primary>
36184 <secondary>message size; limiting</secondary>
36185 </indexterm>
36186 This option controls the size of messages passed through the transport. It is
36187 expanded before use; the result of the expansion must be a sequence of decimal
36188 digits, optionally followed by K or M. If the expansion fails for any reason,
36189 including forced failure, or if the result is not of the required form,
36190 delivery is deferred. If the value is greater than zero and the size of a
36191 message exceeds this limit, the address is failed. If there is any chance that
36192 the resulting bounce message could be routed to the same transport, you should
36193 ensure that <option>return_size_limit</option> is less than the transport&#x2019;s
36194 <option>message_size_limit</option>, as otherwise the bounce message will fail to get
36195 delivered.
36196 </para>
36197 <para>
36198 <indexterm role="option">
36199 <primary><option>rcpt_include_affixes</option></primary>
36200 </indexterm>
36201 </para>
36202 <informaltable frame="all">
36203 <tgroup cols="4" colsep="0" rowsep="0">
36204 <colspec colwidth="8*" align="left"/>
36205 <colspec colwidth="6*" align="center"/>
36206 <colspec colwidth="6*" align="center"/>
36207 <colspec colwidth="6*" align="right"/>
36208 <tbody>
36209 <row>
36210 <entry><option>rcpt_include_affixes</option></entry>
36211 <entry>Use: <emphasis>transports</emphasis></entry>
36212 <entry>Type: <emphasis>boolean</emphasis></entry>
36213 <entry>Default: <emphasis>false</emphasis></entry>
36214 </row>
36215 </tbody>
36216 </tgroup>
36217 </informaltable>
36218 <para>
36219 <indexterm role="concept">
36220 <primary>prefix</primary>
36221 <secondary>for local part, including in envelope</secondary>
36222 </indexterm>
36223 <indexterm role="concept">
36224 <primary>suffix for local part</primary>
36225 <secondary>including in envelope</secondary>
36226 </indexterm>
36227 <indexterm role="concept">
36228 <primary>local part</primary>
36229 <secondary>prefix</secondary>
36230 </indexterm>
36231 <indexterm role="concept">
36232 <primary>local part</primary>
36233 <secondary>suffix</secondary>
36234 </indexterm>
36235 When this option is false (the default), and an address that has had any
36236 affixes (prefixes or suffixes) removed from the local part is delivered by any
36237 form of SMTP or LMTP, the affixes are not included. For example, if a router
36238 that contains
36239 </para>
36240 <literallayout class="monospaced">
36241 local_part_prefix = *-
36242 </literallayout>
36243 <para>
36244 routes the address <emphasis>abc-xyz@some.domain</emphasis> to an SMTP transport, the envelope
36245 is delivered with
36246 </para>
36247 <literallayout class="monospaced">
36248 RCPT TO:&lt;xyz@some.domain&gt;
36249 </literallayout>
36250 <para>
36251 This is also the case when an ACL-time callout is being used to verify a
36252 recipient address. However, if <option>rcpt_include_affixes</option> is set true, the
36253 whole local part is included in the RCPT command. This option applies to BSMTP
36254 deliveries by the <command>appendfile</command> and <command>pipe</command> transports as well as to the
36255 <command>lmtp</command> and <command>smtp</command> transports.
36256 </para>
36257 <para>
36258 <indexterm role="option">
36259 <primary><option>retry_use_local_part</option></primary>
36260 </indexterm>
36261 </para>
36262 <informaltable frame="all">
36263 <tgroup cols="4" colsep="0" rowsep="0">
36264 <colspec colwidth="8*" align="left"/>
36265 <colspec colwidth="6*" align="center"/>
36266 <colspec colwidth="6*" align="center"/>
36267 <colspec colwidth="6*" align="right"/>
36268 <tbody>
36269 <row>
36270 <entry><option>retry_use_local_part</option></entry>
36271 <entry>Use: <emphasis>transports</emphasis></entry>
36272 <entry>Type: <emphasis>boolean</emphasis></entry>
36273 <entry>Default: <emphasis>see below</emphasis></entry>
36274 </row>
36275 </tbody>
36276 </tgroup>
36277 </informaltable>
36278 <para>
36279 <indexterm role="concept">
36280 <primary>hints database</primary>
36281 <secondary>retry keys</secondary>
36282 </indexterm>
36283 When a delivery suffers a temporary failure, a retry record is created
36284 in Exim&#x2019;s hints database. For remote deliveries, the key for the retry record
36285 is based on the name and/or IP address of the failing remote host. For local
36286 deliveries, the key is normally the entire address, including both the local
36287 part and the domain. This is suitable for most common cases of local delivery
36288 temporary failure &ndash; for example, exceeding a mailbox quota should delay only
36289 deliveries to that mailbox, not to the whole domain.
36290 </para>
36291 <para>
36292 However, in some special cases you may want to treat a temporary local delivery
36293 as a failure associated with the domain, and not with a particular local part.
36294 (For example, if you are storing all mail for some domain in files.) You can do
36295 this by setting <option>retry_use_local_part</option> false.
36296 </para>
36297 <para>
36298 For all the local transports, its default value is true. For remote transports,
36299 the default value is false for tidiness, but changing the value has no effect
36300 on a remote transport in the current implementation.
36301 </para>
36302 <para>
36303 <indexterm role="option">
36304 <primary><option>return_path</option></primary>
36305 </indexterm>
36306 </para>
36307 <informaltable frame="all">
36308 <tgroup cols="4" colsep="0" rowsep="0">
36309 <colspec colwidth="8*" align="left"/>
36310 <colspec colwidth="6*" align="center"/>
36311 <colspec colwidth="6*" align="center"/>
36312 <colspec colwidth="6*" align="right"/>
36313 <tbody>
36314 <row>
36315 <entry><option>return_path</option></entry>
36316 <entry>Use: <emphasis>transports</emphasis></entry>
36317 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
36318 <entry>Default: <emphasis>unset</emphasis></entry>
36319 </row>
36320 </tbody>
36321 </tgroup>
36322 </informaltable>
36323 <para>
36324 <indexterm role="concept">
36325 <primary>envelope sender</primary>
36326 </indexterm>
36327 <indexterm role="concept">
36328 <primary>transport</primary>
36329 <secondary>return path; changing</secondary>
36330 </indexterm>
36331 <indexterm role="concept">
36332 <primary>return path</primary>
36333 <secondary>changing in transport</secondary>
36334 </indexterm>
36335 If this option is set, the string is expanded at transport time and replaces
36336 the existing return path (envelope sender) value in the copy of the message
36337 that is being delivered. An empty return path is permitted. This feature is
36338 designed for remote deliveries, where the value of this option is used in the
36339 SMTP MAIL command. If you set <option>return_path</option> for a local transport, the
36340 only effect is to change the address that is placed in the <emphasis>Return-path:</emphasis>
36341 header line, if one is added to the message (see the next option).
36342 </para>
36343 <para>
36344 <emphasis role="bold">Note:</emphasis> A changed return path is not logged unless you add
36345 <option>return_path_on_delivery</option> to the log selector.
36346 </para>
36347 <para>
36348 <indexterm role="variable">
36349 <primary><varname>$return_path</varname></primary>
36350 </indexterm>
36351 The expansion can refer to the existing value via <varname>$return_path</varname>. This is
36352 either the message&#x2019;s envelope sender, or an address set by the
36353 <option>errors_to</option> option on a router. If the expansion is forced to fail, no
36354 replacement occurs; if it fails for another reason, delivery is deferred. This
36355 option can be used to support VERP (Variable Envelope Return Paths) &ndash; see
36356 section <xref linkend="SECTverp"/>.
36357 </para>
36358 <para>
36359 <emphasis role="bold">Note</emphasis>: If a delivery error is detected locally, including the case when a
36360 remote server rejects a message at SMTP time, the bounce message is not sent to
36361 the value of this option. It is sent to the previously set errors address.
36362 This defaults to the incoming sender address, but can be changed by setting
36363 <option>errors_to</option> in a router.
36364 </para>
36365 <para>
36366 <indexterm role="option">
36367 <primary><option>return_path_add</option></primary>
36368 </indexterm>
36369 </para>
36370 <informaltable frame="all">
36371 <tgroup cols="4" colsep="0" rowsep="0">
36372 <colspec colwidth="8*" align="left"/>
36373 <colspec colwidth="6*" align="center"/>
36374 <colspec colwidth="6*" align="center"/>
36375 <colspec colwidth="6*" align="right"/>
36376 <tbody>
36377 <row>
36378 <entry><option>return_path_add</option></entry>
36379 <entry>Use: <emphasis>transports</emphasis></entry>
36380 <entry>Type: <emphasis>boolean</emphasis></entry>
36381 <entry>Default: <emphasis>false</emphasis></entry>
36382 </row>
36383 </tbody>
36384 </tgroup>
36385 </informaltable>
36386 <para>
36387 <indexterm role="concept">
36388 <primary><emphasis>Return-path:</emphasis> header line</primary>
36389 </indexterm>
36390 If this option is true, a <emphasis>Return-path:</emphasis> header is added to the message.
36391 Although the return path is normally available in the prefix line of BSD
36392 mailboxes, this is commonly not displayed by MUAs, and so the user does not
36393 have easy access to it.
36394 </para>
36395 <para>
36396 RFC 2821 states that the <emphasis>Return-path:</emphasis> header is added to a message <quote>when
36397 the delivery SMTP server makes the final delivery</quote>. This implies that this
36398 header should not be present in incoming messages. Exim has a configuration
36399 option, <option>return_path_remove</option>, which requests removal of this header from
36400 incoming messages, so that delivered messages can safely be resent to other
36401 recipients.
36402 </para>
36403 <para>
36404 <indexterm role="option">
36405 <primary><option>shadow_condition</option></primary>
36406 </indexterm>
36407 </para>
36408 <informaltable frame="all">
36409 <tgroup cols="4" colsep="0" rowsep="0">
36410 <colspec colwidth="8*" align="left"/>
36411 <colspec colwidth="6*" align="center"/>
36412 <colspec colwidth="6*" align="center"/>
36413 <colspec colwidth="6*" align="right"/>
36414 <tbody>
36415 <row>
36416 <entry><option>shadow_condition</option></entry>
36417 <entry>Use: <emphasis>transports</emphasis></entry>
36418 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
36419 <entry>Default: <emphasis>unset</emphasis></entry>
36420 </row>
36421 </tbody>
36422 </tgroup>
36423 </informaltable>
36424 <para>
36425 See <option>shadow_transport</option> below.
36426 </para>
36427 <para>
36428 <indexterm role="option">
36429 <primary><option>shadow_transport</option></primary>
36430 </indexterm>
36431 </para>
36432 <informaltable frame="all">
36433 <tgroup cols="4" colsep="0" rowsep="0">
36434 <colspec colwidth="8*" align="left"/>
36435 <colspec colwidth="6*" align="center"/>
36436 <colspec colwidth="6*" align="center"/>
36437 <colspec colwidth="6*" align="right"/>
36438 <tbody>
36439 <row>
36440 <entry><option>shadow_transport</option></entry>
36441 <entry>Use: <emphasis>transports</emphasis></entry>
36442 <entry>Type: <emphasis>string</emphasis></entry>
36443 <entry>Default: <emphasis>unset</emphasis></entry>
36444 </row>
36445 </tbody>
36446 </tgroup>
36447 </informaltable>
36448 <para>
36449 <indexterm role="concept">
36450 <primary>shadow transport</primary>
36451 </indexterm>
36452 <indexterm role="concept">
36453 <primary>transport</primary>
36454 <secondary>shadow</secondary>
36455 </indexterm>
36456 A local transport may set the <option>shadow_transport</option> option to the name of
36457 another local transport. Shadow remote transports are not supported.
36458 </para>
36459 <para>
36460 Whenever a delivery to the main transport succeeds, and either
36461 <option>shadow_condition</option> is unset, or its expansion does not result in the empty
36462 string or one of the strings <quote>0</quote> or <quote>no</quote> or <quote>false</quote>, the message is also
36463 passed to the shadow transport, with the same delivery address or addresses. If
36464 expansion fails, no action is taken except that non-forced expansion failures
36465 cause a log line to be written.
36466 </para>
36467 <para>
36468 The result of the shadow transport is discarded and does not affect the
36469 subsequent processing of the message. Only a single level of shadowing is
36470 provided; the <option>shadow_transport</option> option is ignored on any transport when it
36471 is running as a shadow. Options concerned with output from pipes are also
36472 ignored. The log line for the successful delivery has an item added on the end,
36473 of the form
36474 </para>
36475 <literallayout class="monospaced">
36476 ST=&lt;shadow transport name&gt;
36477 </literallayout>
36478 <para>
36479 If the shadow transport did not succeed, the error message is put in
36480 parentheses afterwards. Shadow transports can be used for a number of different
36481 purposes, including keeping more detailed log information than Exim normally
36482 provides, and implementing automatic acknowledgment policies based on message
36483 headers that some sites insist on.
36484 </para>
36485 <para>
36486 <indexterm role="option">
36487 <primary><option>transport_filter</option></primary>
36488 </indexterm>
36489 </para>
36490 <informaltable frame="all">
36491 <tgroup cols="4" colsep="0" rowsep="0">
36492 <colspec colwidth="8*" align="left"/>
36493 <colspec colwidth="6*" align="center"/>
36494 <colspec colwidth="6*" align="center"/>
36495 <colspec colwidth="6*" align="right"/>
36496 <tbody>
36497 <row>
36498 <entry><option>transport_filter</option></entry>
36499 <entry>Use: <emphasis>transports</emphasis></entry>
36500 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
36501 <entry>Default: <emphasis>unset</emphasis></entry>
36502 </row>
36503 </tbody>
36504 </tgroup>
36505 </informaltable>
36506 <para>
36507 <indexterm role="concept">
36508 <primary>transport</primary>
36509 <secondary>filter</secondary>
36510 </indexterm>
36511 <indexterm role="concept">
36512 <primary>filter</primary>
36513 <secondary>transport filter</secondary>
36514 </indexterm>
36515 This option sets up a filtering (in the Unix shell sense) process for messages
36516 at transport time. It should not be confused with mail filtering as set up by
36517 individual users or via a system filter.
36518 </para>
36519 <para>
36520 When the message is about to be written out, the command specified by
36521 <option>transport_filter</option> is started up in a separate, parallel process, and
36522 the entire message, including the header lines, is passed to it on its standard
36523 input (this in fact is done from a third process, to avoid deadlock). The
36524 command must be specified as an absolute path.
36525 </para>
36526 <para>
36527 The lines of the message that are written to the transport filter are
36528 terminated by newline (<quote>\n</quote>). The message is passed to the filter before any
36529 SMTP-specific processing, such as turning <quote>\n</quote> into <quote>\r\n</quote> and escaping
36530 lines beginning with a dot, and also before any processing implied by the
36531 settings of <option>check_string</option> and <option>escape_string</option> in the <command>appendfile</command> or
36532 <command>pipe</command> transports.
36533 </para>
36534 <para>
36535 The standard error for the filter process is set to the same destination as its
36536 standard output; this is read and written to the message&#x2019;s ultimate
36537 destination. The process that writes the message to the filter, the
36538 filter itself, and the original process that reads the result and delivers it
36539 are all run in parallel, like a shell pipeline.
36540 </para>
36541 <para>
36542 The filter can perform any transformations it likes, but of course should take
36543 care not to break RFC 2822 syntax. Exim does not check the result, except to
36544 test for a final newline when SMTP is in use. All messages transmitted over
36545 SMTP must end with a newline, so Exim supplies one if it is missing.
36546 </para>
36547 <para>
36548 <indexterm role="concept">
36549 <primary>content scanning</primary>
36550 <secondary>per user</secondary>
36551 </indexterm>
36552 A transport filter can be used to provide content-scanning on a per-user basis
36553 at delivery time if the only required effect of the scan is to modify the
36554 message. For example, a content scan could insert a new header line containing
36555 a spam score. This could be interpreted by a filter in the user&#x2019;s MUA. It is
36556 not possible to discard a message at this stage.
36557 </para>
36558 <para>
36559 <indexterm role="concept">
36560 <primary>SMTP</primary>
36561 <secondary>SIZE</secondary>
36562 </indexterm>
36563 A problem might arise if the filter increases the size of a message that is
36564 being sent down an SMTP connection. If the receiving SMTP server has indicated
36565 support for the SIZE parameter, Exim will have sent the size of the message
36566 at the start of the SMTP session. If what is actually sent is substantially
36567 more, the server might reject the message. This can be worked round by setting
36568 the <option>size_addition</option> option on the <command>smtp</command> transport, either to allow for
36569 additions to the message, or to disable the use of SIZE altogether.
36570 </para>
36571 <para>
36572 <indexterm role="variable">
36573 <primary><varname>$pipe_addresses</varname></primary>
36574 </indexterm>
36575 The value of the <option>transport_filter</option> option is the command string for starting
36576 the filter, which is run directly from Exim, not under a shell. The string is
36577 parsed by Exim in the same way as a command string for the <command>pipe</command> transport:
36578 Exim breaks it up into arguments and then expands each argument separately (see
36579 section <xref linkend="SECThowcommandrun"/>). Any kind of expansion failure causes delivery
36580 to be deferred. The special argument <varname>$pipe_addresses</varname> is replaced by a number
36581 of arguments, one for each address that applies to this delivery. (This isn&#x2019;t
36582 an ideal name for this feature here, but as it was already implemented for the
36583 <command>pipe</command> transport, it seemed sensible not to change it.)
36584 </para>
36585 <para>
36586 <indexterm role="variable">
36587 <primary><varname>$host</varname></primary>
36588 </indexterm>
36589 <indexterm role="variable">
36590 <primary><varname>$host_address</varname></primary>
36591 </indexterm>
36592 The expansion variables <varname>$host</varname> and <varname>$host_address</varname> are available when the
36593 transport is a remote one. They contain the name and IP address of the host to
36594 which the message is being sent. For example:
36595 </para>
36596 <literallayout class="monospaced">
36597 transport_filter = /some/directory/transport-filter.pl \
36598   $host $host_address $sender_address $pipe_addresses
36599 </literallayout>
36600 <para>
36601 Two problems arise if you want to use more complicated expansion items to
36602 generate transport filter commands, both of which due to the fact that the
36603 command is split up <emphasis>before</emphasis> expansion.
36604 </para>
36605 <itemizedlist>
36606 <listitem>
36607 <para>
36608 If an expansion item contains white space, you must quote it, so that it is all
36609 part of the same command item. If the entire option setting is one such
36610 expansion item, you have to take care what kind of quoting you use. For
36611 example:
36612 </para>
36613 <literallayout class="monospaced">
36614 transport_filter = '/bin/cmd${if eq{$host}{a.b.c}{1}{2}}'
36615 </literallayout>
36616 <para>
36617 This runs the command <command>/bin/cmd1</command> if the host name is <emphasis>a.b.c</emphasis>, and
36618 <command>/bin/cmd2</command> otherwise. If double quotes had been used, they would have been
36619 stripped by Exim when it read the option&#x2019;s value. When the value is used, if
36620 the single quotes were missing, the line would be split into two items,
36621 <literal>/bin/cmd${if</literal> and <literal>eq{$host}{a.b.c}{1}{2}</literal>, and an error would occur when
36622 Exim tried to expand the first one.
36623 </para>
36624 </listitem>
36625 <listitem>
36626 <para>
36627 Except for the special case of <varname>$pipe_addresses</varname> that is mentioned above, an
36628 expansion cannot generate multiple arguments, or a command name followed by
36629 arguments. Consider this example:
36630 </para>
36631 <literallayout class="monospaced">
36632 transport_filter = ${lookup{$host}lsearch{/a/file}\
36633                     {$value}{/bin/cat}}
36634 </literallayout>
36635 <para>
36636 The result of the lookup is interpreted as the name of the command, even
36637 if it contains white space. The simplest way round this is to use a shell:
36638 </para>
36639 <literallayout class="monospaced">
36640 transport_filter = /bin/sh -c ${lookup{$host}lsearch{/a/file}\
36641                                {$value}{/bin/cat}}
36642 </literallayout>
36643 </listitem>
36644 </itemizedlist>
36645 <para>
36646 The filter process is run under the same uid and gid as the normal delivery.
36647 For remote deliveries this is the Exim uid/gid by default. The command should
36648 normally yield a zero return code. Transport filters are not supposed to fail.
36649 A non-zero code is taken to mean that the transport filter encountered some
36650 serious problem. Delivery of the message is deferred; the message remains on
36651 the queue and is tried again later. It is not possible to cause a message to be
36652 bounced from a transport filter.
36653 </para>
36654 <para>
36655 If a transport filter is set on an autoreply transport, the original message is
36656 passed through the filter as it is being copied into the newly generated
36657 message, which happens if the <option>return_message</option> option is set.
36658 </para>
36659 <para>
36660 <indexterm role="option">
36661 <primary><option>transport_filter_timeout</option></primary>
36662 </indexterm>
36663 </para>
36664 <informaltable frame="all">
36665 <tgroup cols="4" colsep="0" rowsep="0">
36666 <colspec colwidth="8*" align="left"/>
36667 <colspec colwidth="6*" align="center"/>
36668 <colspec colwidth="6*" align="center"/>
36669 <colspec colwidth="6*" align="right"/>
36670 <tbody>
36671 <row>
36672 <entry><option>transport_filter_timeout</option></entry>
36673 <entry>Use: <emphasis>transports</emphasis></entry>
36674 <entry>Type: <emphasis>time</emphasis></entry>
36675 <entry>Default: <emphasis>5m</emphasis></entry>
36676 </row>
36677 </tbody>
36678 </tgroup>
36679 </informaltable>
36680 <para>
36681 <indexterm role="concept">
36682 <primary>transport</primary>
36683 <secondary>filter, timeout</secondary>
36684 </indexterm>
36685 When Exim is reading the output of a transport filter, it a applies a timeout
36686 that can be set by this option. Exceeding the timeout is normally treated as a
36687 temporary delivery failure. However, if a transport filter is used with a
36688 <command>pipe</command> transport, a timeout in the transport filter is treated in the same
36689 way as a timeout in the pipe command itself. By default, a timeout is a hard
36690 error, but if the <command>pipe</command> transport&#x2019;s <option>timeout_defer</option> option is set true, it
36691 becomes a temporary error.
36692 </para>
36693 <para>
36694 <indexterm role="option">
36695 <primary><option>user</option></primary>
36696 </indexterm>
36697 </para>
36698 <informaltable frame="all">
36699 <tgroup cols="4" colsep="0" rowsep="0">
36700 <colspec colwidth="8*" align="left"/>
36701 <colspec colwidth="6*" align="center"/>
36702 <colspec colwidth="6*" align="center"/>
36703 <colspec colwidth="6*" align="right"/>
36704 <tbody>
36705 <row>
36706 <entry><option>user</option></entry>
36707 <entry>Use: <emphasis>transports</emphasis></entry>
36708 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
36709 <entry>Default: <emphasis>Exim user</emphasis></entry>
36710 </row>
36711 </tbody>
36712 </tgroup>
36713 </informaltable>
36714 <para>
36715 <indexterm role="concept">
36716 <primary>uid (user id)</primary>
36717 <secondary>local delivery</secondary>
36718 </indexterm>
36719 <indexterm role="concept">
36720 <primary>transport</primary>
36721 <secondary>user, specifying</secondary>
36722 </indexterm>
36723 This option specifies the user under whose uid the delivery process is to be
36724 run, overriding any uid that may have been set by the router. If the user is
36725 given as a name, the uid is looked up from the password data, and the
36726 associated group is taken as the value of the gid to be used if the <option>group</option>
36727 option is not set.
36728 </para>
36729 <para>
36730 For deliveries that use local transports, a user and group are normally
36731 specified explicitly or implicitly (for example, as a result of
36732 <option>check_local_user</option>) by the router or transport.
36733 </para>
36734 <para>
36735 <indexterm role="concept">
36736 <primary>hints database</primary>
36737 <secondary>access by remote transport</secondary>
36738 </indexterm>
36739 For remote transports, you should leave this option unset unless you really are
36740 sure you know what you are doing. When a remote transport is running, it needs
36741 to be able to access Exim&#x2019;s hints databases, because each host may have its own
36742 retry data.
36743 <indexterm role="concept" startref="IIDgenoptra1" class="endofrange"/>
36744 <indexterm role="concept" startref="IIDgenoptra2" class="endofrange"/>
36745 <indexterm role="concept" startref="IIDgenoptra3" class="endofrange"/>
36746 </para>
36747 </chapter>
36748
36749 <chapter id="CHAPbatching">
36750 <title>Address batching in local transports</title>
36751 <titleabbrev>Address batching</titleabbrev>
36752 <para>
36753 <indexterm role="concept">
36754 <primary>transport</primary>
36755 <secondary>local; address batching in</secondary>
36756 </indexterm>
36757 The only remote transport (<command>smtp</command>) is normally configured to handle more than
36758 one address at a time, so that when several addresses are routed to the same
36759 remote host, just one copy of the message is sent. Local transports, however,
36760 normally handle one address at a time. That is, a separate instance of the
36761 transport is run for each address that is routed to the transport. A separate
36762 copy of the message is delivered each time.
36763 </para>
36764 <para>
36765 <indexterm role="concept">
36766 <primary>batched local delivery</primary>
36767 </indexterm>
36768 <indexterm role="option">
36769 <primary><option>batch_max</option></primary>
36770 </indexterm>
36771 <indexterm role="option">
36772 <primary><option>batch_id</option></primary>
36773 </indexterm>
36774 In special cases, it may be desirable to handle several addresses at once in a
36775 local transport, for example:
36776 </para>
36777 <itemizedlist>
36778 <listitem>
36779 <para>
36780 In an <command>appendfile</command> transport, when storing messages in files for later
36781 delivery by some other means, a single copy of the message with multiple
36782 recipients saves space.
36783 </para>
36784 </listitem>
36785 <listitem>
36786 <para>
36787 In an <command>lmtp</command> transport, when delivering over <quote>local SMTP</quote> to some process,
36788 a single copy saves time, and is the normal way LMTP is expected to work.
36789 </para>
36790 </listitem>
36791 <listitem>
36792 <para>
36793 In a <command>pipe</command> transport, when passing the message
36794 to a scanner program or
36795 to some other delivery mechanism such as UUCP, multiple recipients may be
36796 acceptable.
36797 </para>
36798 </listitem>
36799 </itemizedlist>
36800 <para>
36801 These three local transports all have the same options for controlling multiple
36802 (<quote>batched</quote>) deliveries, namely <option>batch_max</option> and <option>batch_id</option>. To save
36803 repeating the information for each transport, these options are described here.
36804 </para>
36805 <para>
36806 The <option>batch_max</option> option specifies the maximum number of addresses that can be
36807 delivered together in a single run of the transport. Its default value is one
36808 (no batching). When more than one address is routed to a transport that has a
36809 <option>batch_max</option> value greater than one, the addresses are delivered in a batch
36810 (that is, in a single run of the transport with multiple recipients), subject
36811 to certain conditions:
36812 </para>
36813 <itemizedlist>
36814 <listitem>
36815 <para>
36816 <indexterm role="variable">
36817 <primary><varname>$local_part</varname></primary>
36818 </indexterm>
36819 If any of the transport&#x2019;s options contain a reference to <varname>$local_part</varname>, no
36820 batching is possible.
36821 </para>
36822 </listitem>
36823 <listitem>
36824 <para>
36825 <indexterm role="variable">
36826 <primary><varname>$domain</varname></primary>
36827 </indexterm>
36828 If any of the transport&#x2019;s options contain a reference to <varname>$domain</varname>, only
36829 addresses with the same domain are batched.
36830 </para>
36831 </listitem>
36832 <listitem>
36833 <para>
36834 <indexterm role="concept">
36835 <primary>customizing</primary>
36836 <secondary>batching condition</secondary>
36837 </indexterm>
36838 If <option>batch_id</option> is set, it is expanded for each address, and only those
36839 addresses with the same expanded value are batched. This allows you to specify
36840 customized batching conditions. Failure of the expansion for any reason,
36841 including forced failure, disables batching, but it does not stop the delivery
36842 from taking place.
36843 </para>
36844 </listitem>
36845 <listitem>
36846 <para>
36847 Batched addresses must also have the same errors address (where to send
36848 delivery errors), the same header additions and removals, the same user and
36849 group for the transport, and if a host list is present, the first host must
36850 be the same.
36851 </para>
36852 </listitem>
36853 </itemizedlist>
36854 <para>
36855 In the case of the <command>appendfile</command> and <command>pipe</command> transports, batching applies
36856 both when the file or pipe command is specified in the transport, and when it
36857 is specified by a <command>redirect</command> router, but all the batched addresses must of
36858 course be routed to the same file or pipe command. These two transports have an
36859 option called <option>use_bsmtp</option>, which causes them to deliver the message in
36860 <quote>batched SMTP</quote> format, with the envelope represented as SMTP commands. The
36861 <option>check_string</option> and <option>escape_string</option> options are forced to the values
36862 </para>
36863 <literallayout class="monospaced">
36864 check_string = "."
36865 escape_string = ".."
36866 </literallayout>
36867 <para>
36868 when batched SMTP is in use. A full description of the batch SMTP mechanism is
36869 given in section <xref linkend="SECTbatchSMTP"/>. The <command>lmtp</command> transport does not have a
36870 <option>use_bsmtp</option> option, because it always delivers using the SMTP protocol.
36871 </para>
36872 <para>
36873 <indexterm role="concept">
36874 <primary><emphasis>Envelope-to:</emphasis> header line</primary>
36875 </indexterm>
36876 If the generic <option>envelope_to_add</option> option is set for a batching transport, the
36877 <emphasis>Envelope-to:</emphasis> header that is added to the message contains all the addresses
36878 that are being processed together. If you are using a batching <command>appendfile</command>
36879 transport without <option>use_bsmtp</option>, the only way to preserve the recipient
36880 addresses is to set the <option>envelope_to_add</option> option.
36881 </para>
36882 <para>
36883 <indexterm role="concept">
36884 <primary><command>pipe</command> transport</primary>
36885 <secondary>with multiple addresses</secondary>
36886 </indexterm>
36887 <indexterm role="variable">
36888 <primary><varname>$pipe_addresses</varname></primary>
36889 </indexterm>
36890 If you are using a <command>pipe</command> transport without BSMTP, and setting the
36891 transport&#x2019;s <option>command</option> option, you can include <varname>$pipe_addresses</varname> as part of
36892 the command. This is not a true variable; it is a bit of magic that causes each
36893 of the recipient addresses to be inserted into the command as a separate
36894 argument. This provides a way of accessing all the addresses that are being
36895 delivered in the batch. <emphasis role="bold">Note:</emphasis> This is not possible for pipe commands that
36896 are specified by a <command>redirect</command> router.
36897 </para>
36898 </chapter>
36899
36900 <chapter id="CHAPappendfile">
36901 <title>The appendfile transport</title>
36902 <para>
36903 <indexterm role="concept" id="IIDapptra1" class="startofrange">
36904 <primary><command>appendfile</command> transport</primary>
36905 </indexterm>
36906 <indexterm role="concept" id="IIDapptra2" class="startofrange">
36907 <primary>transports</primary>
36908 <secondary><command>appendfile</command></secondary>
36909 </indexterm>
36910 <indexterm role="concept">
36911 <primary>directory creation</primary>
36912 </indexterm>
36913 <indexterm role="concept">
36914 <primary>creating directories</primary>
36915 </indexterm>
36916 The <command>appendfile</command> transport delivers a message by appending it to an existing
36917 file, or by creating an entirely new file in a specified directory. Single
36918 files to which messages are appended can be in the traditional Unix mailbox
36919 format, or optionally in the MBX format supported by the Pine MUA and
36920 University of Washington IMAP daemon, <emphasis>inter alia</emphasis>. When each message is
36921 being delivered as a separate file, <quote>maildir</quote> format can optionally be used
36922 to give added protection against failures that happen part-way through the
36923 delivery. A third form of separate-file delivery known as <quote>mailstore</quote> is also
36924 supported. For all file formats, Exim attempts to create as many levels of
36925 directory as necessary, provided that <option>create_directory</option> is set.
36926 </para>
36927 <para>
36928 The code for the optional formats is not included in the Exim binary by
36929 default. It is necessary to set SUPPORT_MBX, SUPPORT_MAILDIR and/or
36930 SUPPORT_MAILSTORE in <filename>Local/Makefile</filename> to have the appropriate code
36931 included.
36932 </para>
36933 <para>
36934 <indexterm role="concept">
36935 <primary>quota</primary>
36936 <secondary>system</secondary>
36937 </indexterm>
36938 Exim recognizes system quota errors, and generates an appropriate message. Exim
36939 also supports its own quota control within the transport, for use when the
36940 system facility is unavailable or cannot be used for some reason.
36941 </para>
36942 <para>
36943 If there is an error while appending to a file (for example, quota exceeded or
36944 partition filled), Exim attempts to reset the file&#x2019;s length and last
36945 modification time back to what they were before. If there is an error while
36946 creating an entirely new file, the new file is removed.
36947 </para>
36948 <para>
36949 Before appending to a file, a number of security checks are made, and the
36950 file is locked. A detailed description is given below, after the list of
36951 private options.
36952 </para>
36953 <para>
36954 The <command>appendfile</command> transport is most commonly used for local deliveries to
36955 users&#x2019; mailboxes. However, it can also be used as a pseudo-remote transport for
36956 putting messages into files for remote delivery by some means other than Exim.
36957 <quote>Batch SMTP</quote> format is often used in this case (see the <option>use_bsmtp</option>
36958 option).
36959 </para>
36960 <section id="SECTfildiropt">
36961 <title>The file and directory options</title>
36962 <para>
36963 The <option>file</option> option specifies a single file, to which the message is appended;
36964 the <option>directory</option> option specifies a directory, in which a new file containing
36965 the message is created. Only one of these two options can be set, and for
36966 normal deliveries to mailboxes, one of them <emphasis>must</emphasis> be set.
36967 </para>
36968 <para>
36969 <indexterm role="variable">
36970 <primary><varname>$address_file</varname></primary>
36971 </indexterm>
36972 <indexterm role="variable">
36973 <primary><varname>$local_part</varname></primary>
36974 </indexterm>
36975 However, <command>appendfile</command> is also used for delivering messages to files or
36976 directories whose names (or parts of names) are obtained from alias,
36977 forwarding, or filtering operations (for example, a <option>save</option> command in a
36978 user&#x2019;s Exim filter). When such a transport is running, <varname>$local_part</varname> contains
36979 the local part that was aliased or forwarded, and <varname>$address_file</varname> contains the
36980 name (or partial name) of the file or directory generated by the redirection
36981 operation. There are two cases:
36982 </para>
36983 <itemizedlist>
36984 <listitem>
36985 <para>
36986 If neither <option>file</option> nor <option>directory</option> is set, the redirection operation
36987 must specify an absolute path (one that begins with <literal>/</literal>). This is the most
36988 common case when users with local accounts use filtering to sort mail into
36989 different folders. See for example, the <command>address_file</command> transport in the
36990 default configuration. If the path ends with a slash, it is assumed to be the
36991 name of a directory. A delivery to a directory can also be forced by setting
36992 <option>maildir_format</option> or <option>mailstore_format</option>.
36993 </para>
36994 </listitem>
36995 <listitem>
36996 <para>
36997 If <option>file</option> or <option>directory</option> is set for a delivery from a redirection, it is
36998 used to determine the file or directory name for the delivery. Normally, the
36999 contents of <varname>$address_file</varname> are used in some way in the string expansion.
37000 </para>
37001 </listitem>
37002 </itemizedlist>
37003 <para>
37004 <indexterm role="concept">
37005 <primary>Sieve filter</primary>
37006 <secondary>configuring <command>appendfile</command></secondary>
37007 </indexterm>
37008 <indexterm role="concept">
37009 <primary>Sieve filter</primary>
37010 <secondary>relative mailbox path handling</secondary>
37011 </indexterm>
37012 As an example of the second case, consider an environment where users do not
37013 have home directories. They may be permitted to use Exim filter commands of the
37014 form:
37015 </para>
37016 <literallayout class="monospaced">
37017 save folder23
37018 </literallayout>
37019 <para>
37020 or Sieve filter commands of the form:
37021 </para>
37022 <literallayout class="monospaced">
37023 require "fileinto";
37024 fileinto "folder23";
37025 </literallayout>
37026 <para>
37027 In this situation, the expansion of <option>file</option> or <option>directory</option> in the transport
37028 must transform the relative path into an appropriate absolute file name. In the
37029 case of Sieve filters, the name <emphasis>inbox</emphasis> must be handled. It is the name that
37030 is used as a result of a <quote>keep</quote> action in the filter. This example shows one
37031 way of handling this requirement:
37032 </para>
37033 <literallayout class="monospaced">
37034 file = ${if eq{$address_file}{inbox} \
37035             {/var/mail/$local_part} \
37036             {${if eq{${substr_0_1:$address_file}}{/} \
37037                   {$address_file} \
37038                   {$home/mail/$address_file} \
37039             }} \
37040        }
37041 </literallayout>
37042 <para>
37043 With this setting of <option>file</option>, <emphasis>inbox</emphasis> refers to the standard mailbox
37044 location, absolute paths are used without change, and other folders are in the
37045 <filename>mail</filename> directory within the home directory.
37046 </para>
37047 <para>
37048 <emphasis role="bold">Note 1</emphasis>: While processing an Exim filter, a relative path such as
37049 <filename>folder23</filename> is turned into an absolute path if a home directory is known to
37050 the router. In particular, this is the case if <option>check_local_user</option> is set. If
37051 you want to prevent this happening at routing time, you can set
37052 <option>router_home_directory</option> empty. This forces the router to pass the relative
37053 path to the transport.
37054 </para>
37055 <para>
37056 <emphasis role="bold">Note 2</emphasis>: An absolute path in <varname>$address_file</varname> is not treated specially;
37057 the <option>file</option> or <option>directory</option> option is still used if it is set.
37058 </para>
37059 </section>
37060 <section id="SECID134">
37061 <title>Private options for appendfile</title>
37062 <para>
37063 <indexterm role="concept">
37064 <primary>options</primary>
37065 <secondary><command>appendfile</command> transport</secondary>
37066 </indexterm>
37067 </para>
37068 <para>
37069 <indexterm role="option">
37070 <primary><option>allow_fifo</option></primary>
37071 </indexterm>
37072 </para>
37073 <informaltable frame="all">
37074 <tgroup cols="4" colsep="0" rowsep="0">
37075 <colspec colwidth="8*" align="left"/>
37076 <colspec colwidth="6*" align="center"/>
37077 <colspec colwidth="6*" align="center"/>
37078 <colspec colwidth="6*" align="right"/>
37079 <tbody>
37080 <row>
37081 <entry><option>allow_fifo</option></entry>
37082 <entry>Use: <emphasis>appendfile</emphasis></entry>
37083 <entry>Type: <emphasis>boolean</emphasis></entry>
37084 <entry>Default: <emphasis>false</emphasis></entry>
37085 </row>
37086 </tbody>
37087 </tgroup>
37088 </informaltable>
37089 <para>
37090 <indexterm role="concept">
37091 <primary>fifo (named pipe)</primary>
37092 </indexterm>
37093 <indexterm role="concept">
37094 <primary>named pipe (fifo)</primary>
37095 </indexterm>
37096 <indexterm role="concept">
37097 <primary>pipe</primary>
37098 <secondary>named (fifo)</secondary>
37099 </indexterm>
37100 Setting this option permits delivery to named pipes (FIFOs) as well as to
37101 regular files. If no process is reading the named pipe at delivery time, the
37102 delivery is deferred.
37103 </para>
37104 <para>
37105 <indexterm role="option">
37106 <primary><option>allow_symlink</option></primary>
37107 </indexterm>
37108 </para>
37109 <informaltable frame="all">
37110 <tgroup cols="4" colsep="0" rowsep="0">
37111 <colspec colwidth="8*" align="left"/>
37112 <colspec colwidth="6*" align="center"/>
37113 <colspec colwidth="6*" align="center"/>
37114 <colspec colwidth="6*" align="right"/>
37115 <tbody>
37116 <row>
37117 <entry><option>allow_symlink</option></entry>
37118 <entry>Use: <emphasis>appendfile</emphasis></entry>
37119 <entry>Type: <emphasis>boolean</emphasis></entry>
37120 <entry>Default: <emphasis>false</emphasis></entry>
37121 </row>
37122 </tbody>
37123 </tgroup>
37124 </informaltable>
37125 <para>
37126 <indexterm role="concept">
37127 <primary>symbolic link</primary>
37128 <secondary>to mailbox</secondary>
37129 </indexterm>
37130 <indexterm role="concept">
37131 <primary>mailbox</primary>
37132 <secondary>symbolic link</secondary>
37133 </indexterm>
37134 By default, <command>appendfile</command> will not deliver if the path name for the file is
37135 that of a symbolic link. Setting this option relaxes that constraint, but there
37136 are security issues involved in the use of symbolic links. Be sure you know
37137 what you are doing if you set this. Details of exactly what this option affects
37138 are included in the discussion which follows this list of options.
37139 </para>
37140 <para>
37141 <indexterm role="option">
37142 <primary><option>batch_id</option></primary>
37143 </indexterm>
37144 </para>
37145 <informaltable frame="all">
37146 <tgroup cols="4" colsep="0" rowsep="0">
37147 <colspec colwidth="8*" align="left"/>
37148 <colspec colwidth="6*" align="center"/>
37149 <colspec colwidth="6*" align="center"/>
37150 <colspec colwidth="6*" align="right"/>
37151 <tbody>
37152 <row>
37153 <entry><option>batch_id</option></entry>
37154 <entry>Use: <emphasis>appendfile</emphasis></entry>
37155 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
37156 <entry>Default: <emphasis>unset</emphasis></entry>
37157 </row>
37158 </tbody>
37159 </tgroup>
37160 </informaltable>
37161 <para>
37162 See the description of local delivery batching in chapter <xref linkend="CHAPbatching"/>.
37163 However, batching is automatically disabled for <command>appendfile</command> deliveries that
37164 happen as a result of forwarding or aliasing or other redirection directly to a
37165 file.
37166 </para>
37167 <para>
37168 <indexterm role="option">
37169 <primary><option>batch_max</option></primary>
37170 </indexterm>
37171 </para>
37172 <informaltable frame="all">
37173 <tgroup cols="4" colsep="0" rowsep="0">
37174 <colspec colwidth="8*" align="left"/>
37175 <colspec colwidth="6*" align="center"/>
37176 <colspec colwidth="6*" align="center"/>
37177 <colspec colwidth="6*" align="right"/>
37178 <tbody>
37179 <row>
37180 <entry><option>batch_max</option></entry>
37181 <entry>Use: <emphasis>appendfile</emphasis></entry>
37182 <entry>Type: <emphasis>integer</emphasis></entry>
37183 <entry>Default: <emphasis>1</emphasis></entry>
37184 </row>
37185 </tbody>
37186 </tgroup>
37187 </informaltable>
37188 <para>
37189 See the description of local delivery batching in chapter <xref linkend="CHAPbatching"/>.
37190 </para>
37191 <para>
37192 <indexterm role="option">
37193 <primary><option>check_group</option></primary>
37194 </indexterm>
37195 </para>
37196 <informaltable frame="all">
37197 <tgroup cols="4" colsep="0" rowsep="0">
37198 <colspec colwidth="8*" align="left"/>
37199 <colspec colwidth="6*" align="center"/>
37200 <colspec colwidth="6*" align="center"/>
37201 <colspec colwidth="6*" align="right"/>
37202 <tbody>
37203 <row>
37204 <entry><option>check_group</option></entry>
37205 <entry>Use: <emphasis>appendfile</emphasis></entry>
37206 <entry>Type: <emphasis>boolean</emphasis></entry>
37207 <entry>Default: <emphasis>false</emphasis></entry>
37208 </row>
37209 </tbody>
37210 </tgroup>
37211 </informaltable>
37212 <para>
37213 When this option is set, the group owner of the file defined by the <option>file</option>
37214 option is checked to see that it is the same as the group under which the
37215 delivery process is running. The default setting is false because the default
37216 file mode is 0600, which means that the group is irrelevant.
37217 </para>
37218 <para>
37219 <indexterm role="option">
37220 <primary><option>check_owner</option></primary>
37221 </indexterm>
37222 </para>
37223 <informaltable frame="all">
37224 <tgroup cols="4" colsep="0" rowsep="0">
37225 <colspec colwidth="8*" align="left"/>
37226 <colspec colwidth="6*" align="center"/>
37227 <colspec colwidth="6*" align="center"/>
37228 <colspec colwidth="6*" align="right"/>
37229 <tbody>
37230 <row>
37231 <entry><option>check_owner</option></entry>
37232 <entry>Use: <emphasis>appendfile</emphasis></entry>
37233 <entry>Type: <emphasis>boolean</emphasis></entry>
37234 <entry>Default: <emphasis>true</emphasis></entry>
37235 </row>
37236 </tbody>
37237 </tgroup>
37238 </informaltable>
37239 <para>
37240 When this option is set, the owner of the file defined by the <option>file</option> option
37241 is checked to ensure that it is the same as the user under which the delivery
37242 process is running.
37243 </para>
37244 <para>
37245 <indexterm role="option">
37246 <primary><option>check_string</option></primary>
37247 </indexterm>
37248 </para>
37249 <informaltable frame="all">
37250 <tgroup cols="4" colsep="0" rowsep="0">
37251 <colspec colwidth="8*" align="left"/>
37252 <colspec colwidth="6*" align="center"/>
37253 <colspec colwidth="6*" align="center"/>
37254 <colspec colwidth="6*" align="right"/>
37255 <tbody>
37256 <row>
37257 <entry><option>check_string</option></entry>
37258 <entry>Use: <emphasis>appendfile</emphasis></entry>
37259 <entry>Type: <emphasis>string</emphasis></entry>
37260 <entry>Default: <emphasis>see below</emphasis></entry>
37261 </row>
37262 </tbody>
37263 </tgroup>
37264 </informaltable>
37265 <para>
37266 <indexterm role="concept">
37267 <primary><quote>From</quote> line</primary>
37268 </indexterm>
37269 As <command>appendfile</command> writes the message, the start of each line is tested for
37270 matching <option>check_string</option>, and if it does, the initial matching characters are
37271 replaced by the contents of <option>escape_string</option>. The value of <option>check_string</option> is
37272 a literal string, not a regular expression, and the case of any letters it
37273 contains is significant.
37274 </para>
37275 <para>
37276 If <option>use_bsmtp</option> is set the values of <option>check_string</option> and <option>escape_string</option>
37277 are forced to <quote>.</quote> and <quote>..</quote> respectively, and any settings in the
37278 configuration are ignored. Otherwise, they default to <quote>From&nbsp;</quote> and
37279 <quote>&gt;From&nbsp;</quote> when the <option>file</option> option is set, and unset when any of the
37280 <option>directory</option>, <option>maildir</option>, or <option>mailstore</option> options are set.
37281 </para>
37282 <para>
37283 The default settings, along with <option>message_prefix</option> and <option>message_suffix</option>, are
37284 suitable for traditional <quote>BSD</quote> mailboxes, where a line beginning with
37285 <quote>From&nbsp;</quote> indicates the start of a new message. All four options need changing
37286 if another format is used. For example, to deliver to mailboxes in MMDF format:
37287 <indexterm role="concept">
37288 <primary>MMDF format mailbox</primary>
37289 </indexterm>
37290 <indexterm role="concept">
37291 <primary>mailbox</primary>
37292 <secondary>MMDF format</secondary>
37293 </indexterm>
37294 </para>
37295 <literallayout class="monospaced">
37296 check_string = "\1\1\1\1\n"
37297 escape_string = "\1\1\1\1 \n"
37298 message_prefix = "\1\1\1\1\n"
37299 message_suffix = "\1\1\1\1\n"
37300 </literallayout>
37301 <para>
37302 <indexterm role="option">
37303 <primary><option>create_directory</option></primary>
37304 </indexterm>
37305 </para>
37306 <informaltable frame="all">
37307 <tgroup cols="4" colsep="0" rowsep="0">
37308 <colspec colwidth="8*" align="left"/>
37309 <colspec colwidth="6*" align="center"/>
37310 <colspec colwidth="6*" align="center"/>
37311 <colspec colwidth="6*" align="right"/>
37312 <tbody>
37313 <row>
37314 <entry><option>create_directory</option></entry>
37315 <entry>Use: <emphasis>appendfile</emphasis></entry>
37316 <entry>Type: <emphasis>boolean</emphasis></entry>
37317 <entry>Default: <emphasis>true</emphasis></entry>
37318 </row>
37319 </tbody>
37320 </tgroup>
37321 </informaltable>
37322 <para>
37323 <indexterm role="concept">
37324 <primary>directory creation</primary>
37325 </indexterm>
37326 When this option is true, Exim attempts to create any missing superior
37327 directories for the file that it is about to write. A created directory&#x2019;s mode
37328 is given by the <option>directory_mode</option> option.
37329 </para>
37330 <para>
37331 The group ownership of a newly created directory is highly dependent on the
37332 operating system (and possibly the file system) that is being used. For
37333 example, in Solaris, if the parent directory has the setgid bit set, its group
37334 is propagated to the child; if not, the currently set group is used. However,
37335 in FreeBSD, the parent&#x2019;s group is always used.
37336 </para>
37337 <para>
37338 <indexterm role="option">
37339 <primary><option>create_file</option></primary>
37340 </indexterm>
37341 </para>
37342 <informaltable frame="all">
37343 <tgroup cols="4" colsep="0" rowsep="0">
37344 <colspec colwidth="8*" align="left"/>
37345 <colspec colwidth="6*" align="center"/>
37346 <colspec colwidth="6*" align="center"/>
37347 <colspec colwidth="6*" align="right"/>
37348 <tbody>
37349 <row>
37350 <entry><option>create_file</option></entry>
37351 <entry>Use: <emphasis>appendfile</emphasis></entry>
37352 <entry>Type: <emphasis>string</emphasis></entry>
37353 <entry>Default: <emphasis>anywhere</emphasis></entry>
37354 </row>
37355 </tbody>
37356 </tgroup>
37357 </informaltable>
37358 <para>
37359 This option constrains the location of files and directories that are created
37360 by this transport. It applies to files defined by the <option>file</option> option and
37361 directories defined by the <option>directory</option> option. In the case of maildir
37362 delivery, it applies to the top level directory, not the maildir directories
37363 beneath.
37364 </para>
37365 <para>
37366 The option must be set to one of the words <quote>anywhere</quote>, <quote>inhome</quote>, or
37367 <quote>belowhome</quote>. In the second and third cases, a home directory must have been
37368 set for the transport. This option is not useful when an explicit file name is
37369 given for normal mailbox deliveries. It is intended for the case when file
37370 names are generated from users&#x2019; <filename>.forward</filename> files. These are usually handled
37371 by an <command>appendfile</command> transport called <option>address_file</option>. See also
37372 <option>file_must_exist</option>.
37373 </para>
37374 <para>
37375 <indexterm role="option">
37376 <primary><option>directory</option></primary>
37377 </indexterm>
37378 </para>
37379 <informaltable frame="all">
37380 <tgroup cols="4" colsep="0" rowsep="0">
37381 <colspec colwidth="8*" align="left"/>
37382 <colspec colwidth="6*" align="center"/>
37383 <colspec colwidth="6*" align="center"/>
37384 <colspec colwidth="6*" align="right"/>
37385 <tbody>
37386 <row>
37387 <entry><option>directory</option></entry>
37388 <entry>Use: <emphasis>appendfile</emphasis></entry>
37389 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
37390 <entry>Default: <emphasis>unset</emphasis></entry>
37391 </row>
37392 </tbody>
37393 </tgroup>
37394 </informaltable>
37395 <para>
37396 This option is mutually exclusive with the <option>file</option> option, but one of <option>file</option>
37397 or <option>directory</option> must be set, unless the delivery is the direct result of a
37398 redirection (see section <xref linkend="SECTfildiropt"/>).
37399 </para>
37400 <para>
37401 When <option>directory</option> is set, the string is expanded, and the message is delivered
37402 into a new file or files in or below the given directory, instead of being
37403 appended to a single mailbox file. A number of different formats are provided
37404 (see <option>maildir_format</option> and <option>mailstore_format</option>), and see section
37405 <xref linkend="SECTopdir"/> for further details of this form of delivery.
37406 </para>
37407 <para>
37408 <indexterm role="option">
37409 <primary><option>directory_file</option></primary>
37410 </indexterm>
37411 </para>
37412 <informaltable frame="all">
37413 <tgroup cols="4" colsep="0" rowsep="0">
37414 <colspec colwidth="8*" align="left"/>
37415 <colspec colwidth="6*" align="center"/>
37416 <colspec colwidth="6*" align="center"/>
37417 <colspec colwidth="6*" align="right"/>
37418 <tbody>
37419 <row>
37420 <entry><option>directory_file</option></entry>
37421 <entry>Use: <emphasis>appendfile</emphasis></entry>
37422 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
37423 <entry>Default: <emphasis>see below</emphasis></entry>
37424 </row>
37425 </tbody>
37426 </tgroup>
37427 </informaltable>
37428 <para>
37429 <indexterm role="concept">
37430 <primary>base62</primary>
37431 </indexterm>
37432 <indexterm role="variable">
37433 <primary><varname>$inode</varname></primary>
37434 </indexterm>
37435 When <option>directory</option> is set, but neither <option>maildir_format</option> nor
37436 <option>mailstore_format</option> is set, <command>appendfile</command> delivers each message into a file
37437 whose name is obtained by expanding this string. The default value is:
37438 </para>
37439 <literallayout class="monospaced">
37440 q${base62:$tod_epoch}-$inode
37441 </literallayout>
37442 <para>
37443 This generates a unique name from the current time, in base 62 form, and the
37444 inode of the file. The variable <varname>$inode</varname> is available only when expanding this
37445 option.
37446 </para>
37447 <para>
37448 <indexterm role="option">
37449 <primary><option>directory_mode</option></primary>
37450 </indexterm>
37451 </para>
37452 <informaltable frame="all">
37453 <tgroup cols="4" colsep="0" rowsep="0">
37454 <colspec colwidth="8*" align="left"/>
37455 <colspec colwidth="6*" align="center"/>
37456 <colspec colwidth="6*" align="center"/>
37457 <colspec colwidth="6*" align="right"/>
37458 <tbody>
37459 <row>
37460 <entry><option>directory_mode</option></entry>
37461 <entry>Use: <emphasis>appendfile</emphasis></entry>
37462 <entry>Type: <emphasis>octal integer</emphasis></entry>
37463 <entry>Default: <emphasis>0700</emphasis></entry>
37464 </row>
37465 </tbody>
37466 </tgroup>
37467 </informaltable>
37468 <para>
37469 If <command>appendfile</command> creates any directories as a result of the
37470 <option>create_directory</option> option, their mode is specified by this option.
37471 </para>
37472 <para>
37473 <indexterm role="option">
37474 <primary><option>escape_string</option></primary>
37475 </indexterm>
37476 </para>
37477 <informaltable frame="all">
37478 <tgroup cols="4" colsep="0" rowsep="0">
37479 <colspec colwidth="8*" align="left"/>
37480 <colspec colwidth="6*" align="center"/>
37481 <colspec colwidth="6*" align="center"/>
37482 <colspec colwidth="6*" align="right"/>
37483 <tbody>
37484 <row>
37485 <entry><option>escape_string</option></entry>
37486 <entry>Use: <emphasis>appendfile</emphasis></entry>
37487 <entry>Type: <emphasis>string</emphasis></entry>
37488 <entry>Default: <emphasis>see description</emphasis></entry>
37489 </row>
37490 </tbody>
37491 </tgroup>
37492 </informaltable>
37493 <para>
37494 See <option>check_string</option> above.
37495 </para>
37496 <para>
37497 <indexterm role="option">
37498 <primary><option>file</option></primary>
37499 </indexterm>
37500 </para>
37501 <informaltable frame="all">
37502 <tgroup cols="4" colsep="0" rowsep="0">
37503 <colspec colwidth="8*" align="left"/>
37504 <colspec colwidth="6*" align="center"/>
37505 <colspec colwidth="6*" align="center"/>
37506 <colspec colwidth="6*" align="right"/>
37507 <tbody>
37508 <row>
37509 <entry><option>file</option></entry>
37510 <entry>Use: <emphasis>appendfile</emphasis></entry>
37511 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
37512 <entry>Default: <emphasis>unset</emphasis></entry>
37513 </row>
37514 </tbody>
37515 </tgroup>
37516 </informaltable>
37517 <para>
37518 This option is mutually exclusive with the <option>directory</option> option, but one of
37519 <option>file</option> or <option>directory</option> must be set, unless the delivery is the direct result
37520 of a redirection (see section <xref linkend="SECTfildiropt"/>). The <option>file</option> option
37521 specifies a single file, to which the message is appended. One or more of
37522 <option>use_fcntl_lock</option>, <option>use_flock_lock</option>, or <option>use_lockfile</option> must be set with
37523 <option>file</option>.
37524 </para>
37525 <para>
37526 <indexterm role="concept">
37527 <primary>NFS</primary>
37528 <secondary>lock file</secondary>
37529 </indexterm>
37530 <indexterm role="concept">
37531 <primary>locking files</primary>
37532 </indexterm>
37533 <indexterm role="concept">
37534 <primary>lock files</primary>
37535 </indexterm>
37536 If you are using more than one host to deliver over NFS into the same
37537 mailboxes, you should always use lock files.
37538 </para>
37539 <para>
37540 The string value is expanded for each delivery, and must yield an absolute
37541 path. The most common settings of this option are variations on one of these
37542 examples:
37543 </para>
37544 <literallayout class="monospaced">
37545 file = /var/spool/mail/$local_part
37546 file = /home/$local_part/inbox
37547 file = $home/inbox
37548 </literallayout>
37549 <para>
37550 <indexterm role="concept">
37551 <primary><quote>sticky</quote> bit</primary>
37552 </indexterm>
37553 In the first example, all deliveries are done into the same directory. If Exim
37554 is configured to use lock files (see <option>use_lockfile</option> below) it must be able to
37555 create a file in the directory, so the <quote>sticky</quote> bit must be turned on for
37556 deliveries to be possible, or alternatively the <option>group</option> option can be used to
37557 run the delivery under a group id which has write access to the directory.
37558 </para>
37559 <para>
37560 <indexterm role="option">
37561 <primary><option>file_format</option></primary>
37562 </indexterm>
37563 </para>
37564 <informaltable frame="all">
37565 <tgroup cols="4" colsep="0" rowsep="0">
37566 <colspec colwidth="8*" align="left"/>
37567 <colspec colwidth="6*" align="center"/>
37568 <colspec colwidth="6*" align="center"/>
37569 <colspec colwidth="6*" align="right"/>
37570 <tbody>
37571 <row>
37572 <entry><option>file_format</option></entry>
37573 <entry>Use: <emphasis>appendfile</emphasis></entry>
37574 <entry>Type: <emphasis>string</emphasis></entry>
37575 <entry>Default: <emphasis>unset</emphasis></entry>
37576 </row>
37577 </tbody>
37578 </tgroup>
37579 </informaltable>
37580 <para>
37581 <indexterm role="concept">
37582 <primary>file</primary>
37583 <secondary>mailbox; checking existing format</secondary>
37584 </indexterm>
37585 This option requests the transport to check the format of an existing file
37586 before adding to it. The check consists of matching a specific string at the
37587 start of the file. The value of the option consists of an even number of
37588 colon-separated strings. The first of each pair is the test string, and the
37589 second is the name of a transport. If the transport associated with a matched
37590 string is not the current transport, control is passed over to the other
37591 transport. For example, suppose the standard <command>local_delivery</command> transport has
37592 this added to it:
37593 </para>
37594 <literallayout class="monospaced">
37595 file_format = "From       : local_delivery :\
37596                \1\1\1\1\n : local_mmdf_delivery"
37597 </literallayout>
37598 <para>
37599 Mailboxes that begin with <quote>From</quote> are still handled by this transport, but if
37600 a mailbox begins with four binary ones followed by a newline, control is passed
37601 to a transport called <option>local_mmdf_delivery</option>, which presumably is configured
37602 to do the delivery in MMDF format. If a mailbox does not exist or is empty, it
37603 is assumed to match the current transport. If the start of a mailbox doesn&#x2019;t
37604 match any string, or if the transport named for a given string is not defined,
37605 delivery is deferred.
37606 </para>
37607 <para>
37608 <indexterm role="option">
37609 <primary><option>file_must_exist</option></primary>
37610 </indexterm>
37611 </para>
37612 <informaltable frame="all">
37613 <tgroup cols="4" colsep="0" rowsep="0">
37614 <colspec colwidth="8*" align="left"/>
37615 <colspec colwidth="6*" align="center"/>
37616 <colspec colwidth="6*" align="center"/>
37617 <colspec colwidth="6*" align="right"/>
37618 <tbody>
37619 <row>
37620 <entry><option>file_must_exist</option></entry>
37621 <entry>Use: <emphasis>appendfile</emphasis></entry>
37622 <entry>Type: <emphasis>boolean</emphasis></entry>
37623 <entry>Default: <emphasis>false</emphasis></entry>
37624 </row>
37625 </tbody>
37626 </tgroup>
37627 </informaltable>
37628 <para>
37629 If this option is true, the file specified by the <option>file</option> option must exist.
37630 A temporary error occurs if it does not, causing delivery to be deferred.
37631 If this option is false, the file is created if it does not exist.
37632 </para>
37633 <para>
37634 <indexterm role="option">
37635 <primary><option>lock_fcntl_timeout</option></primary>
37636 </indexterm>
37637 </para>
37638 <informaltable frame="all">
37639 <tgroup cols="4" colsep="0" rowsep="0">
37640 <colspec colwidth="8*" align="left"/>
37641 <colspec colwidth="6*" align="center"/>
37642 <colspec colwidth="6*" align="center"/>
37643 <colspec colwidth="6*" align="right"/>
37644 <tbody>
37645 <row>
37646 <entry><option>lock_fcntl_timeout</option></entry>
37647 <entry>Use: <emphasis>appendfile</emphasis></entry>
37648 <entry>Type: <emphasis>time</emphasis></entry>
37649 <entry>Default: <emphasis>0s</emphasis></entry>
37650 </row>
37651 </tbody>
37652 </tgroup>
37653 </informaltable>
37654 <para>
37655 <indexterm role="concept">
37656 <primary>timeout</primary>
37657 <secondary>mailbox locking</secondary>
37658 </indexterm>
37659 <indexterm role="concept">
37660 <primary>mailbox</primary>
37661 <secondary>locking, blocking and non-blocking</secondary>
37662 </indexterm>
37663 <indexterm role="concept">
37664 <primary>locking files</primary>
37665 </indexterm>
37666 By default, the <command>appendfile</command> transport uses non-blocking calls to <function>fcntl()</function>
37667 when locking an open mailbox file. If the call fails, the delivery process
37668 sleeps for <option>lock_interval</option> and tries again, up to <option>lock_retries</option> times.
37669 Non-blocking calls are used so that the file is not kept open during the wait
37670 for the lock; the reason for this is to make it as safe as possible for
37671 deliveries over NFS in the case when processes might be accessing an NFS
37672 mailbox without using a lock file. This should not be done, but
37673 misunderstandings and hence misconfigurations are not unknown.
37674 </para>
37675 <para>
37676 On a busy system, however, the performance of a non-blocking lock approach is
37677 not as good as using a blocking lock with a timeout. In this case, the waiting
37678 is done inside the system call, and Exim&#x2019;s delivery process acquires the lock
37679 and can proceed as soon as the previous lock holder releases it.
37680 </para>
37681 <para>
37682 If <option>lock_fcntl_timeout</option> is set to a non-zero time, blocking locks, with that
37683 timeout, are used. There may still be some retrying: the maximum number of
37684 retries is
37685 </para>
37686 <literallayout class="monospaced">
37687 (lock_retries * lock_interval) / lock_fcntl_timeout
37688 </literallayout>
37689 <para>
37690 rounded up to the next whole number. In other words, the total time during
37691 which <command>appendfile</command> is trying to get a lock is roughly the same, unless
37692 <option>lock_fcntl_timeout</option> is set very large.
37693 </para>
37694 <para>
37695 You should consider setting this option if you are getting a lot of delayed
37696 local deliveries because of errors of the form
37697 </para>
37698 <literallayout class="monospaced">
37699 failed to lock mailbox /some/file (fcntl)
37700 </literallayout>
37701 <para>
37702 <indexterm role="option">
37703 <primary><option>lock_flock_timeout</option></primary>
37704 </indexterm>
37705 </para>
37706 <informaltable frame="all">
37707 <tgroup cols="4" colsep="0" rowsep="0">
37708 <colspec colwidth="8*" align="left"/>
37709 <colspec colwidth="6*" align="center"/>
37710 <colspec colwidth="6*" align="center"/>
37711 <colspec colwidth="6*" align="right"/>
37712 <tbody>
37713 <row>
37714 <entry><option>lock_flock_timeout</option></entry>
37715 <entry>Use: <emphasis>appendfile</emphasis></entry>
37716 <entry>Type: <emphasis>time</emphasis></entry>
37717 <entry>Default: <emphasis>0s</emphasis></entry>
37718 </row>
37719 </tbody>
37720 </tgroup>
37721 </informaltable>
37722 <para>
37723 This timeout applies to file locking when using <function>flock()</function> (see
37724 <option>use_flock</option>); the timeout operates in a similar manner to
37725 <option>lock_fcntl_timeout</option>.
37726 </para>
37727 <para>
37728 <indexterm role="option">
37729 <primary><option>lock_interval</option></primary>
37730 </indexterm>
37731 </para>
37732 <informaltable frame="all">
37733 <tgroup cols="4" colsep="0" rowsep="0">
37734 <colspec colwidth="8*" align="left"/>
37735 <colspec colwidth="6*" align="center"/>
37736 <colspec colwidth="6*" align="center"/>
37737 <colspec colwidth="6*" align="right"/>
37738 <tbody>
37739 <row>
37740 <entry><option>lock_interval</option></entry>
37741 <entry>Use: <emphasis>appendfile</emphasis></entry>
37742 <entry>Type: <emphasis>time</emphasis></entry>
37743 <entry>Default: <emphasis>3s</emphasis></entry>
37744 </row>
37745 </tbody>
37746 </tgroup>
37747 </informaltable>
37748 <para>
37749 This specifies the time to wait between attempts to lock the file. See below
37750 for details of locking.
37751 </para>
37752 <para>
37753 <indexterm role="option">
37754 <primary><option>lock_retries</option></primary>
37755 </indexterm>
37756 </para>
37757 <informaltable frame="all">
37758 <tgroup cols="4" colsep="0" rowsep="0">
37759 <colspec colwidth="8*" align="left"/>
37760 <colspec colwidth="6*" align="center"/>
37761 <colspec colwidth="6*" align="center"/>
37762 <colspec colwidth="6*" align="right"/>
37763 <tbody>
37764 <row>
37765 <entry><option>lock_retries</option></entry>
37766 <entry>Use: <emphasis>appendfile</emphasis></entry>
37767 <entry>Type: <emphasis>integer</emphasis></entry>
37768 <entry>Default: <emphasis>10</emphasis></entry>
37769 </row>
37770 </tbody>
37771 </tgroup>
37772 </informaltable>
37773 <para>
37774 This specifies the maximum number of attempts to lock the file. A value of zero
37775 is treated as 1. See below for details of locking.
37776 </para>
37777 <para>
37778 <indexterm role="option">
37779 <primary><option>lockfile_mode</option></primary>
37780 </indexterm>
37781 </para>
37782 <informaltable frame="all">
37783 <tgroup cols="4" colsep="0" rowsep="0">
37784 <colspec colwidth="8*" align="left"/>
37785 <colspec colwidth="6*" align="center"/>
37786 <colspec colwidth="6*" align="center"/>
37787 <colspec colwidth="6*" align="right"/>
37788 <tbody>
37789 <row>
37790 <entry><option>lockfile_mode</option></entry>
37791 <entry>Use: <emphasis>appendfile</emphasis></entry>
37792 <entry>Type: <emphasis>octal integer</emphasis></entry>
37793 <entry>Default: <emphasis>0600</emphasis></entry>
37794 </row>
37795 </tbody>
37796 </tgroup>
37797 </informaltable>
37798 <para>
37799 This specifies the mode of the created lock file, when a lock file is being
37800 used (see <option>use_lockfile</option> and <option>use_mbx_lock</option>).
37801 </para>
37802 <para>
37803 <indexterm role="option">
37804 <primary><option>lockfile_timeout</option></primary>
37805 </indexterm>
37806 </para>
37807 <informaltable frame="all">
37808 <tgroup cols="4" colsep="0" rowsep="0">
37809 <colspec colwidth="8*" align="left"/>
37810 <colspec colwidth="6*" align="center"/>
37811 <colspec colwidth="6*" align="center"/>
37812 <colspec colwidth="6*" align="right"/>
37813 <tbody>
37814 <row>
37815 <entry><option>lockfile_timeout</option></entry>
37816 <entry>Use: <emphasis>appendfile</emphasis></entry>
37817 <entry>Type: <emphasis>time</emphasis></entry>
37818 <entry>Default: <emphasis>30m</emphasis></entry>
37819 </row>
37820 </tbody>
37821 </tgroup>
37822 </informaltable>
37823 <para>
37824 <indexterm role="concept">
37825 <primary>timeout</primary>
37826 <secondary>mailbox locking</secondary>
37827 </indexterm>
37828 When a lock file is being used (see <option>use_lockfile</option>), if a lock file already
37829 exists and is older than this value, it is assumed to have been left behind by
37830 accident, and Exim attempts to remove it.
37831 </para>
37832 <para>
37833 <indexterm role="option">
37834 <primary><option>mailbox_filecount</option></primary>
37835 </indexterm>
37836 </para>
37837 <informaltable frame="all">
37838 <tgroup cols="4" colsep="0" rowsep="0">
37839 <colspec colwidth="8*" align="left"/>
37840 <colspec colwidth="6*" align="center"/>
37841 <colspec colwidth="6*" align="center"/>
37842 <colspec colwidth="6*" align="right"/>
37843 <tbody>
37844 <row>
37845 <entry><option>mailbox_filecount</option></entry>
37846 <entry>Use: <emphasis>appendfile</emphasis></entry>
37847 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
37848 <entry>Default: <emphasis>unset</emphasis></entry>
37849 </row>
37850 </tbody>
37851 </tgroup>
37852 </informaltable>
37853 <para>
37854 <indexterm role="concept">
37855 <primary>mailbox</primary>
37856 <secondary>specifying size of</secondary>
37857 </indexterm>
37858 <indexterm role="concept">
37859 <primary>size</primary>
37860 <secondary>of mailbox</secondary>
37861 </indexterm>
37862 If this option is set, it is expanded, and the result is taken as the current
37863 number of files in the mailbox. It must be a decimal number, optionally
37864 followed by K or M. This provides a way of obtaining this information from an
37865 external source that maintains the data.
37866 </para>
37867 <para>
37868 <indexterm role="option">
37869 <primary><option>mailbox_size</option></primary>
37870 </indexterm>
37871 </para>
37872 <informaltable frame="all">
37873 <tgroup cols="4" colsep="0" rowsep="0">
37874 <colspec colwidth="8*" align="left"/>
37875 <colspec colwidth="6*" align="center"/>
37876 <colspec colwidth="6*" align="center"/>
37877 <colspec colwidth="6*" align="right"/>
37878 <tbody>
37879 <row>
37880 <entry><option>mailbox_size</option></entry>
37881 <entry>Use: <emphasis>appendfile</emphasis></entry>
37882 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
37883 <entry>Default: <emphasis>unset</emphasis></entry>
37884 </row>
37885 </tbody>
37886 </tgroup>
37887 </informaltable>
37888 <para>
37889 <indexterm role="concept">
37890 <primary>mailbox</primary>
37891 <secondary>specifying size of</secondary>
37892 </indexterm>
37893 <indexterm role="concept">
37894 <primary>size</primary>
37895 <secondary>of mailbox</secondary>
37896 </indexterm>
37897 If this option is set, it is expanded, and the result is taken as the current
37898 size the mailbox. It must be a decimal number, optionally followed by K or M.
37899 This provides a way of obtaining this information from an external source that
37900 maintains the data. This is likely to be helpful for maildir deliveries where
37901 it is computationally expensive to compute the size of a mailbox.
37902 </para>
37903 <para>
37904 <indexterm role="option">
37905 <primary><option>maildir_format</option></primary>
37906 </indexterm>
37907 </para>
37908 <informaltable frame="all">
37909 <tgroup cols="4" colsep="0" rowsep="0">
37910 <colspec colwidth="8*" align="left"/>
37911 <colspec colwidth="6*" align="center"/>
37912 <colspec colwidth="6*" align="center"/>
37913 <colspec colwidth="6*" align="right"/>
37914 <tbody>
37915 <row>
37916 <entry><option>maildir_format</option></entry>
37917 <entry>Use: <emphasis>appendfile</emphasis></entry>
37918 <entry>Type: <emphasis>boolean</emphasis></entry>
37919 <entry>Default: <emphasis>false</emphasis></entry>
37920 </row>
37921 </tbody>
37922 </tgroup>
37923 </informaltable>
37924 <para>
37925 <indexterm role="concept">
37926 <primary>maildir format</primary>
37927 <secondary>specifying</secondary>
37928 </indexterm>
37929 If this option is set with the <option>directory</option> option, the delivery is into a new
37930 file, in the <quote>maildir</quote> format that is used by other mail software. When the
37931 transport is activated directly from a <command>redirect</command> router (for example, the
37932 <command>address_file</command> transport in the default configuration), setting
37933 <option>maildir_format</option> causes the path received from the router to be treated as a
37934 directory, whether or not it ends with <literal>/</literal>. This option is available only if
37935 SUPPORT_MAILDIR is present in <filename>Local/Makefile</filename>. See section
37936 <xref linkend="SECTmaildirdelivery"/> below for further details.
37937 </para>
37938 <para>
37939 <indexterm role="option">
37940 <primary><option>maildir_quota_directory_regex</option></primary>
37941 </indexterm>
37942 </para>
37943 <informaltable frame="all">
37944 <tgroup cols="4" colsep="0" rowsep="0">
37945 <colspec colwidth="8*" align="left"/>
37946 <colspec colwidth="6*" align="center"/>
37947 <colspec colwidth="6*" align="center"/>
37948 <colspec colwidth="6*" align="right"/>
37949 <tbody>
37950 <row>
37951 <entry><option>maildir_quota_directory_regex</option></entry>
37952 <entry>Use: <emphasis>appendfile</emphasis></entry>
37953 <entry>Type: <emphasis>string</emphasis></entry>
37954 <entry>Default: <emphasis>See below</emphasis></entry>
37955 </row>
37956 </tbody>
37957 </tgroup>
37958 </informaltable>
37959 <para>
37960 <indexterm role="concept">
37961 <primary>maildir format</primary>
37962 <secondary>quota; directories included in</secondary>
37963 </indexterm>
37964 <indexterm role="concept">
37965 <primary>quota</primary>
37966 <secondary>maildir; directories included in</secondary>
37967 </indexterm>
37968 This option is relevant only when <option>maildir_use_size_file</option> is set. It defines
37969 a regular expression for specifying directories, relative to the quota
37970 directory (see <option>quota_directory</option>), that should be included in the quota
37971 calculation. The default value is:
37972 </para>
37973 <literallayout class="monospaced">
37974 maildir_quota_directory_regex = ^(?:cur|new|\..*)$
37975 </literallayout>
37976 <para>
37977 This includes the <filename>cur</filename> and <filename>new</filename> directories, and any maildir++ folders
37978 (directories whose names begin with a dot). If you want to exclude the
37979 <filename>Trash</filename>
37980 folder from the count (as some sites do), you need to change this setting to
37981 </para>
37982 <literallayout class="monospaced">
37983 maildir_quota_directory_regex = ^(?:cur|new|\.(?!Trash).*)$
37984 </literallayout>
37985 <para>
37986 This uses a negative lookahead in the regular expression to exclude the
37987 directory whose name is <filename>.Trash</filename>. When a directory is excluded from quota
37988 calculations, quota processing is bypassed for any messages that are delivered
37989 directly into that directory.
37990 </para>
37991 <para>
37992 <indexterm role="option">
37993 <primary><option>maildir_retries</option></primary>
37994 </indexterm>
37995 </para>
37996 <informaltable frame="all">
37997 <tgroup cols="4" colsep="0" rowsep="0">
37998 <colspec colwidth="8*" align="left"/>
37999 <colspec colwidth="6*" align="center"/>
38000 <colspec colwidth="6*" align="center"/>
38001 <colspec colwidth="6*" align="right"/>
38002 <tbody>
38003 <row>
38004 <entry><option>maildir_retries</option></entry>
38005 <entry>Use: <emphasis>appendfile</emphasis></entry>
38006 <entry>Type: <emphasis>integer</emphasis></entry>
38007 <entry>Default: <emphasis>10</emphasis></entry>
38008 </row>
38009 </tbody>
38010 </tgroup>
38011 </informaltable>
38012 <para>
38013 This option specifies the number of times to retry when writing a file in
38014 <quote>maildir</quote> format. See section <xref linkend="SECTmaildirdelivery"/> below.
38015 </para>
38016 <para>
38017 <indexterm role="option">
38018 <primary><option>maildir_tag</option></primary>
38019 </indexterm>
38020 </para>
38021 <informaltable frame="all">
38022 <tgroup cols="4" colsep="0" rowsep="0">
38023 <colspec colwidth="8*" align="left"/>
38024 <colspec colwidth="6*" align="center"/>
38025 <colspec colwidth="6*" align="center"/>
38026 <colspec colwidth="6*" align="right"/>
38027 <tbody>
38028 <row>
38029 <entry><option>maildir_tag</option></entry>
38030 <entry>Use: <emphasis>appendfile</emphasis></entry>
38031 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
38032 <entry>Default: <emphasis>unset</emphasis></entry>
38033 </row>
38034 </tbody>
38035 </tgroup>
38036 </informaltable>
38037 <para>
38038 This option applies only to deliveries in maildir format, and is described in
38039 section <xref linkend="SECTmaildirdelivery"/> below.
38040 </para>
38041 <para>
38042 <indexterm role="option">
38043 <primary><option>maildir_use_size_file</option></primary>
38044 </indexterm>
38045 </para>
38046 <informaltable frame="all">
38047 <tgroup cols="4" colsep="0" rowsep="0">
38048 <colspec colwidth="8*" align="left"/>
38049 <colspec colwidth="6*" align="center"/>
38050 <colspec colwidth="6*" align="center"/>
38051 <colspec colwidth="6*" align="right"/>
38052 <tbody>
38053 <row>
38054 <entry><option>maildir_use_size_file</option></entry>
38055 <entry>Use: <emphasis>appendfile</emphasis></entry>
38056 <entry>Type: <emphasis>boolean</emphasis></entry>
38057 <entry>Default: <emphasis>false</emphasis></entry>
38058 </row>
38059 </tbody>
38060 </tgroup>
38061 </informaltable>
38062 <para>
38063 <indexterm role="concept">
38064 <primary>maildir format</primary>
38065 <secondary><filename>maildirsize</filename> file</secondary>
38066 </indexterm>
38067 Setting this option true enables support for <filename>maildirsize</filename> files. Exim
38068 creates a <filename>maildirsize</filename> file in a maildir if one does not exist, taking the
38069 quota from the <option>quota</option> option of the transport. If <option>quota</option> is unset, the
38070 value is zero. See <option>maildir_quota_directory_regex</option> above and section
38071 <xref linkend="SECTmaildirdelivery"/> below for further details.
38072 </para>
38073 <para>
38074 <indexterm role="option">
38075 <primary><option>maildirfolder_create_regex</option></primary>
38076 </indexterm>
38077 </para>
38078 <informaltable frame="all">
38079 <tgroup cols="4" colsep="0" rowsep="0">
38080 <colspec colwidth="8*" align="left"/>
38081 <colspec colwidth="6*" align="center"/>
38082 <colspec colwidth="6*" align="center"/>
38083 <colspec colwidth="6*" align="right"/>
38084 <tbody>
38085 <row>
38086 <entry><option>maildirfolder_create_regex</option></entry>
38087 <entry>Use: <emphasis>appendfile</emphasis></entry>
38088 <entry>Type: <emphasis>string</emphasis></entry>
38089 <entry>Default: <emphasis>unset</emphasis></entry>
38090 </row>
38091 </tbody>
38092 </tgroup>
38093 </informaltable>
38094 <para>
38095 <indexterm role="concept">
38096 <primary>maildir format</primary>
38097 <secondary><filename>maildirfolder</filename> file</secondary>
38098 </indexterm>
38099 <indexterm role="concept">
38100 <primary><filename>maildirfolder</filename>, creating</primary>
38101 </indexterm>
38102 The value of this option is a regular expression. If it is unset, it has no
38103 effect. Otherwise, before a maildir delivery takes place, the pattern is
38104 matched against the name of the maildir directory, that is, the directory
38105 containing the <filename>new</filename> and <filename>tmp</filename> subdirectories that will be used for the
38106 delivery. If there is a match, Exim checks for the existence of a file called
38107 <filename>maildirfolder</filename> in the directory, and creates it if it does not exist.
38108 See section <xref linkend="SECTmaildirdelivery"/> for more details.
38109 </para>
38110 <para>
38111 <indexterm role="option">
38112 <primary><option>mailstore_format</option></primary>
38113 </indexterm>
38114 </para>
38115 <informaltable frame="all">
38116 <tgroup cols="4" colsep="0" rowsep="0">
38117 <colspec colwidth="8*" align="left"/>
38118 <colspec colwidth="6*" align="center"/>
38119 <colspec colwidth="6*" align="center"/>
38120 <colspec colwidth="6*" align="right"/>
38121 <tbody>
38122 <row>
38123 <entry><option>mailstore_format</option></entry>
38124 <entry>Use: <emphasis>appendfile</emphasis></entry>
38125 <entry>Type: <emphasis>boolean</emphasis></entry>
38126 <entry>Default: <emphasis>false</emphasis></entry>
38127 </row>
38128 </tbody>
38129 </tgroup>
38130 </informaltable>
38131 <para>
38132 <indexterm role="concept">
38133 <primary>mailstore format</primary>
38134 <secondary>specifying</secondary>
38135 </indexterm>
38136 If this option is set with the <option>directory</option> option, the delivery is into two
38137 new files in  <quote>mailstore</quote> format. The option is available only if
38138 SUPPORT_MAILSTORE is present in <filename>Local/Makefile</filename>. See section <xref linkend="SECTopdir"/>
38139 below for further details.
38140 </para>
38141 <para>
38142 <indexterm role="option">
38143 <primary><option>mailstore_prefix</option></primary>
38144 </indexterm>
38145 </para>
38146 <informaltable frame="all">
38147 <tgroup cols="4" colsep="0" rowsep="0">
38148 <colspec colwidth="8*" align="left"/>
38149 <colspec colwidth="6*" align="center"/>
38150 <colspec colwidth="6*" align="center"/>
38151 <colspec colwidth="6*" align="right"/>
38152 <tbody>
38153 <row>
38154 <entry><option>mailstore_prefix</option></entry>
38155 <entry>Use: <emphasis>appendfile</emphasis></entry>
38156 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
38157 <entry>Default: <emphasis>unset</emphasis></entry>
38158 </row>
38159 </tbody>
38160 </tgroup>
38161 </informaltable>
38162 <para>
38163 This option applies only to deliveries in mailstore format, and is described in
38164 section <xref linkend="SECTopdir"/> below.
38165 </para>
38166 <para>
38167 <indexterm role="option">
38168 <primary><option>mailstore_suffix</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>mailstore_suffix</option></entry>
38180 <entry>Use: <emphasis>appendfile</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 applies only to deliveries in mailstore format, and is described in
38189 section <xref linkend="SECTopdir"/> below.
38190 </para>
38191 <para>
38192 <indexterm role="option">
38193 <primary><option>mbx_format</option></primary>
38194 </indexterm>
38195 </para>
38196 <informaltable frame="all">
38197 <tgroup cols="4" colsep="0" rowsep="0">
38198 <colspec colwidth="8*" align="left"/>
38199 <colspec colwidth="6*" align="center"/>
38200 <colspec colwidth="6*" align="center"/>
38201 <colspec colwidth="6*" align="right"/>
38202 <tbody>
38203 <row>
38204 <entry><option>mbx_format</option></entry>
38205 <entry>Use: <emphasis>appendfile</emphasis></entry>
38206 <entry>Type: <emphasis>boolean</emphasis></entry>
38207 <entry>Default: <emphasis>false</emphasis></entry>
38208 </row>
38209 </tbody>
38210 </tgroup>
38211 </informaltable>
38212 <para>
38213 <indexterm role="concept">
38214 <primary>locking files</primary>
38215 </indexterm>
38216 <indexterm role="concept">
38217 <primary>file</primary>
38218 <secondary>locking</secondary>
38219 </indexterm>
38220 <indexterm role="concept">
38221 <primary>file</primary>
38222 <secondary>MBX format</secondary>
38223 </indexterm>
38224 <indexterm role="concept">
38225 <primary>MBX format, specifying</primary>
38226 </indexterm>
38227 This option is available only if Exim has been compiled with SUPPORT_MBX
38228 set in <filename>Local/Makefile</filename>. If <option>mbx_format</option> is set with the <option>file</option> option,
38229 the message is appended to the mailbox file in MBX format instead of
38230 traditional Unix format. This format is supported by Pine4 and its associated
38231 IMAP and POP daemons, by means of the <emphasis>c-client</emphasis> library that they all use.
38232 </para>
38233 <para>
38234 <emphasis role="bold">Note</emphasis>: The <option>message_prefix</option> and <option>message_suffix</option> options are not
38235 automatically changed by the use of <option>mbx_format</option>. They should normally be set
38236 empty when using MBX format, so this option almost always appears in this
38237 combination:
38238 </para>
38239 <literallayout class="monospaced">
38240 mbx_format = true
38241 message_prefix =
38242 message_suffix =
38243 </literallayout>
38244 <para>
38245 If none of the locking options are mentioned in the configuration,
38246 <option>use_mbx_lock</option> is assumed and the other locking options default to false. It
38247 is possible to specify the other kinds of locking with <option>mbx_format</option>, but
38248 <option>use_fcntl_lock</option> and <option>use_mbx_lock</option> are mutually exclusive. MBX locking
38249 interworks with <emphasis>c-client</emphasis>, providing for shared access to the mailbox. It
38250 should not be used if any program that does not use this form of locking is
38251 going to access the mailbox, nor should it be used if the mailbox file is NFS
38252 mounted, because it works only when the mailbox is accessed from a single host.
38253 </para>
38254 <para>
38255 If you set <option>use_fcntl_lock</option> with an MBX-format mailbox, you cannot use
38256 the standard version of <emphasis>c-client</emphasis>, because as long as it has a mailbox open
38257 (this means for the whole of a Pine or IMAP session), Exim will not be able to
38258 append messages to it.
38259 </para>
38260 <para>
38261 <indexterm role="option">
38262 <primary><option>message_prefix</option></primary>
38263 </indexterm>
38264 </para>
38265 <informaltable frame="all">
38266 <tgroup cols="4" colsep="0" rowsep="0">
38267 <colspec colwidth="8*" align="left"/>
38268 <colspec colwidth="6*" align="center"/>
38269 <colspec colwidth="6*" align="center"/>
38270 <colspec colwidth="6*" align="right"/>
38271 <tbody>
38272 <row>
38273 <entry><option>message_prefix</option></entry>
38274 <entry>Use: <emphasis>appendfile</emphasis></entry>
38275 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
38276 <entry>Default: <emphasis>see below</emphasis></entry>
38277 </row>
38278 </tbody>
38279 </tgroup>
38280 </informaltable>
38281 <para>
38282 <indexterm role="concept">
38283 <primary><quote>From</quote> line</primary>
38284 </indexterm>
38285 The string specified here is expanded and output at the start of every message.
38286 The default is unset unless <option>file</option> is specified and <option>use_bsmtp</option> is not set,
38287 in which case it is:
38288 </para>
38289 <literallayout class="monospaced">
38290 message_prefix = "From ${if def:return_path{$return_path}\
38291   {MAILER-DAEMON}} $tod_bsdinbox\n"
38292 </literallayout>
38293 <para>
38294 <emphasis role="bold">Note:</emphasis> If you set <option>use_crlf</option> true, you must change any occurrences of
38295 <literal>\n</literal> to <literal>\r\n</literal> in <option>message_prefix</option>.
38296 </para>
38297 <para>
38298 <indexterm role="option">
38299 <primary><option>message_suffix</option></primary>
38300 </indexterm>
38301 </para>
38302 <informaltable frame="all">
38303 <tgroup cols="4" colsep="0" rowsep="0">
38304 <colspec colwidth="8*" align="left"/>
38305 <colspec colwidth="6*" align="center"/>
38306 <colspec colwidth="6*" align="center"/>
38307 <colspec colwidth="6*" align="right"/>
38308 <tbody>
38309 <row>
38310 <entry><option>message_suffix</option></entry>
38311 <entry>Use: <emphasis>appendfile</emphasis></entry>
38312 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
38313 <entry>Default: <emphasis>see below</emphasis></entry>
38314 </row>
38315 </tbody>
38316 </tgroup>
38317 </informaltable>
38318 <para>
38319 The string specified here is expanded and output at the end of every message.
38320 The default is unset unless <option>file</option> is specified and <option>use_bsmtp</option> is not set,
38321 in which case it is a single newline character. The suffix can be suppressed by
38322 setting
38323 </para>
38324 <literallayout class="monospaced">
38325 message_suffix =
38326 </literallayout>
38327 <para>
38328 <emphasis role="bold">Note:</emphasis> If you set <option>use_crlf</option> true, you must change any occurrences of
38329 <literal>\n</literal> to <literal>\r\n</literal> in <option>message_suffix</option>.
38330 </para>
38331 <para>
38332 <indexterm role="option">
38333 <primary><option>mode</option></primary>
38334 </indexterm>
38335 </para>
38336 <informaltable frame="all">
38337 <tgroup cols="4" colsep="0" rowsep="0">
38338 <colspec colwidth="8*" align="left"/>
38339 <colspec colwidth="6*" align="center"/>
38340 <colspec colwidth="6*" align="center"/>
38341 <colspec colwidth="6*" align="right"/>
38342 <tbody>
38343 <row>
38344 <entry><option>mode</option></entry>
38345 <entry>Use: <emphasis>appendfile</emphasis></entry>
38346 <entry>Type: <emphasis>octal integer</emphasis></entry>
38347 <entry>Default: <emphasis>0600</emphasis></entry>
38348 </row>
38349 </tbody>
38350 </tgroup>
38351 </informaltable>
38352 <para>
38353 If the output file is created, it is given this mode. If it already exists and
38354 has wider permissions, they are reduced to this mode. If it has narrower
38355 permissions, an error occurs unless <option>mode_fail_narrower</option> is false. However,
38356 if the delivery is the result of a <option>save</option> command in a filter file specifying
38357 a particular mode, the mode of the output file is always forced to take that
38358 value, and this option is ignored.
38359 </para>
38360 <para>
38361 <indexterm role="option">
38362 <primary><option>mode_fail_narrower</option></primary>
38363 </indexterm>
38364 </para>
38365 <informaltable frame="all">
38366 <tgroup cols="4" colsep="0" rowsep="0">
38367 <colspec colwidth="8*" align="left"/>
38368 <colspec colwidth="6*" align="center"/>
38369 <colspec colwidth="6*" align="center"/>
38370 <colspec colwidth="6*" align="right"/>
38371 <tbody>
38372 <row>
38373 <entry><option>mode_fail_narrower</option></entry>
38374 <entry>Use: <emphasis>appendfile</emphasis></entry>
38375 <entry>Type: <emphasis>boolean</emphasis></entry>
38376 <entry>Default: <emphasis>true</emphasis></entry>
38377 </row>
38378 </tbody>
38379 </tgroup>
38380 </informaltable>
38381 <para>
38382 This option applies in the case when an existing mailbox file has a narrower
38383 mode than that specified by the <option>mode</option> option. If <option>mode_fail_narrower</option> is
38384 true, the delivery is deferred (<quote>mailbox has the wrong mode</quote>); otherwise Exim
38385 continues with the delivery attempt, using the existing mode of the file.
38386 </para>
38387 <para>
38388 <indexterm role="option">
38389 <primary><option>notify_comsat</option></primary>
38390 </indexterm>
38391 </para>
38392 <informaltable frame="all">
38393 <tgroup cols="4" colsep="0" rowsep="0">
38394 <colspec colwidth="8*" align="left"/>
38395 <colspec colwidth="6*" align="center"/>
38396 <colspec colwidth="6*" align="center"/>
38397 <colspec colwidth="6*" align="right"/>
38398 <tbody>
38399 <row>
38400 <entry><option>notify_comsat</option></entry>
38401 <entry>Use: <emphasis>appendfile</emphasis></entry>
38402 <entry>Type: <emphasis>boolean</emphasis></entry>
38403 <entry>Default: <emphasis>false</emphasis></entry>
38404 </row>
38405 </tbody>
38406 </tgroup>
38407 </informaltable>
38408 <para>
38409 If this option is true, the <emphasis>comsat</emphasis> daemon is notified after every
38410 successful delivery to a user mailbox. This is the daemon that notifies logged
38411 on users about incoming mail.
38412 </para>
38413 <para>
38414 <indexterm role="option">
38415 <primary><option>quota</option></primary>
38416 </indexterm>
38417 </para>
38418 <informaltable frame="all">
38419 <tgroup cols="4" colsep="0" rowsep="0">
38420 <colspec colwidth="8*" align="left"/>
38421 <colspec colwidth="6*" align="center"/>
38422 <colspec colwidth="6*" align="center"/>
38423 <colspec colwidth="6*" align="right"/>
38424 <tbody>
38425 <row>
38426 <entry><option>quota</option></entry>
38427 <entry>Use: <emphasis>appendfile</emphasis></entry>
38428 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
38429 <entry>Default: <emphasis>unset</emphasis></entry>
38430 </row>
38431 </tbody>
38432 </tgroup>
38433 </informaltable>
38434 <para>
38435 <indexterm role="concept">
38436 <primary>quota</primary>
38437 <secondary>imposed by Exim</secondary>
38438 </indexterm>
38439 This option imposes a limit on the size of the file to which Exim is appending,
38440 or to the total space used in the directory tree when the <option>directory</option> option
38441 is set. In the latter case, computation of the space used is expensive, because
38442 all the files in the directory (and any sub-directories) have to be
38443 individually inspected and their sizes summed. (See <option>quota_size_regex</option> and
38444 <option>maildir_use_size_file</option> for ways to avoid this in environments where users
38445 have no shell access to their mailboxes).
38446 </para>
38447 <para>
38448 As there is no interlock against two simultaneous deliveries into a
38449 multi-file mailbox, it is possible for the quota to be overrun in this case.
38450 For single-file mailboxes, of course, an interlock is a necessity.
38451 </para>
38452 <para>
38453 A file&#x2019;s size is taken as its <emphasis>used</emphasis> value. Because of blocking effects, this
38454 may be a lot less than the actual amount of disk space allocated to the file.
38455 If the sizes of a number of files are being added up, the rounding effect can
38456 become quite noticeable, especially on systems that have large block sizes.
38457 Nevertheless, it seems best to stick to the <emphasis>used</emphasis> figure, because this is
38458 the obvious value which users understand most easily.
38459 </para>
38460 <para>
38461 The value of the option is expanded, and must then be a numerical value
38462 (decimal point allowed), optionally followed by one of the letters K, M, or G,
38463 for kilobytes, megabytes, or gigabytes. If Exim is running on a system with
38464 large file support (Linux and FreeBSD have this), mailboxes larger than 2G can
38465 be handled.
38466 </para>
38467 <para>
38468 <emphasis role="bold">Note</emphasis>: A value of zero is interpreted as <quote>no quota</quote>.
38469 </para>
38470 <para>
38471 The expansion happens while Exim is running as root, before it changes uid for
38472 the delivery. This means that files that are inaccessible to the end user can
38473 be used to hold quota values that are looked up in the expansion. When delivery
38474 fails because this quota is exceeded, the handling of the error is as for
38475 system quota failures.
38476 </para>
38477 <para>
38478 By default, Exim&#x2019;s quota checking mimics system quotas, and restricts the
38479 mailbox to the specified maximum size, though the value is not accurate to the
38480 last byte, owing to separator lines and additional headers that may get added
38481 during message delivery. When a mailbox is nearly full, large messages may get
38482 refused even though small ones are accepted, because the size of the current
38483 message is added to the quota when the check is made. This behaviour can be
38484 changed by setting <option>quota_is_inclusive</option> false. When this is done, the check
38485 for exceeding the quota does not include the current message. Thus, deliveries
38486 continue until the quota has been exceeded; thereafter, no further messages are
38487 delivered. See also <option>quota_warn_threshold</option>.
38488 </para>
38489 <para>
38490 <indexterm role="option">
38491 <primary><option>quota_directory</option></primary>
38492 </indexterm>
38493 </para>
38494 <informaltable frame="all">
38495 <tgroup cols="4" colsep="0" rowsep="0">
38496 <colspec colwidth="8*" align="left"/>
38497 <colspec colwidth="6*" align="center"/>
38498 <colspec colwidth="6*" align="center"/>
38499 <colspec colwidth="6*" align="right"/>
38500 <tbody>
38501 <row>
38502 <entry><option>quota_directory</option></entry>
38503 <entry>Use: <emphasis>appendfile</emphasis></entry>
38504 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
38505 <entry>Default: <emphasis>unset</emphasis></entry>
38506 </row>
38507 </tbody>
38508 </tgroup>
38509 </informaltable>
38510 <para>
38511 This option defines the directory to check for quota purposes when delivering
38512 into individual files. The default is the delivery directory, or, if a file
38513 called <filename>maildirfolder</filename> exists in a maildir directory, the parent of the
38514 delivery directory.
38515 </para>
38516 <para>
38517 <indexterm role="option">
38518 <primary><option>quota_filecount</option></primary>
38519 </indexterm>
38520 </para>
38521 <informaltable frame="all">
38522 <tgroup cols="4" colsep="0" rowsep="0">
38523 <colspec colwidth="8*" align="left"/>
38524 <colspec colwidth="6*" align="center"/>
38525 <colspec colwidth="6*" align="center"/>
38526 <colspec colwidth="6*" align="right"/>
38527 <tbody>
38528 <row>
38529 <entry><option>quota_filecount</option></entry>
38530 <entry>Use: <emphasis>appendfile</emphasis></entry>
38531 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
38532 <entry>Default: <emphasis>0</emphasis></entry>
38533 </row>
38534 </tbody>
38535 </tgroup>
38536 </informaltable>
38537 <para>
38538 This option applies when the <option>directory</option> option is set. It limits the total
38539 number of files in the directory (compare the inode limit in system quotas). It
38540 can only be used if <option>quota</option> is also set. The value is expanded; an expansion
38541 failure causes delivery to be deferred. A value of zero is interpreted as
38542 <quote>no quota</quote>.
38543 </para>
38544 <para>
38545 <indexterm role="option">
38546 <primary><option>quota_is_inclusive</option></primary>
38547 </indexterm>
38548 </para>
38549 <informaltable frame="all">
38550 <tgroup cols="4" colsep="0" rowsep="0">
38551 <colspec colwidth="8*" align="left"/>
38552 <colspec colwidth="6*" align="center"/>
38553 <colspec colwidth="6*" align="center"/>
38554 <colspec colwidth="6*" align="right"/>
38555 <tbody>
38556 <row>
38557 <entry><option>quota_is_inclusive</option></entry>
38558 <entry>Use: <emphasis>appendfile</emphasis></entry>
38559 <entry>Type: <emphasis>boolean</emphasis></entry>
38560 <entry>Default: <emphasis>true</emphasis></entry>
38561 </row>
38562 </tbody>
38563 </tgroup>
38564 </informaltable>
38565 <para>
38566 See <option>quota</option> above.
38567 </para>
38568 <para>
38569 <indexterm role="option">
38570 <primary><option>quota_size_regex</option></primary>
38571 </indexterm>
38572 </para>
38573 <informaltable frame="all">
38574 <tgroup cols="4" colsep="0" rowsep="0">
38575 <colspec colwidth="8*" align="left"/>
38576 <colspec colwidth="6*" align="center"/>
38577 <colspec colwidth="6*" align="center"/>
38578 <colspec colwidth="6*" align="right"/>
38579 <tbody>
38580 <row>
38581 <entry><option>quota_size_regex</option></entry>
38582 <entry>Use: <emphasis>appendfile</emphasis></entry>
38583 <entry>Type: <emphasis>string</emphasis></entry>
38584 <entry>Default: <emphasis>unset</emphasis></entry>
38585 </row>
38586 </tbody>
38587 </tgroup>
38588 </informaltable>
38589 <para>
38590 This option applies when one of the delivery modes that writes a separate file
38591 for each message is being used. When Exim wants to find the size of one of
38592 these files in order to test the quota, it first checks <option>quota_size_regex</option>.
38593 If this is set to a regular expression that matches the file name, and it
38594 captures one string, that string is interpreted as a representation of the
38595 file&#x2019;s size. The value of <option>quota_size_regex</option> is not expanded.
38596 </para>
38597 <para>
38598 This feature is useful only when users have no shell access to their mailboxes
38599 &ndash; otherwise they could defeat the quota simply by renaming the files. This
38600 facility can be used with maildir deliveries, by setting <option>maildir_tag</option> to add
38601 the file length to the file name. For example:
38602 </para>
38603 <literallayout class="monospaced">
38604 maildir_tag = ,S=$message_size
38605 quota_size_regex = ,S=(\d+)
38606 </literallayout>
38607 <para>
38608 An alternative to <varname>$message_size</varname> is <varname>$message_linecount</varname>, which contains the
38609 number of lines in the message.
38610 </para>
38611 <para>
38612 The regular expression should not assume that the length is at the end of the
38613 file name (even though <option>maildir_tag</option> puts it there) because maildir MUAs
38614 sometimes add other information onto the ends of message file names.
38615 </para>
38616 <para>
38617 <indexterm role="option">
38618 <primary><option>quota_warn_message</option></primary>
38619 </indexterm>
38620 </para>
38621 <informaltable frame="all">
38622 <tgroup cols="4" colsep="0" rowsep="0">
38623 <colspec colwidth="8*" align="left"/>
38624 <colspec colwidth="6*" align="center"/>
38625 <colspec colwidth="6*" align="center"/>
38626 <colspec colwidth="6*" align="right"/>
38627 <tbody>
38628 <row>
38629 <entry><option>quota_warn_message</option></entry>
38630 <entry>Use: <emphasis>appendfile</emphasis></entry>
38631 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
38632 <entry>Default: <emphasis>see below</emphasis></entry>
38633 </row>
38634 </tbody>
38635 </tgroup>
38636 </informaltable>
38637 <para>
38638 See below for the use of this option. If it is not set when
38639 <option>quota_warn_threshold</option> is set, it defaults to
38640 </para>
38641 <literallayout class="monospaced">
38642 quota_warn_message = "\
38643   To: $local_part@$domain\n\
38644   Subject: Your mailbox\n\n\
38645   This message is automatically created \
38646   by mail delivery software.\n\n\
38647   The size of your mailbox has exceeded \
38648   a warning threshold that is\n\
38649   set by the system administrator.\n"
38650 </literallayout>
38651 <para>
38652 <indexterm role="option">
38653 <primary><option>quota_warn_threshold</option></primary>
38654 </indexterm>
38655 </para>
38656 <informaltable frame="all">
38657 <tgroup cols="4" colsep="0" rowsep="0">
38658 <colspec colwidth="8*" align="left"/>
38659 <colspec colwidth="6*" align="center"/>
38660 <colspec colwidth="6*" align="center"/>
38661 <colspec colwidth="6*" align="right"/>
38662 <tbody>
38663 <row>
38664 <entry><option>quota_warn_threshold</option></entry>
38665 <entry>Use: <emphasis>appendfile</emphasis></entry>
38666 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
38667 <entry>Default: <emphasis>0</emphasis></entry>
38668 </row>
38669 </tbody>
38670 </tgroup>
38671 </informaltable>
38672 <para>
38673 <indexterm role="concept">
38674 <primary>quota</primary>
38675 <secondary>warning threshold</secondary>
38676 </indexterm>
38677 <indexterm role="concept">
38678 <primary>mailbox</primary>
38679 <secondary>size warning</secondary>
38680 </indexterm>
38681 <indexterm role="concept">
38682 <primary>size</primary>
38683 <secondary>of mailbox</secondary>
38684 </indexterm>
38685 This option is expanded in the same way as <option>quota</option> (see above). If the
38686 resulting value is greater than zero, and delivery of the message causes the
38687 size of the file or total space in the directory tree to cross the given
38688 threshold, a warning message is sent. If <option>quota</option> is also set, the threshold
38689 may be specified as a percentage of it by following the value with a percent
38690 sign. For example:
38691 </para>
38692 <literallayout class="monospaced">
38693 quota = 10M
38694 quota_warn_threshold = 75%
38695 </literallayout>
38696 <para>
38697 If <option>quota</option> is not set, a setting of <option>quota_warn_threshold</option> that ends with a
38698 percent sign is ignored.
38699 </para>
38700 <para>
38701 The warning message itself is specified by the <option>quota_warn_message</option> option,
38702 and it must start with a <emphasis>To:</emphasis> header line containing the recipient(s) of the
38703 warning message. These do not necessarily have to include the recipient(s) of
38704 the original message. A <emphasis>Subject:</emphasis> line should also normally be supplied. You
38705 can include any other header lines that you want. If you do not include a
38706 <emphasis>From:</emphasis> line, the default is:
38707 </para>
38708 <literallayout class="monospaced">
38709 From: Mail Delivery System &lt;mailer-daemon@$qualify_domain_sender&gt;
38710 </literallayout>
38711 <para>
38712 <indexterm role="option">
38713 <primary><option>errors_reply_to</option></primary>
38714 </indexterm>
38715 If you supply a <emphasis>Reply-To:</emphasis> line, it overrides the global <option>errors_reply_to</option>
38716 option.
38717 </para>
38718 <para>
38719 The <option>quota</option> option does not have to be set in order to use this option; they
38720 are independent of one another except when the threshold is specified as a
38721 percentage.
38722 </para>
38723 <para>
38724 <indexterm role="option">
38725 <primary><option>use_bsmtp</option></primary>
38726 </indexterm>
38727 </para>
38728 <informaltable frame="all">
38729 <tgroup cols="4" colsep="0" rowsep="0">
38730 <colspec colwidth="8*" align="left"/>
38731 <colspec colwidth="6*" align="center"/>
38732 <colspec colwidth="6*" align="center"/>
38733 <colspec colwidth="6*" align="right"/>
38734 <tbody>
38735 <row>
38736 <entry><option>use_bsmtp</option></entry>
38737 <entry>Use: <emphasis>appendfile</emphasis></entry>
38738 <entry>Type: <emphasis>boolean</emphasis></entry>
38739 <entry>Default: <emphasis>false</emphasis></entry>
38740 </row>
38741 </tbody>
38742 </tgroup>
38743 </informaltable>
38744 <para>
38745 <indexterm role="concept">
38746 <primary>envelope sender</primary>
38747 </indexterm>
38748 If this option is set true, <command>appendfile</command> writes messages in <quote>batch SMTP</quote>
38749 format, with the envelope sender and recipient(s) included as SMTP commands. If
38750 you want to include a leading HELO command with such messages, you can do
38751 so by setting the <option>message_prefix</option> option. See section <xref linkend="SECTbatchSMTP"/>
38752 for details of batch SMTP.
38753 </para>
38754 <para>
38755 <indexterm role="option">
38756 <primary><option>use_crlf</option></primary>
38757 </indexterm>
38758 </para>
38759 <informaltable frame="all">
38760 <tgroup cols="4" colsep="0" rowsep="0">
38761 <colspec colwidth="8*" align="left"/>
38762 <colspec colwidth="6*" align="center"/>
38763 <colspec colwidth="6*" align="center"/>
38764 <colspec colwidth="6*" align="right"/>
38765 <tbody>
38766 <row>
38767 <entry><option>use_crlf</option></entry>
38768 <entry>Use: <emphasis>appendfile</emphasis></entry>
38769 <entry>Type: <emphasis>boolean</emphasis></entry>
38770 <entry>Default: <emphasis>false</emphasis></entry>
38771 </row>
38772 </tbody>
38773 </tgroup>
38774 </informaltable>
38775 <para>
38776 <indexterm role="concept">
38777 <primary>carriage return</primary>
38778 </indexterm>
38779 <indexterm role="concept">
38780 <primary>linefeed</primary>
38781 </indexterm>
38782 This option causes lines to be terminated with the two-character CRLF sequence
38783 (carriage return, linefeed) instead of just a linefeed character. In the case
38784 of batched SMTP, the byte sequence written to the file is then an exact image
38785 of what would be sent down a real SMTP connection.
38786 </para>
38787 <para>
38788 <emphasis role="bold">Note:</emphasis> The contents of the <option>message_prefix</option> and <option>message_suffix</option> options
38789 (which are used to supply the traditional <quote>From&nbsp;</quote> and blank line separators
38790 in Berkeley-style mailboxes) are written verbatim, so must contain their own
38791 carriage return characters if these are needed. In cases where these options
38792 have non-empty defaults, the values end with a single linefeed, so they must be
38793 changed to end with <literal>\r\n</literal> if <option>use_crlf</option> is set.
38794 </para>
38795 <para>
38796 <indexterm role="option">
38797 <primary><option>use_fcntl_lock</option></primary>
38798 </indexterm>
38799 </para>
38800 <informaltable frame="all">
38801 <tgroup cols="4" colsep="0" rowsep="0">
38802 <colspec colwidth="8*" align="left"/>
38803 <colspec colwidth="6*" align="center"/>
38804 <colspec colwidth="6*" align="center"/>
38805 <colspec colwidth="6*" align="right"/>
38806 <tbody>
38807 <row>
38808 <entry><option>use_fcntl_lock</option></entry>
38809 <entry>Use: <emphasis>appendfile</emphasis></entry>
38810 <entry>Type: <emphasis>boolean</emphasis></entry>
38811 <entry>Default: <emphasis>see below</emphasis></entry>
38812 </row>
38813 </tbody>
38814 </tgroup>
38815 </informaltable>
38816 <para>
38817 This option controls the use of the <function>fcntl()</function> function to lock a file for
38818 exclusive use when a message is being appended. It is set by default unless
38819 <option>use_flock_lock</option> is set. Otherwise, it should be turned off only if you know
38820 that all your MUAs use lock file locking. When both <option>use_fcntl_lock</option> and
38821 <option>use_flock_lock</option> are unset, <option>use_lockfile</option> must be set.
38822 </para>
38823 <para>
38824 <indexterm role="option">
38825 <primary><option>use_flock_lock</option></primary>
38826 </indexterm>
38827 </para>
38828 <informaltable frame="all">
38829 <tgroup cols="4" colsep="0" rowsep="0">
38830 <colspec colwidth="8*" align="left"/>
38831 <colspec colwidth="6*" align="center"/>
38832 <colspec colwidth="6*" align="center"/>
38833 <colspec colwidth="6*" align="right"/>
38834 <tbody>
38835 <row>
38836 <entry><option>use_flock_lock</option></entry>
38837 <entry>Use: <emphasis>appendfile</emphasis></entry>
38838 <entry>Type: <emphasis>boolean</emphasis></entry>
38839 <entry>Default: <emphasis>false</emphasis></entry>
38840 </row>
38841 </tbody>
38842 </tgroup>
38843 </informaltable>
38844 <para>
38845 This option is provided to support the use of <function>flock()</function> for file locking, for
38846 the few situations where it is needed. Most modern operating systems support
38847 <function>fcntl()</function> and <function>lockf()</function> locking, and these two functions interwork with
38848 each other. Exim uses <function>fcntl()</function> locking by default.
38849 </para>
38850 <para>
38851 This option is required only if you are using an operating system where
38852 <function>flock()</function> is used by programs that access mailboxes (typically MUAs), and
38853 where <function>flock()</function> does not correctly interwork with <function>fcntl()</function>. You can use
38854 both <function>fcntl()</function> and <function>flock()</function> locking simultaneously if you want.
38855 </para>
38856 <para>
38857 <indexterm role="concept">
38858 <primary>Solaris</primary>
38859 <secondary><function>flock()</function> support</secondary>
38860 </indexterm>
38861 Not all operating systems provide <function>flock()</function>. Some versions of Solaris do not
38862 have it (and some, I think, provide a not quite right version built on top of
38863 <function>lockf()</function>). If the OS does not have <function>flock()</function>, Exim will be built without
38864 the ability to use it, and any attempt to do so will cause a configuration
38865 error.
38866 </para>
38867 <para>
38868 <emphasis role="bold">Warning</emphasis>: <function>flock()</function> locks do not work on NFS files (unless <function>flock()</function>
38869 is just being mapped onto <function>fcntl()</function> by the OS).
38870 </para>
38871 <para>
38872 <indexterm role="option">
38873 <primary><option>use_lockfile</option></primary>
38874 </indexterm>
38875 </para>
38876 <informaltable frame="all">
38877 <tgroup cols="4" colsep="0" rowsep="0">
38878 <colspec colwidth="8*" align="left"/>
38879 <colspec colwidth="6*" align="center"/>
38880 <colspec colwidth="6*" align="center"/>
38881 <colspec colwidth="6*" align="right"/>
38882 <tbody>
38883 <row>
38884 <entry><option>use_lockfile</option></entry>
38885 <entry>Use: <emphasis>appendfile</emphasis></entry>
38886 <entry>Type: <emphasis>boolean</emphasis></entry>
38887 <entry>Default: <emphasis>see below</emphasis></entry>
38888 </row>
38889 </tbody>
38890 </tgroup>
38891 </informaltable>
38892 <para>
38893 If this option is turned off, Exim does not attempt to create a lock file when
38894 appending to a mailbox file. In this situation, the only locking is by
38895 <function>fcntl()</function>. You should only turn <option>use_lockfile</option> off if you are absolutely
38896 sure that every MUA that is ever going to look at your users&#x2019; mailboxes uses
38897 <function>fcntl()</function> rather than a lock file, and even then only when you are not
38898 delivering over NFS from more than one host.
38899 </para>
38900 <para>
38901 <indexterm role="concept">
38902 <primary>NFS</primary>
38903 <secondary>lock file</secondary>
38904 </indexterm>
38905 In order to append to an NFS file safely from more than one host, it is
38906 necessary to take out a lock <emphasis>before</emphasis> opening the file, and the lock file
38907 achieves this. Otherwise, even with <function>fcntl()</function> locking, there is a risk of
38908 file corruption.
38909 </para>
38910 <para>
38911 The <option>use_lockfile</option> option is set by default unless <option>use_mbx_lock</option> is set.
38912 It is not possible to turn both <option>use_lockfile</option> and <option>use_fcntl_lock</option> off,
38913 except when <option>mbx_format</option> is set.
38914 </para>
38915 <para>
38916 <indexterm role="option">
38917 <primary><option>use_mbx_lock</option></primary>
38918 </indexterm>
38919 </para>
38920 <informaltable frame="all">
38921 <tgroup cols="4" colsep="0" rowsep="0">
38922 <colspec colwidth="8*" align="left"/>
38923 <colspec colwidth="6*" align="center"/>
38924 <colspec colwidth="6*" align="center"/>
38925 <colspec colwidth="6*" align="right"/>
38926 <tbody>
38927 <row>
38928 <entry><option>use_mbx_lock</option></entry>
38929 <entry>Use: <emphasis>appendfile</emphasis></entry>
38930 <entry>Type: <emphasis>boolean</emphasis></entry>
38931 <entry>Default: <emphasis>see below</emphasis></entry>
38932 </row>
38933 </tbody>
38934 </tgroup>
38935 </informaltable>
38936 <para>
38937 This option is available only if Exim has been compiled with SUPPORT_MBX
38938 set in <filename>Local/Makefile</filename>. Setting the option specifies that special MBX
38939 locking rules be used. It is set by default if <option>mbx_format</option> is set and none
38940 of the locking options are mentioned in the configuration. The locking rules
38941 are the same as are used by the <emphasis>c-client</emphasis> library that underlies Pine and
38942 the IMAP4 and POP daemons that come with it (see the discussion below). The
38943 rules allow for shared access to the mailbox. However, this kind of locking
38944 does not work when the mailbox is NFS mounted.
38945 </para>
38946 <para>
38947 You can set <option>use_mbx_lock</option> with either (or both) of <option>use_fcntl_lock</option> and
38948 <option>use_flock_lock</option> to control what kind of locking is used in implementing the
38949 MBX locking rules. The default is to use <function>fcntl()</function> if <option>use_mbx_lock</option> is set
38950 without <option>use_fcntl_lock</option> or <option>use_flock_lock</option>.
38951 </para>
38952 </section>
38953 <section id="SECTopappend">
38954 <title>Operational details for appending</title>
38955 <para>
38956 <indexterm role="concept">
38957 <primary>appending to a file</primary>
38958 </indexterm>
38959 <indexterm role="concept">
38960 <primary>file</primary>
38961 <secondary>appending</secondary>
38962 </indexterm>
38963 Before appending to a file, the following preparations are made:
38964 </para>
38965 <itemizedlist>
38966 <listitem>
38967 <para>
38968 If the name of the file is <filename>/dev/null</filename>, no action is taken, and a success
38969 return is given.
38970 </para>
38971 </listitem>
38972 <listitem>
38973 <para>
38974 <indexterm role="concept">
38975 <primary>directory creation</primary>
38976 </indexterm>
38977 If any directories on the file&#x2019;s path are missing, Exim creates them if the
38978 <option>create_directory</option> option is set. A created directory&#x2019;s mode is given by the
38979 <option>directory_mode</option> option.
38980 </para>
38981 </listitem>
38982 <listitem>
38983 <para>
38984 If <option>file_format</option> is set, the format of an existing file is checked. If this
38985 indicates that a different transport should be used, control is passed to that
38986 transport.
38987 </para>
38988 </listitem>
38989 <listitem>
38990 <para>
38991 <indexterm role="concept">
38992 <primary>file</primary>
38993 <secondary>locking</secondary>
38994 </indexterm>
38995 <indexterm role="concept">
38996 <primary>locking files</primary>
38997 </indexterm>
38998 <indexterm role="concept">
38999 <primary>NFS</primary>
39000 <secondary>lock file</secondary>
39001 </indexterm>
39002 If <option>use_lockfile</option> is set, a lock file is built in a way that will work
39003 reliably over NFS, as follows:
39004 </para>
39005 <orderedlist numeration="arabic">
39006 <listitem>
39007 <para>
39008 Create a <quote>hitching post</quote> file whose name is that of the lock file with the
39009 current time, primary host name, and process id added, by opening for writing
39010 as a new file. If this fails with an access error, delivery is deferred.
39011 </para>
39012 </listitem>
39013 <listitem>
39014 <para>
39015 Close the hitching post file, and hard link it to the lock file name.
39016 </para>
39017 </listitem>
39018 <listitem>
39019 <para>
39020 If the call to <function>link()</function> succeeds, creation of the lock file has succeeded.
39021 Unlink the hitching post name.
39022 </para>
39023 </listitem>
39024 <listitem>
39025 <para>
39026 Otherwise, use <function>stat()</function> to get information about the hitching post file, and
39027 then unlink hitching post name. If the number of links is exactly two, creation
39028 of the lock file succeeded but something (for example, an NFS server crash and
39029 restart) caused this fact not to be communicated to the <function>link()</function> call.
39030 </para>
39031 </listitem>
39032 <listitem>
39033 <para>
39034 If creation of the lock file failed, wait for <option>lock_interval</option> and try again,
39035 up to <option>lock_retries</option> times. However, since any program that writes to a
39036 mailbox should complete its task very quickly, it is reasonable to time out old
39037 lock files that are normally the result of user agent and system crashes. If an
39038 existing lock file is older than <option>lockfile_timeout</option> Exim attempts to unlink
39039 it before trying again.
39040 </para>
39041 </listitem>
39042 </orderedlist>
39043 </listitem>
39044 <listitem>
39045 <para>
39046 A call is made to <function>lstat()</function> to discover whether the main file exists, and if
39047 so, what its characteristics are. If <function>lstat()</function> fails for any reason other
39048 than non-existence, delivery is deferred.
39049 </para>
39050 </listitem>
39051 <listitem>
39052 <para>
39053 <indexterm role="concept">
39054 <primary>symbolic link</primary>
39055 <secondary>to mailbox</secondary>
39056 </indexterm>
39057 <indexterm role="concept">
39058 <primary>mailbox</primary>
39059 <secondary>symbolic link</secondary>
39060 </indexterm>
39061 If the file does exist and is a symbolic link, delivery is deferred, unless the
39062 <option>allow_symlink</option> option is set, in which case the ownership of the link is
39063 checked, and then <function>stat()</function> is called to find out about the real file, which
39064 is then subjected to the checks below. The check on the top-level link
39065 ownership prevents one user creating a link for another&#x2019;s mailbox in a sticky
39066 directory, though allowing symbolic links in this case is definitely not a good
39067 idea. If there is a chain of symbolic links, the intermediate ones are not
39068 checked.
39069 </para>
39070 </listitem>
39071 <listitem>
39072 <para>
39073 If the file already exists but is not a regular file, or if the file&#x2019;s owner
39074 and group (if the group is being checked &ndash; see <option>check_group</option> above) are
39075 different from the user and group under which the delivery is running,
39076 delivery is deferred.
39077 </para>
39078 </listitem>
39079 <listitem>
39080 <para>
39081 If the file&#x2019;s permissions are more generous than specified, they are reduced.
39082 If they are insufficient, delivery is deferred, unless <option>mode_fail_narrower</option>
39083 is set false, in which case the delivery is tried using the existing
39084 permissions.
39085 </para>
39086 </listitem>
39087 <listitem>
39088 <para>
39089 The file&#x2019;s inode number is saved, and the file is then opened for appending.
39090 If this fails because the file has vanished, <command>appendfile</command> behaves as if it
39091 hadn&#x2019;t existed (see below). For any other failures, delivery is deferred.
39092 </para>
39093 </listitem>
39094 <listitem>
39095 <para>
39096 If the file is opened successfully, check that the inode number hasn&#x2019;t
39097 changed, that it is still a regular file, and that the owner and permissions
39098 have not changed. If anything is wrong, defer delivery and freeze the message.
39099 </para>
39100 </listitem>
39101 <listitem>
39102 <para>
39103 If the file did not exist originally, defer delivery if the <option>file_must_exist</option>
39104 option is set. Otherwise, check that the file is being created in a permitted
39105 directory if the <option>create_file</option> option is set (deferring on failure), and then
39106 open for writing as a new file, with the O_EXCL and O_CREAT options,
39107 except when dealing with a symbolic link (the <option>allow_symlink</option> option must be
39108 set). In this case, which can happen if the link points to a non-existent file,
39109 the file is opened for writing using O_CREAT but not O_EXCL, because
39110 that prevents link following.
39111 </para>
39112 </listitem>
39113 <listitem>
39114 <para>
39115 <indexterm role="concept">
39116 <primary>loop</primary>
39117 <secondary>while file testing</secondary>
39118 </indexterm>
39119 If opening fails because the file exists, obey the tests given above for
39120 existing files. However, to avoid looping in a situation where the file is
39121 being continuously created and destroyed, the exists/not-exists loop is broken
39122 after 10 repetitions, and the message is then frozen.
39123 </para>
39124 </listitem>
39125 <listitem>
39126 <para>
39127 If opening fails with any other error, defer delivery.
39128 </para>
39129 </listitem>
39130 <listitem>
39131 <para>
39132 <indexterm role="concept">
39133 <primary>file</primary>
39134 <secondary>locking</secondary>
39135 </indexterm>
39136 <indexterm role="concept">
39137 <primary>locking files</primary>
39138 </indexterm>
39139 Once the file is open, unless both <option>use_fcntl_lock</option> and <option>use_flock_lock</option>
39140 are false, it is locked using <function>fcntl()</function> or <function>flock()</function> or both. If
39141 <option>use_mbx_lock</option> is false, an exclusive lock is requested in each case.
39142 However, if <option>use_mbx_lock</option> is true, Exim takes out a shared lock on the open
39143 file, and an exclusive lock on the file whose name is
39144 </para>
39145 <literallayout class="monospaced">
39146 /tmp/.&lt;device-number&gt;.&lt;inode-number&gt;
39147 </literallayout>
39148 <para>
39149 using the device and inode numbers of the open mailbox file, in accordance with
39150 the MBX locking rules. This file is created with a mode that is specified by
39151 the <option>lockfile_mode</option> option.
39152 </para>
39153 <para>
39154 If Exim fails to lock the file, there are two possible courses of action,
39155 depending on the value of the locking timeout. This is obtained from
39156 <option>lock_fcntl_timeout</option> or <option>lock_flock_timeout</option>, as appropriate.
39157 </para>
39158 <para>
39159 If the timeout value is zero, the file is closed, Exim waits for
39160 <option>lock_interval</option>, and then goes back and re-opens the file as above and tries
39161 to lock it again. This happens up to <option>lock_retries</option> times, after which the
39162 delivery is deferred.
39163 </para>
39164 <para>
39165 If the timeout has a value greater than zero, blocking calls to <function>fcntl()</function> or
39166 <function>flock()</function> are used (with the given timeout), so there has already been some
39167 waiting involved by the time locking fails. Nevertheless, Exim does not give up
39168 immediately. It retries up to
39169 </para>
39170 <literallayout class="monospaced">
39171 (lock_retries * lock_interval) / &lt;timeout&gt;
39172 </literallayout>
39173 <para>
39174 times (rounded up).
39175 </para>
39176 </listitem>
39177 </itemizedlist>
39178 <para>
39179 At the end of delivery, Exim closes the file (which releases the <function>fcntl()</function>
39180 and/or <function>flock()</function> locks) and then deletes the lock file if one was created.
39181 </para>
39182 </section>
39183 <section id="SECTopdir">
39184 <title>Operational details for delivery to a new file</title>
39185 <para>
39186 <indexterm role="concept">
39187 <primary>delivery</primary>
39188 <secondary>to single file</secondary>
39189 </indexterm>
39190 <indexterm role="concept">
39191 <primary><quote>From</quote> line</primary>
39192 </indexterm>
39193 When the <option>directory</option> option is set instead of <option>file</option>, each message is
39194 delivered into a newly-created file or set of files. When <command>appendfile</command> is
39195 activated directly from a <command>redirect</command> router, neither <option>file</option> nor
39196 <option>directory</option> is normally set, because the path for delivery is supplied by the
39197 router. (See for example, the <command>address_file</command> transport in the default
39198 configuration.) In this case, delivery is to a new file if either the path name
39199 ends in <literal>/</literal>, or the <option>maildir_format</option> or <option>mailstore_format</option> option is set.
39200 </para>
39201 <para>
39202 No locking is required while writing the message to a new file, so the various
39203 locking options of the transport are ignored. The <quote>From</quote> line that by default
39204 separates messages in a single file is not normally needed, nor is the escaping
39205 of message lines that start with <quote>From</quote>, and there is no need to ensure a
39206 newline at the end of each message. Consequently, the default values for
39207 <option>check_string</option>, <option>message_prefix</option>, and <option>message_suffix</option> are all unset when
39208 any of <option>directory</option>, <option>maildir_format</option>, or <option>mailstore_format</option> is set.
39209 </para>
39210 <para>
39211 If Exim is required to check a <option>quota</option> setting, it adds up the sizes of all
39212 the files in the delivery directory by default. However, you can specify a
39213 different directory by setting <option>quota_directory</option>. Also, for maildir
39214 deliveries (see below) the <filename>maildirfolder</filename> convention is honoured.
39215 </para>
39216 <para>
39217 <indexterm role="concept">
39218 <primary>maildir format</primary>
39219 </indexterm>
39220 <indexterm role="concept">
39221 <primary>mailstore format</primary>
39222 </indexterm>
39223 There are three different ways in which delivery to individual files can be
39224 done, controlled by the settings of the <option>maildir_format</option> and
39225 <option>mailstore_format</option> options. Note that code to support maildir or mailstore
39226 formats is not included in the binary unless SUPPORT_MAILDIR or
39227 SUPPORT_MAILSTORE, respectively, is set in <filename>Local/Makefile</filename>.
39228 </para>
39229 <para>
39230 <indexterm role="concept">
39231 <primary>directory creation</primary>
39232 </indexterm>
39233 In all three cases an attempt is made to create the directory and any necessary
39234 sub-directories if they do not exist, provided that the <option>create_directory</option>
39235 option is set (the default). The location of a created directory can be
39236 constrained by setting <option>create_file</option>. A created directory&#x2019;s mode is given by
39237 the <option>directory_mode</option> option. If creation fails, or if the
39238 <option>create_directory</option> option is not set when creation is required, delivery is
39239 deferred.
39240 </para>
39241 </section>
39242 <section id="SECTmaildirdelivery">
39243 <title>Maildir delivery</title>
39244 <para>
39245 <indexterm role="concept">
39246 <primary>maildir format</primary>
39247 <secondary>description of</secondary>
39248 </indexterm>
39249 If the <option>maildir_format</option> option is true, Exim delivers each message by writing
39250 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
39251 directory that is defined by the <option>directory</option> option (the <quote>delivery
39252 directory</quote>). If the delivery is successful, the file is renamed into the
39253 <filename>new</filename> subdirectory.
39254 </para>
39255 <para>
39256 In the file name, &lt;<emphasis>stime</emphasis>&gt; is the current time of day in seconds, and
39257 &lt;<emphasis>mtime</emphasis>&gt; is the microsecond fraction of the time. After a maildir delivery,
39258 Exim checks that the time-of-day clock has moved on by at least one microsecond
39259 before terminating the delivery process. This guarantees uniqueness for the
39260 file name. However, as a precaution, Exim calls <function>stat()</function> for the file before
39261 opening it. If any response other than ENOENT (does not exist) is given,
39262 Exim waits 2 seconds and tries again, up to <option>maildir_retries</option> times.
39263 </para>
39264 <para>
39265 Before Exim carries out a maildir delivery, it ensures that subdirectories
39266 called <filename>new</filename>, <filename>cur</filename>, and <filename>tmp</filename> exist in the delivery directory. If they
39267 do not exist, Exim tries to create them and any superior directories in their
39268 path, subject to the <option>create_directory</option> and <option>create_file</option> options. If the
39269 <option>maildirfolder_create_regex</option> option is set, and the regular expression it
39270 contains matches the delivery directory, Exim also ensures that a file called
39271 <filename>maildirfolder</filename> exists in the delivery directory. If a missing directory or
39272 <filename>maildirfolder</filename> file cannot be created, delivery is deferred.
39273 </para>
39274 <para>
39275 These features make it possible to use Exim to create all the necessary files
39276 and directories in a maildir mailbox, including subdirectories for maildir++
39277 folders. Consider this example:
39278 </para>
39279 <literallayout class="monospaced">
39280 maildir_format = true
39281 directory = /var/mail/$local_part\
39282            ${if eq{$local_part_suffix}{}{}\
39283            {/.${substr_1:$local_part_suffix}}}
39284 maildirfolder_create_regex = /\.[^/]+$
39285 </literallayout>
39286 <para>
39287 If <varname>$local_part_suffix</varname> is empty (there was no suffix for the local part),
39288 delivery is into a toplevel maildir with a name like <filename>/var/mail/pimbo</filename> (for
39289 the user called <emphasis>pimbo</emphasis>). The pattern in <option>maildirfolder_create_regex</option> does
39290 not match this name, so Exim will not look for or create the file
39291 <filename>/var/mail/pimbo/maildirfolder</filename>, though it will create
39292 <filename>/var/mail/pimbo/{cur,new,tmp}</filename> if necessary.
39293 </para>
39294 <para>
39295 However, if <varname>$local_part_suffix</varname> contains <literal>-eximusers</literal> (for example),
39296 delivery is into the maildir++ folder <filename>/var/mail/pimbo/.eximusers</filename>, which
39297 does match <option>maildirfolder_create_regex</option>. In this case, Exim will create
39298 <filename>/var/mail/pimbo/.eximusers/maildirfolder</filename> as well as the three maildir
39299 directories <filename>/var/mail/pimbo/.eximusers/{cur,new,tmp}</filename>.
39300 </para>
39301 <para>
39302 <emphasis role="bold">Warning:</emphasis> Take care when setting <option>maildirfolder_create_regex</option> that it does
39303 not inadvertently match the toplevel maildir directory, because a
39304 <filename>maildirfolder</filename> file at top level would completely break quota calculations.
39305 </para>
39306 <para>
39307 <indexterm role="concept">
39308 <primary>quota</primary>
39309 <secondary>in maildir delivery</secondary>
39310 </indexterm>
39311 <indexterm role="concept">
39312 <primary>maildir++</primary>
39313 </indexterm>
39314 If Exim is required to check a <option>quota</option> setting before a maildir delivery, and
39315 <option>quota_directory</option> is not set, it looks for a file called <filename>maildirfolder</filename> in
39316 the maildir directory (alongside <filename>new</filename>, <filename>cur</filename>, <filename>tmp</filename>). If this exists,
39317 Exim assumes the directory is a maildir++ folder directory, which is one level
39318 down from the user&#x2019;s top level mailbox directory. This causes it to start at
39319 the parent directory instead of the current directory when calculating the
39320 amount of space used.
39321 </para>
39322 <para>
39323 One problem with delivering into a multi-file mailbox is that it is
39324 computationally expensive to compute the size of the mailbox for quota
39325 checking. Various approaches have been taken to reduce the amount of work
39326 needed. The next two sections describe two of them. A third alternative is to
39327 use some external process for maintaining the size data, and use the expansion
39328 of the <option>mailbox_size</option> option as a way of importing it into Exim.
39329 </para>
39330 </section>
39331 <section id="SECID135">
39332 <title>Using tags to record message sizes</title>
39333 <para>
39334 If <option>maildir_tag</option> is set, the string is expanded for each delivery.
39335 When the maildir file is renamed into the <filename>new</filename> sub-directory, the
39336 tag is added to its name. However, if adding the tag takes the length of the
39337 name to the point where the test <function>stat()</function> call fails with ENAMETOOLONG,
39338 the tag is dropped and the maildir file is created with no tag.
39339 </para>
39340 <para>
39341 <indexterm role="variable">
39342 <primary><varname>$message_size</varname></primary>
39343 </indexterm>
39344 Tags can be used to encode the size of files in their names; see
39345 <option>quota_size_regex</option> above for an example. The expansion of <option>maildir_tag</option>
39346 happens after the message has been written. The value of the <varname>$message_size</varname>
39347 variable is set to the number of bytes actually written. If the expansion is
39348 forced to fail, the tag is ignored, but a non-forced failure causes delivery to
39349 be deferred. The expanded tag may contain any printing characters except <quote>/</quote>.
39350 Non-printing characters in the string are ignored; if the resulting string is
39351 empty, it is ignored. If it starts with an alphanumeric character, a leading
39352 colon is inserted.
39353 </para>
39354 </section>
39355 <section id="SECID136">
39356 <title>Using a maildirsize file</title>
39357 <para>
39358 <indexterm role="concept">
39359 <primary>quota</primary>
39360 <secondary>in maildir delivery</secondary>
39361 </indexterm>
39362 <indexterm role="concept">
39363 <primary>maildir format</primary>
39364 <secondary><filename>maildirsize</filename> file</secondary>
39365 </indexterm>
39366 If <option>maildir_use_size_file</option> is true, Exim implements the maildir++ rules for
39367 storing quota and message size information in a file called <filename>maildirsize</filename>
39368 within the toplevel maildir directory. If this file does not exist, Exim
39369 creates it, setting the quota from the <option>quota</option> option of the transport. If
39370 the maildir directory itself does not exist, it is created before any attempt
39371 to write a <filename>maildirsize</filename> file.
39372 </para>
39373 <para>
39374 The <filename>maildirsize</filename> file is used to hold information about the sizes of
39375 messages in the maildir, thus speeding up quota calculations. The quota value
39376 in the file is just a cache; if the quota is changed in the transport, the new
39377 value overrides the cached value when the next message is delivered. The cache
39378 is maintained for the benefit of other programs that access the maildir and
39379 need to know the quota.
39380 </para>
39381 <para>
39382 If the <option>quota</option> option in the transport is unset or zero, the <filename>maildirsize</filename>
39383 file is maintained (with a zero quota setting), but no quota is imposed.
39384 </para>
39385 <para>
39386 A regular expression is available for controlling which directories in the
39387 maildir participate in quota calculations when a <filename>maildirsizefile</filename> is in use.
39388 See the description of the <option>maildir_quota_directory_regex</option> option above for
39389 details.
39390 </para>
39391 </section>
39392 <section id="SECID137">
39393 <title>Mailstore delivery</title>
39394 <para>
39395 <indexterm role="concept">
39396 <primary>mailstore format</primary>
39397 <secondary>description of</secondary>
39398 </indexterm>
39399 If the <option>mailstore_format</option> option is true, each message is written as two
39400 files in the given directory. A unique base name is constructed from the
39401 message id and the current delivery process, and the files that are written use
39402 this base name plus the suffixes <filename>.env</filename> and <filename>.msg</filename>. The <filename>.env</filename> file
39403 contains the message&#x2019;s envelope, and the <filename>.msg</filename> file contains the message
39404 itself. The base name is placed in the variable <varname>$mailstore_basename</varname>.
39405 </para>
39406 <para>
39407 During delivery, the envelope is first written to a file with the suffix
39408 <filename>.tmp</filename>. The <filename>.msg</filename> file is then written, and when it is complete, the
39409 <filename>.tmp</filename> file is renamed as the <filename>.env</filename> file. Programs that access messages in
39410 mailstore format should wait for the presence of both a <filename>.msg</filename> and a <filename>.env</filename>
39411 file before accessing either of them. An alternative approach is to wait for
39412 the absence of a <filename>.tmp</filename> file.
39413 </para>
39414 <para>
39415 The envelope file starts with any text defined by the <option>mailstore_prefix</option>
39416 option, expanded and terminated by a newline if there isn&#x2019;t one. Then follows
39417 the sender address on one line, then all the recipient addresses, one per line.
39418 There can be more than one recipient only if the <option>batch_max</option> option is set
39419 greater than one. Finally, <option>mailstore_suffix</option> is expanded and the result
39420 appended to the file, followed by a newline if it does not end with one.
39421 </para>
39422 <para>
39423 If expansion of <option>mailstore_prefix</option> or <option>mailstore_suffix</option> ends with a forced
39424 failure, it is ignored. Other expansion errors are treated as serious
39425 configuration errors, and delivery is deferred. The variable
39426 <varname>$mailstore_basename</varname> is available for use during these expansions.
39427 </para>
39428 </section>
39429 <section id="SECID138">
39430 <title>Non-special new file delivery</title>
39431 <para>
39432 If neither <option>maildir_format</option> nor <option>mailstore_format</option> is set, a single new
39433 file is created directly in the named directory. For example, when delivering
39434 messages into files in batched SMTP format for later delivery to some host (see
39435 section <xref linkend="SECTbatchSMTP"/>), a setting such as
39436 </para>
39437 <literallayout class="monospaced">
39438 directory = /var/bsmtp/$host
39439 </literallayout>
39440 <para>
39441 might be used. A message is written to a file with a temporary name, which is
39442 then renamed when the delivery is complete. The final name is obtained by
39443 expanding the contents of the <option>directory_file</option> option.
39444 <indexterm role="concept" startref="IIDapptra1" class="endofrange"/>
39445 <indexterm role="concept" startref="IIDapptra2" class="endofrange"/>
39446 </para>
39447 </section>
39448 </chapter>
39449
39450 <chapter id="CHID8">
39451 <title>The autoreply transport</title>
39452 <para>
39453 <indexterm role="concept" id="IIDauttra1" class="startofrange">
39454 <primary>transports</primary>
39455 <secondary><command>autoreply</command></secondary>
39456 </indexterm>
39457 <indexterm role="concept" id="IIDauttra2" class="startofrange">
39458 <primary><command>autoreply</command> transport</primary>
39459 </indexterm>
39460 The <command>autoreply</command> transport is not a true transport in that it does not cause
39461 the message to be transmitted. Instead, it generates a new mail message as an
39462 automatic reply to the incoming message. <emphasis>References:</emphasis> and
39463 <emphasis>Auto-Submitted:</emphasis> header lines are included. These are constructed according
39464 to the rules in RFCs 2822 and 3834, respectively.
39465 </para>
39466 <para>
39467 If the router that passes the message to this transport does not have the
39468 <option>unseen</option> option set, the original message (for the current recipient) is not
39469 delivered anywhere. However, when the <option>unseen</option> option is set on the router
39470 that passes the message to this transport, routing of the address continues, so
39471 another router can set up a normal message delivery.
39472 </para>
39473 <para>
39474 The <command>autoreply</command> transport is usually run as the result of mail filtering, a
39475 <quote>vacation</quote> message being the standard example. However, it can also be run
39476 directly from a router like any other transport. To reduce the possibility of
39477 message cascades, messages created by the <command>autoreply</command> transport always have
39478 empty envelope sender addresses, like bounce messages.
39479 </para>
39480 <para>
39481 The parameters of the message to be sent can be specified in the configuration
39482 by options described below. However, these are used only when the address
39483 passed to the transport does not contain its own reply information. When the
39484 transport is run as a consequence of a
39485 <option>mail</option>
39486 or <option>vacation</option> command in a filter file, the parameters of the message are
39487 supplied by the filter, and passed with the address. The transport&#x2019;s options
39488 that define the message are then ignored (so they are not usually set in this
39489 case). The message is specified entirely by the filter or by the transport; it
39490 is never built from a mixture of options. However, the <option>file_optional</option>,
39491 <option>mode</option>, and <option>return_message</option> options apply in all cases.
39492 </para>
39493 <para>
39494 <command>Autoreply</command> is implemented as a local transport. When used as a result of a
39495 command in a user&#x2019;s filter file, <command>autoreply</command> normally runs under the uid and
39496 gid of the user, and with appropriate current and home directories (see chapter
39497 <xref linkend="CHAPenvironment"/>).
39498 </para>
39499 <para>
39500 There is a subtle difference between routing a message to a <command>pipe</command> transport
39501 that generates some text to be returned to the sender, and routing it to an
39502 <command>autoreply</command> transport. This difference is noticeable only if more than one
39503 address from the same message is so handled. In the case of a pipe, the
39504 separate outputs from the different addresses are gathered up and returned to
39505 the sender in a single message, whereas if <command>autoreply</command> is used, a separate
39506 message is generated for each address that is passed to it.
39507 </para>
39508 <para>
39509 Non-printing characters are not permitted in the header lines generated for the
39510 message that <command>autoreply</command> creates, with the exception of newlines that are
39511 immediately followed by white space. If any non-printing characters are found,
39512 the transport defers.
39513 Whether characters with the top bit set count as printing characters or not is
39514 controlled by the <option>print_topbitchars</option> global option.
39515 </para>
39516 <para>
39517 If any of the generic options for manipulating headers (for example,
39518 <option>headers_add</option>) are set on an <command>autoreply</command> transport, they apply to the copy
39519 of the original message that is included in the generated message when
39520 <option>return_message</option> is set. They do not apply to the generated message itself.
39521 </para>
39522 <para>
39523 <indexterm role="variable">
39524 <primary><varname>$sender_address</varname></primary>
39525 </indexterm>
39526 If the <command>autoreply</command> transport receives return code 2 from Exim when it submits
39527 the message, indicating that there were no recipients, it does not treat this
39528 as an error. This means that autoreplies sent to <varname>$sender_address</varname> when this
39529 is empty (because the incoming message is a bounce message) do not cause
39530 problems. They are just discarded.
39531 </para>
39532 <section id="SECID139">
39533 <title>Private options for autoreply</title>
39534 <para>
39535 <indexterm role="concept">
39536 <primary>options</primary>
39537 <secondary><command>autoreply</command> transport</secondary>
39538 </indexterm>
39539 </para>
39540 <para>
39541 <indexterm role="option">
39542 <primary><option>bcc</option></primary>
39543 </indexterm>
39544 </para>
39545 <informaltable frame="all">
39546 <tgroup cols="4" colsep="0" rowsep="0">
39547 <colspec colwidth="8*" align="left"/>
39548 <colspec colwidth="6*" align="center"/>
39549 <colspec colwidth="6*" align="center"/>
39550 <colspec colwidth="6*" align="right"/>
39551 <tbody>
39552 <row>
39553 <entry><option>bcc</option></entry>
39554 <entry>Use: <emphasis>autoreply</emphasis></entry>
39555 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
39556 <entry>Default: <emphasis>unset</emphasis></entry>
39557 </row>
39558 </tbody>
39559 </tgroup>
39560 </informaltable>
39561 <para>
39562 This specifies the addresses that are to receive <quote>blind carbon copies</quote> of the
39563 message when the message is specified by the transport.
39564 </para>
39565 <para>
39566 <indexterm role="option">
39567 <primary><option>cc</option></primary>
39568 </indexterm>
39569 </para>
39570 <informaltable frame="all">
39571 <tgroup cols="4" colsep="0" rowsep="0">
39572 <colspec colwidth="8*" align="left"/>
39573 <colspec colwidth="6*" align="center"/>
39574 <colspec colwidth="6*" align="center"/>
39575 <colspec colwidth="6*" align="right"/>
39576 <tbody>
39577 <row>
39578 <entry><option>cc</option></entry>
39579 <entry>Use: <emphasis>autoreply</emphasis></entry>
39580 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
39581 <entry>Default: <emphasis>unset</emphasis></entry>
39582 </row>
39583 </tbody>
39584 </tgroup>
39585 </informaltable>
39586 <para>
39587 This specifies recipients of the message and the contents of the <emphasis>Cc:</emphasis> header
39588 when the message is specified by the transport.
39589 </para>
39590 <para>
39591 <indexterm role="option">
39592 <primary><option>file</option></primary>
39593 </indexterm>
39594 </para>
39595 <informaltable frame="all">
39596 <tgroup cols="4" colsep="0" rowsep="0">
39597 <colspec colwidth="8*" align="left"/>
39598 <colspec colwidth="6*" align="center"/>
39599 <colspec colwidth="6*" align="center"/>
39600 <colspec colwidth="6*" align="right"/>
39601 <tbody>
39602 <row>
39603 <entry><option>file</option></entry>
39604 <entry>Use: <emphasis>autoreply</emphasis></entry>
39605 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
39606 <entry>Default: <emphasis>unset</emphasis></entry>
39607 </row>
39608 </tbody>
39609 </tgroup>
39610 </informaltable>
39611 <para>
39612 The contents of the file are sent as the body of the message when the message
39613 is specified by the transport. If both <option>file</option> and <option>text</option> are set, the text
39614 string comes first.
39615 </para>
39616 <para>
39617 <indexterm role="option">
39618 <primary><option>file_expand</option></primary>
39619 </indexterm>
39620 </para>
39621 <informaltable frame="all">
39622 <tgroup cols="4" colsep="0" rowsep="0">
39623 <colspec colwidth="8*" align="left"/>
39624 <colspec colwidth="6*" align="center"/>
39625 <colspec colwidth="6*" align="center"/>
39626 <colspec colwidth="6*" align="right"/>
39627 <tbody>
39628 <row>
39629 <entry><option>file_expand</option></entry>
39630 <entry>Use: <emphasis>autoreply</emphasis></entry>
39631 <entry>Type: <emphasis>boolean</emphasis></entry>
39632 <entry>Default: <emphasis>false</emphasis></entry>
39633 </row>
39634 </tbody>
39635 </tgroup>
39636 </informaltable>
39637 <para>
39638 If this is set, the contents of the file named by the <option>file</option> option are
39639 subjected to string expansion as they are added to the message.
39640 </para>
39641 <para>
39642 <indexterm role="option">
39643 <primary><option>file_optional</option></primary>
39644 </indexterm>
39645 </para>
39646 <informaltable frame="all">
39647 <tgroup cols="4" colsep="0" rowsep="0">
39648 <colspec colwidth="8*" align="left"/>
39649 <colspec colwidth="6*" align="center"/>
39650 <colspec colwidth="6*" align="center"/>
39651 <colspec colwidth="6*" align="right"/>
39652 <tbody>
39653 <row>
39654 <entry><option>file_optional</option></entry>
39655 <entry>Use: <emphasis>autoreply</emphasis></entry>
39656 <entry>Type: <emphasis>boolean</emphasis></entry>
39657 <entry>Default: <emphasis>false</emphasis></entry>
39658 </row>
39659 </tbody>
39660 </tgroup>
39661 </informaltable>
39662 <para>
39663 If this option is true, no error is generated if the file named by the <option>file</option>
39664 option or passed with the address does not exist or cannot be read.
39665 </para>
39666 <para>
39667 <indexterm role="option">
39668 <primary><option>from</option></primary>
39669 </indexterm>
39670 </para>
39671 <informaltable frame="all">
39672 <tgroup cols="4" colsep="0" rowsep="0">
39673 <colspec colwidth="8*" align="left"/>
39674 <colspec colwidth="6*" align="center"/>
39675 <colspec colwidth="6*" align="center"/>
39676 <colspec colwidth="6*" align="right"/>
39677 <tbody>
39678 <row>
39679 <entry><option>from</option></entry>
39680 <entry>Use: <emphasis>autoreply</emphasis></entry>
39681 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
39682 <entry>Default: <emphasis>unset</emphasis></entry>
39683 </row>
39684 </tbody>
39685 </tgroup>
39686 </informaltable>
39687 <para>
39688 This specifies the contents of the <emphasis>From:</emphasis> header when the message is
39689 specified by the transport.
39690 </para>
39691 <para>
39692 <indexterm role="option">
39693 <primary><option>headers</option></primary>
39694 </indexterm>
39695 </para>
39696 <informaltable frame="all">
39697 <tgroup cols="4" colsep="0" rowsep="0">
39698 <colspec colwidth="8*" align="left"/>
39699 <colspec colwidth="6*" align="center"/>
39700 <colspec colwidth="6*" align="center"/>
39701 <colspec colwidth="6*" align="right"/>
39702 <tbody>
39703 <row>
39704 <entry><option>headers</option></entry>
39705 <entry>Use: <emphasis>autoreply</emphasis></entry>
39706 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
39707 <entry>Default: <emphasis>unset</emphasis></entry>
39708 </row>
39709 </tbody>
39710 </tgroup>
39711 </informaltable>
39712 <para>
39713 This specifies additional RFC 2822 headers that are to be added to the message
39714 when the message is specified by the transport. Several can be given by using
39715 <quote>\n</quote> to separate them. There is no check on the format.
39716 </para>
39717 <para>
39718 <indexterm role="option">
39719 <primary><option>log</option></primary>
39720 </indexterm>
39721 </para>
39722 <informaltable frame="all">
39723 <tgroup cols="4" colsep="0" rowsep="0">
39724 <colspec colwidth="8*" align="left"/>
39725 <colspec colwidth="6*" align="center"/>
39726 <colspec colwidth="6*" align="center"/>
39727 <colspec colwidth="6*" align="right"/>
39728 <tbody>
39729 <row>
39730 <entry><option>log</option></entry>
39731 <entry>Use: <emphasis>autoreply</emphasis></entry>
39732 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
39733 <entry>Default: <emphasis>unset</emphasis></entry>
39734 </row>
39735 </tbody>
39736 </tgroup>
39737 </informaltable>
39738 <para>
39739 This option names a file in which a record of every message sent is logged when
39740 the message is specified by the transport.
39741 </para>
39742 <para>
39743 <indexterm role="option">
39744 <primary><option>mode</option></primary>
39745 </indexterm>
39746 </para>
39747 <informaltable frame="all">
39748 <tgroup cols="4" colsep="0" rowsep="0">
39749 <colspec colwidth="8*" align="left"/>
39750 <colspec colwidth="6*" align="center"/>
39751 <colspec colwidth="6*" align="center"/>
39752 <colspec colwidth="6*" align="right"/>
39753 <tbody>
39754 <row>
39755 <entry><option>mode</option></entry>
39756 <entry>Use: <emphasis>autoreply</emphasis></entry>
39757 <entry>Type: <emphasis>octal integer</emphasis></entry>
39758 <entry>Default: <emphasis>0600</emphasis></entry>
39759 </row>
39760 </tbody>
39761 </tgroup>
39762 </informaltable>
39763 <para>
39764 If either the log file or the <quote>once</quote> file has to be created, this mode is
39765 used.
39766 </para>
39767 <para>
39768 <indexterm role="option">
39769 <primary><option>never_mail</option></primary>
39770 </indexterm>
39771 </para>
39772 <informaltable frame="all">
39773 <tgroup cols="4" colsep="0" rowsep="0">
39774 <colspec colwidth="8*" align="left"/>
39775 <colspec colwidth="6*" align="center"/>
39776 <colspec colwidth="6*" align="center"/>
39777 <colspec colwidth="6*" align="right"/>
39778 <tbody>
39779 <row>
39780 <entry><option>never_mail</option></entry>
39781 <entry>Use: <emphasis>autoreply</emphasis></entry>
39782 <entry>Type: <emphasis>address list</emphasis>&dagger;<emphasis></emphasis></entry>
39783 <entry>Default: <emphasis>unset</emphasis></entry>
39784 </row>
39785 </tbody>
39786 </tgroup>
39787 </informaltable>
39788 <para>
39789 If any run of the transport creates a message with a recipient that matches any
39790 item in the list, that recipient is quietly discarded. If all recipients are
39791 discarded, no message is created. This applies both when the recipients are
39792 generated by a filter and when they are specified in the transport.
39793 </para>
39794 <para>
39795 <indexterm role="option">
39796 <primary><option>once</option></primary>
39797 </indexterm>
39798 </para>
39799 <informaltable frame="all">
39800 <tgroup cols="4" colsep="0" rowsep="0">
39801 <colspec colwidth="8*" align="left"/>
39802 <colspec colwidth="6*" align="center"/>
39803 <colspec colwidth="6*" align="center"/>
39804 <colspec colwidth="6*" align="right"/>
39805 <tbody>
39806 <row>
39807 <entry><option>once</option></entry>
39808 <entry>Use: <emphasis>autoreply</emphasis></entry>
39809 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
39810 <entry>Default: <emphasis>unset</emphasis></entry>
39811 </row>
39812 </tbody>
39813 </tgroup>
39814 </informaltable>
39815 <para>
39816 This option names a file or DBM database in which a record of each <emphasis>To:</emphasis>
39817 recipient is kept when the message is specified by the transport. <emphasis role="bold">Note</emphasis>:
39818 This does not apply to <emphasis>Cc:</emphasis> or <emphasis>Bcc:</emphasis> recipients.
39819 </para>
39820 <para>
39821 If <option>once</option> is unset, or is set to an empty string, the message is always sent.
39822 By default, if <option>once</option> is set to a non-empty file name, the message
39823 is not sent if a potential recipient is already listed in the database.
39824 However, if the <option>once_repeat</option> option specifies a time greater than zero, the
39825 message is sent if that much time has elapsed since a message was last sent to
39826 this recipient. A setting of zero time for <option>once_repeat</option> (the default)
39827 prevents a message from being sent a second time &ndash; in this case, zero means
39828 infinity.
39829 </para>
39830 <para>
39831 If <option>once_file_size</option> is zero, a DBM database is used to remember recipients,
39832 and it is allowed to grow as large as necessary. If <option>once_file_size</option> is set
39833 greater than zero, it changes the way Exim implements the <option>once</option> option.
39834 Instead of using a DBM file to record every recipient it sends to, it uses a
39835 regular file, whose size will never get larger than the given value.
39836 </para>
39837 <para>
39838 In the file, Exim keeps a linear list of recipient addresses and the times at
39839 which they were sent messages. If the file is full when a new address needs to
39840 be added, the oldest address is dropped. If <option>once_repeat</option> is not set, this
39841 means that a given recipient may receive multiple messages, but at
39842 unpredictable intervals that depend on the rate of turnover of addresses in the
39843 file. If <option>once_repeat</option> is set, it specifies a maximum time between repeats.
39844 </para>
39845 <para>
39846 <indexterm role="option">
39847 <primary><option>once_file_size</option></primary>
39848 </indexterm>
39849 </para>
39850 <informaltable frame="all">
39851 <tgroup cols="4" colsep="0" rowsep="0">
39852 <colspec colwidth="8*" align="left"/>
39853 <colspec colwidth="6*" align="center"/>
39854 <colspec colwidth="6*" align="center"/>
39855 <colspec colwidth="6*" align="right"/>
39856 <tbody>
39857 <row>
39858 <entry><option>once_file_size</option></entry>
39859 <entry>Use: <emphasis>autoreply</emphasis></entry>
39860 <entry>Type: <emphasis>integer</emphasis></entry>
39861 <entry>Default: <emphasis>0</emphasis></entry>
39862 </row>
39863 </tbody>
39864 </tgroup>
39865 </informaltable>
39866 <para>
39867 See <option>once</option> above.
39868 </para>
39869 <para>
39870 <indexterm role="option">
39871 <primary><option>once_repeat</option></primary>
39872 </indexterm>
39873 </para>
39874 <informaltable frame="all">
39875 <tgroup cols="4" colsep="0" rowsep="0">
39876 <colspec colwidth="8*" align="left"/>
39877 <colspec colwidth="6*" align="center"/>
39878 <colspec colwidth="6*" align="center"/>
39879 <colspec colwidth="6*" align="right"/>
39880 <tbody>
39881 <row>
39882 <entry><option>once_repeat</option></entry>
39883 <entry>Use: <emphasis>autoreply</emphasis></entry>
39884 <entry>Type: <emphasis>time</emphasis>&dagger;<emphasis></emphasis></entry>
39885 <entry>Default: <emphasis>0s</emphasis></entry>
39886 </row>
39887 </tbody>
39888 </tgroup>
39889 </informaltable>
39890 <para>
39891 See <option>once</option> above.
39892 After expansion, the value of this option must be a valid time value.
39893 </para>
39894 <para>
39895 <indexterm role="option">
39896 <primary><option>reply_to</option></primary>
39897 </indexterm>
39898 </para>
39899 <informaltable frame="all">
39900 <tgroup cols="4" colsep="0" rowsep="0">
39901 <colspec colwidth="8*" align="left"/>
39902 <colspec colwidth="6*" align="center"/>
39903 <colspec colwidth="6*" align="center"/>
39904 <colspec colwidth="6*" align="right"/>
39905 <tbody>
39906 <row>
39907 <entry><option>reply_to</option></entry>
39908 <entry>Use: <emphasis>autoreply</emphasis></entry>
39909 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
39910 <entry>Default: <emphasis>unset</emphasis></entry>
39911 </row>
39912 </tbody>
39913 </tgroup>
39914 </informaltable>
39915 <para>
39916 This specifies the contents of the <emphasis>Reply-To:</emphasis> header when the message is
39917 specified by the transport.
39918 </para>
39919 <para>
39920 <indexterm role="option">
39921 <primary><option>return_message</option></primary>
39922 </indexterm>
39923 </para>
39924 <informaltable frame="all">
39925 <tgroup cols="4" colsep="0" rowsep="0">
39926 <colspec colwidth="8*" align="left"/>
39927 <colspec colwidth="6*" align="center"/>
39928 <colspec colwidth="6*" align="center"/>
39929 <colspec colwidth="6*" align="right"/>
39930 <tbody>
39931 <row>
39932 <entry><option>return_message</option></entry>
39933 <entry>Use: <emphasis>autoreply</emphasis></entry>
39934 <entry>Type: <emphasis>boolean</emphasis></entry>
39935 <entry>Default: <emphasis>false</emphasis></entry>
39936 </row>
39937 </tbody>
39938 </tgroup>
39939 </informaltable>
39940 <para>
39941 If this is set, a copy of the original message is returned with the new
39942 message, subject to the maximum size set in the <option>return_size_limit</option> global
39943 configuration option.
39944 </para>
39945 <para>
39946 <indexterm role="option">
39947 <primary><option>subject</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>subject</option></entry>
39959 <entry>Use: <emphasis>autoreply</emphasis></entry>
39960 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
39961 <entry>Default: <emphasis>unset</emphasis></entry>
39962 </row>
39963 </tbody>
39964 </tgroup>
39965 </informaltable>
39966 <para>
39967 This specifies the contents of the <emphasis>Subject:</emphasis> header when the message is
39968 specified by the transport. It is tempting to quote the original subject in
39969 automatic responses. For example:
39970 </para>
39971 <literallayout class="monospaced">
39972 subject = Re: $h_subject:
39973 </literallayout>
39974 <para>
39975 There is a danger in doing this, however. It may allow a third party to
39976 subscribe your users to an opt-in mailing list, provided that the list accepts
39977 bounce messages as subscription confirmations. Well-managed lists require a
39978 non-bounce message to confirm a subscription, so the danger is relatively
39979 small.
39980 </para>
39981 <para>
39982 <indexterm role="option">
39983 <primary><option>text</option></primary>
39984 </indexterm>
39985 </para>
39986 <informaltable frame="all">
39987 <tgroup cols="4" colsep="0" rowsep="0">
39988 <colspec colwidth="8*" align="left"/>
39989 <colspec colwidth="6*" align="center"/>
39990 <colspec colwidth="6*" align="center"/>
39991 <colspec colwidth="6*" align="right"/>
39992 <tbody>
39993 <row>
39994 <entry><option>text</option></entry>
39995 <entry>Use: <emphasis>autoreply</emphasis></entry>
39996 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
39997 <entry>Default: <emphasis>unset</emphasis></entry>
39998 </row>
39999 </tbody>
40000 </tgroup>
40001 </informaltable>
40002 <para>
40003 This specifies a single string to be used as the body of the message when the
40004 message is specified by the transport. If both <option>text</option> and <option>file</option> are set,
40005 the text comes first.
40006 </para>
40007 <para>
40008 <indexterm role="option">
40009 <primary><option>to</option></primary>
40010 </indexterm>
40011 </para>
40012 <informaltable frame="all">
40013 <tgroup cols="4" colsep="0" rowsep="0">
40014 <colspec colwidth="8*" align="left"/>
40015 <colspec colwidth="6*" align="center"/>
40016 <colspec colwidth="6*" align="center"/>
40017 <colspec colwidth="6*" align="right"/>
40018 <tbody>
40019 <row>
40020 <entry><option>to</option></entry>
40021 <entry>Use: <emphasis>autoreply</emphasis></entry>
40022 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
40023 <entry>Default: <emphasis>unset</emphasis></entry>
40024 </row>
40025 </tbody>
40026 </tgroup>
40027 </informaltable>
40028 <para>
40029 This specifies recipients of the message and the contents of the <emphasis>To:</emphasis> header
40030 when the message is specified by the transport.
40031 <indexterm role="concept" startref="IIDauttra1" class="endofrange"/>
40032 <indexterm role="concept" startref="IIDauttra2" class="endofrange"/>
40033 </para>
40034 </section>
40035 </chapter>
40036
40037 <chapter id="CHAPLMTP">
40038 <title>The lmtp transport</title>
40039 <para>
40040 <indexterm role="concept">
40041 <primary>transports</primary>
40042 <secondary><command>lmtp</command></secondary>
40043 </indexterm>
40044 <indexterm role="concept">
40045 <primary><command>lmtp</command> transport</primary>
40046 </indexterm>
40047 <indexterm role="concept">
40048 <primary>LMTP</primary>
40049 <secondary>over a pipe</secondary>
40050 </indexterm>
40051 <indexterm role="concept">
40052 <primary>LMTP</primary>
40053 <secondary>over a socket</secondary>
40054 </indexterm>
40055 The <command>lmtp</command> transport runs the LMTP protocol (RFC 2033) over a pipe to a
40056 specified command
40057 or by interacting with a Unix domain socket.
40058 This transport is something of a cross between the <command>pipe</command> and <command>smtp</command>
40059 transports. Exim also has support for using LMTP over TCP/IP; this is
40060 implemented as an option for the <command>smtp</command> transport. Because LMTP is expected
40061 to be of minority interest, the default build-time configure in <filename>src/EDITME</filename>
40062 has it commented out. You need to ensure that
40063 </para>
40064 <literallayout class="monospaced">
40065 TRANSPORT_LMTP=yes
40066 </literallayout>
40067 <para>
40068 <indexterm role="concept">
40069 <primary>options</primary>
40070 <secondary><command>lmtp</command> transport</secondary>
40071 </indexterm>
40072 is present in your <filename>Local/Makefile</filename> in order to have the <command>lmtp</command> transport
40073 included in the Exim binary. The private options of the <command>lmtp</command> transport are
40074 as follows:
40075 </para>
40076 <para>
40077 <indexterm role="option">
40078 <primary><option>batch_id</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>batch_id</option></entry>
40090 <entry>Use: <emphasis>lmtp</emphasis></entry>
40091 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
40092 <entry>Default: <emphasis>unset</emphasis></entry>
40093 </row>
40094 </tbody>
40095 </tgroup>
40096 </informaltable>
40097 <para>
40098 See the description of local delivery batching in chapter <xref linkend="CHAPbatching"/>.
40099 </para>
40100 <para>
40101 <indexterm role="option">
40102 <primary><option>batch_max</option></primary>
40103 </indexterm>
40104 </para>
40105 <informaltable frame="all">
40106 <tgroup cols="4" colsep="0" rowsep="0">
40107 <colspec colwidth="8*" align="left"/>
40108 <colspec colwidth="6*" align="center"/>
40109 <colspec colwidth="6*" align="center"/>
40110 <colspec colwidth="6*" align="right"/>
40111 <tbody>
40112 <row>
40113 <entry><option>batch_max</option></entry>
40114 <entry>Use: <emphasis>lmtp</emphasis></entry>
40115 <entry>Type: <emphasis>integer</emphasis></entry>
40116 <entry>Default: <emphasis>1</emphasis></entry>
40117 </row>
40118 </tbody>
40119 </tgroup>
40120 </informaltable>
40121 <para>
40122 This limits the number of addresses that can be handled in a single delivery.
40123 Most LMTP servers can handle several addresses at once, so it is normally a
40124 good idea to increase this value. See the description of local delivery
40125 batching in chapter <xref linkend="CHAPbatching"/>.
40126 </para>
40127 <para>
40128 <indexterm role="option">
40129 <primary><option>command</option></primary>
40130 </indexterm>
40131 </para>
40132 <informaltable frame="all">
40133 <tgroup cols="4" colsep="0" rowsep="0">
40134 <colspec colwidth="8*" align="left"/>
40135 <colspec colwidth="6*" align="center"/>
40136 <colspec colwidth="6*" align="center"/>
40137 <colspec colwidth="6*" align="right"/>
40138 <tbody>
40139 <row>
40140 <entry><option>command</option></entry>
40141 <entry>Use: <emphasis>lmtp</emphasis></entry>
40142 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
40143 <entry>Default: <emphasis>unset</emphasis></entry>
40144 </row>
40145 </tbody>
40146 </tgroup>
40147 </informaltable>
40148 <para>
40149 This option must be set if <option>socket</option> is not set. The string is a command which
40150 is run in a separate process. It is split up into a command name and list of
40151 arguments, each of which is separately expanded (so expansion cannot change the
40152 number of arguments). The command is run directly, not via a shell. The message
40153 is passed to the new process using the standard input and output to operate the
40154 LMTP protocol.
40155 </para>
40156 <para>
40157 <indexterm role="option">
40158 <primary><option>ignore_quota</option></primary>
40159 </indexterm>
40160 </para>
40161 <informaltable frame="all">
40162 <tgroup cols="4" colsep="0" rowsep="0">
40163 <colspec colwidth="8*" align="left"/>
40164 <colspec colwidth="6*" align="center"/>
40165 <colspec colwidth="6*" align="center"/>
40166 <colspec colwidth="6*" align="right"/>
40167 <tbody>
40168 <row>
40169 <entry><option>ignore_quota</option></entry>
40170 <entry>Use: <emphasis>lmtp</emphasis></entry>
40171 <entry>Type: <emphasis>boolean</emphasis></entry>
40172 <entry>Default: <emphasis>false</emphasis></entry>
40173 </row>
40174 </tbody>
40175 </tgroup>
40176 </informaltable>
40177 <para>
40178 <indexterm role="concept">
40179 <primary>LMTP</primary>
40180 <secondary>ignoring quota errors</secondary>
40181 </indexterm>
40182 If this option is set true, the string <literal>IGNOREQUOTA</literal> is added to RCPT
40183 commands, provided that the LMTP server has advertised support for IGNOREQUOTA
40184 in its response to the LHLO command.
40185 </para>
40186 <para>
40187 <indexterm role="option">
40188 <primary><option>socket</option></primary>
40189 </indexterm>
40190 </para>
40191 <informaltable frame="all">
40192 <tgroup cols="4" colsep="0" rowsep="0">
40193 <colspec colwidth="8*" align="left"/>
40194 <colspec colwidth="6*" align="center"/>
40195 <colspec colwidth="6*" align="center"/>
40196 <colspec colwidth="6*" align="right"/>
40197 <tbody>
40198 <row>
40199 <entry><option>socket</option></entry>
40200 <entry>Use: <emphasis>lmtp</emphasis></entry>
40201 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
40202 <entry>Default: <emphasis>unset</emphasis></entry>
40203 </row>
40204 </tbody>
40205 </tgroup>
40206 </informaltable>
40207 <para>
40208 This option must be set if <option>command</option> is not set. The result of expansion must
40209 be the name of a Unix domain socket. The transport connects to the socket and
40210 delivers the message to it using the LMTP protocol.
40211 </para>
40212 <para>
40213 <indexterm role="option">
40214 <primary><option>timeout</option></primary>
40215 </indexterm>
40216 </para>
40217 <informaltable frame="all">
40218 <tgroup cols="4" colsep="0" rowsep="0">
40219 <colspec colwidth="8*" align="left"/>
40220 <colspec colwidth="6*" align="center"/>
40221 <colspec colwidth="6*" align="center"/>
40222 <colspec colwidth="6*" align="right"/>
40223 <tbody>
40224 <row>
40225 <entry><option>timeout</option></entry>
40226 <entry>Use: <emphasis>lmtp</emphasis></entry>
40227 <entry>Type: <emphasis>time</emphasis></entry>
40228 <entry>Default: <emphasis>5m</emphasis></entry>
40229 </row>
40230 </tbody>
40231 </tgroup>
40232 </informaltable>
40233 <para>
40234 The transport is aborted if the created process or Unix domain socket does not
40235 respond to LMTP commands or message input within this timeout. Delivery
40236 is deferred, and will be tried again later. Here is an example of a typical
40237 LMTP transport:
40238 </para>
40239 <literallayout class="monospaced">
40240 lmtp:
40241   driver = lmtp
40242   command = /some/local/lmtp/delivery/program
40243   batch_max = 20
40244   user = exim
40245 </literallayout>
40246 <para>
40247 This delivers up to 20 addresses at a time, in a mixture of domains if
40248 necessary, running as the user <emphasis>exim</emphasis>.
40249 </para>
40250 </chapter>
40251
40252 <chapter id="CHAPpipetransport">
40253 <title>The pipe transport</title>
40254 <para>
40255 <indexterm role="concept" id="IIDpiptra1" class="startofrange">
40256 <primary>transports</primary>
40257 <secondary><command>pipe</command></secondary>
40258 </indexterm>
40259 <indexterm role="concept" id="IIDpiptra2" class="startofrange">
40260 <primary><command>pipe</command> transport</primary>
40261 </indexterm>
40262 The <command>pipe</command> transport is used to deliver messages via a pipe to a command
40263 running in another process. One example is the use of <command>pipe</command> as a
40264 pseudo-remote transport for passing messages to some other delivery mechanism
40265 (such as UUCP). Another is the use by individual users to automatically process
40266 their incoming messages. The <command>pipe</command> transport can be used in one of the
40267 following ways:
40268 </para>
40269 <itemizedlist>
40270 <listitem>
40271 <para>
40272 <indexterm role="variable">
40273 <primary><varname>$local_part</varname></primary>
40274 </indexterm>
40275 A router routes one address to a transport in the normal way, and the
40276 transport is configured as a <command>pipe</command> transport. In this case, <varname>$local_part</varname>
40277 contains the local part of the address (as usual), and the command that is run
40278 is specified by the <option>command</option> option on the transport.
40279 </para>
40280 </listitem>
40281 <listitem>
40282 <para>
40283 <indexterm role="variable">
40284 <primary><varname>$pipe_addresses</varname></primary>
40285 </indexterm>
40286 If the <option>batch_max</option> option is set greater than 1 (the default is 1), the
40287 transport can handle more than one address in a single run. In this case, when
40288 more than one address is routed to the transport, <varname>$local_part</varname> is not set
40289 (because it is not unique). However, the pseudo-variable <varname>$pipe_addresses</varname>
40290 (described in section <xref linkend="SECThowcommandrun"/> below) contains all the addresses
40291 that are routed to the transport.
40292 </para>
40293 </listitem>
40294 <listitem>
40295 <para>
40296 <indexterm role="variable">
40297 <primary><varname>$address_pipe</varname></primary>
40298 </indexterm>
40299 A router redirects an address directly to a pipe command (for example, from an
40300 alias or forward file). In this case, <varname>$address_pipe</varname> contains the text of the
40301 pipe command, and the <option>command</option> option on the transport is ignored. If only
40302 one address is being transported (<option>batch_max</option> is not greater than one, or
40303 only one address was redirected to this pipe command), <varname>$local_part</varname> contains
40304 the local part that was redirected.
40305 </para>
40306 </listitem>
40307 </itemizedlist>
40308 <para>
40309 The <command>pipe</command> transport is a non-interactive delivery method. Exim can also
40310 deliver messages over pipes using the LMTP interactive protocol. This is
40311 implemented by the <command>lmtp</command> transport.
40312 </para>
40313 <para>
40314 In the case when <command>pipe</command> is run as a consequence of an entry in a local user&#x2019;s
40315 <filename>.forward</filename> file, the command runs under the uid and gid of that user. In
40316 other cases, the uid and gid have to be specified explicitly, either on the
40317 transport or on the router that handles the address. Current and <quote>home</quote>
40318 directories are also controllable. See chapter <xref linkend="CHAPenvironment"/> for
40319 details of the local delivery environment and chapter <xref linkend="CHAPbatching"/>
40320 for a discussion of local delivery batching.
40321 </para>
40322 <section id="SECID140">
40323 <title>Concurrent delivery</title>
40324 <para>
40325 If two messages arrive at almost the same time, and both are routed to a pipe
40326 delivery, the two pipe transports may be run concurrently. You must ensure that
40327 any pipe commands you set up are robust against this happening. If the commands
40328 write to a file, the <option>exim_lock</option> utility might be of use.
40329 </para>
40330 </section>
40331 <section id="SECID141">
40332 <title>Returned status and data</title>
40333 <para>
40334 <indexterm role="concept">
40335 <primary><command>pipe</command> transport</primary>
40336 <secondary>returned data</secondary>
40337 </indexterm>
40338 If the command exits with a non-zero return code, the delivery is deemed to
40339 have failed, unless either the <option>ignore_status</option> option is set (in which case
40340 the return code is treated as zero), or the return code is one of those listed
40341 in the <option>temp_errors</option> option, which are interpreted as meaning <quote>try again
40342 later</quote>. In this case, delivery is deferred. Details of a permanent failure are
40343 logged, but are not included in the bounce message, which merely contains
40344 <quote>local delivery failed</quote>.
40345 </para>
40346 <para>
40347 If the return code is greater than 128 and the command being run is a shell
40348 script, it normally means that the script was terminated by a signal whose
40349 value is the return code minus 128.
40350 </para>
40351 <para>
40352 If Exim is unable to run the command (that is, if <function>execve()</function> fails), the
40353 return code is set to 127. This is the value that a shell returns if it is
40354 asked to run a non-existent command. The wording for the log line suggests that
40355 a non-existent command may be the problem.
40356 </para>
40357 <para>
40358 The <option>return_output</option> option can affect the result of a pipe delivery. If it is
40359 set and the command produces any output on its standard output or standard
40360 error streams, the command is considered to have failed, even if it gave a zero
40361 return code or if <option>ignore_status</option> is set. The output from the command is
40362 included as part of the bounce message. The <option>return_fail_output</option> option is
40363 similar, except that output is returned only when the command exits with a
40364 failure return code, that is, a value other than zero or a code that matches
40365 <option>temp_errors</option>.
40366 </para>
40367 </section>
40368 <section id="SECThowcommandrun">
40369 <title>How the command is run</title>
40370 <para>
40371 <indexterm role="concept">
40372 <primary><command>pipe</command> transport</primary>
40373 <secondary>path for command</secondary>
40374 </indexterm>
40375 The command line is (by default) broken down into a command name and arguments
40376 by the <command>pipe</command> transport itself. The <option>allow_commands</option> and
40377 <option>restrict_to_path</option> options can be used to restrict the commands that may be
40378 run.
40379 </para>
40380 <para>
40381 <indexterm role="concept">
40382 <primary>quoting</primary>
40383 <secondary>in pipe command</secondary>
40384 </indexterm>
40385 Unquoted arguments are delimited by white space. If an argument appears in
40386 double quotes, backslash is interpreted as an escape character in the usual
40387 way. If an argument appears in single quotes, no escaping is done.
40388 </para>
40389 <para>
40390 String expansion is applied to the command line except when it comes from a
40391 traditional <filename>.forward</filename> file (commands from a filter file are expanded). The
40392 expansion is applied to each argument in turn rather than to the whole line.
40393 For this reason, any string expansion item that contains white space must be
40394 quoted so as to be contained within a single argument. A setting such as
40395 </para>
40396 <literallayout class="monospaced">
40397 command = /some/path ${if eq{$local_part}{postmaster}{xx}{yy}}
40398 </literallayout>
40399 <para>
40400 will not work, because the expansion item gets split between several
40401 arguments. You have to write
40402 </para>
40403 <literallayout class="monospaced">
40404 command = /some/path "${if eq{$local_part}{postmaster}{xx}{yy}}"
40405 </literallayout>
40406 <para>
40407 to ensure that it is all in one argument. The expansion is done in this way,
40408 argument by argument, so that the number of arguments cannot be changed as a
40409 result of expansion, and quotes or backslashes in inserted variables do not
40410 interact with external quoting. However, this leads to problems if you want to
40411 generate multiple arguments (or the command name plus arguments) from a single
40412 expansion. In this situation, the simplest solution is to use a shell. For
40413 example:
40414 </para>
40415 <literallayout class="monospaced">
40416 command = /bin/sh -c ${lookup{$local_part}lsearch{/some/file}}
40417 </literallayout>
40418 <para>
40419 <indexterm role="concept">
40420 <primary>transport</primary>
40421 <secondary>filter</secondary>
40422 </indexterm>
40423 <indexterm role="concept">
40424 <primary>filter</primary>
40425 <secondary>transport filter</secondary>
40426 </indexterm>
40427 <indexterm role="variable">
40428 <primary><varname>$pipe_addresses</varname></primary>
40429 </indexterm>
40430 Special handling takes place when an argument consists of precisely the text
40431 <literal>$pipe_addresses</literal>. This is not a general expansion variable; the only
40432 place this string is recognized is when it appears as an argument for a pipe or
40433 transport filter command. It causes each address that is being handled to be
40434 inserted in the argument list at that point <emphasis>as a separate argument</emphasis>. This
40435 avoids any problems with spaces or shell metacharacters, and is of use when a
40436 <command>pipe</command> transport is handling groups of addresses in a batch.
40437 </para>
40438 <para>
40439 After splitting up into arguments and expansion, the resulting command is run
40440 in a subprocess directly from the transport, <emphasis>not</emphasis> under a shell. The
40441 message that is being delivered is supplied on the standard input, and the
40442 standard output and standard error are both connected to a single pipe that is
40443 read by Exim. The <option>max_output</option> option controls how much output the command
40444 may produce, and the <option>return_output</option> and <option>return_fail_output</option> options
40445 control what is done with it.
40446 </para>
40447 <para>
40448 Not running the command under a shell (by default) lessens the security risks
40449 in cases when a command from a user&#x2019;s filter file is built out of data that was
40450 taken from an incoming message. If a shell is required, it can of course be
40451 explicitly specified as the command to be run. However, there are circumstances
40452 where existing commands (for example, in <filename>.forward</filename> files) expect to be run
40453 under a shell and cannot easily be modified. To allow for these cases, there is
40454 an option called <option>use_shell</option>, which changes the way the <command>pipe</command> transport
40455 works. Instead of breaking up the command line as just described, it expands it
40456 as a single string and passes the result to <filename>/bin/sh</filename>. The
40457 <option>restrict_to_path</option> option and the <varname>$pipe_addresses</varname> facility cannot be used
40458 with <option>use_shell</option>, and the whole mechanism is inherently less secure.
40459 </para>
40460 </section>
40461 <section id="SECTpipeenv">
40462 <title>Environment variables</title>
40463 <para>
40464 <indexterm role="concept">
40465 <primary><command>pipe</command> transport</primary>
40466 <secondary>environment for command</secondary>
40467 </indexterm>
40468 <indexterm role="concept">
40469 <primary>environment for pipe transport</primary>
40470 </indexterm>
40471 The environment variables listed below are set up when the command is invoked.
40472 This list is a compromise for maximum compatibility with other MTAs. Note that
40473 the <option>environment</option> option can be used to add additional variables to this
40474 environment.
40475 </para>
40476 <literallayout>
40477 <literal>DOMAIN            </literal>   the domain of the address
40478 <literal>HOME              </literal>   the home directory, if set
40479 <literal>HOST              </literal>   the host name when called from a router (see below)
40480 <literal>LOCAL_PART        </literal>   see below
40481 <literal>LOCAL_PART_PREFIX </literal>   see below
40482 <literal>LOCAL_PART_SUFFIX </literal>   see below
40483 <literal>LOGNAME           </literal>   see below
40484 <literal>MESSAGE_ID        </literal>   Exim&#x2019;s local ID for the message
40485 <literal>PATH              </literal>   as specified by the <option>path</option> option below
40486 <literal>QUALIFY_DOMAIN    </literal>   the sender qualification domain
40487 <literal>RECIPIENT         </literal>   the complete recipient address
40488 <literal>SENDER            </literal>   the sender of the message (empty if a bounce)
40489 <literal>SHELL             </literal>   <literal>/bin/sh</literal>
40490 <literal>TZ                </literal>   the value of the <option>timezone</option> option, if set
40491 <literal>USER              </literal>   see below
40492 </literallayout>
40493 <para>
40494 When a <command>pipe</command> transport is called directly from (for example) an <command>accept</command>
40495 router, LOCAL_PART is set to the local part of the address. When it is
40496 called as a result of a forward or alias expansion, LOCAL_PART is set to
40497 the local part of the address that was expanded. In both cases, any affixes are
40498 removed from the local part, and made available in LOCAL_PART_PREFIX and
40499 LOCAL_PART_SUFFIX, respectively. LOGNAME and USER are set to the
40500 same value as LOCAL_PART for compatibility with other MTAs.
40501 </para>
40502 <para>
40503 <indexterm role="concept">
40504 <primary>HOST</primary>
40505 </indexterm>
40506 HOST is set only when a <command>pipe</command> transport is called from a router that
40507 associates hosts with an address, typically when using <command>pipe</command> as a
40508 pseudo-remote transport. HOST is set to the first host name specified by
40509 the router.
40510 </para>
40511 <para>
40512 <indexterm role="concept">
40513 <primary>HOME</primary>
40514 </indexterm>
40515 If the transport&#x2019;s generic <option>home_directory</option> option is set, its value is used
40516 for the HOME environment variable. Otherwise, a home directory may be set
40517 by the router&#x2019;s <option>transport_home_directory</option> option, which defaults to the
40518 user&#x2019;s home directory if <option>check_local_user</option> is set.
40519 </para>
40520 </section>
40521 <section id="SECID142">
40522 <title>Private options for pipe</title>
40523 <para>
40524 <indexterm role="concept">
40525 <primary>options</primary>
40526 <secondary><command>pipe</command> transport</secondary>
40527 </indexterm>
40528 </para>
40529 <para>
40530 <indexterm role="option">
40531 <primary><option>allow_commands</option></primary>
40532 </indexterm>
40533 </para>
40534 <informaltable frame="all">
40535 <tgroup cols="4" colsep="0" rowsep="0">
40536 <colspec colwidth="8*" align="left"/>
40537 <colspec colwidth="6*" align="center"/>
40538 <colspec colwidth="6*" align="center"/>
40539 <colspec colwidth="6*" align="right"/>
40540 <tbody>
40541 <row>
40542 <entry><option>allow_commands</option></entry>
40543 <entry>Use: <emphasis>pipe</emphasis></entry>
40544 <entry>Type: <emphasis>string list</emphasis>&dagger;<emphasis></emphasis></entry>
40545 <entry>Default: <emphasis>unset</emphasis></entry>
40546 </row>
40547 </tbody>
40548 </tgroup>
40549 </informaltable>
40550 <para>
40551 <indexterm role="concept">
40552 <primary><command>pipe</command> transport</primary>
40553 <secondary>permitted commands</secondary>
40554 </indexterm>
40555 The string is expanded, and is then interpreted as a colon-separated list of
40556 permitted commands. If <option>restrict_to_path</option> is not set, the only commands
40557 permitted are those in the <option>allow_commands</option> list. They need not be absolute
40558 paths; the <option>path</option> option is still used for relative paths. If
40559 <option>restrict_to_path</option> is set with <option>allow_commands</option>, the command must either be
40560 in the <option>allow_commands</option> list, or a name without any slashes that is found on
40561 the path. In other words, if neither <option>allow_commands</option> nor
40562 <option>restrict_to_path</option> is set, there is no restriction on the command, but
40563 otherwise only commands that are permitted by one or the other are allowed. For
40564 example, if
40565 </para>
40566 <literallayout class="monospaced">
40567 allow_commands = /usr/bin/vacation
40568 </literallayout>
40569 <para>
40570 and <option>restrict_to_path</option> is not set, the only permitted command is
40571 <filename>/usr/bin/vacation</filename>. The <option>allow_commands</option> option may not be set if
40572 <option>use_shell</option> is set.
40573 </para>
40574 <para>
40575 <indexterm role="option">
40576 <primary><option>batch_id</option></primary>
40577 </indexterm>
40578 </para>
40579 <informaltable frame="all">
40580 <tgroup cols="4" colsep="0" rowsep="0">
40581 <colspec colwidth="8*" align="left"/>
40582 <colspec colwidth="6*" align="center"/>
40583 <colspec colwidth="6*" align="center"/>
40584 <colspec colwidth="6*" align="right"/>
40585 <tbody>
40586 <row>
40587 <entry><option>batch_id</option></entry>
40588 <entry>Use: <emphasis>pipe</emphasis></entry>
40589 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
40590 <entry>Default: <emphasis>unset</emphasis></entry>
40591 </row>
40592 </tbody>
40593 </tgroup>
40594 </informaltable>
40595 <para>
40596 See the description of local delivery batching in chapter <xref linkend="CHAPbatching"/>.
40597 </para>
40598 <para>
40599 <indexterm role="option">
40600 <primary><option>batch_max</option></primary>
40601 </indexterm>
40602 </para>
40603 <informaltable frame="all">
40604 <tgroup cols="4" colsep="0" rowsep="0">
40605 <colspec colwidth="8*" align="left"/>
40606 <colspec colwidth="6*" align="center"/>
40607 <colspec colwidth="6*" align="center"/>
40608 <colspec colwidth="6*" align="right"/>
40609 <tbody>
40610 <row>
40611 <entry><option>batch_max</option></entry>
40612 <entry>Use: <emphasis>pipe</emphasis></entry>
40613 <entry>Type: <emphasis>integer</emphasis></entry>
40614 <entry>Default: <emphasis>1</emphasis></entry>
40615 </row>
40616 </tbody>
40617 </tgroup>
40618 </informaltable>
40619 <para>
40620 This limits the number of addresses that can be handled in a single delivery.
40621 See the description of local delivery batching in chapter <xref linkend="CHAPbatching"/>.
40622 </para>
40623 <para>
40624 <indexterm role="option">
40625 <primary><option>check_string</option></primary>
40626 </indexterm>
40627 </para>
40628 <informaltable frame="all">
40629 <tgroup cols="4" colsep="0" rowsep="0">
40630 <colspec colwidth="8*" align="left"/>
40631 <colspec colwidth="6*" align="center"/>
40632 <colspec colwidth="6*" align="center"/>
40633 <colspec colwidth="6*" align="right"/>
40634 <tbody>
40635 <row>
40636 <entry><option>check_string</option></entry>
40637 <entry>Use: <emphasis>pipe</emphasis></entry>
40638 <entry>Type: <emphasis>string</emphasis></entry>
40639 <entry>Default: <emphasis>unset</emphasis></entry>
40640 </row>
40641 </tbody>
40642 </tgroup>
40643 </informaltable>
40644 <para>
40645 As <command>pipe</command> writes the message, the start of each line is tested for matching
40646 <option>check_string</option>, and if it does, the initial matching characters are replaced
40647 by the contents of <option>escape_string</option>, provided both are set. The value of
40648 <option>check_string</option> is a literal string, not a regular expression, and the case of
40649 any letters it contains is significant. When <option>use_bsmtp</option> is set, the contents
40650 of <option>check_string</option> and <option>escape_string</option> are forced to values that implement
40651 the SMTP escaping protocol. Any settings made in the configuration file are
40652 ignored.
40653 </para>
40654 <para>
40655 <indexterm role="option">
40656 <primary><option>command</option></primary>
40657 </indexterm>
40658 </para>
40659 <informaltable frame="all">
40660 <tgroup cols="4" colsep="0" rowsep="0">
40661 <colspec colwidth="8*" align="left"/>
40662 <colspec colwidth="6*" align="center"/>
40663 <colspec colwidth="6*" align="center"/>
40664 <colspec colwidth="6*" align="right"/>
40665 <tbody>
40666 <row>
40667 <entry><option>command</option></entry>
40668 <entry>Use: <emphasis>pipe</emphasis></entry>
40669 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
40670 <entry>Default: <emphasis>unset</emphasis></entry>
40671 </row>
40672 </tbody>
40673 </tgroup>
40674 </informaltable>
40675 <para>
40676 This option need not be set when <command>pipe</command> is being used to deliver to pipes
40677 obtained directly from address redirections. In other cases, the option must be
40678 set, to provide a command to be run. It need not yield an absolute path (see
40679 the <option>path</option> option below). The command is split up into separate arguments by
40680 Exim, and each argument is separately expanded, as described in section
40681 <xref linkend="SECThowcommandrun"/> above.
40682 </para>
40683 <para>
40684 <indexterm role="option">
40685 <primary><option>environment</option></primary>
40686 </indexterm>
40687 </para>
40688 <informaltable frame="all">
40689 <tgroup cols="4" colsep="0" rowsep="0">
40690 <colspec colwidth="8*" align="left"/>
40691 <colspec colwidth="6*" align="center"/>
40692 <colspec colwidth="6*" align="center"/>
40693 <colspec colwidth="6*" align="right"/>
40694 <tbody>
40695 <row>
40696 <entry><option>environment</option></entry>
40697 <entry>Use: <emphasis>pipe</emphasis></entry>
40698 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
40699 <entry>Default: <emphasis>unset</emphasis></entry>
40700 </row>
40701 </tbody>
40702 </tgroup>
40703 </informaltable>
40704 <para>
40705 <indexterm role="concept">
40706 <primary><command>pipe</command> transport</primary>
40707 <secondary>environment for command</secondary>
40708 </indexterm>
40709 <indexterm role="concept">
40710 <primary>environment for <command>pipe</command> transport</primary>
40711 </indexterm>
40712 This option is used to add additional variables to the environment in which the
40713 command runs (see section <xref linkend="SECTpipeenv"/> for the default list). Its value is
40714 a string which is expanded, and then interpreted as a colon-separated list of
40715 environment settings of the form &lt;<emphasis>name</emphasis>&gt;=&lt;<emphasis>value</emphasis>&gt;.
40716 </para>
40717 <para>
40718 <indexterm role="option">
40719 <primary><option>escape_string</option></primary>
40720 </indexterm>
40721 </para>
40722 <informaltable frame="all">
40723 <tgroup cols="4" colsep="0" rowsep="0">
40724 <colspec colwidth="8*" align="left"/>
40725 <colspec colwidth="6*" align="center"/>
40726 <colspec colwidth="6*" align="center"/>
40727 <colspec colwidth="6*" align="right"/>
40728 <tbody>
40729 <row>
40730 <entry><option>escape_string</option></entry>
40731 <entry>Use: <emphasis>pipe</emphasis></entry>
40732 <entry>Type: <emphasis>string</emphasis></entry>
40733 <entry>Default: <emphasis>unset</emphasis></entry>
40734 </row>
40735 </tbody>
40736 </tgroup>
40737 </informaltable>
40738 <para>
40739 See <option>check_string</option> above.
40740 </para>
40741 <para>
40742 <indexterm role="option">
40743 <primary><option>freeze_exec_fail</option></primary>
40744 </indexterm>
40745 </para>
40746 <informaltable frame="all">
40747 <tgroup cols="4" colsep="0" rowsep="0">
40748 <colspec colwidth="8*" align="left"/>
40749 <colspec colwidth="6*" align="center"/>
40750 <colspec colwidth="6*" align="center"/>
40751 <colspec colwidth="6*" align="right"/>
40752 <tbody>
40753 <row>
40754 <entry><option>freeze_exec_fail</option></entry>
40755 <entry>Use: <emphasis>pipe</emphasis></entry>
40756 <entry>Type: <emphasis>boolean</emphasis></entry>
40757 <entry>Default: <emphasis>false</emphasis></entry>
40758 </row>
40759 </tbody>
40760 </tgroup>
40761 </informaltable>
40762 <para>
40763 <indexterm role="concept">
40764 <primary>exec failure</primary>
40765 </indexterm>
40766 <indexterm role="concept">
40767 <primary>failure of exec</primary>
40768 </indexterm>
40769 <indexterm role="concept">
40770 <primary><command>pipe</command> transport</primary>
40771 <secondary>failure of exec</secondary>
40772 </indexterm>
40773 Failure to exec the command in a pipe transport is by default treated like
40774 any other failure while running the command. However, if <option>freeze_exec_fail</option>
40775 is set, failure to exec is treated specially, and causes the message to be
40776 frozen, whatever the setting of <option>ignore_status</option>.
40777 </para>
40778 <para>
40779 <indexterm role="option">
40780 <primary><option>ignore_status</option></primary>
40781 </indexterm>
40782 </para>
40783 <informaltable frame="all">
40784 <tgroup cols="4" colsep="0" rowsep="0">
40785 <colspec colwidth="8*" align="left"/>
40786 <colspec colwidth="6*" align="center"/>
40787 <colspec colwidth="6*" align="center"/>
40788 <colspec colwidth="6*" align="right"/>
40789 <tbody>
40790 <row>
40791 <entry><option>ignore_status</option></entry>
40792 <entry>Use: <emphasis>pipe</emphasis></entry>
40793 <entry>Type: <emphasis>boolean</emphasis></entry>
40794 <entry>Default: <emphasis>false</emphasis></entry>
40795 </row>
40796 </tbody>
40797 </tgroup>
40798 </informaltable>
40799 <para>
40800 If this option is true, the status returned by the subprocess that is set up to
40801 run the command is ignored, and Exim behaves as if zero had been returned.
40802 Otherwise, a non-zero status or termination by signal causes an error return
40803 from the transport unless the status value is one of those listed in
40804 <option>temp_errors</option>; these cause the delivery to be deferred and tried again later.
40805 </para>
40806 <para>
40807 <emphasis role="bold">Note</emphasis>: This option does not apply to timeouts, which do not return a status.
40808 See the <option>timeout_defer</option> option for how timeouts are handled.
40809 </para>
40810 <para>
40811 <indexterm role="option">
40812 <primary><option>log_defer_output</option></primary>
40813 </indexterm>
40814 </para>
40815 <informaltable frame="all">
40816 <tgroup cols="4" colsep="0" rowsep="0">
40817 <colspec colwidth="8*" align="left"/>
40818 <colspec colwidth="6*" align="center"/>
40819 <colspec colwidth="6*" align="center"/>
40820 <colspec colwidth="6*" align="right"/>
40821 <tbody>
40822 <row>
40823 <entry><option>log_defer_output</option></entry>
40824 <entry>Use: <emphasis>pipe</emphasis></entry>
40825 <entry>Type: <emphasis>boolean</emphasis></entry>
40826 <entry>Default: <emphasis>false</emphasis></entry>
40827 </row>
40828 </tbody>
40829 </tgroup>
40830 </informaltable>
40831 <para>
40832 <indexterm role="concept">
40833 <primary><command>pipe</command> transport</primary>
40834 <secondary>logging output</secondary>
40835 </indexterm>
40836 If this option is set, and the status returned by the command is
40837 one of the codes listed in <option>temp_errors</option> (that is, delivery was deferred),
40838 and any output was produced, the first line of it is written to the main log.
40839 </para>
40840 <para>
40841 <indexterm role="option">
40842 <primary><option>log_fail_output</option></primary>
40843 </indexterm>
40844 </para>
40845 <informaltable frame="all">
40846 <tgroup cols="4" colsep="0" rowsep="0">
40847 <colspec colwidth="8*" align="left"/>
40848 <colspec colwidth="6*" align="center"/>
40849 <colspec colwidth="6*" align="center"/>
40850 <colspec colwidth="6*" align="right"/>
40851 <tbody>
40852 <row>
40853 <entry><option>log_fail_output</option></entry>
40854 <entry>Use: <emphasis>pipe</emphasis></entry>
40855 <entry>Type: <emphasis>boolean</emphasis></entry>
40856 <entry>Default: <emphasis>false</emphasis></entry>
40857 </row>
40858 </tbody>
40859 </tgroup>
40860 </informaltable>
40861 <para>
40862 If this option is set, and the command returns any output, and also ends with a
40863 return code that is neither zero nor one of the return codes listed in
40864 <option>temp_errors</option> (that is, the delivery failed), the first line of output is
40865 written to the main log. This option and <option>log_output</option> are mutually exclusive.
40866 Only one of them may be set.
40867 </para>
40868 <para>
40869 <indexterm role="option">
40870 <primary><option>log_output</option></primary>
40871 </indexterm>
40872 </para>
40873 <informaltable frame="all">
40874 <tgroup cols="4" colsep="0" rowsep="0">
40875 <colspec colwidth="8*" align="left"/>
40876 <colspec colwidth="6*" align="center"/>
40877 <colspec colwidth="6*" align="center"/>
40878 <colspec colwidth="6*" align="right"/>
40879 <tbody>
40880 <row>
40881 <entry><option>log_output</option></entry>
40882 <entry>Use: <emphasis>pipe</emphasis></entry>
40883 <entry>Type: <emphasis>boolean</emphasis></entry>
40884 <entry>Default: <emphasis>false</emphasis></entry>
40885 </row>
40886 </tbody>
40887 </tgroup>
40888 </informaltable>
40889 <para>
40890 If this option is set and the command returns any output, the first line of
40891 output is written to the main log, whatever the return code. This option and
40892 <option>log_fail_output</option> are mutually exclusive. Only one of them may be set.
40893 </para>
40894 <para>
40895 <indexterm role="option">
40896 <primary><option>max_output</option></primary>
40897 </indexterm>
40898 </para>
40899 <informaltable frame="all">
40900 <tgroup cols="4" colsep="0" rowsep="0">
40901 <colspec colwidth="8*" align="left"/>
40902 <colspec colwidth="6*" align="center"/>
40903 <colspec colwidth="6*" align="center"/>
40904 <colspec colwidth="6*" align="right"/>
40905 <tbody>
40906 <row>
40907 <entry><option>max_output</option></entry>
40908 <entry>Use: <emphasis>pipe</emphasis></entry>
40909 <entry>Type: <emphasis>integer</emphasis></entry>
40910 <entry>Default: <emphasis>20K</emphasis></entry>
40911 </row>
40912 </tbody>
40913 </tgroup>
40914 </informaltable>
40915 <para>
40916 This specifies the maximum amount of output that the command may produce on its
40917 standard output and standard error file combined. If the limit is exceeded, the
40918 process running the command is killed. This is intended as a safety measure to
40919 catch runaway processes. The limit is applied independently of the settings of
40920 the options that control what is done with such output (for example,
40921 <option>return_output</option>). Because of buffering effects, the amount of output may
40922 exceed the limit by a small amount before Exim notices.
40923 </para>
40924 <para>
40925 <indexterm role="option">
40926 <primary><option>message_prefix</option></primary>
40927 </indexterm>
40928 </para>
40929 <informaltable frame="all">
40930 <tgroup cols="4" colsep="0" rowsep="0">
40931 <colspec colwidth="8*" align="left"/>
40932 <colspec colwidth="6*" align="center"/>
40933 <colspec colwidth="6*" align="center"/>
40934 <colspec colwidth="6*" align="right"/>
40935 <tbody>
40936 <row>
40937 <entry><option>message_prefix</option></entry>
40938 <entry>Use: <emphasis>pipe</emphasis></entry>
40939 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
40940 <entry>Default: <emphasis>see below</emphasis></entry>
40941 </row>
40942 </tbody>
40943 </tgroup>
40944 </informaltable>
40945 <para>
40946 The string specified here is expanded and output at the start of every message.
40947 The default is unset if <option>use_bsmtp</option> is set. Otherwise it is
40948 </para>
40949 <literallayout class="monospaced">
40950 message_prefix = \
40951   From ${if def:return_path{$return_path}{MAILER-DAEMON}}\
40952   ${tod_bsdinbox}\n
40953 </literallayout>
40954 <para>
40955 <indexterm role="concept">
40956 <primary>Cyrus</primary>
40957 </indexterm>
40958 <indexterm role="concept">
40959 <primary><option>tmail</option></primary>
40960 </indexterm>
40961 <indexterm role="concept">
40962 <primary><quote>From</quote> line</primary>
40963 </indexterm>
40964 This is required by the commonly used <filename>/usr/bin/vacation</filename> program.
40965 However, it must <emphasis>not</emphasis> be present if delivery is to the Cyrus IMAP server,
40966 or to the <option>tmail</option> local delivery agent. The prefix can be suppressed by
40967 setting
40968 </para>
40969 <literallayout class="monospaced">
40970 message_prefix =
40971 </literallayout>
40972 <para>
40973 <emphasis role="bold">Note:</emphasis> If you set <option>use_crlf</option> true, you must change any occurrences of
40974 <literal>\n</literal> to <literal>\r\n</literal> in <option>message_prefix</option>.
40975 </para>
40976 <para>
40977 <indexterm role="option">
40978 <primary><option>message_suffix</option></primary>
40979 </indexterm>
40980 </para>
40981 <informaltable frame="all">
40982 <tgroup cols="4" colsep="0" rowsep="0">
40983 <colspec colwidth="8*" align="left"/>
40984 <colspec colwidth="6*" align="center"/>
40985 <colspec colwidth="6*" align="center"/>
40986 <colspec colwidth="6*" align="right"/>
40987 <tbody>
40988 <row>
40989 <entry><option>message_suffix</option></entry>
40990 <entry>Use: <emphasis>pipe</emphasis></entry>
40991 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
40992 <entry>Default: <emphasis>see below</emphasis></entry>
40993 </row>
40994 </tbody>
40995 </tgroup>
40996 </informaltable>
40997 <para>
40998 The string specified here is expanded and output at the end of every message.
40999 The default is unset if <option>use_bsmtp</option> is set. Otherwise it is a single newline.
41000 The suffix can be suppressed by setting
41001 </para>
41002 <literallayout class="monospaced">
41003 message_suffix =
41004 </literallayout>
41005 <para>
41006 <emphasis role="bold">Note:</emphasis> If you set <option>use_crlf</option> true, you must change any occurrences of
41007 <literal>\n</literal> to <literal>\r\n</literal> in <option>message_suffix</option>.
41008 </para>
41009 <para>
41010 <indexterm role="option">
41011 <primary><option>path</option></primary>
41012 </indexterm>
41013 </para>
41014 <informaltable frame="all">
41015 <tgroup cols="4" colsep="0" rowsep="0">
41016 <colspec colwidth="8*" align="left"/>
41017 <colspec colwidth="6*" align="center"/>
41018 <colspec colwidth="6*" align="center"/>
41019 <colspec colwidth="6*" align="right"/>
41020 <tbody>
41021 <row>
41022 <entry><option>path</option></entry>
41023 <entry>Use: <emphasis>pipe</emphasis></entry>
41024 <entry>Type: <emphasis>string</emphasis></entry>
41025 <entry>Default: <emphasis>see below</emphasis></entry>
41026 </row>
41027 </tbody>
41028 </tgroup>
41029 </informaltable>
41030 <para>
41031 This option specifies the string that is set up in the PATH environment
41032 variable of the subprocess. The default is:
41033 </para>
41034 <literallayout class="monospaced">
41035 /bin:/usr/bin
41036 </literallayout>
41037 <para>
41038 If the <option>command</option> option does not yield an absolute path name, the command is
41039 sought in the PATH directories, in the usual way. <emphasis role="bold">Warning</emphasis>: This does not
41040 apply to a command specified as a transport filter.
41041 </para>
41042 <para revisionflag="changed">
41043 <indexterm role="option">
41044 <primary><option>permit_coredump</option></primary>
41045 </indexterm>
41046 </para>
41047 <informaltable frame="all" revisionflag="changed">
41048 <tgroup cols="4" colsep="0" rowsep="0">
41049 <colspec colwidth="8*" align="left"/>
41050 <colspec colwidth="6*" align="center"/>
41051 <colspec colwidth="6*" align="center"/>
41052 <colspec colwidth="6*" align="right"/>
41053 <tbody>
41054 <row>
41055 <entry><option>permit_coredump</option></entry>
41056 <entry>Use: <emphasis>pipe</emphasis></entry>
41057 <entry>Type: <emphasis>boolean</emphasis></entry>
41058 <entry>Default: <emphasis>false</emphasis></entry>
41059 </row>
41060 </tbody>
41061 </tgroup>
41062 </informaltable>
41063 <para revisionflag="changed">
41064 Normally Exim inhibits core-dumps during delivery.  If you have a need to get
41065 a core-dump of a pipe command, enable this command.  This enables core-dumps
41066 during delivery and affects both the Exim binary and the pipe command run.
41067 It is recommended that this option remain off unless and until you have a need
41068 for it and that this only be enabled when needed, as the risk of excessive
41069 resource consumption can be quite high.  Note also that Exim is typically
41070 installed as a setuid binary and most operating systems will inhibit coredumps
41071 of these by default, so further OS-specific action may be required.
41072 </para>
41073 <para>
41074 <indexterm role="option">
41075 <primary><option>pipe_as_creator</option></primary>
41076 </indexterm>
41077 </para>
41078 <informaltable frame="all">
41079 <tgroup cols="4" colsep="0" rowsep="0">
41080 <colspec colwidth="8*" align="left"/>
41081 <colspec colwidth="6*" align="center"/>
41082 <colspec colwidth="6*" align="center"/>
41083 <colspec colwidth="6*" align="right"/>
41084 <tbody>
41085 <row>
41086 <entry><option>pipe_as_creator</option></entry>
41087 <entry>Use: <emphasis>pipe</emphasis></entry>
41088 <entry>Type: <emphasis>boolean</emphasis></entry>
41089 <entry>Default: <emphasis>false</emphasis></entry>
41090 </row>
41091 </tbody>
41092 </tgroup>
41093 </informaltable>
41094 <para>
41095 <indexterm role="concept">
41096 <primary>uid (user id)</primary>
41097 <secondary>local delivery</secondary>
41098 </indexterm>
41099 If the generic <option>user</option> option is not set and this option is true, the delivery
41100 process is run under the uid that was in force when Exim was originally called
41101 to accept the message. If the group id is not otherwise set (via the generic
41102 <option>group</option> option), the gid that was in force when Exim was originally called to
41103 accept the message is used.
41104 </para>
41105 <para>
41106 <indexterm role="option">
41107 <primary><option>restrict_to_path</option></primary>
41108 </indexterm>
41109 </para>
41110 <informaltable frame="all">
41111 <tgroup cols="4" colsep="0" rowsep="0">
41112 <colspec colwidth="8*" align="left"/>
41113 <colspec colwidth="6*" align="center"/>
41114 <colspec colwidth="6*" align="center"/>
41115 <colspec colwidth="6*" align="right"/>
41116 <tbody>
41117 <row>
41118 <entry><option>restrict_to_path</option></entry>
41119 <entry>Use: <emphasis>pipe</emphasis></entry>
41120 <entry>Type: <emphasis>boolean</emphasis></entry>
41121 <entry>Default: <emphasis>false</emphasis></entry>
41122 </row>
41123 </tbody>
41124 </tgroup>
41125 </informaltable>
41126 <para>
41127 When this option is set, any command name not listed in <option>allow_commands</option> must
41128 contain no slashes. The command is searched for only in the directories listed
41129 in the <option>path</option> option. This option is intended for use in the case when a pipe
41130 command has been generated from a user&#x2019;s <filename>.forward</filename> file. This is usually
41131 handled by a <command>pipe</command> transport called <option>address_pipe</option>.
41132 </para>
41133 <para>
41134 <indexterm role="option">
41135 <primary><option>return_fail_output</option></primary>
41136 </indexterm>
41137 </para>
41138 <informaltable frame="all">
41139 <tgroup cols="4" colsep="0" rowsep="0">
41140 <colspec colwidth="8*" align="left"/>
41141 <colspec colwidth="6*" align="center"/>
41142 <colspec colwidth="6*" align="center"/>
41143 <colspec colwidth="6*" align="right"/>
41144 <tbody>
41145 <row>
41146 <entry><option>return_fail_output</option></entry>
41147 <entry>Use: <emphasis>pipe</emphasis></entry>
41148 <entry>Type: <emphasis>boolean</emphasis></entry>
41149 <entry>Default: <emphasis>false</emphasis></entry>
41150 </row>
41151 </tbody>
41152 </tgroup>
41153 </informaltable>
41154 <para>
41155 If this option is true, and the command produced any output and ended with a
41156 return code other than zero or one of the codes listed in <option>temp_errors</option> (that
41157 is, the delivery failed), the output is returned in the bounce message.
41158 However, if the message has a null sender (that is, it is itself a bounce
41159 message), output from the command is discarded. This option and
41160 <option>return_output</option> are mutually exclusive. Only one of them may be set.
41161 </para>
41162 <para>
41163 <indexterm role="option">
41164 <primary><option>return_output</option></primary>
41165 </indexterm>
41166 </para>
41167 <informaltable frame="all">
41168 <tgroup cols="4" colsep="0" rowsep="0">
41169 <colspec colwidth="8*" align="left"/>
41170 <colspec colwidth="6*" align="center"/>
41171 <colspec colwidth="6*" align="center"/>
41172 <colspec colwidth="6*" align="right"/>
41173 <tbody>
41174 <row>
41175 <entry><option>return_output</option></entry>
41176 <entry>Use: <emphasis>pipe</emphasis></entry>
41177 <entry>Type: <emphasis>boolean</emphasis></entry>
41178 <entry>Default: <emphasis>false</emphasis></entry>
41179 </row>
41180 </tbody>
41181 </tgroup>
41182 </informaltable>
41183 <para>
41184 If this option is true, and the command produced any output, the delivery is
41185 deemed to have failed whatever the return code from the command, and the output
41186 is returned in the bounce message. Otherwise, the output is just discarded.
41187 However, if the message has a null sender (that is, it is a bounce message),
41188 output from the command is always discarded, whatever the setting of this
41189 option. This option and <option>return_fail_output</option> are mutually exclusive. Only one
41190 of them may be set.
41191 </para>
41192 <para>
41193 <indexterm role="option">
41194 <primary><option>temp_errors</option></primary>
41195 </indexterm>
41196 </para>
41197 <informaltable frame="all">
41198 <tgroup cols="4" colsep="0" rowsep="0">
41199 <colspec colwidth="8*" align="left"/>
41200 <colspec colwidth="6*" align="center"/>
41201 <colspec colwidth="6*" align="center"/>
41202 <colspec colwidth="6*" align="right"/>
41203 <tbody>
41204 <row>
41205 <entry><option>temp_errors</option></entry>
41206 <entry>Use: <emphasis>pipe</emphasis></entry>
41207 <entry>Type: <emphasis>string list</emphasis></entry>
41208 <entry>Default: <emphasis>see below</emphasis></entry>
41209 </row>
41210 </tbody>
41211 </tgroup>
41212 </informaltable>
41213 <para>
41214 <indexterm role="concept">
41215 <primary><command>pipe</command> transport</primary>
41216 <secondary>temporary failure</secondary>
41217 </indexterm>
41218 This option contains either a colon-separated list of numbers, or a single
41219 asterisk. If <option>ignore_status</option> is false
41220 and <option>return_output</option> is not set,
41221 and the command exits with a non-zero return code, the failure is treated as
41222 temporary and the delivery is deferred if the return code matches one of the
41223 numbers, or if the setting is a single asterisk. Otherwise, non-zero return
41224 codes are treated as permanent errors. The default setting contains the codes
41225 defined by EX_TEMPFAIL and EX_CANTCREAT in <filename>sysexits.h</filename>. If Exim is
41226 compiled on a system that does not define these macros, it assumes values of 75
41227 and 73, respectively.
41228 </para>
41229 <para>
41230 <indexterm role="option">
41231 <primary><option>timeout</option></primary>
41232 </indexterm>
41233 </para>
41234 <informaltable frame="all">
41235 <tgroup cols="4" colsep="0" rowsep="0">
41236 <colspec colwidth="8*" align="left"/>
41237 <colspec colwidth="6*" align="center"/>
41238 <colspec colwidth="6*" align="center"/>
41239 <colspec colwidth="6*" align="right"/>
41240 <tbody>
41241 <row>
41242 <entry><option>timeout</option></entry>
41243 <entry>Use: <emphasis>pipe</emphasis></entry>
41244 <entry>Type: <emphasis>time</emphasis></entry>
41245 <entry>Default: <emphasis>1h</emphasis></entry>
41246 </row>
41247 </tbody>
41248 </tgroup>
41249 </informaltable>
41250 <para>
41251 If the command fails to complete within this time, it is killed. This normally
41252 causes the delivery to fail (but see <option>timeout_defer</option>). A zero time interval
41253 specifies no timeout. In order to ensure that any subprocesses created by the
41254 command are also killed, Exim makes the initial process a process group leader,
41255 and kills the whole process group on a timeout. However, this can be defeated
41256 if one of the processes starts a new process group.
41257 </para>
41258 <para>
41259 <indexterm role="option">
41260 <primary><option>timeout_defer</option></primary>
41261 </indexterm>
41262 </para>
41263 <informaltable frame="all">
41264 <tgroup cols="4" colsep="0" rowsep="0">
41265 <colspec colwidth="8*" align="left"/>
41266 <colspec colwidth="6*" align="center"/>
41267 <colspec colwidth="6*" align="center"/>
41268 <colspec colwidth="6*" align="right"/>
41269 <tbody>
41270 <row>
41271 <entry><option>timeout_defer</option></entry>
41272 <entry>Use: <emphasis>pipe</emphasis></entry>
41273 <entry>Type: <emphasis>boolean</emphasis></entry>
41274 <entry>Default: <emphasis>false</emphasis></entry>
41275 </row>
41276 </tbody>
41277 </tgroup>
41278 </informaltable>
41279 <para>
41280 A timeout in a <command>pipe</command> transport, either in the command that the transport
41281 runs, or in a transport filter that is associated with it, is by default
41282 treated as a hard error, and the delivery fails. However, if <option>timeout_defer</option>
41283 is set true, both kinds of timeout become temporary errors, causing the
41284 delivery to be deferred.
41285 </para>
41286 <para>
41287 <indexterm role="option">
41288 <primary><option>umask</option></primary>
41289 </indexterm>
41290 </para>
41291 <informaltable frame="all">
41292 <tgroup cols="4" colsep="0" rowsep="0">
41293 <colspec colwidth="8*" align="left"/>
41294 <colspec colwidth="6*" align="center"/>
41295 <colspec colwidth="6*" align="center"/>
41296 <colspec colwidth="6*" align="right"/>
41297 <tbody>
41298 <row>
41299 <entry><option>umask</option></entry>
41300 <entry>Use: <emphasis>pipe</emphasis></entry>
41301 <entry>Type: <emphasis>octal integer</emphasis></entry>
41302 <entry>Default: <emphasis>022</emphasis></entry>
41303 </row>
41304 </tbody>
41305 </tgroup>
41306 </informaltable>
41307 <para>
41308 This specifies the umask setting for the subprocess that runs the command.
41309 </para>
41310 <para>
41311 <indexterm role="option">
41312 <primary><option>use_bsmtp</option></primary>
41313 </indexterm>
41314 </para>
41315 <informaltable frame="all">
41316 <tgroup cols="4" colsep="0" rowsep="0">
41317 <colspec colwidth="8*" align="left"/>
41318 <colspec colwidth="6*" align="center"/>
41319 <colspec colwidth="6*" align="center"/>
41320 <colspec colwidth="6*" align="right"/>
41321 <tbody>
41322 <row>
41323 <entry><option>use_bsmtp</option></entry>
41324 <entry>Use: <emphasis>pipe</emphasis></entry>
41325 <entry>Type: <emphasis>boolean</emphasis></entry>
41326 <entry>Default: <emphasis>false</emphasis></entry>
41327 </row>
41328 </tbody>
41329 </tgroup>
41330 </informaltable>
41331 <para>
41332 <indexterm role="concept">
41333 <primary>envelope sender</primary>
41334 </indexterm>
41335 If this option is set true, the <command>pipe</command> transport writes messages in <quote>batch
41336 SMTP</quote> format, with the envelope sender and recipient(s) included as SMTP
41337 commands. If you want to include a leading HELO command with such messages,
41338 you can do so by setting the <option>message_prefix</option> option. See section
41339 <xref linkend="SECTbatchSMTP"/> for details of batch SMTP.
41340 </para>
41341 <para>
41342 <indexterm role="option">
41343 <primary><option>use_classresources</option></primary>
41344 </indexterm>
41345 </para>
41346 <informaltable frame="all">
41347 <tgroup cols="4" colsep="0" rowsep="0">
41348 <colspec colwidth="8*" align="left"/>
41349 <colspec colwidth="6*" align="center"/>
41350 <colspec colwidth="6*" align="center"/>
41351 <colspec colwidth="6*" align="right"/>
41352 <tbody>
41353 <row>
41354 <entry><option>use_classresources</option></entry>
41355 <entry>Use: <emphasis>pipe</emphasis></entry>
41356 <entry>Type: <emphasis>boolean</emphasis></entry>
41357 <entry>Default: <emphasis>false</emphasis></entry>
41358 </row>
41359 </tbody>
41360 </tgroup>
41361 </informaltable>
41362 <para>
41363 <indexterm role="concept">
41364 <primary>class resources (BSD)</primary>
41365 </indexterm>
41366 This option is available only when Exim is running on FreeBSD, NetBSD, or
41367 BSD/OS. If it is set true, the <function>setclassresources()</function> function is used to set
41368 resource limits when a <command>pipe</command> transport is run to perform a delivery. The
41369 limits for the uid under which the pipe is to run are obtained from the login
41370 class database.
41371 </para>
41372 <para>
41373 <indexterm role="option">
41374 <primary><option>use_crlf</option></primary>
41375 </indexterm>
41376 </para>
41377 <informaltable frame="all">
41378 <tgroup cols="4" colsep="0" rowsep="0">
41379 <colspec colwidth="8*" align="left"/>
41380 <colspec colwidth="6*" align="center"/>
41381 <colspec colwidth="6*" align="center"/>
41382 <colspec colwidth="6*" align="right"/>
41383 <tbody>
41384 <row>
41385 <entry><option>use_crlf</option></entry>
41386 <entry>Use: <emphasis>pipe</emphasis></entry>
41387 <entry>Type: <emphasis>boolean</emphasis></entry>
41388 <entry>Default: <emphasis>false</emphasis></entry>
41389 </row>
41390 </tbody>
41391 </tgroup>
41392 </informaltable>
41393 <para>
41394 <indexterm role="concept">
41395 <primary>carriage return</primary>
41396 </indexterm>
41397 <indexterm role="concept">
41398 <primary>linefeed</primary>
41399 </indexterm>
41400 This option causes lines to be terminated with the two-character CRLF sequence
41401 (carriage return, linefeed) instead of just a linefeed character. In the case
41402 of batched SMTP, the byte sequence written to the pipe is then an exact image
41403 of what would be sent down a real SMTP connection.
41404 </para>
41405 <para>
41406 The contents of the <option>message_prefix</option> and <option>message_suffix</option> options are
41407 written verbatim, so must contain their own carriage return characters if these
41408 are needed. When <option>use_bsmtp</option> is not set, the default values for both
41409 <option>message_prefix</option> and <option>message_suffix</option> end with a single linefeed, so their
41410 values must be changed to end with <literal>\r\n</literal> if <option>use_crlf</option> is set.
41411 </para>
41412 <para>
41413 <indexterm role="option">
41414 <primary><option>use_shell</option></primary>
41415 </indexterm>
41416 </para>
41417 <informaltable frame="all">
41418 <tgroup cols="4" colsep="0" rowsep="0">
41419 <colspec colwidth="8*" align="left"/>
41420 <colspec colwidth="6*" align="center"/>
41421 <colspec colwidth="6*" align="center"/>
41422 <colspec colwidth="6*" align="right"/>
41423 <tbody>
41424 <row>
41425 <entry><option>use_shell</option></entry>
41426 <entry>Use: <emphasis>pipe</emphasis></entry>
41427 <entry>Type: <emphasis>boolean</emphasis></entry>
41428 <entry>Default: <emphasis>false</emphasis></entry>
41429 </row>
41430 </tbody>
41431 </tgroup>
41432 </informaltable>
41433 <para>
41434 <indexterm role="variable">
41435 <primary><varname>$pipe_addresses</varname></primary>
41436 </indexterm>
41437 If this option is set, it causes the command to be passed to <filename>/bin/sh</filename>
41438 instead of being run directly from the transport, as described in section
41439 <xref linkend="SECThowcommandrun"/>. This is less secure, but is needed in some situations
41440 where the command is expected to be run under a shell and cannot easily be
41441 modified. The <option>allow_commands</option> and <option>restrict_to_path</option> options, and the
41442 <literal>$pipe_addresses</literal> facility are incompatible with <option>use_shell</option>. The
41443 command is expanded as a single string, and handed to <filename>/bin/sh</filename> as data for
41444 its <option>-c</option> option.
41445 </para>
41446 </section>
41447 <section id="SECID143">
41448 <title>Using an external local delivery agent</title>
41449 <para>
41450 <indexterm role="concept">
41451 <primary>local delivery</primary>
41452 <secondary>using an external agent</secondary>
41453 </indexterm>
41454 <indexterm role="concept">
41455 <primary><emphasis>procmail</emphasis></primary>
41456 </indexterm>
41457 <indexterm role="concept">
41458 <primary>external local delivery</primary>
41459 </indexterm>
41460 <indexterm role="concept">
41461 <primary>delivery</primary>
41462 <secondary><emphasis>procmail</emphasis></secondary>
41463 </indexterm>
41464 <indexterm role="concept">
41465 <primary>delivery</primary>
41466 <secondary>by external agent</secondary>
41467 </indexterm>
41468 The <command>pipe</command> transport can be used to pass all messages that require local
41469 delivery to a separate local delivery agent such as <option>procmail</option>. When doing
41470 this, care must be taken to ensure that the pipe is run under an appropriate
41471 uid and gid. In some configurations one wants this to be a uid that is trusted
41472 by the delivery agent to supply the correct sender of the message. It may be
41473 necessary to recompile or reconfigure the delivery agent so that it trusts an
41474 appropriate user. The following is an example transport and router
41475 configuration for <option>procmail</option>:
41476 </para>
41477 <literallayout class="monospaced">
41478 # transport
41479 procmail_pipe:
41480   driver = pipe
41481   command = /usr/local/bin/procmail -d $local_part
41482   return_path_add
41483   delivery_date_add
41484   envelope_to_add
41485   check_string = "From "
41486   escape_string = "&gt;From "
41487   umask = 077
41488   user = $local_part
41489   group = mail
41490
41491 # router
41492 procmail:
41493   driver = accept
41494   check_local_user
41495   transport = procmail_pipe
41496 </literallayout>
41497 <para>
41498 In this example, the pipe is run as the local user, but with the group set to
41499 <emphasis>mail</emphasis>. An alternative is to run the pipe as a specific user such as <emphasis>mail</emphasis>
41500 or <emphasis>exim</emphasis>, but in this case you must arrange for <option>procmail</option> to trust that
41501 user to supply a correct sender address. If you do not specify either a
41502 <option>group</option> or a <option>user</option> option, the pipe command is run as the local user. The
41503 home directory is the user&#x2019;s home directory by default.
41504 </para>
41505 <para>
41506 <emphasis role="bold">Note</emphasis>: The command that the pipe transport runs does <emphasis>not</emphasis> begin with
41507 </para>
41508 <literallayout class="monospaced">
41509 IFS=" "
41510 </literallayout>
41511 <para>
41512 as shown in some <option>procmail</option> documentation, because Exim does not by default
41513 use a shell to run pipe commands.
41514 </para>
41515 <para>
41516 <indexterm role="concept">
41517 <primary>Cyrus</primary>
41518 </indexterm>
41519 The next example shows a transport and a router for a system where local
41520 deliveries are handled by the Cyrus IMAP server.
41521 </para>
41522 <literallayout class="monospaced">
41523 # transport
41524 local_delivery_cyrus:
41525   driver = pipe
41526   command = /usr/cyrus/bin/deliver \
41527             -m ${substr_1:$local_part_suffix} -- $local_part
41528   user = cyrus
41529   group = mail
41530   return_output
41531   log_output
41532   message_prefix =
41533   message_suffix =
41534
41535 # router
41536 local_user_cyrus:
41537   driver = accept
41538   check_local_user
41539   local_part_suffix = .*
41540   transport = local_delivery_cyrus
41541 </literallayout>
41542 <para>
41543 Note the unsetting of <option>message_prefix</option> and <option>message_suffix</option>, and the use of
41544 <option>return_output</option> to cause any text written by Cyrus to be returned to the
41545 sender.
41546 <indexterm role="concept" startref="IIDpiptra1" class="endofrange"/>
41547 <indexterm role="concept" startref="IIDpiptra2" class="endofrange"/>
41548 </para>
41549 </section>
41550 </chapter>
41551
41552 <chapter id="CHAPsmtptrans">
41553 <title>The smtp transport</title>
41554 <para>
41555 <indexterm role="concept" id="IIDsmttra1" class="startofrange">
41556 <primary>transports</primary>
41557 <secondary><command>smtp</command></secondary>
41558 </indexterm>
41559 <indexterm role="concept" id="IIDsmttra2" class="startofrange">
41560 <primary><command>smtp</command> transport</primary>
41561 </indexterm>
41562 The <command>smtp</command> transport delivers messages over TCP/IP connections using the SMTP
41563 or LMTP protocol. The list of hosts to try can either be taken from the address
41564 that is being processed (having been set up by the router), or specified
41565 explicitly for the transport. Timeout and retry processing (see chapter
41566 <xref linkend="CHAPretry"/>) is applied to each IP address independently.
41567 </para>
41568 <section id="SECID144">
41569 <title>Multiple messages on a single connection</title>
41570 <para>
41571 The sending of multiple messages over a single TCP/IP connection can arise in
41572 two ways:
41573 </para>
41574 <itemizedlist>
41575 <listitem>
41576 <para>
41577 If a message contains more than <option>max_rcpt</option> (see below) addresses that are
41578 routed to the same host, more than one copy of the message has to be sent to
41579 that host. In this situation, multiple copies may be sent in a single run of
41580 the <command>smtp</command> transport over a single TCP/IP connection. (What Exim actually
41581 does when it has too many addresses to send in one message also depends on the
41582 value of the global <option>remote_max_parallel</option> option. Details are given in
41583 section <xref linkend="SECToutSMTPTCP"/>.)
41584 </para>
41585 </listitem>
41586 <listitem>
41587 <para>
41588 <indexterm role="concept">
41589 <primary>hints database</primary>
41590 <secondary>remembering routing</secondary>
41591 </indexterm>
41592 When a message has been successfully delivered over a TCP/IP connection, Exim
41593 looks in its hints database to see if there are any other messages awaiting a
41594 connection to the same host. If there are, a new delivery process is started
41595 for one of them, and the current TCP/IP connection is passed on to it. The new
41596 process may in turn send multiple copies and possibly create yet another
41597 process.
41598 </para>
41599 </listitem>
41600 </itemizedlist>
41601 <para>
41602 For each copy sent over the same TCP/IP connection, a sequence counter is
41603 incremented, and if it ever gets to the value of <option>connection_max_messages</option>,
41604 no further messages are sent over that connection.
41605 </para>
41606 </section>
41607 <section id="SECID145">
41608 <title>Use of the $host and $host_address variables</title>
41609 <para>
41610 <indexterm role="variable">
41611 <primary><varname>$host</varname></primary>
41612 </indexterm>
41613 <indexterm role="variable">
41614 <primary><varname>$host_address</varname></primary>
41615 </indexterm>
41616 At the start of a run of the <command>smtp</command> transport, the values of <varname>$host</varname> and
41617 <varname>$host_address</varname> are the name and IP address of the first host on the host list
41618 passed by the router. However, when the transport is about to connect to a
41619 specific host, and while it is connected to that host, <varname>$host</varname> and
41620 <varname>$host_address</varname> are set to the values for that host. These are the values
41621 that are in force when the <option>helo_data</option>, <option>hosts_try_auth</option>, <option>interface</option>,
41622 <option>serialize_hosts</option>, and the various TLS options are expanded.
41623 </para>
41624 </section>
41625 <section id="usecippeer">
41626 <title>Use of $tls_cipher and $tls_peerdn</title>
41627 <para>
41628 <indexterm role="variable">
41629 <primary><varname>$tls_cipher</varname></primary>
41630 </indexterm>
41631 <indexterm role="variable">
41632 <primary><varname>$tls_peerdn</varname></primary>
41633 </indexterm>
41634 At the start of a run of the <command>smtp</command> transport, the values of <varname>$tls_cipher</varname>
41635 and <varname>$tls_peerdn</varname> are the values that were set when the message was received.
41636 These are the values that are used for options that are expanded before any
41637 SMTP connections are made. Just before each connection is made, these two
41638 variables are emptied. If TLS is subsequently started, they are set to the
41639 appropriate values for the outgoing connection, and these are the values that
41640 are in force when any authenticators are run and when the
41641 <option>authenticated_sender</option> option is expanded.
41642 </para>
41643 </section>
41644 <section id="SECID146">
41645 <title>Private options for smtp</title>
41646 <para>
41647 <indexterm role="concept">
41648 <primary>options</primary>
41649 <secondary><command>smtp</command> transport</secondary>
41650 </indexterm>
41651 The private options of the <command>smtp</command> transport are as follows:
41652 </para>
41653 <para>
41654 <indexterm role="option">
41655 <primary><option>address_retry_include_sender</option></primary>
41656 </indexterm>
41657 </para>
41658 <informaltable frame="all">
41659 <tgroup cols="4" colsep="0" rowsep="0">
41660 <colspec colwidth="8*" align="left"/>
41661 <colspec colwidth="6*" align="center"/>
41662 <colspec colwidth="6*" align="center"/>
41663 <colspec colwidth="6*" align="right"/>
41664 <tbody>
41665 <row>
41666 <entry><option>address_retry_include_sender</option></entry>
41667 <entry>Use: <emphasis>smtp</emphasis></entry>
41668 <entry>Type: <emphasis>boolean</emphasis></entry>
41669 <entry>Default: <emphasis>true</emphasis></entry>
41670 </row>
41671 </tbody>
41672 </tgroup>
41673 </informaltable>
41674 <para>
41675 <indexterm role="concept">
41676 <primary>4<emphasis>xx</emphasis> responses</primary>
41677 <secondary>retrying after</secondary>
41678 </indexterm>
41679 When an address is delayed because of a 4<emphasis>xx</emphasis> response to a RCPT command, it
41680 is the combination of sender and recipient that is delayed in subsequent queue
41681 runs until the retry time is reached. You can delay the recipient without
41682 reference to the sender (which is what earlier versions of Exim did), by
41683 setting <option>address_retry_include_sender</option> false. However, this can lead to
41684 problems with servers that regularly issue 4<emphasis>xx</emphasis> responses to RCPT commands.
41685 </para>
41686 <para>
41687 <indexterm role="option">
41688 <primary><option>allow_localhost</option></primary>
41689 </indexterm>
41690 </para>
41691 <informaltable frame="all">
41692 <tgroup cols="4" colsep="0" rowsep="0">
41693 <colspec colwidth="8*" align="left"/>
41694 <colspec colwidth="6*" align="center"/>
41695 <colspec colwidth="6*" align="center"/>
41696 <colspec colwidth="6*" align="right"/>
41697 <tbody>
41698 <row>
41699 <entry><option>allow_localhost</option></entry>
41700 <entry>Use: <emphasis>smtp</emphasis></entry>
41701 <entry>Type: <emphasis>boolean</emphasis></entry>
41702 <entry>Default: <emphasis>false</emphasis></entry>
41703 </row>
41704 </tbody>
41705 </tgroup>
41706 </informaltable>
41707 <para>
41708 <indexterm role="concept">
41709 <primary>local host</primary>
41710 <secondary>sending to</secondary>
41711 </indexterm>
41712 <indexterm role="concept">
41713 <primary>fallback</primary>
41714 <secondary>hosts specified on transport</secondary>
41715 </indexterm>
41716 When a host specified in <option>hosts</option> or <option>fallback_hosts</option> (see below) turns out
41717 to be the local host, or is listed in <option>hosts_treat_as_local</option>, delivery is
41718 deferred by default. However, if <option>allow_localhost</option> is set, Exim goes on to do
41719 the delivery anyway. This should be used only in special cases when the
41720 configuration ensures that no looping will result (for example, a differently
41721 configured Exim is listening on the port to which the message is sent).
41722 </para>
41723 <para>
41724 <indexterm role="option">
41725 <primary><option>authenticated_sender</option></primary>
41726 </indexterm>
41727 </para>
41728 <informaltable frame="all">
41729 <tgroup cols="4" colsep="0" rowsep="0">
41730 <colspec colwidth="8*" align="left"/>
41731 <colspec colwidth="6*" align="center"/>
41732 <colspec colwidth="6*" align="center"/>
41733 <colspec colwidth="6*" align="right"/>
41734 <tbody>
41735 <row>
41736 <entry><option>authenticated_sender</option></entry>
41737 <entry>Use: <emphasis>smtp</emphasis></entry>
41738 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
41739 <entry>Default: <emphasis>unset</emphasis></entry>
41740 </row>
41741 </tbody>
41742 </tgroup>
41743 </informaltable>
41744 <para>
41745 <indexterm role="concept">
41746 <primary>Cyrus</primary>
41747 </indexterm>
41748 When Exim has authenticated as a client, or if <option>authenticated_sender_force</option>
41749 is true, this option sets a value for the AUTH= item on outgoing MAIL commands,
41750 overriding any existing authenticated sender value. If the string expansion is
41751 forced to fail, the option is ignored. Other expansion failures cause delivery
41752 to be deferred. If the result of expansion is an empty string, that is also
41753 ignored.
41754 </para>
41755 <para>
41756 The expansion happens after the outgoing connection has been made and TLS
41757 started, if required. This means that the <varname>$host</varname>, <varname>$host_address</varname>,
41758 <varname>$tls_cipher</varname>, and <varname>$tls_peerdn</varname> variables are set according to the
41759 particular connection.
41760 </para>
41761 <para>
41762 If the SMTP session is not authenticated, the expansion of
41763 <option>authenticated_sender</option> still happens (and can cause the delivery to be
41764 deferred if it fails), but no AUTH= item is added to MAIL commands
41765 unless <option>authenticated_sender_force</option> is true.
41766 </para>
41767 <para>
41768 This option allows you to use the <command>smtp</command> transport in LMTP mode to
41769 deliver mail to Cyrus IMAP and provide the proper local part as the
41770 <quote>authenticated sender</quote>, via a setting such as:
41771 </para>
41772 <literallayout class="monospaced">
41773 authenticated_sender = $local_part
41774 </literallayout>
41775 <para>
41776 This removes the need for IMAP subfolders to be assigned special ACLs to
41777 allow direct delivery to those subfolders.
41778 </para>
41779 <para>
41780 Because of expected uses such as that just described for Cyrus (when no
41781 domain is involved), there is no checking on the syntax of the provided
41782 value.
41783 </para>
41784 <para>
41785 <indexterm role="option">
41786 <primary><option>authenticated_sender_force</option></primary>
41787 </indexterm>
41788 </para>
41789 <informaltable frame="all">
41790 <tgroup cols="4" colsep="0" rowsep="0">
41791 <colspec colwidth="8*" align="left"/>
41792 <colspec colwidth="6*" align="center"/>
41793 <colspec colwidth="6*" align="center"/>
41794 <colspec colwidth="6*" align="right"/>
41795 <tbody>
41796 <row>
41797 <entry><option>authenticated_sender_force</option></entry>
41798 <entry>Use: <emphasis>smtp</emphasis></entry>
41799 <entry>Type: <emphasis>boolean</emphasis></entry>
41800 <entry>Default: <emphasis>false</emphasis></entry>
41801 </row>
41802 </tbody>
41803 </tgroup>
41804 </informaltable>
41805 <para>
41806 If this option is set true, the <option>authenticated_sender</option> option&#x2019;s value
41807 is used for the AUTH= item on outgoing MAIL commands, even if Exim has not
41808 authenticated as a client.
41809 </para>
41810 <para>
41811 <indexterm role="option">
41812 <primary><option>command_timeout</option></primary>
41813 </indexterm>
41814 </para>
41815 <informaltable frame="all">
41816 <tgroup cols="4" colsep="0" rowsep="0">
41817 <colspec colwidth="8*" align="left"/>
41818 <colspec colwidth="6*" align="center"/>
41819 <colspec colwidth="6*" align="center"/>
41820 <colspec colwidth="6*" align="right"/>
41821 <tbody>
41822 <row>
41823 <entry><option>command_timeout</option></entry>
41824 <entry>Use: <emphasis>smtp</emphasis></entry>
41825 <entry>Type: <emphasis>time</emphasis></entry>
41826 <entry>Default: <emphasis>5m</emphasis></entry>
41827 </row>
41828 </tbody>
41829 </tgroup>
41830 </informaltable>
41831 <para>
41832 This sets a timeout for receiving a response to an SMTP command that has been
41833 sent out. It is also used when waiting for the initial banner line from the
41834 remote host. Its value must not be zero.
41835 </para>
41836 <para>
41837 <indexterm role="option">
41838 <primary><option>connect_timeout</option></primary>
41839 </indexterm>
41840 </para>
41841 <informaltable frame="all">
41842 <tgroup cols="4" colsep="0" rowsep="0">
41843 <colspec colwidth="8*" align="left"/>
41844 <colspec colwidth="6*" align="center"/>
41845 <colspec colwidth="6*" align="center"/>
41846 <colspec colwidth="6*" align="right"/>
41847 <tbody>
41848 <row>
41849 <entry><option>connect_timeout</option></entry>
41850 <entry>Use: <emphasis>smtp</emphasis></entry>
41851 <entry>Type: <emphasis>time</emphasis></entry>
41852 <entry>Default: <emphasis>5m</emphasis></entry>
41853 </row>
41854 </tbody>
41855 </tgroup>
41856 </informaltable>
41857 <para>
41858 This sets a timeout for the <function>connect()</function> function, which sets up a TCP/IP call
41859 to a remote host. A setting of zero allows the system timeout (typically
41860 several minutes) to act. To have any effect, the value of this option must be
41861 less than the system timeout. However, it has been observed that on some
41862 systems there is no system timeout, which is why the default value for this
41863 option is 5 minutes, a value recommended by RFC 1123.
41864 </para>
41865 <para>
41866 <indexterm role="option">
41867 <primary><option>connection_max_messages</option></primary>
41868 </indexterm>
41869 </para>
41870 <informaltable frame="all">
41871 <tgroup cols="4" colsep="0" rowsep="0">
41872 <colspec colwidth="8*" align="left"/>
41873 <colspec colwidth="6*" align="center"/>
41874 <colspec colwidth="6*" align="center"/>
41875 <colspec colwidth="6*" align="right"/>
41876 <tbody>
41877 <row>
41878 <entry><option>connection_max_messages</option></entry>
41879 <entry>Use: <emphasis>smtp</emphasis></entry>
41880 <entry>Type: <emphasis>integer</emphasis></entry>
41881 <entry>Default: <emphasis>500</emphasis></entry>
41882 </row>
41883 </tbody>
41884 </tgroup>
41885 </informaltable>
41886 <para>
41887 <indexterm role="concept">
41888 <primary>SMTP</primary>
41889 <secondary>passed connection</secondary>
41890 </indexterm>
41891 <indexterm role="concept">
41892 <primary>SMTP</primary>
41893 <secondary>multiple deliveries</secondary>
41894 </indexterm>
41895 <indexterm role="concept">
41896 <primary>multiple SMTP deliveries</primary>
41897 </indexterm>
41898 This controls the maximum number of separate message deliveries that are sent
41899 over a single TCP/IP connection. If the value is zero, there is no limit.
41900 For testing purposes, this value can be overridden by the <option>-oB</option> command line
41901 option.
41902 </para>
41903 <para>
41904 <indexterm role="option">
41905 <primary><option>data_timeout</option></primary>
41906 </indexterm>
41907 </para>
41908 <informaltable frame="all">
41909 <tgroup cols="4" colsep="0" rowsep="0">
41910 <colspec colwidth="8*" align="left"/>
41911 <colspec colwidth="6*" align="center"/>
41912 <colspec colwidth="6*" align="center"/>
41913 <colspec colwidth="6*" align="right"/>
41914 <tbody>
41915 <row>
41916 <entry><option>data_timeout</option></entry>
41917 <entry>Use: <emphasis>smtp</emphasis></entry>
41918 <entry>Type: <emphasis>time</emphasis></entry>
41919 <entry>Default: <emphasis>5m</emphasis></entry>
41920 </row>
41921 </tbody>
41922 </tgroup>
41923 </informaltable>
41924 <para>
41925 This sets a timeout for the transmission of each block in the data portion of
41926 the message. As a result, the overall timeout for a message depends on the size
41927 of the message. Its value must not be zero. See also <option>final_timeout</option>.
41928 </para>
41929 <para>
41930 <indexterm role="option">
41931 <primary><option>delay_after_cutoff</option></primary>
41932 </indexterm>
41933 </para>
41934 <informaltable frame="all">
41935 <tgroup cols="4" colsep="0" rowsep="0">
41936 <colspec colwidth="8*" align="left"/>
41937 <colspec colwidth="6*" align="center"/>
41938 <colspec colwidth="6*" align="center"/>
41939 <colspec colwidth="6*" align="right"/>
41940 <tbody>
41941 <row>
41942 <entry><option>delay_after_cutoff</option></entry>
41943 <entry>Use: <emphasis>smtp</emphasis></entry>
41944 <entry>Type: <emphasis>boolean</emphasis></entry>
41945 <entry>Default: <emphasis>true</emphasis></entry>
41946 </row>
41947 </tbody>
41948 </tgroup>
41949 </informaltable>
41950 <para>
41951 This option controls what happens when all remote IP addresses for a given
41952 domain have been inaccessible for so long that they have passed their retry
41953 cutoff times.
41954 </para>
41955 <para>
41956 In the default state, if the next retry time has not been reached for any of
41957 them, the address is bounced without trying any deliveries. In other words,
41958 Exim delays retrying an IP address after the final cutoff time until a new
41959 retry time is reached, and can therefore bounce an address without ever trying
41960 a delivery, when machines have been down for a long time. Some people are
41961 unhappy at this prospect, so...
41962 </para>
41963 <para>
41964 If <option>delay_after_cutoff</option> is set false, Exim behaves differently. If all IP
41965 addresses are past their final cutoff time, Exim tries to deliver to those
41966 IP addresses that have not been tried since the message arrived. If there are
41967 none, of if they all fail, the address is bounced. In other words, it does not
41968 delay when a new message arrives, but immediately tries those expired IP
41969 addresses that haven&#x2019;t been tried since the message arrived. If there is a
41970 continuous stream of messages for the dead hosts, unsetting
41971 <option>delay_after_cutoff</option> means that there will be many more attempts to deliver
41972 to them.
41973 </para>
41974 <para>
41975 <indexterm role="option">
41976 <primary><option>dns_qualify_single</option></primary>
41977 </indexterm>
41978 </para>
41979 <informaltable frame="all">
41980 <tgroup cols="4" colsep="0" rowsep="0">
41981 <colspec colwidth="8*" align="left"/>
41982 <colspec colwidth="6*" align="center"/>
41983 <colspec colwidth="6*" align="center"/>
41984 <colspec colwidth="6*" align="right"/>
41985 <tbody>
41986 <row>
41987 <entry><option>dns_qualify_single</option></entry>
41988 <entry>Use: <emphasis>smtp</emphasis></entry>
41989 <entry>Type: <emphasis>boolean</emphasis></entry>
41990 <entry>Default: <emphasis>true</emphasis></entry>
41991 </row>
41992 </tbody>
41993 </tgroup>
41994 </informaltable>
41995 <para>
41996 If the <option>hosts</option> or <option>fallback_hosts</option> option is being used,
41997 and the <option>gethostbyname</option> option is false,
41998 the RES_DEFNAMES resolver option is set. See the <option>qualify_single</option> option
41999 in chapter <xref linkend="CHAPdnslookup"/> for more details.
42000 </para>
42001 <para>
42002 <indexterm role="option">
42003 <primary><option>dns_search_parents</option></primary>
42004 </indexterm>
42005 </para>
42006 <informaltable frame="all">
42007 <tgroup cols="4" colsep="0" rowsep="0">
42008 <colspec colwidth="8*" align="left"/>
42009 <colspec colwidth="6*" align="center"/>
42010 <colspec colwidth="6*" align="center"/>
42011 <colspec colwidth="6*" align="right"/>
42012 <tbody>
42013 <row>
42014 <entry><option>dns_search_parents</option></entry>
42015 <entry>Use: <emphasis>smtp</emphasis></entry>
42016 <entry>Type: <emphasis>boolean</emphasis></entry>
42017 <entry>Default: <emphasis>false</emphasis></entry>
42018 </row>
42019 </tbody>
42020 </tgroup>
42021 </informaltable>
42022 <para>
42023 If the <option>hosts</option> or <option>fallback_hosts</option> option is being used, and the
42024 <option>gethostbyname</option> option is false, the RES_DNSRCH resolver option is set.
42025 See the <option>search_parents</option> option in chapter <xref linkend="CHAPdnslookup"/> for more
42026 details.
42027 </para>
42028 <para>
42029 <indexterm role="option">
42030 <primary><option>fallback_hosts</option></primary>
42031 </indexterm>
42032 </para>
42033 <informaltable frame="all">
42034 <tgroup cols="4" colsep="0" rowsep="0">
42035 <colspec colwidth="8*" align="left"/>
42036 <colspec colwidth="6*" align="center"/>
42037 <colspec colwidth="6*" align="center"/>
42038 <colspec colwidth="6*" align="right"/>
42039 <tbody>
42040 <row>
42041 <entry><option>fallback_hosts</option></entry>
42042 <entry>Use: <emphasis>smtp</emphasis></entry>
42043 <entry>Type: <emphasis>string list</emphasis></entry>
42044 <entry>Default: <emphasis>unset</emphasis></entry>
42045 </row>
42046 </tbody>
42047 </tgroup>
42048 </informaltable>
42049 <para>
42050 <indexterm role="concept">
42051 <primary>fallback</primary>
42052 <secondary>hosts specified on transport</secondary>
42053 </indexterm>
42054 String expansion is not applied to this option. The argument must be a
42055 colon-separated list of host names or IP addresses, optionally also including
42056 port numbers, though the separator can be changed, as described in section
42057 <xref linkend="SECTlistconstruct"/>. Each individual item in the list is the same as an
42058 item in a <option>route_list</option> setting for the <command>manualroute</command> router, as described
42059 in section <xref linkend="SECTformatonehostitem"/>.
42060 </para>
42061 <para>
42062 Fallback hosts can also be specified on routers, which associate them with the
42063 addresses they process. As for the <option>hosts</option> option without <option>hosts_override</option>,
42064 <option>fallback_hosts</option> specified on the transport is used only if the address does
42065 not have its own associated fallback host list. Unlike <option>hosts</option>, a setting of
42066 <option>fallback_hosts</option> on an address is not overridden by <option>hosts_override</option>.
42067 However, <option>hosts_randomize</option> does apply to fallback host lists.
42068 </para>
42069 <para>
42070 If Exim is unable to deliver to any of the hosts for a particular address, and
42071 the errors are not permanent rejections, the address is put on a separate
42072 transport queue with its host list replaced by the fallback hosts, unless the
42073 address was routed via MX records and the current host was in the original MX
42074 list. In that situation, the fallback host list is not used.
42075 </para>
42076 <para>
42077 Once normal deliveries are complete, the fallback queue is delivered by
42078 re-running the same transports with the new host lists. If several failing
42079 addresses have the same fallback hosts (and <option>max_rcpt</option> permits it), a single
42080 copy of the message is sent.
42081 </para>
42082 <para>
42083 The resolution of the host names on the fallback list is controlled by the
42084 <option>gethostbyname</option> option, as for the <option>hosts</option> option. Fallback hosts apply
42085 both to cases when the host list comes with the address and when it is taken
42086 from <option>hosts</option>. This option provides a <quote>use a smart host only if delivery
42087 fails</quote> facility.
42088 </para>
42089 <para>
42090 <indexterm role="option">
42091 <primary><option>final_timeout</option></primary>
42092 </indexterm>
42093 </para>
42094 <informaltable frame="all">
42095 <tgroup cols="4" colsep="0" rowsep="0">
42096 <colspec colwidth="8*" align="left"/>
42097 <colspec colwidth="6*" align="center"/>
42098 <colspec colwidth="6*" align="center"/>
42099 <colspec colwidth="6*" align="right"/>
42100 <tbody>
42101 <row>
42102 <entry><option>final_timeout</option></entry>
42103 <entry>Use: <emphasis>smtp</emphasis></entry>
42104 <entry>Type: <emphasis>time</emphasis></entry>
42105 <entry>Default: <emphasis>10m</emphasis></entry>
42106 </row>
42107 </tbody>
42108 </tgroup>
42109 </informaltable>
42110 <para>
42111 This is the timeout that applies while waiting for the response to the final
42112 line containing just <quote>.</quote> that terminates a message. Its value must not be
42113 zero.
42114 </para>
42115 <para>
42116 <indexterm role="option">
42117 <primary><option>gethostbyname</option></primary>
42118 </indexterm>
42119 </para>
42120 <informaltable frame="all">
42121 <tgroup cols="4" colsep="0" rowsep="0">
42122 <colspec colwidth="8*" align="left"/>
42123 <colspec colwidth="6*" align="center"/>
42124 <colspec colwidth="6*" align="center"/>
42125 <colspec colwidth="6*" align="right"/>
42126 <tbody>
42127 <row>
42128 <entry><option>gethostbyname</option></entry>
42129 <entry>Use: <emphasis>smtp</emphasis></entry>
42130 <entry>Type: <emphasis>boolean</emphasis></entry>
42131 <entry>Default: <emphasis>false</emphasis></entry>
42132 </row>
42133 </tbody>
42134 </tgroup>
42135 </informaltable>
42136 <para>
42137 If this option is true when the <option>hosts</option> and/or <option>fallback_hosts</option> options are
42138 being used, names are looked up using <function>gethostbyname()</function>
42139 (or <function>getipnodebyname()</function> when available)
42140 instead of using the DNS. Of course, that function may in fact use the DNS, but
42141 it may also consult other sources of information such as <filename>/etc/hosts</filename>.
42142 </para>
42143 <para>
42144 <indexterm role="option">
42145 <primary><option>gnutls_require_kx</option></primary>
42146 </indexterm>
42147 </para>
42148 <informaltable frame="all">
42149 <tgroup cols="4" colsep="0" rowsep="0">
42150 <colspec colwidth="8*" align="left"/>
42151 <colspec colwidth="6*" align="center"/>
42152 <colspec colwidth="6*" align="center"/>
42153 <colspec colwidth="6*" align="right"/>
42154 <tbody>
42155 <row>
42156 <entry><option>gnutls_require_kx</option></entry>
42157 <entry>Use: <emphasis>smtp</emphasis></entry>
42158 <entry>Type: <emphasis>string</emphasis></entry>
42159 <entry>Default: <emphasis>unset</emphasis></entry>
42160 </row>
42161 </tbody>
42162 </tgroup>
42163 </informaltable>
42164 <para>
42165 This option controls the key exchange mechanisms when GnuTLS is used in an Exim
42166 client. For details, see section <xref linkend="SECTreqciphgnu"/>.
42167 </para>
42168 <para>
42169 <indexterm role="option">
42170 <primary><option>gnutls_require_mac</option></primary>
42171 </indexterm>
42172 </para>
42173 <informaltable frame="all">
42174 <tgroup cols="4" colsep="0" rowsep="0">
42175 <colspec colwidth="8*" align="left"/>
42176 <colspec colwidth="6*" align="center"/>
42177 <colspec colwidth="6*" align="center"/>
42178 <colspec colwidth="6*" align="right"/>
42179 <tbody>
42180 <row>
42181 <entry><option>gnutls_require_mac</option></entry>
42182 <entry>Use: <emphasis>smtp</emphasis></entry>
42183 <entry>Type: <emphasis>string</emphasis></entry>
42184 <entry>Default: <emphasis>unset</emphasis></entry>
42185 </row>
42186 </tbody>
42187 </tgroup>
42188 </informaltable>
42189 <para>
42190 This option controls the MAC algorithms when GnuTLS is used in an Exim
42191 client. For details, see section <xref linkend="SECTreqciphgnu"/>.
42192 </para>
42193 <para>
42194 <indexterm role="option">
42195 <primary><option>gnutls_require_protocols</option></primary>
42196 </indexterm>
42197 </para>
42198 <informaltable frame="all">
42199 <tgroup cols="4" colsep="0" rowsep="0">
42200 <colspec colwidth="8*" align="left"/>
42201 <colspec colwidth="6*" align="center"/>
42202 <colspec colwidth="6*" align="center"/>
42203 <colspec colwidth="6*" align="right"/>
42204 <tbody>
42205 <row>
42206 <entry><option>gnutls_require_protocols</option></entry>
42207 <entry>Use: <emphasis>smtp</emphasis></entry>
42208 <entry>Type: <emphasis>string</emphasis></entry>
42209 <entry>Default: <emphasis>unset</emphasis></entry>
42210 </row>
42211 </tbody>
42212 </tgroup>
42213 </informaltable>
42214 <para>
42215 This option controls the protocols when GnuTLS is used in an Exim
42216 client. For details, see section <xref linkend="SECTreqciphgnu"/>.
42217 </para>
42218 <para>
42219 <indexterm role="option">
42220 <primary><option>gnutls_compat_mode</option></primary>
42221 </indexterm>
42222 </para>
42223 <informaltable frame="all">
42224 <tgroup cols="4" colsep="0" rowsep="0">
42225 <colspec colwidth="8*" align="left"/>
42226 <colspec colwidth="6*" align="center"/>
42227 <colspec colwidth="6*" align="center"/>
42228 <colspec colwidth="6*" align="right"/>
42229 <tbody>
42230 <row>
42231 <entry><option>gnutls_compat_mode</option></entry>
42232 <entry>Use: <emphasis>smtp</emphasis></entry>
42233 <entry>Type: <emphasis>boolean</emphasis></entry>
42234 <entry>Default: <emphasis>unset</emphasis></entry>
42235 </row>
42236 </tbody>
42237 </tgroup>
42238 </informaltable>
42239 <para>
42240 This option controls whether GnuTLS is used in compatibility mode in an Exim
42241 server. This reduces security slightly, but improves interworking with older
42242 implementations of TLS.
42243 </para>
42244 <para>
42245 <indexterm role="option">
42246 <primary><option>helo_data</option></primary>
42247 </indexterm>
42248 </para>
42249 <informaltable frame="all">
42250 <tgroup cols="4" colsep="0" rowsep="0">
42251 <colspec colwidth="8*" align="left"/>
42252 <colspec colwidth="6*" align="center"/>
42253 <colspec colwidth="6*" align="center"/>
42254 <colspec colwidth="6*" align="right"/>
42255 <tbody>
42256 <row>
42257 <entry><option>helo_data</option></entry>
42258 <entry>Use: <emphasis>smtp</emphasis></entry>
42259 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
42260 <entry>Default: <emphasis>see below</emphasis></entry>
42261 </row>
42262 </tbody>
42263 </tgroup>
42264 </informaltable>
42265 <para>
42266 <indexterm role="concept">
42267 <primary>HELO</primary>
42268 <secondary>argument, setting</secondary>
42269 </indexterm>
42270 <indexterm role="concept">
42271 <primary>EHLO</primary>
42272 <secondary>argument, setting</secondary>
42273 </indexterm>
42274 <indexterm role="concept">
42275 <primary>LHLO argument setting</primary>
42276 </indexterm>
42277 The value of this option is expanded after a connection to a another host has
42278 been set up. The result is used as the argument for the EHLO, HELO, or LHLO
42279 command that starts the outgoing SMTP or LMTP session. The default value of the
42280 option is:
42281 </para>
42282 <literallayout class="monospaced">
42283 $primary_hostname
42284 </literallayout>
42285 <para>
42286 During the expansion, the variables <varname>$host</varname> and <varname>$host_address</varname> are set to
42287 the identity of the remote host, and the variables <varname>$sending_ip_address</varname> and
42288 <varname>$sending_port</varname> are set to the local IP address and port number that are being
42289 used. These variables can be used to generate different values for different
42290 servers or different local IP addresses. For example, if you want the string
42291 that is used for <option>helo_data</option> to be obtained by a DNS lookup of the outgoing
42292 interface address, you could use this:
42293 </para>
42294 <literallayout class="monospaced">
42295 helo_data = ${lookup dnsdb{ptr=$sending_ip_address}{$value}\
42296   {$primary_hostname}}
42297 </literallayout>
42298 <para>
42299 The use of <option>helo_data</option> applies both to sending messages and when doing
42300 callouts.
42301 </para>
42302 <para>
42303 <indexterm role="option">
42304 <primary><option>hosts</option></primary>
42305 </indexterm>
42306 </para>
42307 <informaltable frame="all">
42308 <tgroup cols="4" colsep="0" rowsep="0">
42309 <colspec colwidth="8*" align="left"/>
42310 <colspec colwidth="6*" align="center"/>
42311 <colspec colwidth="6*" align="center"/>
42312 <colspec colwidth="6*" align="right"/>
42313 <tbody>
42314 <row>
42315 <entry><option>hosts</option></entry>
42316 <entry>Use: <emphasis>smtp</emphasis></entry>
42317 <entry>Type: <emphasis>string list</emphasis>&dagger;<emphasis></emphasis></entry>
42318 <entry>Default: <emphasis>unset</emphasis></entry>
42319 </row>
42320 </tbody>
42321 </tgroup>
42322 </informaltable>
42323 <para>
42324 Hosts are associated with an address by a router such as <command>dnslookup</command>, which
42325 finds the hosts by looking up the address domain in the DNS, or by
42326 <command>manualroute</command>, which has lists of hosts in its configuration. However,
42327 email addresses can be passed to the <command>smtp</command> transport by any router, and not
42328 all of them can provide an associated list of hosts.
42329 </para>
42330 <para>
42331 The <option>hosts</option> option specifies a list of hosts to be used if the address being
42332 processed does not have any hosts associated with it. The hosts specified by
42333 <option>hosts</option> are also used, whether or not the address has its own hosts, if
42334 <option>hosts_override</option> is set.
42335 </para>
42336 <para>
42337 The string is first expanded, before being interpreted as a colon-separated
42338 list of host names or IP addresses, possibly including port numbers. The
42339 separator may be changed to something other than colon, as described in section
42340 <xref linkend="SECTlistconstruct"/>. Each individual item in the list is the same as an
42341 item in a <option>route_list</option> setting for the <command>manualroute</command> router, as described
42342 in section <xref linkend="SECTformatonehostitem"/>. However, note that the <literal>/MX</literal> facility
42343 of the <command>manualroute</command> router is not available here.
42344 </para>
42345 <para>
42346 If the expansion fails, delivery is deferred. Unless the failure was caused by
42347 the inability to complete a lookup, the error is logged to the panic log as
42348 well as the main log. Host names are looked up either by searching directly for
42349 address records in the DNS or by calling <function>gethostbyname()</function> (or
42350 <function>getipnodebyname()</function> when available), depending on the setting of the
42351 <option>gethostbyname</option> option. When Exim is compiled with IPv6 support, if a host
42352 that is looked up in the DNS has both IPv4 and IPv6 addresses, both types of
42353 address are used.
42354 </para>
42355 <para>
42356 During delivery, the hosts are tried in order, subject to their retry status,
42357 unless <option>hosts_randomize</option> is set.
42358 </para>
42359 <para>
42360 <indexterm role="option">
42361 <primary><option>hosts_avoid_esmtp</option></primary>
42362 </indexterm>
42363 </para>
42364 <informaltable frame="all">
42365 <tgroup cols="4" colsep="0" rowsep="0">
42366 <colspec colwidth="8*" align="left"/>
42367 <colspec colwidth="6*" align="center"/>
42368 <colspec colwidth="6*" align="center"/>
42369 <colspec colwidth="6*" align="right"/>
42370 <tbody>
42371 <row>
42372 <entry><option>hosts_avoid_esmtp</option></entry>
42373 <entry>Use: <emphasis>smtp</emphasis></entry>
42374 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
42375 <entry>Default: <emphasis>unset</emphasis></entry>
42376 </row>
42377 </tbody>
42378 </tgroup>
42379 </informaltable>
42380 <para>
42381 <indexterm role="concept">
42382 <primary>ESMTP, avoiding use of</primary>
42383 </indexterm>
42384 <indexterm role="concept">
42385 <primary>HELO</primary>
42386 <secondary>forcing use of</secondary>
42387 </indexterm>
42388 <indexterm role="concept">
42389 <primary>EHLO</primary>
42390 <secondary>avoiding use of</secondary>
42391 </indexterm>
42392 <indexterm role="concept">
42393 <primary>PIPELINING</primary>
42394 <secondary>avoiding the use of</secondary>
42395 </indexterm>
42396 This option is for use with broken hosts that announce ESMTP facilities (for
42397 example, PIPELINING) and then fail to implement them properly. When a host
42398 matches <option>hosts_avoid_esmtp</option>, Exim sends HELO rather than EHLO at the
42399 start of the SMTP session. This means that it cannot use any of the ESMTP
42400 facilities such as AUTH, PIPELINING, SIZE, and STARTTLS.
42401 </para>
42402 <para>
42403 <indexterm role="option">
42404 <primary><option>hosts_avoid_pipelining</option></primary>
42405 </indexterm>
42406 </para>
42407 <informaltable frame="all">
42408 <tgroup cols="4" colsep="0" rowsep="0">
42409 <colspec colwidth="8*" align="left"/>
42410 <colspec colwidth="6*" align="center"/>
42411 <colspec colwidth="6*" align="center"/>
42412 <colspec colwidth="6*" align="right"/>
42413 <tbody>
42414 <row>
42415 <entry><option>hosts_avoid_pipelining</option></entry>
42416 <entry>Use: <emphasis>smtp</emphasis></entry>
42417 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
42418 <entry>Default: <emphasis>unset</emphasis></entry>
42419 </row>
42420 </tbody>
42421 </tgroup>
42422 </informaltable>
42423 <para>
42424 <indexterm role="concept">
42425 <primary>PIPELINING</primary>
42426 <secondary>avoiding the use of</secondary>
42427 </indexterm>
42428 Exim will not use the SMTP PIPELINING extension when delivering to any host
42429 that matches this list, even if the server host advertises PIPELINING support.
42430 </para>
42431 <para>
42432 <indexterm role="option">
42433 <primary><option>hosts_avoid_tls</option></primary>
42434 </indexterm>
42435 </para>
42436 <informaltable frame="all">
42437 <tgroup cols="4" colsep="0" rowsep="0">
42438 <colspec colwidth="8*" align="left"/>
42439 <colspec colwidth="6*" align="center"/>
42440 <colspec colwidth="6*" align="center"/>
42441 <colspec colwidth="6*" align="right"/>
42442 <tbody>
42443 <row>
42444 <entry><option>hosts_avoid_tls</option></entry>
42445 <entry>Use: <emphasis>smtp</emphasis></entry>
42446 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
42447 <entry>Default: <emphasis>unset</emphasis></entry>
42448 </row>
42449 </tbody>
42450 </tgroup>
42451 </informaltable>
42452 <para>
42453 <indexterm role="concept">
42454 <primary>TLS</primary>
42455 <secondary>avoiding for certain hosts</secondary>
42456 </indexterm>
42457 Exim will not try to start a TLS session when delivering to any host that
42458 matches this list. See chapter <xref linkend="CHAPTLS"/> for details of TLS.
42459 </para>
42460 <para>
42461 <indexterm role="option">
42462 <primary><option>hosts_max_try</option></primary>
42463 </indexterm>
42464 </para>
42465 <informaltable frame="all">
42466 <tgroup cols="4" colsep="0" rowsep="0">
42467 <colspec colwidth="8*" align="left"/>
42468 <colspec colwidth="6*" align="center"/>
42469 <colspec colwidth="6*" align="center"/>
42470 <colspec colwidth="6*" align="right"/>
42471 <tbody>
42472 <row>
42473 <entry><option>hosts_max_try</option></entry>
42474 <entry>Use: <emphasis>smtp</emphasis></entry>
42475 <entry>Type: <emphasis>integer</emphasis></entry>
42476 <entry>Default: <emphasis>5</emphasis></entry>
42477 </row>
42478 </tbody>
42479 </tgroup>
42480 </informaltable>
42481 <para>
42482 <indexterm role="concept">
42483 <primary>host</primary>
42484 <secondary>maximum number to try</secondary>
42485 </indexterm>
42486 <indexterm role="concept">
42487 <primary>limit</primary>
42488 <secondary>number of hosts tried</secondary>
42489 </indexterm>
42490 <indexterm role="concept">
42491 <primary>limit</primary>
42492 <secondary>number of MX tried</secondary>
42493 </indexterm>
42494 <indexterm role="concept">
42495 <primary>MX record</primary>
42496 <secondary>maximum tried</secondary>
42497 </indexterm>
42498 This option limits the number of IP addresses that are tried for any one
42499 delivery in cases where there are temporary delivery errors. Section
42500 <xref linkend="SECTvalhosmax"/> describes in detail how the value of this option is used.
42501 </para>
42502 <para>
42503 <indexterm role="option">
42504 <primary><option>hosts_max_try_hardlimit</option></primary>
42505 </indexterm>
42506 </para>
42507 <informaltable frame="all">
42508 <tgroup cols="4" colsep="0" rowsep="0">
42509 <colspec colwidth="8*" align="left"/>
42510 <colspec colwidth="6*" align="center"/>
42511 <colspec colwidth="6*" align="center"/>
42512 <colspec colwidth="6*" align="right"/>
42513 <tbody>
42514 <row>
42515 <entry><option>hosts_max_try_hardlimit</option></entry>
42516 <entry>Use: <emphasis>smtp</emphasis></entry>
42517 <entry>Type: <emphasis>integer</emphasis></entry>
42518 <entry>Default: <emphasis>50</emphasis></entry>
42519 </row>
42520 </tbody>
42521 </tgroup>
42522 </informaltable>
42523 <para>
42524 This is an additional check on the maximum number of IP addresses that Exim
42525 tries for any one delivery. Section <xref linkend="SECTvalhosmax"/> describes its use and
42526 why it exists.
42527 </para>
42528 <para>
42529 <indexterm role="option">
42530 <primary><option>hosts_nopass_tls</option></primary>
42531 </indexterm>
42532 </para>
42533 <informaltable frame="all">
42534 <tgroup cols="4" colsep="0" rowsep="0">
42535 <colspec colwidth="8*" align="left"/>
42536 <colspec colwidth="6*" align="center"/>
42537 <colspec colwidth="6*" align="center"/>
42538 <colspec colwidth="6*" align="right"/>
42539 <tbody>
42540 <row>
42541 <entry><option>hosts_nopass_tls</option></entry>
42542 <entry>Use: <emphasis>smtp</emphasis></entry>
42543 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
42544 <entry>Default: <emphasis>unset</emphasis></entry>
42545 </row>
42546 </tbody>
42547 </tgroup>
42548 </informaltable>
42549 <para>
42550 <indexterm role="concept">
42551 <primary>TLS</primary>
42552 <secondary>passing connection</secondary>
42553 </indexterm>
42554 <indexterm role="concept">
42555 <primary>multiple SMTP deliveries</primary>
42556 </indexterm>
42557 <indexterm role="concept">
42558 <primary>TLS</primary>
42559 <secondary>multiple message deliveries</secondary>
42560 </indexterm>
42561 For any host that matches this list, a connection on which a TLS session has
42562 been started will not be passed to a new delivery process for sending another
42563 message on the same connection. See section <xref linkend="SECTmulmessam"/> for an
42564 explanation of when this might be needed.
42565 </para>
42566 <para>
42567 <indexterm role="option">
42568 <primary><option>hosts_override</option></primary>
42569 </indexterm>
42570 </para>
42571 <informaltable frame="all">
42572 <tgroup cols="4" colsep="0" rowsep="0">
42573 <colspec colwidth="8*" align="left"/>
42574 <colspec colwidth="6*" align="center"/>
42575 <colspec colwidth="6*" align="center"/>
42576 <colspec colwidth="6*" align="right"/>
42577 <tbody>
42578 <row>
42579 <entry><option>hosts_override</option></entry>
42580 <entry>Use: <emphasis>smtp</emphasis></entry>
42581 <entry>Type: <emphasis>boolean</emphasis></entry>
42582 <entry>Default: <emphasis>false</emphasis></entry>
42583 </row>
42584 </tbody>
42585 </tgroup>
42586 </informaltable>
42587 <para>
42588 If this option is set and the <option>hosts</option> option is also set, any hosts that are
42589 attached to the address are ignored, and instead the hosts specified by the
42590 <option>hosts</option> option are always used. This option does not apply to
42591 <option>fallback_hosts</option>.
42592 </para>
42593 <para>
42594 <indexterm role="option">
42595 <primary><option>hosts_randomize</option></primary>
42596 </indexterm>
42597 </para>
42598 <informaltable frame="all">
42599 <tgroup cols="4" colsep="0" rowsep="0">
42600 <colspec colwidth="8*" align="left"/>
42601 <colspec colwidth="6*" align="center"/>
42602 <colspec colwidth="6*" align="center"/>
42603 <colspec colwidth="6*" align="right"/>
42604 <tbody>
42605 <row>
42606 <entry><option>hosts_randomize</option></entry>
42607 <entry>Use: <emphasis>smtp</emphasis></entry>
42608 <entry>Type: <emphasis>boolean</emphasis></entry>
42609 <entry>Default: <emphasis>false</emphasis></entry>
42610 </row>
42611 </tbody>
42612 </tgroup>
42613 </informaltable>
42614 <para>
42615 <indexterm role="concept">
42616 <primary>randomized host list</primary>
42617 </indexterm>
42618 <indexterm role="concept">
42619 <primary>host</primary>
42620 <secondary>list of; randomized</secondary>
42621 </indexterm>
42622 <indexterm role="concept">
42623 <primary>fallback</primary>
42624 <secondary>randomized hosts</secondary>
42625 </indexterm>
42626 If this option is set, and either the list of hosts is taken from the
42627 <option>hosts</option> or the <option>fallback_hosts</option> option, or the hosts supplied by the router
42628 were not obtained from MX records (this includes fallback hosts from the
42629 router), and were not randomized by the router, the order of trying the hosts
42630 is randomized each time the transport runs. Randomizing the order of a host
42631 list can be used to do crude load sharing.
42632 </para>
42633 <para>
42634 When <option>hosts_randomize</option> is true, a host list may be split into groups whose
42635 order is separately randomized. This makes it possible to set up MX-like
42636 behaviour. The boundaries between groups are indicated by an item that is just
42637 <literal>+</literal> in the host list. For example:
42638 </para>
42639 <literallayout class="monospaced">
42640 hosts = host1:host2:host3:+:host4:host5
42641 </literallayout>
42642 <para>
42643 The order of the first three hosts and the order of the last two hosts is
42644 randomized for each use, but the first three always end up before the last two.
42645 If <option>hosts_randomize</option> is not set, a <literal>+</literal> item in the list is ignored.
42646 </para>
42647 <para>
42648 <indexterm role="option">
42649 <primary><option>hosts_require_auth</option></primary>
42650 </indexterm>
42651 </para>
42652 <informaltable frame="all">
42653 <tgroup cols="4" colsep="0" rowsep="0">
42654 <colspec colwidth="8*" align="left"/>
42655 <colspec colwidth="6*" align="center"/>
42656 <colspec colwidth="6*" align="center"/>
42657 <colspec colwidth="6*" align="right"/>
42658 <tbody>
42659 <row>
42660 <entry><option>hosts_require_auth</option></entry>
42661 <entry>Use: <emphasis>smtp</emphasis></entry>
42662 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
42663 <entry>Default: <emphasis>unset</emphasis></entry>
42664 </row>
42665 </tbody>
42666 </tgroup>
42667 </informaltable>
42668 <para>
42669 <indexterm role="concept">
42670 <primary>authentication</primary>
42671 <secondary>required by client</secondary>
42672 </indexterm>
42673 This option provides a list of servers for which authentication must succeed
42674 before Exim will try to transfer a message. If authentication fails for
42675 servers which are not in this list, Exim tries to send unauthenticated. If
42676 authentication fails for one of these servers, delivery is deferred. This
42677 temporary error is detectable in the retry rules, so it can be turned into a
42678 hard failure if required. See also <option>hosts_try_auth</option>, and chapter
42679 <xref linkend="CHAPSMTPAUTH"/> for details of authentication.
42680 </para>
42681 <para>
42682 <indexterm role="option">
42683 <primary><option>hosts_require_tls</option></primary>
42684 </indexterm>
42685 </para>
42686 <informaltable frame="all">
42687 <tgroup cols="4" colsep="0" rowsep="0">
42688 <colspec colwidth="8*" align="left"/>
42689 <colspec colwidth="6*" align="center"/>
42690 <colspec colwidth="6*" align="center"/>
42691 <colspec colwidth="6*" align="right"/>
42692 <tbody>
42693 <row>
42694 <entry><option>hosts_require_tls</option></entry>
42695 <entry>Use: <emphasis>smtp</emphasis></entry>
42696 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
42697 <entry>Default: <emphasis>unset</emphasis></entry>
42698 </row>
42699 </tbody>
42700 </tgroup>
42701 </informaltable>
42702 <para>
42703 <indexterm role="concept">
42704 <primary>TLS</primary>
42705 <secondary>requiring for certain servers</secondary>
42706 </indexterm>
42707 Exim will insist on using a TLS session when delivering to any host that
42708 matches this list. See chapter <xref linkend="CHAPTLS"/> for details of TLS.
42709 <emphasis role="bold">Note</emphasis>: This option affects outgoing mail only. To insist on TLS for
42710 incoming messages, use an appropriate ACL.
42711 </para>
42712 <para>
42713 <indexterm role="option">
42714 <primary><option>hosts_try_auth</option></primary>
42715 </indexterm>
42716 </para>
42717 <informaltable frame="all">
42718 <tgroup cols="4" colsep="0" rowsep="0">
42719 <colspec colwidth="8*" align="left"/>
42720 <colspec colwidth="6*" align="center"/>
42721 <colspec colwidth="6*" align="center"/>
42722 <colspec colwidth="6*" align="right"/>
42723 <tbody>
42724 <row>
42725 <entry><option>hosts_try_auth</option></entry>
42726 <entry>Use: <emphasis>smtp</emphasis></entry>
42727 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
42728 <entry>Default: <emphasis>unset</emphasis></entry>
42729 </row>
42730 </tbody>
42731 </tgroup>
42732 </informaltable>
42733 <para>
42734 <indexterm role="concept">
42735 <primary>authentication</primary>
42736 <secondary>optional in client</secondary>
42737 </indexterm>
42738 This option provides a list of servers to which, provided they announce
42739 authentication support, Exim will attempt to authenticate as a client when it
42740 connects. If authentication fails, Exim will try to transfer the message
42741 unauthenticated. See also <option>hosts_require_auth</option>, and chapter
42742 <xref linkend="CHAPSMTPAUTH"/> for details of authentication.
42743 </para>
42744 <para>
42745 <indexterm role="option">
42746 <primary><option>interface</option></primary>
42747 </indexterm>
42748 </para>
42749 <informaltable frame="all">
42750 <tgroup cols="4" colsep="0" rowsep="0">
42751 <colspec colwidth="8*" align="left"/>
42752 <colspec colwidth="6*" align="center"/>
42753 <colspec colwidth="6*" align="center"/>
42754 <colspec colwidth="6*" align="right"/>
42755 <tbody>
42756 <row>
42757 <entry><option>interface</option></entry>
42758 <entry>Use: <emphasis>smtp</emphasis></entry>
42759 <entry>Type: <emphasis>string list</emphasis>&dagger;<emphasis></emphasis></entry>
42760 <entry>Default: <emphasis>unset</emphasis></entry>
42761 </row>
42762 </tbody>
42763 </tgroup>
42764 </informaltable>
42765 <para>
42766 <indexterm role="concept">
42767 <primary>bind IP address</primary>
42768 </indexterm>
42769 <indexterm role="concept">
42770 <primary>IP address</primary>
42771 <secondary>binding</secondary>
42772 </indexterm>
42773 <indexterm role="variable">
42774 <primary><varname>$host</varname></primary>
42775 </indexterm>
42776 <indexterm role="variable">
42777 <primary><varname>$host_address</varname></primary>
42778 </indexterm>
42779 This option specifies which interface to bind to when making an outgoing SMTP
42780 call. The value is an IP address, not an interface name such as
42781 <literal>eth0</literal>. Do not confuse this with the interface address that was used when a
42782 message was received, which is in <varname>$received_ip_address</varname>, formerly known as
42783 <varname>$interface_address</varname>. The name was changed to minimize confusion with the
42784 outgoing interface address. There is no variable that contains an outgoing
42785 interface address because, unless it is set by this option, its value is
42786 unknown.
42787 </para>
42788 <para>
42789 During the expansion of the <option>interface</option> option the variables <varname>$host</varname> and
42790 <varname>$host_address</varname> refer to the host to which a connection is about to be made
42791 during the expansion of the string. Forced expansion failure, or an empty
42792 string result causes the option to be ignored. Otherwise, after expansion, the
42793 string must be a list of IP addresses, colon-separated by default, but the
42794 separator can be changed in the usual way. For example:
42795 </para>
42796 <literallayout class="monospaced">
42797 interface = &lt;; 192.168.123.123 ; 3ffe:ffff:836f::fe86:a061
42798 </literallayout>
42799 <para>
42800 The first interface of the correct type (IPv4 or IPv6) is used for the outgoing
42801 connection. If none of them are the correct type, the option is ignored. If
42802 <option>interface</option> is not set, or is ignored, the system&#x2019;s IP functions choose which
42803 interface to use if the host has more than one.
42804 </para>
42805 <para>
42806 <indexterm role="option">
42807 <primary><option>keepalive</option></primary>
42808 </indexterm>
42809 </para>
42810 <informaltable frame="all">
42811 <tgroup cols="4" colsep="0" rowsep="0">
42812 <colspec colwidth="8*" align="left"/>
42813 <colspec colwidth="6*" align="center"/>
42814 <colspec colwidth="6*" align="center"/>
42815 <colspec colwidth="6*" align="right"/>
42816 <tbody>
42817 <row>
42818 <entry><option>keepalive</option></entry>
42819 <entry>Use: <emphasis>smtp</emphasis></entry>
42820 <entry>Type: <emphasis>boolean</emphasis></entry>
42821 <entry>Default: <emphasis>true</emphasis></entry>
42822 </row>
42823 </tbody>
42824 </tgroup>
42825 </informaltable>
42826 <para>
42827 <indexterm role="concept">
42828 <primary>keepalive</primary>
42829 <secondary>on outgoing connection</secondary>
42830 </indexterm>
42831 This option controls the setting of SO_KEEPALIVE on outgoing TCP/IP socket
42832 connections. When set, it causes the kernel to probe idle connections
42833 periodically, by sending packets with <quote>old</quote> sequence numbers. The other end
42834 of the connection should send a acknowledgment if the connection is still okay
42835 or a reset if the connection has been aborted. The reason for doing this is
42836 that it has the beneficial effect of freeing up certain types of connection
42837 that can get stuck when the remote host is disconnected without tidying up the
42838 TCP/IP call properly. The keepalive mechanism takes several hours to detect
42839 unreachable hosts.
42840 </para>
42841 <para>
42842 <indexterm role="option">
42843 <primary><option>lmtp_ignore_quota</option></primary>
42844 </indexterm>
42845 </para>
42846 <informaltable frame="all">
42847 <tgroup cols="4" colsep="0" rowsep="0">
42848 <colspec colwidth="8*" align="left"/>
42849 <colspec colwidth="6*" align="center"/>
42850 <colspec colwidth="6*" align="center"/>
42851 <colspec colwidth="6*" align="right"/>
42852 <tbody>
42853 <row>
42854 <entry><option>lmtp_ignore_quota</option></entry>
42855 <entry>Use: <emphasis>smtp</emphasis></entry>
42856 <entry>Type: <emphasis>boolean</emphasis></entry>
42857 <entry>Default: <emphasis>false</emphasis></entry>
42858 </row>
42859 </tbody>
42860 </tgroup>
42861 </informaltable>
42862 <para>
42863 <indexterm role="concept">
42864 <primary>LMTP</primary>
42865 <secondary>ignoring quota errors</secondary>
42866 </indexterm>
42867 If this option is set true when the <option>protocol</option> option is set to <quote>lmtp</quote>, the
42868 string <literal>IGNOREQUOTA</literal> is added to RCPT commands, provided that the LMTP server
42869 has advertised support for IGNOREQUOTA in its response to the LHLO command.
42870 </para>
42871 <para>
42872 <indexterm role="option">
42873 <primary><option>max_rcpt</option></primary>
42874 </indexterm>
42875 </para>
42876 <informaltable frame="all">
42877 <tgroup cols="4" colsep="0" rowsep="0">
42878 <colspec colwidth="8*" align="left"/>
42879 <colspec colwidth="6*" align="center"/>
42880 <colspec colwidth="6*" align="center"/>
42881 <colspec colwidth="6*" align="right"/>
42882 <tbody>
42883 <row>
42884 <entry><option>max_rcpt</option></entry>
42885 <entry>Use: <emphasis>smtp</emphasis></entry>
42886 <entry>Type: <emphasis>integer</emphasis></entry>
42887 <entry>Default: <emphasis>100</emphasis></entry>
42888 </row>
42889 </tbody>
42890 </tgroup>
42891 </informaltable>
42892 <para>
42893 <indexterm role="concept">
42894 <primary>RCPT</primary>
42895 <secondary>maximum number of outgoing</secondary>
42896 </indexterm>
42897 This option limits the number of RCPT commands that are sent in a single
42898 SMTP message transaction. Each set of addresses is treated independently, and
42899 so can cause parallel connections to the same host if <option>remote_max_parallel</option>
42900 permits this.
42901 </para>
42902 <para>
42903 <indexterm role="option">
42904 <primary><option>multi_domain</option></primary>
42905 </indexterm>
42906 </para>
42907 <informaltable frame="all">
42908 <tgroup cols="4" colsep="0" rowsep="0">
42909 <colspec colwidth="8*" align="left"/>
42910 <colspec colwidth="6*" align="center"/>
42911 <colspec colwidth="6*" align="center"/>
42912 <colspec colwidth="6*" align="right"/>
42913 <tbody>
42914 <row>
42915 <entry><option>multi_domain</option></entry>
42916 <entry>Use: <emphasis>smtp</emphasis></entry>
42917 <entry>Type: <emphasis>boolean</emphasis></entry>
42918 <entry>Default: <emphasis>true</emphasis></entry>
42919 </row>
42920 </tbody>
42921 </tgroup>
42922 </informaltable>
42923 <para>
42924 <indexterm role="variable">
42925 <primary><varname>$domain</varname></primary>
42926 </indexterm>
42927 When this option is set, the <command>smtp</command> transport can handle a number of
42928 addresses containing a mixture of different domains provided they all resolve
42929 to the same list of hosts. Turning the option off restricts the transport to
42930 handling only one domain at a time. This is useful if you want to use
42931 <varname>$domain</varname> in an expansion for the transport, because it is set only when there
42932 is a single domain involved in a remote delivery.
42933 </para>
42934 <para>
42935 <indexterm role="option">
42936 <primary><option>port</option></primary>
42937 </indexterm>
42938 </para>
42939 <informaltable frame="all">
42940 <tgroup cols="4" colsep="0" rowsep="0">
42941 <colspec colwidth="8*" align="left"/>
42942 <colspec colwidth="6*" align="center"/>
42943 <colspec colwidth="6*" align="center"/>
42944 <colspec colwidth="6*" align="right"/>
42945 <tbody>
42946 <row>
42947 <entry><option>port</option></entry>
42948 <entry>Use: <emphasis>smtp</emphasis></entry>
42949 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
42950 <entry>Default: <emphasis>see below</emphasis></entry>
42951 </row>
42952 </tbody>
42953 </tgroup>
42954 </informaltable>
42955 <para>
42956 <indexterm role="concept">
42957 <primary>port</primary>
42958 <secondary>sending TCP/IP</secondary>
42959 </indexterm>
42960 <indexterm role="concept">
42961 <primary>TCP/IP</primary>
42962 <secondary>setting outgoing port</secondary>
42963 </indexterm>
42964 This option specifies the TCP/IP port on the server to which Exim connects.
42965 <emphasis role="bold">Note:</emphasis> Do not confuse this with the port that was used when a message was
42966 received, which is in <varname>$received_port</varname>, formerly known as <varname>$interface_port</varname>.
42967 The name was changed to minimize confusion with the outgoing port. There is no
42968 variable that contains an outgoing port.
42969 </para>
42970 <para>
42971 If the value of this option begins with a digit it is taken as a port number;
42972 otherwise it is looked up using <function>getservbyname()</function>. The default value is
42973 normally <quote>smtp</quote>, but if <option>protocol</option> is set to <quote>lmtp</quote>, the default is
42974 <quote>lmtp</quote>. If the expansion fails, or if a port number cannot be found, delivery
42975 is deferred.
42976 </para>
42977 <para>
42978 <indexterm role="option">
42979 <primary><option>protocol</option></primary>
42980 </indexterm>
42981 </para>
42982 <informaltable frame="all">
42983 <tgroup cols="4" colsep="0" rowsep="0">
42984 <colspec colwidth="8*" align="left"/>
42985 <colspec colwidth="6*" align="center"/>
42986 <colspec colwidth="6*" align="center"/>
42987 <colspec colwidth="6*" align="right"/>
42988 <tbody>
42989 <row>
42990 <entry><option>protocol</option></entry>
42991 <entry>Use: <emphasis>smtp</emphasis></entry>
42992 <entry>Type: <emphasis>string</emphasis></entry>
42993 <entry>Default: <emphasis>smtp</emphasis></entry>
42994 </row>
42995 </tbody>
42996 </tgroup>
42997 </informaltable>
42998 <para>
42999 <indexterm role="concept">
43000 <primary>LMTP</primary>
43001 <secondary>over TCP/IP</secondary>
43002 </indexterm>
43003 If this option is set to <quote>lmtp</quote> instead of <quote>smtp</quote>, the default value for
43004 the <option>port</option> option changes to <quote>lmtp</quote>, and the transport operates the LMTP
43005 protocol (RFC 2033) instead of SMTP. This protocol is sometimes used for local
43006 deliveries into closed message stores. Exim also has support for running LMTP
43007 over a pipe to a local process &ndash; see chapter <xref linkend="CHAPLMTP"/>.
43008 </para>
43009 <para>
43010 <indexterm role="option">
43011 <primary><option>retry_include_ip_address</option></primary>
43012 </indexterm>
43013 </para>
43014 <informaltable frame="all">
43015 <tgroup cols="4" colsep="0" rowsep="0">
43016 <colspec colwidth="8*" align="left"/>
43017 <colspec colwidth="6*" align="center"/>
43018 <colspec colwidth="6*" align="center"/>
43019 <colspec colwidth="6*" align="right"/>
43020 <tbody>
43021 <row>
43022 <entry><option>retry_include_ip_address</option></entry>
43023 <entry>Use: <emphasis>smtp</emphasis></entry>
43024 <entry>Type: <emphasis>boolean</emphasis></entry>
43025 <entry>Default: <emphasis>true</emphasis></entry>
43026 </row>
43027 </tbody>
43028 </tgroup>
43029 </informaltable>
43030 <para>
43031 Exim normally includes both the host name and the IP address in the key it
43032 constructs for indexing retry data after a temporary delivery failure. This
43033 means that when one of several IP addresses for a host is failing, it gets
43034 tried periodically (controlled by the retry rules), but use of the other IP
43035 addresses is not affected.
43036 </para>
43037 <para>
43038 However, in some dialup environments hosts are assigned a different IP address
43039 each time they connect. In this situation the use of the IP address as part of
43040 the retry key leads to undesirable behaviour. Setting this option false causes
43041 Exim to use only the host name. This should normally be done on a separate
43042 instance of the <command>smtp</command> transport, set up specially to handle the dialup
43043 hosts.
43044 </para>
43045 <para>
43046 <indexterm role="option">
43047 <primary><option>serialize_hosts</option></primary>
43048 </indexterm>
43049 </para>
43050 <informaltable frame="all">
43051 <tgroup cols="4" colsep="0" rowsep="0">
43052 <colspec colwidth="8*" align="left"/>
43053 <colspec colwidth="6*" align="center"/>
43054 <colspec colwidth="6*" align="center"/>
43055 <colspec colwidth="6*" align="right"/>
43056 <tbody>
43057 <row>
43058 <entry><option>serialize_hosts</option></entry>
43059 <entry>Use: <emphasis>smtp</emphasis></entry>
43060 <entry>Type: <emphasis>host list</emphasis>&dagger;<emphasis></emphasis></entry>
43061 <entry>Default: <emphasis>unset</emphasis></entry>
43062 </row>
43063 </tbody>
43064 </tgroup>
43065 </informaltable>
43066 <para>
43067 <indexterm role="concept">
43068 <primary>serializing connections</primary>
43069 </indexterm>
43070 <indexterm role="concept">
43071 <primary>host</primary>
43072 <secondary>serializing connections</secondary>
43073 </indexterm>
43074 Because Exim operates in a distributed manner, if several messages for the same
43075 host arrive at around the same time, more than one simultaneous connection to
43076 the remote host can occur. This is not usually a problem except when there is a
43077 slow link between the hosts. In that situation it may be helpful to restrict
43078 Exim to one connection at a time. This can be done by setting
43079 <option>serialize_hosts</option> to match the relevant hosts.
43080 </para>
43081 <para>
43082 <indexterm role="concept">
43083 <primary>hints database</primary>
43084 <secondary>serializing deliveries to a host</secondary>
43085 </indexterm>
43086 Exim implements serialization by means of a hints database in which a record is
43087 written whenever a process connects to one of the restricted hosts. The record
43088 is deleted when the connection is completed. Obviously there is scope for
43089 records to get left lying around if there is a system or program crash. To
43090 guard against this, Exim ignores any records that are more than six hours old.
43091 </para>
43092 <para>
43093 If you set up this kind of serialization, you should also arrange to delete the
43094 relevant hints database whenever your system reboots. The names of the files
43095 start with <filename>misc</filename> and they are kept in the <filename>spool/db</filename> directory. There
43096 may be one or two files, depending on the type of DBM in use. The same files
43097 are used for ETRN serialization.
43098 </para>
43099 <para>
43100 <indexterm role="option">
43101 <primary><option>size_addition</option></primary>
43102 </indexterm>
43103 </para>
43104 <informaltable frame="all">
43105 <tgroup cols="4" colsep="0" rowsep="0">
43106 <colspec colwidth="8*" align="left"/>
43107 <colspec colwidth="6*" align="center"/>
43108 <colspec colwidth="6*" align="center"/>
43109 <colspec colwidth="6*" align="right"/>
43110 <tbody>
43111 <row>
43112 <entry><option>size_addition</option></entry>
43113 <entry>Use: <emphasis>smtp</emphasis></entry>
43114 <entry>Type: <emphasis>integer</emphasis></entry>
43115 <entry>Default: <emphasis>1024</emphasis></entry>
43116 </row>
43117 </tbody>
43118 </tgroup>
43119 </informaltable>
43120 <para>
43121 <indexterm role="concept">
43122 <primary>SMTP</primary>
43123 <secondary>SIZE</secondary>
43124 </indexterm>
43125 <indexterm role="concept">
43126 <primary>message</primary>
43127 <secondary>size issue for transport filter</secondary>
43128 </indexterm>
43129 <indexterm role="concept">
43130 <primary>size</primary>
43131 <secondary>of message</secondary>
43132 </indexterm>
43133 <indexterm role="concept">
43134 <primary>transport</primary>
43135 <secondary>filter</secondary>
43136 </indexterm>
43137 <indexterm role="concept">
43138 <primary>filter</primary>
43139 <secondary>transport filter</secondary>
43140 </indexterm>
43141 If a remote SMTP server indicates that it supports the SIZE option of the
43142 MAIL command, Exim uses this to pass over the message size at the start of
43143 an SMTP transaction. It adds the value of <option>size_addition</option> to the value it
43144 sends, to allow for headers and other text that may be added during delivery by
43145 configuration options or in a transport filter. It may be necessary to increase
43146 this if a lot of text is added to messages.
43147 </para>
43148 <para>
43149 Alternatively, if the value of <option>size_addition</option> is set negative, it disables
43150 the use of the SIZE option altogether.
43151 </para>
43152 <para>
43153 <indexterm role="option">
43154 <primary><option>tls_certificate</option></primary>
43155 </indexterm>
43156 </para>
43157 <informaltable frame="all">
43158 <tgroup cols="4" colsep="0" rowsep="0">
43159 <colspec colwidth="8*" align="left"/>
43160 <colspec colwidth="6*" align="center"/>
43161 <colspec colwidth="6*" align="center"/>
43162 <colspec colwidth="6*" align="right"/>
43163 <tbody>
43164 <row>
43165 <entry><option>tls_certificate</option></entry>
43166 <entry>Use: <emphasis>smtp</emphasis></entry>
43167 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
43168 <entry>Default: <emphasis>unset</emphasis></entry>
43169 </row>
43170 </tbody>
43171 </tgroup>
43172 </informaltable>
43173 <para>
43174 <indexterm role="concept">
43175 <primary>TLS</primary>
43176 <secondary>client certificate, location of</secondary>
43177 </indexterm>
43178 <indexterm role="concept">
43179 <primary>certificate</primary>
43180 <secondary>client, location of</secondary>
43181 </indexterm>
43182 <indexterm role="variable">
43183 <primary><varname>$host</varname></primary>
43184 </indexterm>
43185 <indexterm role="variable">
43186 <primary><varname>$host_address</varname></primary>
43187 </indexterm>
43188 The value of this option must be the absolute path to a file which contains the
43189 client&#x2019;s certificate, for possible use when sending a message over an encrypted
43190 connection. The values of <varname>$host</varname> and <varname>$host_address</varname> are set to the name and
43191 address of the server during the expansion. See chapter <xref linkend="CHAPTLS"/> for
43192 details of TLS.
43193 </para>
43194 <para>
43195 <emphasis role="bold">Note</emphasis>: This option must be set if you want Exim to be able to use a TLS
43196 certificate when sending messages as a client. The global option of the same
43197 name specifies the certificate for Exim as a server; it is not automatically
43198 assumed that the same certificate should be used when Exim is operating as a
43199 client.
43200 </para>
43201 <para>
43202 <indexterm role="option">
43203 <primary><option>tls_crl</option></primary>
43204 </indexterm>
43205 </para>
43206 <informaltable frame="all">
43207 <tgroup cols="4" colsep="0" rowsep="0">
43208 <colspec colwidth="8*" align="left"/>
43209 <colspec colwidth="6*" align="center"/>
43210 <colspec colwidth="6*" align="center"/>
43211 <colspec colwidth="6*" align="right"/>
43212 <tbody>
43213 <row>
43214 <entry><option>tls_crl</option></entry>
43215 <entry>Use: <emphasis>smtp</emphasis></entry>
43216 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
43217 <entry>Default: <emphasis>unset</emphasis></entry>
43218 </row>
43219 </tbody>
43220 </tgroup>
43221 </informaltable>
43222 <para>
43223 <indexterm role="concept">
43224 <primary>TLS</primary>
43225 <secondary>client certificate revocation list</secondary>
43226 </indexterm>
43227 <indexterm role="concept">
43228 <primary>certificate</primary>
43229 <secondary>revocation list for client</secondary>
43230 </indexterm>
43231 This option specifies a certificate revocation list. The expanded value must
43232 be the name of a file that contains a CRL in PEM format.
43233 </para>
43234 <para>
43235 <indexterm role="option">
43236 <primary><option>tls_privatekey</option></primary>
43237 </indexterm>
43238 </para>
43239 <informaltable frame="all">
43240 <tgroup cols="4" colsep="0" rowsep="0">
43241 <colspec colwidth="8*" align="left"/>
43242 <colspec colwidth="6*" align="center"/>
43243 <colspec colwidth="6*" align="center"/>
43244 <colspec colwidth="6*" align="right"/>
43245 <tbody>
43246 <row>
43247 <entry><option>tls_privatekey</option></entry>
43248 <entry>Use: <emphasis>smtp</emphasis></entry>
43249 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
43250 <entry>Default: <emphasis>unset</emphasis></entry>
43251 </row>
43252 </tbody>
43253 </tgroup>
43254 </informaltable>
43255 <para>
43256 <indexterm role="concept">
43257 <primary>TLS</primary>
43258 <secondary>client private key, location of</secondary>
43259 </indexterm>
43260 <indexterm role="variable">
43261 <primary><varname>$host</varname></primary>
43262 </indexterm>
43263 <indexterm role="variable">
43264 <primary><varname>$host_address</varname></primary>
43265 </indexterm>
43266 The value of this option must be the absolute path to a file which contains the
43267 client&#x2019;s private key. This is used when sending a message over an encrypted
43268 connection using a client certificate. The values of <varname>$host</varname> and
43269 <varname>$host_address</varname> are set to the name and address of the server during the
43270 expansion. If this option is unset, or the expansion is forced to fail, or the
43271 result is an empty string, the private key is assumed to be in the same file as
43272 the certificate. See chapter <xref linkend="CHAPTLS"/> for details of TLS.
43273 </para>
43274 <para>
43275 <indexterm role="option">
43276 <primary><option>tls_require_ciphers</option></primary>
43277 </indexterm>
43278 </para>
43279 <informaltable frame="all">
43280 <tgroup cols="4" colsep="0" rowsep="0">
43281 <colspec colwidth="8*" align="left"/>
43282 <colspec colwidth="6*" align="center"/>
43283 <colspec colwidth="6*" align="center"/>
43284 <colspec colwidth="6*" align="right"/>
43285 <tbody>
43286 <row>
43287 <entry><option>tls_require_ciphers</option></entry>
43288 <entry>Use: <emphasis>smtp</emphasis></entry>
43289 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
43290 <entry>Default: <emphasis>unset</emphasis></entry>
43291 </row>
43292 </tbody>
43293 </tgroup>
43294 </informaltable>
43295 <para>
43296 <indexterm role="concept">
43297 <primary>TLS</primary>
43298 <secondary>requiring specific ciphers</secondary>
43299 </indexterm>
43300 <indexterm role="concept">
43301 <primary>cipher</primary>
43302 <secondary>requiring specific</secondary>
43303 </indexterm>
43304 <indexterm role="variable">
43305 <primary><varname>$host</varname></primary>
43306 </indexterm>
43307 <indexterm role="variable">
43308 <primary><varname>$host_address</varname></primary>
43309 </indexterm>
43310 The value of this option must be a list of permitted cipher suites, for use
43311 when setting up an outgoing encrypted connection. (There is a global option of
43312 the same name for controlling incoming connections.) The values of <varname>$host</varname> and
43313 <varname>$host_address</varname> are set to the name and address of the server during the
43314 expansion. See chapter <xref linkend="CHAPTLS"/> for details of TLS; note that this option
43315 is used in different ways by OpenSSL and GnuTLS (see sections
43316 <xref linkend="SECTreqciphssl"/> and <xref linkend="SECTreqciphgnu"/>). For GnuTLS, the order of the
43317 ciphers is a preference order.
43318 </para>
43319 <para>
43320 <indexterm role="option">
43321 <primary><option>tls_tempfail_tryclear</option></primary>
43322 </indexterm>
43323 </para>
43324 <informaltable frame="all">
43325 <tgroup cols="4" colsep="0" rowsep="0">
43326 <colspec colwidth="8*" align="left"/>
43327 <colspec colwidth="6*" align="center"/>
43328 <colspec colwidth="6*" align="center"/>
43329 <colspec colwidth="6*" align="right"/>
43330 <tbody>
43331 <row>
43332 <entry><option>tls_tempfail_tryclear</option></entry>
43333 <entry>Use: <emphasis>smtp</emphasis></entry>
43334 <entry>Type: <emphasis>boolean</emphasis></entry>
43335 <entry>Default: <emphasis>true</emphasis></entry>
43336 </row>
43337 </tbody>
43338 </tgroup>
43339 </informaltable>
43340 <para>
43341 <indexterm role="concept">
43342 <primary>4<emphasis>xx</emphasis> responses</primary>
43343 <secondary>to STARTTLS</secondary>
43344 </indexterm>
43345 When the server host is not in <option>hosts_require_tls</option>, and there is a problem in
43346 setting up a TLS session, this option determines whether or not Exim should try
43347 to deliver the message unencrypted. If it is set false, delivery to the
43348 current host is deferred; if there are other hosts, they are tried. If this
43349 option is set true, Exim attempts to deliver unencrypted after a 4<emphasis>xx</emphasis>
43350 response to STARTTLS. Also, if STARTTLS is accepted, but the subsequent
43351 TLS negotiation fails, Exim closes the current connection (because it is in an
43352 unknown state), opens a new one to the same host, and then tries the delivery
43353 in clear.
43354 </para>
43355 <para>
43356 <indexterm role="option">
43357 <primary><option>tls_verify_certificates</option></primary>
43358 </indexterm>
43359 </para>
43360 <informaltable frame="all">
43361 <tgroup cols="4" colsep="0" rowsep="0">
43362 <colspec colwidth="8*" align="left"/>
43363 <colspec colwidth="6*" align="center"/>
43364 <colspec colwidth="6*" align="center"/>
43365 <colspec colwidth="6*" align="right"/>
43366 <tbody>
43367 <row>
43368 <entry><option>tls_verify_certificates</option></entry>
43369 <entry>Use: <emphasis>smtp</emphasis></entry>
43370 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
43371 <entry>Default: <emphasis>unset</emphasis></entry>
43372 </row>
43373 </tbody>
43374 </tgroup>
43375 </informaltable>
43376 <para>
43377 <indexterm role="concept">
43378 <primary>TLS</primary>
43379 <secondary>server certificate verification</secondary>
43380 </indexterm>
43381 <indexterm role="concept">
43382 <primary>certificate</primary>
43383 <secondary>verification of server</secondary>
43384 </indexterm>
43385 <indexterm role="variable">
43386 <primary><varname>$host</varname></primary>
43387 </indexterm>
43388 <indexterm role="variable">
43389 <primary><varname>$host_address</varname></primary>
43390 </indexterm>
43391 The value of this option must be the absolute path to a file containing
43392 permitted server certificates, for use when setting up an encrypted connection.
43393 Alternatively, if you are using OpenSSL, you can set
43394 <option>tls_verify_certificates</option> to the name of a directory containing certificate
43395 files. This does not work with GnuTLS; the option must be set to the name of a
43396 single file if you are using GnuTLS. The values of <varname>$host</varname> and
43397 <varname>$host_address</varname> are set to the name and address of the server during the
43398 expansion of this option. See chapter <xref linkend="CHAPTLS"/> for details of TLS.
43399 </para>
43400 </section>
43401 <section id="SECTvalhosmax">
43402 <title>How the limits for the number of hosts to try are used</title>
43403 <para>
43404 <indexterm role="concept">
43405 <primary>host</primary>
43406 <secondary>maximum number to try</secondary>
43407 </indexterm>
43408 <indexterm role="concept">
43409 <primary>limit</primary>
43410 <secondary>hosts; maximum number tried</secondary>
43411 </indexterm>
43412 There are two options that are concerned with the number of hosts that are
43413 tried when an SMTP delivery takes place. They are <option>hosts_max_try</option> and
43414 <option>hosts_max_try_hardlimit</option>.
43415 </para>
43416 <para>
43417 The <option>hosts_max_try</option> option limits the number of hosts that are tried
43418 for a single delivery. However, despite the term <quote>host</quote> in its name, the
43419 option actually applies to each IP address independently. In other words, a
43420 multihomed host is treated as several independent hosts, just as it is for
43421 retrying.
43422 </para>
43423 <para>
43424 Many of the larger ISPs have multiple MX records which often point to
43425 multihomed hosts. As a result, a list of a dozen or more IP addresses may be
43426 created as a result of routing one of these domains.
43427 </para>
43428 <para>
43429 Trying every single IP address on such a long list does not seem sensible; if
43430 several at the top of the list fail, it is reasonable to assume there is some
43431 problem that is likely to affect all of them. Roughly speaking, the value of
43432 <option>hosts_max_try</option> is the maximum number that are tried before deferring the
43433 delivery. However, the logic cannot be quite that simple.
43434 </para>
43435 <para>
43436 Firstly, IP addresses that are skipped because their retry times have not
43437 arrived do not count, and in addition, addresses that are past their retry
43438 limits are also not counted, even when they are tried. This means that when
43439 some IP addresses are past their retry limits, more than the value of
43440 <option>hosts_max_retry</option> may be tried. The reason for this behaviour is to ensure
43441 that all IP addresses are considered before timing out an email address (but
43442 see below for an exception).
43443 </para>
43444 <para>
43445 Secondly, when the <option>hosts_max_try</option> limit is reached, Exim looks down the host
43446 list to see if there is a subsequent host with a different (higher valued) MX.
43447 If there is, that host is considered next, and the current IP address is used
43448 but not counted. This behaviour helps in the case of a domain with a retry rule
43449 that hardly ever delays any hosts, as is now explained:
43450 </para>
43451 <para>
43452 Consider the case of a long list of hosts with one MX value, and a few with a
43453 higher MX value. If <option>hosts_max_try</option> is small (the default is 5) only a few
43454 hosts at the top of the list are tried at first. With the default retry rule,
43455 which specifies increasing retry times, the higher MX hosts are eventually
43456 tried when those at the top of the list are skipped because they have not
43457 reached their retry times.
43458 </para>
43459 <para>
43460 However, it is common practice to put a fixed short retry time on domains for
43461 large ISPs, on the grounds that their servers are rarely down for very long.
43462 Unfortunately, these are exactly the domains that tend to resolve to long lists
43463 of hosts. The short retry time means that the lowest MX hosts are tried every
43464 time. The attempts may be in a different order because of random sorting, but
43465 without the special MX check, the higher MX hosts would never be tried until
43466 all the lower MX hosts had timed out (which might be several days), because
43467 there are always some lower MX hosts that have reached their retry times. With
43468 the special check, Exim considers at least one IP address from each MX value at
43469 every delivery attempt, even if the <option>hosts_max_try</option> limit has already been
43470 reached.
43471 </para>
43472 <para>
43473 The above logic means that <option>hosts_max_try</option> is not a hard limit, and in
43474 particular, Exim normally eventually tries all the IP addresses before timing
43475 out an email address. When <option>hosts_max_try</option> was implemented, this seemed a
43476 reasonable thing to do. Recently, however, some lunatic DNS configurations have
43477 been set up with hundreds of IP addresses for some domains. It can
43478 take a very long time indeed for an address to time out in these cases.
43479 </para>
43480 <para>
43481 The <option>hosts_max_try_hardlimit</option> option was added to help with this problem.
43482 Exim never tries more than this number of IP addresses; if it hits this limit
43483 and they are all timed out, the email address is bounced, even though not all
43484 possible IP addresses have been tried.
43485 <indexterm role="concept" startref="IIDsmttra1" class="endofrange"/>
43486 <indexterm role="concept" startref="IIDsmttra2" class="endofrange"/>
43487 </para>
43488 </section>
43489 </chapter>
43490
43491 <chapter id="CHAPrewrite">
43492 <title>Address rewriting</title>
43493 <para>
43494 <indexterm role="concept" id="IIDaddrew" class="startofrange">
43495 <primary>rewriting</primary>
43496 <secondary>addresses</secondary>
43497 </indexterm>
43498 There are some circumstances in which Exim automatically rewrites domains in
43499 addresses. The two most common are when an address is given without a domain
43500 (referred to as an <quote>unqualified address</quote>) or when an address contains an
43501 abbreviated domain that is expanded by DNS lookup.
43502 </para>
43503 <para>
43504 Unqualified envelope addresses are accepted only for locally submitted
43505 messages, or for messages that are received from hosts matching
43506 <option>sender_unqualified_hosts</option> or <option>recipient_unqualified_hosts</option>, as
43507 appropriate. Unqualified addresses in header lines are qualified if they are in
43508 locally submitted messages, or messages from hosts that are permitted to send
43509 unqualified envelope addresses. Otherwise, unqualified addresses in header
43510 lines are neither qualified nor rewritten.
43511 </para>
43512 <para>
43513 One situation in which Exim does <emphasis>not</emphasis> automatically rewrite a domain is
43514 when it is the name of a CNAME record in the DNS. The older RFCs suggest that
43515 such a domain should be rewritten using the <quote>canonical</quote> name, and some MTAs
43516 do this. The new RFCs do not contain this suggestion.
43517 </para>
43518 <section id="SECID147">
43519 <title>Explicitly configured address rewriting</title>
43520 <para>
43521 This chapter describes the rewriting rules that can be used in the
43522 main rewrite section of the configuration file, and also in the generic
43523 <option>headers_rewrite</option> option that can be set on any transport.
43524 </para>
43525 <para>
43526 Some people believe that configured address rewriting is a Mortal Sin.
43527 Others believe that life is not possible without it. Exim provides the
43528 facility; you do not have to use it.
43529 </para>
43530 <para>
43531 The main rewriting rules that appear in the <quote>rewrite</quote> section of the
43532 configuration file are applied to addresses in incoming messages, both envelope
43533 addresses and addresses in header lines. Each rule specifies the types of
43534 address to which it applies.
43535 </para>
43536 <para>
43537 Whether or not addresses in header lines are rewritten depends on the origin of
43538 the headers and the type of rewriting. Global rewriting, that is, rewriting
43539 rules from the rewrite section of the configuration file, is applied only to
43540 those headers that were received with the message. Header lines that are added
43541 by ACLs or by a system filter or by individual routers or transports (which
43542 are specific to individual recipient addresses) are not rewritten by the global
43543 rules.
43544 </para>
43545 <para>
43546 Rewriting at transport time, by means of the <option>headers_rewrite</option> option,
43547 applies all headers except those added by routers and transports. That is, as
43548 well as the headers that were received with the message, it also applies to
43549 headers that were added by an ACL or a system filter.
43550 </para>
43551 <para>
43552 In general, rewriting addresses from your own system or domain has some
43553 legitimacy. Rewriting other addresses should be done only with great care and
43554 in special circumstances. The author of Exim believes that rewriting should be
43555 used sparingly, and mainly for <quote>regularizing</quote> addresses in your own domains.
43556 Although it can sometimes be used as a routing tool, this is very strongly
43557 discouraged.
43558 </para>
43559 <para>
43560 There are two commonly encountered circumstances where rewriting is used, as
43561 illustrated by these examples:
43562 </para>
43563 <itemizedlist>
43564 <listitem>
43565 <para>
43566 The company whose domain is <emphasis>hitch.fict.example</emphasis> has a number of hosts that
43567 exchange mail with each other behind a firewall, but there is only a single
43568 gateway to the outer world. The gateway rewrites <emphasis>*.hitch.fict.example</emphasis> as
43569 <emphasis>hitch.fict.example</emphasis> when sending mail off-site.
43570 </para>
43571 </listitem>
43572 <listitem>
43573 <para>
43574 A host rewrites the local parts of its own users so that, for example,
43575 <emphasis>fp42@hitch.fict.example</emphasis> becomes <emphasis>Ford.Prefect@hitch.fict.example</emphasis>.
43576 </para>
43577 </listitem>
43578 </itemizedlist>
43579 </section>
43580 <section id="SECID148">
43581 <title>When does rewriting happen?</title>
43582 <para>
43583 <indexterm role="concept">
43584 <primary>rewriting</primary>
43585 <secondary>timing of</secondary>
43586 </indexterm>
43587 <indexterm role="concept">
43588 <primary>access control lists (ACLs)</primary>
43589 <secondary>rewriting addresses in</secondary>
43590 </indexterm>
43591 Configured address rewriting can take place at several different stages of a
43592 message&#x2019;s processing.
43593 </para>
43594 <para>
43595 <indexterm role="variable">
43596 <primary><varname>$sender_address</varname></primary>
43597 </indexterm>
43598 At the start of an ACL for MAIL, the sender address may have been rewritten
43599 by a special SMTP-time rewrite rule (see section <xref linkend="SECTrewriteS"/>), but no
43600 ordinary rewrite rules have yet been applied. If, however, the sender address
43601 is verified in the ACL, it is rewritten before verification, and remains
43602 rewritten thereafter. The subsequent value of <varname>$sender_address</varname> is the
43603 rewritten address. This also applies if sender verification happens in a
43604 RCPT ACL. Otherwise, when the sender address is not verified, it is
43605 rewritten as soon as a message&#x2019;s header lines have been received.
43606 </para>
43607 <para>
43608 <indexterm role="variable">
43609 <primary><varname>$domain</varname></primary>
43610 </indexterm>
43611 <indexterm role="variable">
43612 <primary><varname>$local_part</varname></primary>
43613 </indexterm>
43614 Similarly, at the start of an ACL for RCPT, the current recipient&#x2019;s address
43615 may have been rewritten by a special SMTP-time rewrite rule, but no ordinary
43616 rewrite rules have yet been applied to it. However, the behaviour is different
43617 from the sender address when a recipient is verified. The address is rewritten
43618 for the verification, but the rewriting is not remembered at this stage. The
43619 value of <varname>$local_part</varname> and <varname>$domain</varname> after verification are always the same
43620 as they were before (that is, they contain the unrewritten &ndash; except for
43621 SMTP-time rewriting &ndash; address).
43622 </para>
43623 <para>
43624 As soon as a message&#x2019;s header lines have been received, all the envelope
43625 recipient addresses are permanently rewritten, and rewriting is also applied to
43626 the addresses in the header lines (if configured). This happens before adding
43627 any header lines that were specified in MAIL or RCPT ACLs, and
43628 <indexterm role="concept">
43629 <primary><function>local_scan()</function> function</primary>
43630 <secondary>address rewriting; timing of</secondary>
43631 </indexterm>
43632 before the DATA ACL and <function>local_scan()</function> functions are run.
43633 </para>
43634 <para>
43635 When an address is being routed, either for delivery or for verification,
43636 rewriting is applied immediately to child addresses that are generated by
43637 redirection, unless <option>no_rewrite</option> is set on the router.
43638 </para>
43639 <para>
43640 <indexterm role="concept">
43641 <primary>envelope sender</primary>
43642 <secondary>rewriting at transport time</secondary>
43643 </indexterm>
43644 <indexterm role="concept">
43645 <primary>rewriting</primary>
43646 <secondary>at transport time</secondary>
43647 </indexterm>
43648 <indexterm role="concept">
43649 <primary>header lines</primary>
43650 <secondary>rewriting at transport time</secondary>
43651 </indexterm>
43652 At transport time, additional rewriting of addresses in header lines can be
43653 specified by setting the generic <option>headers_rewrite</option> option on a transport.
43654 This option contains rules that are identical in form to those in the rewrite
43655 section of the configuration file. They are applied to the original message
43656 header lines and any that were added by ACLs or a system filter. They are not
43657 applied to header lines that are added by routers or the transport.
43658 </para>
43659 <para>
43660 The outgoing envelope sender can be rewritten by means of the <option>return_path</option>
43661 transport option. However, it is not possible to rewrite envelope recipients at
43662 transport time.
43663 </para>
43664 </section>
43665 <section id="SECID149">
43666 <title>Testing the rewriting rules that apply on input</title>
43667 <para>
43668 <indexterm role="concept">
43669 <primary>rewriting</primary>
43670 <secondary>testing</secondary>
43671 </indexterm>
43672 <indexterm role="concept">
43673 <primary>testing</primary>
43674 <secondary>rewriting</secondary>
43675 </indexterm>
43676 Exim&#x2019;s input rewriting configuration appears in a part of the run time
43677 configuration file headed by <quote>begin rewrite</quote>. It can be tested by the
43678 <option>-brw</option> command line option. This takes an address (which can be a full RFC
43679 2822 address) as its argument. The output is a list of how the address would be
43680 transformed by the rewriting rules for each of the different places it might
43681 appear in an incoming message, that is, for each different header and for the
43682 envelope sender and recipient fields. For example,
43683 </para>
43684 <literallayout class="monospaced">
43685 exim -brw ph10@exim.workshop.example
43686 </literallayout>
43687 <para>
43688 might produce the output
43689 </para>
43690 <literallayout class="monospaced">
43691 sender: Philip.Hazel@exim.workshop.example
43692 from: Philip.Hazel@exim.workshop.example
43693 to: ph10@exim.workshop.example
43694 cc: ph10@exim.workshop.example
43695 bcc: ph10@exim.workshop.example
43696 reply-to: Philip.Hazel@exim.workshop.example
43697 env-from: Philip.Hazel@exim.workshop.example
43698 env-to: ph10@exim.workshop.example
43699 </literallayout>
43700 <para>
43701 which shows that rewriting has been set up for that address when used in any of
43702 the source fields, but not when it appears as a recipient address. At the
43703 present time, there is no equivalent way of testing rewriting rules that are
43704 set for a particular transport.
43705 </para>
43706 </section>
43707 <section id="SECID150">
43708 <title>Rewriting rules</title>
43709 <para>
43710 <indexterm role="concept">
43711 <primary>rewriting</primary>
43712 <secondary>rules</secondary>
43713 </indexterm>
43714 The rewrite section of the configuration file consists of lines of rewriting
43715 rules in the form
43716 </para>
43717 <literallayout>
43718 &lt;<emphasis>source pattern</emphasis>&gt;  &lt;<emphasis>replacement</emphasis>&gt;  &lt;<emphasis>flags</emphasis>&gt;
43719 </literallayout>
43720 <para>
43721 Rewriting rules that are specified for the <option>headers_rewrite</option> generic
43722 transport option are given as a colon-separated list. Each item in the list
43723 takes the same form as a line in the main rewriting configuration (except that
43724 any colons must be doubled, of course).
43725 </para>
43726 <para>
43727 The formats of source patterns and replacement strings are described below.
43728 Each is terminated by white space, unless enclosed in double quotes, in which
43729 case normal quoting conventions apply inside the quotes. The flags are single
43730 characters which may appear in any order. Spaces and tabs between them are
43731 ignored.
43732 </para>
43733 <para>
43734 For each address that could potentially be rewritten, the rules are scanned in
43735 order, and replacements for the address from earlier rules can themselves be
43736 replaced by later rules (but see the <quote>q</quote> and <quote>R</quote> flags).
43737 </para>
43738 <para>
43739 The order in which addresses are rewritten is undefined, may change between
43740 releases, and must not be relied on, with one exception: when a message is
43741 received, the envelope sender is always rewritten first, before any header
43742 lines are rewritten. For example, the replacement string for a rewrite of an
43743 address in <emphasis>To:</emphasis> must not assume that the message&#x2019;s address in <emphasis>From:</emphasis> has
43744 (or has not) already been rewritten. However, a rewrite of <emphasis>From:</emphasis> may assume
43745 that the envelope sender has already been rewritten.
43746 </para>
43747 <para>
43748 <indexterm role="variable">
43749 <primary><varname>$domain</varname></primary>
43750 </indexterm>
43751 <indexterm role="variable">
43752 <primary><varname>$local_part</varname></primary>
43753 </indexterm>
43754 The variables <varname>$local_part</varname> and <varname>$domain</varname> can be used in the replacement
43755 string to refer to the address that is being rewritten. Note that lookup-driven
43756 rewriting can be done by a rule of the form
43757 </para>
43758 <literallayout class="monospaced">
43759 *@*   ${lookup ...
43760 </literallayout>
43761 <para>
43762 where the lookup key uses <varname>$1</varname> and <varname>$2</varname> or <varname>$local_part</varname> and <varname>$domain</varname> to
43763 refer to the address that is being rewritten.
43764 </para>
43765 </section>
43766 <section id="SECID151">
43767 <title>Rewriting patterns</title>
43768 <para>
43769 <indexterm role="concept">
43770 <primary>rewriting</primary>
43771 <secondary>patterns</secondary>
43772 </indexterm>
43773 <indexterm role="concept">
43774 <primary>address list</primary>
43775 <secondary>in a rewriting pattern</secondary>
43776 </indexterm>
43777 The source pattern in a rewriting rule is any item which may appear in an
43778 address list (see section <xref linkend="SECTaddresslist"/>). It is in fact processed as a
43779 single-item address list, which means that it is expanded before being tested
43780 against the address. As always, if you use a regular expression as a pattern,
43781 you must take care to escape dollar and backslash characters, or use the <literal>\N</literal>
43782 facility to suppress string expansion within the regular expression.
43783 </para>
43784 <para>
43785 Domains in patterns should be given in lower case. Local parts in patterns are
43786 case-sensitive. If you want to do case-insensitive matching of local parts, you
43787 can use a regular expression that starts with <literal>^(?i)</literal>.
43788 </para>
43789 <para>
43790 <indexterm role="concept">
43791 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
43792 <secondary>in rewriting rules</secondary>
43793 </indexterm>
43794 After matching, the numerical variables <varname>$1</varname>, <varname>$2</varname>, etc. may be set,
43795 depending on the type of match which occurred. These can be used in the
43796 replacement string to insert portions of the incoming address. <varname>$0</varname> always
43797 refers to the complete incoming address. When a regular expression is used, the
43798 numerical variables are set from its capturing subexpressions. For other types
43799 of pattern they are set as follows:
43800 </para>
43801 <itemizedlist>
43802 <listitem>
43803 <para>
43804 If a local part or domain starts with an asterisk, the numerical variables
43805 refer to the character strings matched by asterisks, with <varname>$1</varname> associated with
43806 the first asterisk, and <varname>$2</varname> with the second, if present. For example, if the
43807 pattern
43808 </para>
43809 <literallayout class="monospaced">
43810 *queen@*.fict.example
43811 </literallayout>
43812 <para>
43813 is matched against the address <emphasis>hearts-queen@wonderland.fict.example</emphasis> then
43814 </para>
43815 <literallayout class="monospaced">
43816 $0 = hearts-queen@wonderland.fict.example
43817 $1 = hearts-
43818 $2 = wonderland
43819 </literallayout>
43820 <para>
43821 Note that if the local part does not start with an asterisk, but the domain
43822 does, it is <varname>$1</varname> that contains the wild part of the domain.
43823 </para>
43824 </listitem>
43825 <listitem>
43826 <para>
43827 If the domain part of the pattern is a partial lookup, the wild and fixed parts
43828 of the domain are placed in the next available numerical variables. Suppose,
43829 for example, that the address <emphasis>foo@bar.baz.example</emphasis> is processed by a
43830 rewriting rule of the form
43831 </para>
43832 <literallayout>
43833 <literal>*@partial-dbm;/some/dbm/file</literal>    &lt;<emphasis>replacement string</emphasis>&gt;
43834 </literallayout>
43835 <para>
43836 and the key in the file that matches the domain is <literal>*.baz.example</literal>. Then
43837 </para>
43838 <literallayout class="monospaced">
43839 $1 = foo
43840 $2 = bar
43841 $3 = baz.example
43842 </literallayout>
43843 <para>
43844 If the address <emphasis>foo@baz.example</emphasis> is looked up, this matches the same
43845 wildcard file entry, and in this case <varname>$2</varname> is set to the empty string, but
43846 <varname>$3</varname> is still set to <emphasis>baz.example</emphasis>. If a non-wild key is matched in a
43847 partial lookup, <varname>$2</varname> is again set to the empty string and <varname>$3</varname> is set to the
43848 whole domain. For non-partial domain lookups, no numerical variables are set.
43849 </para>
43850 </listitem>
43851 </itemizedlist>
43852 </section>
43853 <section id="SECID152">
43854 <title>Rewriting replacements</title>
43855 <para>
43856 <indexterm role="concept">
43857 <primary>rewriting</primary>
43858 <secondary>replacements</secondary>
43859 </indexterm>
43860 If the replacement string for a rule is a single asterisk, addresses that
43861 match the pattern and the flags are <emphasis>not</emphasis> rewritten, and no subsequent
43862 rewriting rules are scanned. For example,
43863 </para>
43864 <literallayout class="monospaced">
43865 hatta@lookingglass.fict.example  *  f
43866 </literallayout>
43867 <para>
43868 specifies that <emphasis>hatta@lookingglass.fict.example</emphasis> is never to be rewritten in
43869 <emphasis>From:</emphasis> headers.
43870 </para>
43871 <para>
43872 <indexterm role="variable">
43873 <primary><varname>$domain</varname></primary>
43874 </indexterm>
43875 <indexterm role="variable">
43876 <primary><varname>$local_part</varname></primary>
43877 </indexterm>
43878 If the replacement string is not a single asterisk, it is expanded, and must
43879 yield a fully qualified address. Within the expansion, the variables
43880 <varname>$local_part</varname> and <varname>$domain</varname> refer to the address that is being rewritten.
43881 Any letters they contain retain their original case &ndash; they are not lower
43882 cased. The numerical variables are set up according to the type of pattern that
43883 matched the address, as described above. If the expansion is forced to fail by
43884 the presence of <quote>fail</quote> in a conditional or lookup item, rewriting by the
43885 current rule is abandoned, but subsequent rules may take effect. Any other
43886 expansion failure causes the entire rewriting operation to be abandoned, and an
43887 entry written to the panic log.
43888 </para>
43889 </section>
43890 <section id="SECID153">
43891 <title>Rewriting flags</title>
43892 <para>
43893 There are three different kinds of flag that may appear on rewriting rules:
43894 </para>
43895 <itemizedlist>
43896 <listitem>
43897 <para>
43898 Flags that specify which headers and envelope addresses to rewrite: E, F, T, b,
43899 c, f, h, r, s, t.
43900 </para>
43901 </listitem>
43902 <listitem>
43903 <para>
43904 A flag that specifies rewriting at SMTP time: S.
43905 </para>
43906 </listitem>
43907 <listitem>
43908 <para>
43909 Flags that control the rewriting process: Q, q, R, w.
43910 </para>
43911 </listitem>
43912 </itemizedlist>
43913 <para>
43914 For rules that are part of the <option>headers_rewrite</option> generic transport option,
43915 E, F, T, and S are not permitted.
43916 </para>
43917 </section>
43918 <section id="SECID154">
43919 <title>Flags specifying which headers and envelope addresses to rewrite</title>
43920 <para>
43921 <indexterm role="concept">
43922 <primary>rewriting</primary>
43923 <secondary>flags</secondary>
43924 </indexterm>
43925 If none of the following flag letters, nor the <quote>S</quote> flag (see section
43926 <xref linkend="SECTrewriteS"/>) are present, a main rewriting rule applies to all headers
43927 and to both the sender and recipient fields of the envelope, whereas a
43928 transport-time rewriting rule just applies to all headers. Otherwise, the
43929 rewriting rule is skipped unless the relevant addresses are being processed.
43930 </para>
43931 <literallayout>
43932 <literal>E</literal>       rewrite all envelope fields
43933 <literal>F</literal>       rewrite the envelope From field
43934 <literal>T</literal>       rewrite the envelope To field
43935 <literal>b</literal>       rewrite the <emphasis>Bcc:</emphasis> header
43936 <literal>c</literal>       rewrite the <emphasis>Cc:</emphasis> header
43937 <literal>f</literal>       rewrite the <emphasis>From:</emphasis> header
43938 <literal>h</literal>       rewrite all headers
43939 <literal>r</literal>       rewrite the <emphasis>Reply-To:</emphasis> header
43940 <literal>s</literal>       rewrite the <emphasis>Sender:</emphasis> header
43941 <literal>t</literal>       rewrite the <emphasis>To:</emphasis> header
43942 </literallayout>
43943 <para>
43944 "All headers" means all of the headers listed above that can be selected
43945 individually, plus their <emphasis>Resent-</emphasis> versions. It does not include
43946 other headers such as <emphasis>Subject:</emphasis> etc.
43947 </para>
43948 <para>
43949 You should be particularly careful about rewriting <emphasis>Sender:</emphasis> headers, and
43950 restrict this to special known cases in your own domains.
43951 </para>
43952 </section>
43953 <section id="SECTrewriteS">
43954 <title>The SMTP-time rewriting flag</title>
43955 <para>
43956 <indexterm role="concept">
43957 <primary>SMTP</primary>
43958 <secondary>rewriting malformed addresses</secondary>
43959 </indexterm>
43960 <indexterm role="concept">
43961 <primary>RCPT</primary>
43962 <secondary>rewriting argument of</secondary>
43963 </indexterm>
43964 <indexterm role="concept">
43965 <primary>MAIL</primary>
43966 <secondary>rewriting argument of</secondary>
43967 </indexterm>
43968 The rewrite flag <quote>S</quote> specifies a rewrite of incoming envelope addresses at
43969 SMTP time, as soon as an address is received in a MAIL or RCPT command, and
43970 before any other processing; even before syntax checking. The pattern is
43971 required to be a regular expression, and it is matched against the whole of the
43972 data for the command, including any surrounding angle brackets.
43973 </para>
43974 <para>
43975 <indexterm role="variable">
43976 <primary><varname>$domain</varname></primary>
43977 </indexterm>
43978 <indexterm role="variable">
43979 <primary><varname>$local_part</varname></primary>
43980 </indexterm>
43981 This form of rewrite rule allows for the handling of addresses that are not
43982 compliant with RFCs 2821 and 2822 (for example, <quote>bang paths</quote> in batched SMTP
43983 input). Because the input is not required to be a syntactically valid address,
43984 the variables <varname>$local_part</varname> and <varname>$domain</varname> are not available during the
43985 expansion of the replacement string. The result of rewriting replaces the
43986 original address in the MAIL or RCPT command.
43987 </para>
43988 </section>
43989 <section id="SECID155">
43990 <title>Flags controlling the rewriting process</title>
43991 <para>
43992 There are four flags which control the way the rewriting process works. These
43993 take effect only when a rule is invoked, that is, when the address is of the
43994 correct type (matches the flags) and matches the pattern:
43995 </para>
43996 <itemizedlist>
43997 <listitem>
43998 <para>
43999 If the <quote>Q</quote> flag is set on a rule, the rewritten address is permitted to be an
44000 unqualified local part. It is qualified with <option>qualify_recipient</option>. In the
44001 absence of <quote>Q</quote> the rewritten address must always include a domain.
44002 </para>
44003 </listitem>
44004 <listitem>
44005 <para>
44006 If the <quote>q</quote> flag is set on a rule, no further rewriting rules are considered,
44007 even if no rewriting actually takes place because of a <quote>fail</quote> in the
44008 expansion. The <quote>q</quote> flag is not effective if the address is of the wrong type
44009 (does not match the flags) or does not match the pattern.
44010 </para>
44011 </listitem>
44012 <listitem>
44013 <para>
44014 The <quote>R</quote> flag causes a successful rewriting rule to be re-applied to the new
44015 address, up to ten times. It can be combined with the <quote>q</quote> flag, to stop
44016 rewriting once it fails to match (after at least one successful rewrite).
44017 </para>
44018 </listitem>
44019 <listitem>
44020 <para>
44021 <indexterm role="concept">
44022 <primary>rewriting</primary>
44023 <secondary>whole addresses</secondary>
44024 </indexterm>
44025 When an address in a header is rewritten, the rewriting normally applies only
44026 to the working part of the address, with any comments and RFC 2822 <quote>phrase</quote>
44027 left unchanged. For example, rewriting might change
44028 </para>
44029 <literallayout class="monospaced">
44030 From: Ford Prefect &lt;fp42@restaurant.hitch.fict.example&gt;
44031 </literallayout>
44032 <para>
44033 into
44034 </para>
44035 <literallayout class="monospaced">
44036 From: Ford Prefect &lt;prefectf@hitch.fict.example&gt;
44037 </literallayout>
44038 <para>
44039 <indexterm role="concept">
44040 <primary>RFC 2047</primary>
44041 </indexterm>
44042 Sometimes there is a need to replace the whole address item, and this can be
44043 done by adding the flag letter <quote>w</quote> to a rule. If this is set on a rule that
44044 causes an address in a header line to be rewritten, the entire address is
44045 replaced, not just the working part. The replacement must be a complete RFC
44046 2822 address, including the angle brackets if necessary. If text outside angle
44047 brackets contains a character whose value is greater than 126 or less than 32
44048 (except for tab), the text is encoded according to RFC 2047. The character set
44049 is taken from <option>headers_charset</option>, which defaults to ISO-8859-1.
44050 </para>
44051 <para>
44052 When the <quote>w</quote> flag is set on a rule that causes an envelope address to be
44053 rewritten, all but the working part of the replacement address is discarded.
44054 </para>
44055 </listitem>
44056 </itemizedlist>
44057 </section>
44058 <section id="SECID156">
44059 <title>Rewriting examples</title>
44060 <para>
44061 Here is an example of the two common rewriting paradigms:
44062 </para>
44063 <literallayout class="monospaced">
44064 *@*.hitch.fict.example  $1@hitch.fict.example
44065 *@hitch.fict.example    ${lookup{$1}dbm{/etc/realnames}\
44066                      {$value}fail}@hitch.fict.example bctfrF
44067 </literallayout>
44068 <para>
44069 Note the use of <quote>fail</quote> in the lookup expansion in the second rule, forcing
44070 the string expansion to fail if the lookup does not succeed. In this context it
44071 has the effect of leaving the original address unchanged, but Exim goes on to
44072 consider subsequent rewriting rules, if any, because the <quote>q</quote> flag is not
44073 present in that rule. An alternative to <quote>fail</quote> would be to supply <varname>$1</varname>
44074 explicitly, which would cause the rewritten address to be the same as before,
44075 at the cost of a small bit of processing. Not supplying either of these is an
44076 error, since the rewritten address would then contain no local part.
44077 </para>
44078 <para>
44079 The first example above replaces the domain with a superior, more general
44080 domain. This may not be desirable for certain local parts. If the rule
44081 </para>
44082 <literallayout class="monospaced">
44083 root@*.hitch.fict.example  *
44084 </literallayout>
44085 <para>
44086 were inserted before the first rule, rewriting would be suppressed for the
44087 local part <emphasis>root</emphasis> at any domain ending in <emphasis>hitch.fict.example</emphasis>.
44088 </para>
44089 <para>
44090 Rewriting can be made conditional on a number of tests, by making use of
44091 <varname>${if</varname> in the expansion item. For example, to apply a rewriting rule only to
44092 messages that originate outside the local host:
44093 </para>
44094 <literallayout class="monospaced">
44095 *@*.hitch.fict.example  "${if !eq {$sender_host_address}{}\
44096                          {$1@hitch.fict.example}fail}"
44097 </literallayout>
44098 <para>
44099 The replacement string is quoted in this example because it contains white
44100 space.
44101 </para>
44102 <para>
44103 <indexterm role="concept">
44104 <primary>rewriting</primary>
44105 <secondary>bang paths</secondary>
44106 </indexterm>
44107 <indexterm role="concept">
44108 <primary>bang paths</primary>
44109 <secondary>rewriting</secondary>
44110 </indexterm>
44111 Exim does not handle addresses in the form of <quote>bang paths</quote>. If it sees such
44112 an address it treats it as an unqualified local part which it qualifies with
44113 the local qualification domain (if the source of the message is local or if the
44114 remote host is permitted to send unqualified addresses). Rewriting can
44115 sometimes be used to handle simple bang paths with a fixed number of
44116 components. For example, the rule
44117 </para>
44118 <literallayout class="monospaced">
44119 \N^([^!]+)!(.*)@your.domain.example$\N   $2@$1
44120 </literallayout>
44121 <para>
44122 rewrites a two-component bang path <emphasis>host.name!user</emphasis> as the domain address
44123 <emphasis>user@host.name</emphasis>. However, there is a security implication in using this as
44124 a global rewriting rule for envelope addresses. It can provide a backdoor
44125 method for using your system as a relay, because the incoming addresses appear
44126 to be local. If the bang path addresses are received via SMTP, it is safer to
44127 use the <quote>S</quote> flag to rewrite them as they are received, so that relay checking
44128 can be done on the rewritten addresses.
44129 <indexterm role="concept" startref="IIDaddrew" class="endofrange"/>
44130 </para>
44131 </section>
44132 </chapter>
44133
44134 <chapter id="CHAPretry">
44135 <title>Retry configuration</title>
44136 <para>
44137 <indexterm role="concept" id="IIDretconf1" class="startofrange">
44138 <primary>retry</primary>
44139 <secondary>configuration, description of</secondary>
44140 </indexterm>
44141 <indexterm role="concept" id="IIDregconf2" class="startofrange">
44142 <primary>configuration file</primary>
44143 <secondary>retry section</secondary>
44144 </indexterm>
44145 The <quote>retry</quote> section of the runtime configuration file contains a list of
44146 retry rules that control how often Exim tries to deliver messages that cannot
44147 be delivered at the first attempt. If there are no retry rules (the section is
44148 empty or not present), there are no retries. In this situation, temporary
44149 errors are treated as permanent. The default configuration contains a single,
44150 general-purpose retry rule (see section <xref linkend="SECID57"/>). The <option>-brt</option> command
44151 line option can be used to test which retry rule will be used for a given
44152 address, domain and error.
44153 </para>
44154 <para>
44155 The most common cause of retries is temporary failure to deliver to a remote
44156 host because the host is down, or inaccessible because of a network problem.
44157 Exim&#x2019;s retry processing in this case is applied on a per-host (strictly, per IP
44158 address) basis, not on a per-message basis. Thus, if one message has recently
44159 been delayed, delivery of a new message to the same host is not immediately
44160 tried, but waits for the host&#x2019;s retry time to arrive. If the <option>retry_defer</option>
44161 log selector is set, the message
44162 <indexterm role="concept">
44163 <primary>retry</primary>
44164 <secondary>time not reached</secondary>
44165 </indexterm>
44166 <quote>retry time not reached</quote> is written to the main log whenever a delivery is
44167 skipped for this reason. Section <xref linkend="SECToutSMTPerr"/> contains more details of
44168 the handling of errors during remote deliveries.
44169 </para>
44170 <para>
44171 Retry processing applies to routing as well as to delivering, except as covered
44172 in the next paragraph. The retry rules do not distinguish between these
44173 actions. It is not possible, for example, to specify different behaviour for
44174 failures to route the domain <emphasis>snark.fict.example</emphasis> and failures to deliver to
44175 the host <emphasis>snark.fict.example</emphasis>. I didn&#x2019;t think anyone would ever need this
44176 added complication, so did not implement it. However, although they share the
44177 same retry rule, the actual retry times for routing and transporting a given
44178 domain are maintained independently.
44179 </para>
44180 <para>
44181 When a delivery is not part of a queue run (typically an immediate delivery on
44182 receipt of a message), the routers are always run, and local deliveries are
44183 always attempted, even if retry times are set for them. This makes for better
44184 behaviour if one particular message is causing problems (for example, causing
44185 quota overflow, or provoking an error in a filter file). If such a delivery
44186 suffers a temporary failure, the retry data is updated as normal, and
44187 subsequent delivery attempts from queue runs occur only when the retry time for
44188 the local address is reached.
44189 </para>
44190 <section id="SECID157">
44191 <title>Changing retry rules</title>
44192 <para>
44193 If you change the retry rules in your configuration, you should consider
44194 whether or not to delete the retry data that is stored in Exim&#x2019;s spool area in
44195 files with names like <filename>db/retry</filename>. Deleting any of Exim&#x2019;s hints files is
44196 always safe; that is why they are called <quote>hints</quote>.
44197 </para>
44198 <para>
44199 The hints retry data contains suggested retry times based on the previous
44200 rules. In the case of a long-running problem with a remote host, it might
44201 record the fact that the host has timed out. If your new rules increase the
44202 timeout time for such a host, you should definitely remove the old retry data
44203 and let Exim recreate it, based on the new rules. Otherwise Exim might bounce
44204 messages that it should now be retaining.
44205 </para>
44206 </section>
44207 <section id="SECID158">
44208 <title>Format of retry rules</title>
44209 <para>
44210 <indexterm role="concept">
44211 <primary>retry</primary>
44212 <secondary>rules</secondary>
44213 </indexterm>
44214 Each retry rule occupies one line and consists of three or four parts,
44215 separated by white space: a pattern, an error name, an optional list of sender
44216 addresses, and a list of retry parameters. The pattern and sender lists must be
44217 enclosed in double quotes if they contain white space. The rules are searched
44218 in order until one is found where the pattern, error name, and sender list (if
44219 present) match the failing host or address, the error that occurred, and the
44220 message&#x2019;s sender, respectively.
44221 </para>
44222 <para>
44223 The pattern is any single item that may appear in an address list (see section
44224 <xref linkend="SECTaddresslist"/>). It is in fact processed as a one-item address list,
44225 which means that it is expanded before being tested against the address that
44226 has been delayed. A negated address list item is permitted. Address
44227 list processing treats a plain domain name as if it were preceded by <quote>*@</quote>,
44228 which makes it possible for many retry rules to start with just a domain. For
44229 example,
44230 </para>
44231 <literallayout class="monospaced">
44232 lookingglass.fict.example        *  F,24h,30m;
44233 </literallayout>
44234 <para>
44235 provides a rule for any address in the <emphasis>lookingglass.fict.example</emphasis> domain,
44236 whereas
44237 </para>
44238 <literallayout class="monospaced">
44239 alice@lookingglass.fict.example  *  F,24h,30m;
44240 </literallayout>
44241 <para>
44242 applies only to temporary failures involving the local part <option>alice</option>.
44243 In practice, almost all rules start with a domain name pattern without a local
44244 part.
44245 </para>
44246 <para>
44247 <indexterm role="concept">
44248 <primary>regular expressions</primary>
44249 <secondary>in retry rules</secondary>
44250 </indexterm>
44251 <emphasis role="bold">Warning</emphasis>: If you use a regular expression in a routing rule pattern, it
44252 must match a complete address, not just a domain, because that is how regular
44253 expressions work in address lists.
44254 </para>
44255 <literallayout>
44256 <literal>^\Nxyz\d+\.abc\.example$\N        *  G,1h,10m,2</literal>     <option>Wrong</option>
44257 <literal>^\N[^@]+@xyz\d+\.abc\.example$\N  *  G,1h,10m,2</literal>     <option>Right</option>
44258 </literallayout>
44259 </section>
44260 <section id="SECID159">
44261 <title>Choosing which retry rule to use for address errors</title>
44262 <para>
44263 When Exim is looking for a retry rule after a routing attempt has failed (for
44264 example, after a DNS timeout), each line in the retry configuration is tested
44265 against the complete address only if <option>retry_use_local_part</option> is set for the
44266 router. Otherwise, only the domain is used, except when matching against a
44267 regular expression, when the local part of the address is replaced with <quote>*</quote>.
44268 A domain on its own can match a domain pattern, or a pattern that starts with
44269 <quote>*@</quote>. By default, <option>retry_use_local_part</option> is true for routers where
44270 <option>check_local_user</option> is true, and false for other routers.
44271 </para>
44272 <para>
44273 Similarly, when Exim is looking for a retry rule after a local delivery has
44274 failed (for example, after a mailbox full error), each line in the retry
44275 configuration is tested against the complete address only if
44276 <option>retry_use_local_part</option> is set for the transport (it defaults true for all
44277 local transports).
44278 </para>
44279 <para>
44280 <indexterm role="concept">
44281 <primary>4<emphasis>xx</emphasis> responses</primary>
44282 <secondary>retry rules for</secondary>
44283 </indexterm>
44284 However, when Exim is looking for a retry rule after a remote delivery attempt
44285 suffers an address error (a 4<emphasis>xx</emphasis> SMTP response for a recipient address), the
44286 whole address is always used as the key when searching the retry rules. The
44287 rule that is found is used to create a retry time for the combination of the
44288 failing address and the message&#x2019;s sender. It is the combination of sender and
44289 recipient that is delayed in subsequent queue runs until its retry time is
44290 reached. You can delay the recipient without regard to the sender by setting
44291 <option>address_retry_include_sender</option> false in the <command>smtp</command> transport but this can
44292 lead to problems with servers that regularly issue 4<emphasis>xx</emphasis> responses to RCPT
44293 commands.
44294 </para>
44295 </section>
44296 <section id="SECID160">
44297 <title>Choosing which retry rule to use for host and message errors</title>
44298 <para>
44299 For a temporary error that is not related to an individual address (for
44300 example, a connection timeout), each line in the retry configuration is checked
44301 twice. First, the name of the remote host is used as a domain name (preceded by
44302 <quote>*@</quote> when matching a regular expression). If this does not match the line,
44303 the domain from the email address is tried in a similar fashion. For example,
44304 suppose the MX records for <emphasis>a.b.c.example</emphasis> are
44305 </para>
44306 <literallayout class="monospaced">
44307 a.b.c.example  MX  5  x.y.z.example
44308                MX  6  p.q.r.example
44309                MX  7  m.n.o.example
44310 </literallayout>
44311 <para>
44312 and the retry rules are
44313 </para>
44314 <literallayout class="monospaced">
44315 p.q.r.example    *      F,24h,30m;
44316 a.b.c.example    *      F,4d,45m;
44317 </literallayout>
44318 <para>
44319 and a delivery to the host <emphasis>x.y.z.example</emphasis> suffers a connection failure. The
44320 first rule matches neither the host nor the domain, so Exim looks at the second
44321 rule. This does not match the host, but it does match the domain, so it is used
44322 to calculate the retry time for the host <emphasis>x.y.z.example</emphasis>. Meanwhile, Exim
44323 tries to deliver to <emphasis>p.q.r.example</emphasis>. If this also suffers a host error, the
44324 first retry rule is used, because it matches the host.
44325 </para>
44326 <para>
44327 In other words, temporary failures to deliver to host <emphasis>p.q.r.example</emphasis> use the
44328 first rule to determine retry times, but for all the other hosts for the domain
44329 <emphasis>a.b.c.example</emphasis>, the second rule is used. The second rule is also used if
44330 routing to <emphasis>a.b.c.example</emphasis> suffers a temporary failure.
44331 </para>
44332 <para>
44333 <emphasis role="bold">Note</emphasis>: The host name is used when matching the patterns, not its IP address.
44334 However, if a message is routed directly to an IP address without the use of a
44335 host name, for example, if a <command>manualroute</command> router contains a setting such as:
44336 </para>
44337 <literallayout class="monospaced">
44338 route_list = *.a.example  192.168.34.23
44339 </literallayout>
44340 <para>
44341 then the <quote>host name</quote> that is used when searching for a retry rule is the
44342 textual form of the IP address.
44343 </para>
44344 </section>
44345 <section id="SECID161">
44346 <title>Retry rules for specific errors</title>
44347 <para>
44348 <indexterm role="concept">
44349 <primary>retry</primary>
44350 <secondary>specific errors; specifying</secondary>
44351 </indexterm>
44352 The second field in a retry rule is the name of a particular error, or an
44353 asterisk, which matches any error. The errors that can be tested for are:
44354 </para>
44355 <variablelist>
44356 <varlistentry>
44357 <term><option>auth_failed</option></term>
44358 <listitem>
44359 <para>
44360 Authentication failed when trying to send to a host in the
44361 <option>hosts_require_auth</option> list in an <command>smtp</command> transport.
44362 </para>
44363 </listitem></varlistentry>
44364 <varlistentry>
44365 <term><option>data_4xx</option></term>
44366 <listitem>
44367 <para>
44368 A 4<emphasis>xx</emphasis> error was received for an outgoing DATA command, either immediately
44369 after the command, or after sending the message&#x2019;s data.
44370 </para>
44371 </listitem></varlistentry>
44372 <varlistentry>
44373 <term><option>mail_4xx</option></term>
44374 <listitem>
44375 <para>
44376 A 4<emphasis>xx</emphasis> error was received for an outgoing MAIL command.
44377 </para>
44378 </listitem></varlistentry>
44379 <varlistentry>
44380 <term><option>rcpt_4xx</option></term>
44381 <listitem>
44382 <para>
44383 A 4<emphasis>xx</emphasis> error was received for an outgoing RCPT command.
44384 </para>
44385 </listitem></varlistentry>
44386 </variablelist>
44387 <para>
44388 For the three 4<emphasis>xx</emphasis> errors, either the first or both of the x&#x2019;s can be given
44389 as specific digits, for example: <literal>mail_45x</literal> or <literal>rcpt_436</literal>. For example, to
44390 recognize 452 errors given to RCPT commands for addresses in a certain domain,
44391 and have retries every ten minutes with a one-hour timeout, you could set up a
44392 retry rule of this form:
44393 </para>
44394 <literallayout class="monospaced">
44395 the.domain.name  rcpt_452   F,1h,10m
44396 </literallayout>
44397 <para>
44398 These errors apply to both outgoing SMTP (the <command>smtp</command> transport) and outgoing
44399 LMTP (either the <command>lmtp</command> transport, or the <command>smtp</command> transport in LMTP mode).
44400 </para>
44401 <variablelist>
44402 <varlistentry>
44403 <term><option>lost_connection</option></term>
44404 <listitem>
44405 <para>
44406 A server unexpectedly closed the SMTP connection. There may, of course,
44407 legitimate reasons for this (host died, network died), but if it repeats a lot
44408 for the same host, it indicates something odd.
44409 </para>
44410 </listitem></varlistentry>
44411 <varlistentry>
44412 <term><option>refused_MX</option></term>
44413 <listitem>
44414 <para>
44415 A connection to a host obtained from an MX record was refused.
44416 </para>
44417 </listitem></varlistentry>
44418 <varlistentry>
44419 <term><option>refused_A</option></term>
44420 <listitem>
44421 <para>
44422 A connection to a host not obtained from an MX record was refused.
44423 </para>
44424 </listitem></varlistentry>
44425 <varlistentry>
44426 <term><option>refused</option></term>
44427 <listitem>
44428 <para>
44429 A connection was refused.
44430 </para>
44431 </listitem></varlistentry>
44432 <varlistentry>
44433 <term><option>timeout_connect_MX</option></term>
44434 <listitem>
44435 <para>
44436 A connection attempt to a host obtained from an MX record timed out.
44437 </para>
44438 </listitem></varlistentry>
44439 <varlistentry>
44440 <term><option>timeout_connect_A</option></term>
44441 <listitem>
44442 <para>
44443 A connection attempt to a host not obtained from an MX record timed out.
44444 </para>
44445 </listitem></varlistentry>
44446 <varlistentry>
44447 <term><option>timeout_connect</option></term>
44448 <listitem>
44449 <para>
44450 A connection attempt timed out.
44451 </para>
44452 </listitem></varlistentry>
44453 <varlistentry>
44454 <term><option>timeout_MX</option></term>
44455 <listitem>
44456 <para>
44457 There was a timeout while connecting or during an SMTP session with a host
44458 obtained from an MX record.
44459 </para>
44460 </listitem></varlistentry>
44461 <varlistentry>
44462 <term><option>timeout_A</option></term>
44463 <listitem>
44464 <para>
44465 There was a timeout while connecting or during an SMTP session with a host not
44466 obtained from an MX record.
44467 </para>
44468 </listitem></varlistentry>
44469 <varlistentry>
44470 <term><option>timeout</option></term>
44471 <listitem>
44472 <para>
44473 There was a timeout while connecting or during an SMTP session.
44474 </para>
44475 </listitem></varlistentry>
44476 <varlistentry>
44477 <term><option>tls_required</option></term>
44478 <listitem>
44479 <para>
44480 The server was required to use TLS (it matched <option>hosts_require_tls</option> in the
44481 <command>smtp</command> transport), but either did not offer TLS, or it responded with 4<emphasis>xx</emphasis>
44482 to STARTTLS, or there was a problem setting up the TLS connection.
44483 </para>
44484 </listitem></varlistentry>
44485 <varlistentry>
44486 <term><option>quota</option></term>
44487 <listitem>
44488 <para>
44489 A mailbox quota was exceeded in a local delivery by the <command>appendfile</command>
44490 transport.
44491 </para>
44492 </listitem></varlistentry>
44493 <varlistentry>
44494 <term><option>quota_</option>&lt;<emphasis>time</emphasis>&gt;</term>
44495 <listitem>
44496 <para>
44497 <indexterm role="concept">
44498 <primary>quota</primary>
44499 <secondary>error testing in retry rule</secondary>
44500 </indexterm>
44501 <indexterm role="concept">
44502 <primary>retry</primary>
44503 <secondary>quota error testing</secondary>
44504 </indexterm>
44505 A mailbox quota was exceeded in a local delivery by the <command>appendfile</command>
44506 transport, and the mailbox has not been accessed for &lt;<emphasis>time</emphasis>&gt;. For example,
44507 <emphasis>quota_4d</emphasis> applies to a quota error when the mailbox has not been accessed
44508 for four days.
44509 </para>
44510 </listitem></varlistentry>
44511 </variablelist>
44512 <para>
44513 <indexterm role="concept">
44514 <primary>mailbox</primary>
44515 <secondary>time of last read</secondary>
44516 </indexterm>
44517 The idea of <option>quota_</option>&lt;<emphasis>time</emphasis>&gt; is to make it possible to have shorter
44518 timeouts when the mailbox is full and is not being read by its owner. Ideally,
44519 it should be based on the last time that the user accessed the mailbox.
44520 However, it is not always possible to determine this. Exim uses the following
44521 heuristic rules:
44522 </para>
44523 <itemizedlist>
44524 <listitem>
44525 <para>
44526 If the mailbox is a single file, the time of last access (the <quote>atime</quote>) is
44527 used. As no new messages are being delivered (because the mailbox is over
44528 quota), Exim does not access the file, so this is the time of last user access.
44529 </para>
44530 </listitem>
44531 <listitem>
44532 <para>
44533 <indexterm role="concept">
44534 <primary>maildir format</primary>
44535 <secondary>time of last read</secondary>
44536 </indexterm>
44537 For a maildir delivery, the time of last modification of the <filename>new</filename>
44538 subdirectory is used. As the mailbox is over quota, no new files are created in
44539 the <filename>new</filename> subdirectory, because no new messages are being delivered. Any
44540 change to the <filename>new</filename> subdirectory is therefore assumed to be the result of an
44541 MUA moving a new message to the <filename>cur</filename> directory when it is first read. The
44542 time that is used is therefore the last time that the user read a new message.
44543 </para>
44544 </listitem>
44545 <listitem>
44546 <para>
44547 For other kinds of multi-file mailbox, the time of last access cannot be
44548 obtained, so a retry rule that uses this type of error field is never matched.
44549 </para>
44550 </listitem>
44551 </itemizedlist>
44552 <para>
44553 The quota errors apply both to system-enforced quotas and to Exim&#x2019;s own quota
44554 mechanism in the <command>appendfile</command> transport. The <emphasis>quota</emphasis> error also applies
44555 when a local delivery is deferred because a partition is full (the ENOSPC
44556 error).
44557 </para>
44558 </section>
44559 <section id="SECID162">
44560 <title>Retry rules for specified senders</title>
44561 <para>
44562 <indexterm role="concept">
44563 <primary>retry</primary>
44564 <secondary>rules; sender-specific</secondary>
44565 </indexterm>
44566 You can specify retry rules that apply only when the failing message has a
44567 specific sender. In particular, this can be used to define retry rules that
44568 apply only to bounce messages. The third item in a retry rule can be of this
44569 form:
44570 </para>
44571 <literallayout>
44572 <literal>senders=</literal>&lt;<emphasis>address list</emphasis>&gt;
44573 </literallayout>
44574 <para>
44575 The retry timings themselves are then the fourth item. For example:
44576 </para>
44577 <literallayout class="monospaced">
44578 *   rcpt_4xx   senders=:   F,1h,30m
44579 </literallayout>
44580 <para>
44581 matches recipient 4<emphasis>xx</emphasis> errors for bounce messages sent to any address at any
44582 host. If the address list contains white space, it must be enclosed in quotes.
44583 For example:
44584 </para>
44585 <literallayout class="monospaced">
44586 a.domain  rcpt_452  senders="xb.dom : yc.dom"  G,8h,10m,1.5
44587 </literallayout>
44588 <para>
44589 <emphasis role="bold">Warning</emphasis>: This facility can be unhelpful if it is used for host errors
44590 (which do not depend on the recipient). The reason is that the sender is used
44591 only to match the retry rule. Once the rule has been found for a host error,
44592 its contents are used to set a retry time for the host, and this will apply to
44593 all messages, not just those with specific senders.
44594 </para>
44595 <para>
44596 When testing retry rules using <option>-brt</option>, you can supply a sender using the
44597 <option>-f</option> command line option, like this:
44598 </para>
44599 <literallayout class="monospaced">
44600 exim -f "" -brt user@dom.ain
44601 </literallayout>
44602 <para>
44603 If you do not set <option>-f</option> with <option>-brt</option>, a retry rule that contains a senders
44604 list is never matched.
44605 </para>
44606 </section>
44607 <section id="SECID163">
44608 <title>Retry parameters</title>
44609 <para>
44610 <indexterm role="concept">
44611 <primary>retry</primary>
44612 <secondary>parameters in rules</secondary>
44613 </indexterm>
44614 The third (or fourth, if a senders list is present) field in a retry rule is a
44615 sequence of retry parameter sets, separated by semicolons. Each set consists of
44616 </para>
44617 <literallayout>
44618 &lt;<emphasis>letter</emphasis>&gt;,&lt;<emphasis>cutoff time</emphasis>&gt;,&lt;<emphasis>arguments</emphasis>&gt;
44619 </literallayout>
44620 <para>
44621 The letter identifies the algorithm for computing a new retry time; the cutoff
44622 time is the time beyond which this algorithm no longer applies, and the
44623 arguments vary the algorithm&#x2019;s action. The cutoff time is measured from the
44624 time that the first failure for the domain (combined with the local part if
44625 relevant) was detected, not from the time the message was received.
44626 </para>
44627 <para>
44628 <indexterm role="concept">
44629 <primary>retry</primary>
44630 <secondary>algorithms</secondary>
44631 </indexterm>
44632 <indexterm role="concept">
44633 <primary>retry</primary>
44634 <secondary>fixed intervals</secondary>
44635 </indexterm>
44636 <indexterm role="concept">
44637 <primary>retry</primary>
44638 <secondary>increasing intervals</secondary>
44639 </indexterm>
44640 <indexterm role="concept">
44641 <primary>retry</primary>
44642 <secondary>random intervals</secondary>
44643 </indexterm>
44644 The available algorithms are:
44645 </para>
44646 <itemizedlist>
44647 <listitem>
44648 <para>
44649 <emphasis>F</emphasis>: retry at fixed intervals. There is a single time parameter specifying
44650 the interval.
44651 </para>
44652 </listitem>
44653 <listitem>
44654 <para>
44655 <emphasis>G</emphasis>: retry at geometrically increasing intervals. The first argument
44656 specifies a starting value for the interval, and the second a multiplier, which
44657 is used to increase the size of the interval at each retry.
44658 </para>
44659 </listitem>
44660 <listitem>
44661 <para>
44662 <emphasis>H</emphasis>: retry at randomized intervals. The arguments are as for <emphasis>G</emphasis>. For each
44663 retry, the previous interval is multiplied by the factor in order to get a
44664 maximum for the next interval. The minimum interval is the first argument of
44665 the parameter, and an actual interval is chosen randomly between them. Such a
44666 rule has been found to be helpful in cluster configurations when all the
44667 members of the cluster restart at once, and may therefore synchronize their
44668 queue processing times.
44669 </para>
44670 </listitem>
44671 </itemizedlist>
44672 <para>
44673 When computing the next retry time, the algorithm definitions are scanned in
44674 order until one whose cutoff time has not yet passed is reached. This is then
44675 used to compute a new retry time that is later than the current time. In the
44676 case of fixed interval retries, this simply means adding the interval to the
44677 current time. For geometrically increasing intervals, retry intervals are
44678 computed from the rule&#x2019;s parameters until one that is greater than the previous
44679 interval is found. The main configuration variable
44680 <indexterm role="concept">
44681 <primary>limit</primary>
44682 <secondary>retry interval</secondary>
44683 </indexterm>
44684 <indexterm role="concept">
44685 <primary>retry</primary>
44686 <secondary>interval, maximum</secondary>
44687 </indexterm>
44688 <indexterm role="option">
44689 <primary><option>retry_interval_max</option></primary>
44690 </indexterm>
44691 <option>retry_interval_max</option> limits the maximum interval between retries. It
44692 cannot be set greater than <literal>24h</literal>, which is its default value.
44693 </para>
44694 <para>
44695 A single remote domain may have a number of hosts associated with it, and each
44696 host may have more than one IP address. Retry algorithms are selected on the
44697 basis of the domain name, but are applied to each IP address independently. If,
44698 for example, a host has two IP addresses and one is unusable, Exim will
44699 generate retry times for it and will not try to use it until its next retry
44700 time comes. Thus the good IP address is likely to be tried first most of the
44701 time.
44702 </para>
44703 <para>
44704 <indexterm role="concept">
44705 <primary>hints database</primary>
44706 <secondary>use for retrying</secondary>
44707 </indexterm>
44708 Retry times are hints rather than promises. Exim does not make any attempt to
44709 run deliveries exactly at the computed times. Instead, a queue runner process
44710 starts delivery processes for delayed messages periodically, and these attempt
44711 new deliveries only for those addresses that have passed their next retry time.
44712 If a new message arrives for a deferred address, an immediate delivery attempt
44713 occurs only if the address has passed its retry time. In the absence of new
44714 messages, the minimum time between retries is the interval between queue runner
44715 processes. There is not much point in setting retry times of five minutes if
44716 your queue runners happen only once an hour, unless there are a significant
44717 number of incoming messages (which might be the case on a system that is
44718 sending everything to a smart host, for example).
44719 </para>
44720 <para>
44721 The data in the retry hints database can be inspected by using the
44722 <emphasis>exim_dumpdb</emphasis> or <emphasis>exim_fixdb</emphasis> utility programs (see chapter
44723 <xref linkend="CHAPutils"/>). The latter utility can also be used to change the data. The
44724 <emphasis>exinext</emphasis> utility script can be used to find out what the next retry times
44725 are for the hosts associated with a particular mail domain, and also for local
44726 deliveries that have been deferred.
44727 </para>
44728 </section>
44729 <section id="SECID164">
44730 <title>Retry rule examples</title>
44731 <para>
44732 Here are some example retry rules:
44733 </para>
44734 <literallayout class="monospaced">
44735 alice@wonderland.fict.example quota_5d  F,7d,3h
44736 wonderland.fict.example       quota_5d
44737 wonderland.fict.example       *         F,1h,15m; G,2d,1h,2;
44738 lookingglass.fict.example     *         F,24h,30m;
44739 *                 refused_A   F,2h,20m;
44740 *                 *           F,2h,15m; G,16h,1h,1.5; F,5d,8h
44741 </literallayout>
44742 <para>
44743 The first rule sets up special handling for mail to
44744 <emphasis>alice@wonderland.fict.example</emphasis> when there is an over-quota error and the
44745 mailbox has not been read for at least 5 days. Retries continue every three
44746 hours for 7 days. The second rule handles over-quota errors for all other local
44747 parts at <emphasis>wonderland.fict.example</emphasis>; the absence of a local part has the same
44748 effect as supplying <quote>*@</quote>. As no retry algorithms are supplied, messages that
44749 fail are bounced immediately if the mailbox has not been read for at least 5
44750 days.
44751 </para>
44752 <para>
44753 The third rule handles all other errors at <emphasis>wonderland.fict.example</emphasis>; retries
44754 happen every 15 minutes for an hour, then with geometrically increasing
44755 intervals until two days have passed since a delivery first failed. After the
44756 first hour there is a delay of one hour, then two hours, then four hours, and
44757 so on (this is a rather extreme example).
44758 </para>
44759 <para>
44760 The fourth rule controls retries for the domain <emphasis>lookingglass.fict.example</emphasis>.
44761 They happen every 30 minutes for 24 hours only. The remaining two rules handle
44762 all other domains, with special action for connection refusal from hosts that
44763 were not obtained from an MX record.
44764 </para>
44765 <para>
44766 The final rule in a retry configuration should always have asterisks in the
44767 first two fields so as to provide a general catch-all for any addresses that do
44768 not have their own special handling. This example tries every 15 minutes for 2
44769 hours, then with intervals starting at one hour and increasing by a factor of
44770 1.5 up to 16 hours, then every 8 hours up to 5 days.
44771 </para>
44772 </section>
44773 <section id="SECID165">
44774 <title>Timeout of retry data</title>
44775 <para>
44776 <indexterm role="concept">
44777 <primary>timeout</primary>
44778 <secondary>of retry data</secondary>
44779 </indexterm>
44780 <indexterm role="option">
44781 <primary><option>retry_data_expire</option></primary>
44782 </indexterm>
44783 <indexterm role="concept">
44784 <primary>hints database</primary>
44785 <secondary>data expiry</secondary>
44786 </indexterm>
44787 <indexterm role="concept">
44788 <primary>retry</primary>
44789 <secondary>timeout of data</secondary>
44790 </indexterm>
44791 Exim timestamps the data that it writes to its retry hints database. When it
44792 consults the data during a delivery it ignores any that is older than the value
44793 set in <option>retry_data_expire</option> (default 7 days). If, for example, a host hasn&#x2019;t
44794 been tried for 7 days, Exim will try to deliver to it immediately a message
44795 arrives, and if that fails, it will calculate a retry time as if it were
44796 failing for the first time.
44797 </para>
44798 <para>
44799 This improves the behaviour for messages routed to rarely-used hosts such as MX
44800 backups. If such a host was down at one time, and happens to be down again when
44801 Exim tries a month later, using the old retry data would imply that it had been
44802 down all the time, which is not a justified assumption.
44803 </para>
44804 <para>
44805 If a host really is permanently dead, this behaviour causes a burst of retries
44806 every now and again, but only if messages routed to it are rare. If there is a
44807 message at least once every 7 days the retry data never expires.
44808 </para>
44809 </section>
44810 <section id="SECID166">
44811 <title>Long-term failures</title>
44812 <para>
44813 <indexterm role="concept">
44814 <primary>delivery failure, long-term</primary>
44815 </indexterm>
44816 <indexterm role="concept">
44817 <primary>retry</primary>
44818 <secondary>after long-term failure</secondary>
44819 </indexterm>
44820 Special processing happens when an email address has been failing for so long
44821 that the cutoff time for the last algorithm is reached. For example, using the
44822 default retry rule:
44823 </para>
44824 <literallayout class="monospaced">
44825 * * F,2h,15m; G,16h,1h,1.5; F,4d,6h
44826 </literallayout>
44827 <para>
44828 the cutoff time is four days. Reaching the retry cutoff is independent of how
44829 long any specific message has been failing; it is the length of continuous
44830 failure for the recipient address that counts.
44831 </para>
44832 <para>
44833 When the cutoff time is reached for a local delivery, or for all the IP
44834 addresses associated with a remote delivery, a subsequent delivery failure
44835 causes Exim to give up on the address, and a bounce message is generated.
44836 In order to cater for new messages that use the failing address, a next retry
44837 time is still computed from the final algorithm, and is used as follows:
44838 </para>
44839 <para>
44840 For local deliveries, one delivery attempt is always made for any subsequent
44841 messages. If this delivery fails, the address fails immediately. The
44842 post-cutoff retry time is not used.
44843 </para>
44844 <para>
44845 If the delivery is remote, there are two possibilities, controlled by the
44846 <indexterm role="option">
44847 <primary><option>delay_after_cutoff</option></primary>
44848 </indexterm>
44849 <option>delay_after_cutoff</option> option of the <command>smtp</command> transport. The option is true by
44850 default. Until the post-cutoff retry time for one of the IP addresses is
44851 reached, the failing email address is bounced immediately, without a delivery
44852 attempt taking place. After that time, one new delivery attempt is made to
44853 those IP addresses that are past their retry times, and if that still fails,
44854 the address is bounced and new retry times are computed.
44855 </para>
44856 <para>
44857 In other words, when all the hosts for a given email address have been failing
44858 for a long time, Exim bounces rather then defers until one of the hosts&#x2019; retry
44859 times is reached. Then it tries once, and bounces if that attempt fails. This
44860 behaviour ensures that few resources are wasted in repeatedly trying to deliver
44861 to a broken destination, but if the host does recover, Exim will eventually
44862 notice.
44863 </para>
44864 <para>
44865 If <option>delay_after_cutoff</option> is set false, Exim behaves differently. If all IP
44866 addresses are past their final cutoff time, Exim tries to deliver to those IP
44867 addresses that have not been tried since the message arrived. If there are
44868 no suitable IP addresses, or if they all fail, the address is bounced. In other
44869 words, it does not delay when a new message arrives, but tries the expired
44870 addresses immediately, unless they have been tried since the message arrived.
44871 If there is a continuous stream of messages for the failing domains, setting
44872 <option>delay_after_cutoff</option> false means that there will be many more attempts to
44873 deliver to permanently failing IP addresses than when <option>delay_after_cutoff</option> is
44874 true.
44875 </para>
44876 </section>
44877 <section id="SECID167">
44878 <title>Deliveries that work intermittently</title>
44879 <para>
44880 <indexterm role="concept">
44881 <primary>retry</primary>
44882 <secondary>intermittently working deliveries</secondary>
44883 </indexterm>
44884 Some additional logic is needed to cope with cases where a host is
44885 intermittently available, or when a message has some attribute that prevents
44886 its delivery when others to the same address get through. In this situation,
44887 because some messages are successfully delivered, the <quote>retry clock</quote> for the
44888 host or address keeps getting reset by the successful deliveries, and so
44889 failing messages remain on the queue for ever because the cutoff time is never
44890 reached.
44891 </para>
44892 <para>
44893 Two exceptional actions are applied to prevent this happening. The first
44894 applies to errors that are related to a message rather than a remote host.
44895 Section <xref linkend="SECToutSMTPerr"/> has a discussion of the different kinds of error;
44896 examples of message-related errors are 4<emphasis>xx</emphasis> responses to MAIL or DATA
44897 commands, and quota failures. For this type of error, if a message&#x2019;s arrival
44898 time is earlier than the <quote>first failed</quote> time for the error, the earlier time
44899 is used when scanning the retry rules to decide when to try next and when to
44900 time out the address.
44901 </para>
44902 <para>
44903 The exceptional second action applies in all cases. If a message has been on
44904 the queue for longer than the cutoff time of any applicable retry rule for a
44905 given address, a delivery is attempted for that address, even if it is not yet
44906 time, and if this delivery fails, the address is timed out. A new retry time is
44907 not computed in this case, so that other messages for the same address are
44908 considered immediately.
44909 <indexterm role="concept" startref="IIDretconf1" class="endofrange"/>
44910 <indexterm role="concept" startref="IIDregconf2" class="endofrange"/>
44911 </para>
44912 </section>
44913 </chapter>
44914
44915 <chapter id="CHAPSMTPAUTH">
44916 <title>SMTP authentication</title>
44917 <para>
44918 <indexterm role="concept" id="IIDauthconf1" class="startofrange">
44919 <primary>SMTP</primary>
44920 <secondary>authentication configuration</secondary>
44921 </indexterm>
44922 <indexterm role="concept" id="IIDauthconf2" class="startofrange">
44923 <primary>authentication</primary>
44924 </indexterm>
44925 The <quote>authenticators</quote> section of Exim&#x2019;s run time configuration is concerned
44926 with SMTP authentication. This facility is an extension to the SMTP protocol,
44927 described in RFC 2554, which allows a client SMTP host to authenticate itself
44928 to a server. This is a common way for a server to recognize clients that are
44929 permitted to use it as a relay. SMTP authentication is not of relevance to the
44930 transfer of mail between servers that have no managerial connection with each
44931 other.
44932 </para>
44933 <para>
44934 <indexterm role="concept">
44935 <primary>AUTH</primary>
44936 <secondary>description of</secondary>
44937 </indexterm>
44938 Very briefly, the way SMTP authentication works is as follows:
44939 </para>
44940 <itemizedlist>
44941 <listitem>
44942 <para>
44943 The server advertises a number of authentication <emphasis>mechanisms</emphasis> in response to
44944 the client&#x2019;s EHLO command.
44945 </para>
44946 </listitem>
44947 <listitem>
44948 <para>
44949 The client issues an AUTH command, naming a specific mechanism. The command
44950 may, optionally, contain some authentication data.
44951 </para>
44952 </listitem>
44953 <listitem>
44954 <para>
44955 The server may issue one or more <emphasis>challenges</emphasis>, to which the client must send
44956 appropriate responses. In simple authentication mechanisms, the challenges are
44957 just prompts for user names and passwords. The server does not have to issue
44958 any challenges &ndash; in some mechanisms the relevant data may all be transmitted
44959 with the AUTH command.
44960 </para>
44961 </listitem>
44962 <listitem>
44963 <para>
44964 The server either accepts or denies authentication.
44965 </para>
44966 </listitem>
44967 <listitem>
44968 <para>
44969 If authentication succeeds, the client may optionally make use of the AUTH
44970 option on the MAIL command to pass an authenticated sender in subsequent
44971 mail transactions. Authentication lasts for the remainder of the SMTP
44972 connection.
44973 </para>
44974 </listitem>
44975 <listitem>
44976 <para>
44977 If authentication fails, the client may give up, or it may try a different
44978 authentication mechanism, or it may try transferring mail over the
44979 unauthenticated connection.
44980 </para>
44981 </listitem>
44982 </itemizedlist>
44983 <para>
44984 If you are setting up a client, and want to know which authentication
44985 mechanisms the server supports, you can use Telnet to connect to port 25 (the
44986 SMTP port) on the server, and issue an EHLO command. The response to this
44987 includes the list of supported mechanisms. For example:
44988 </para>
44989 <literallayout>
44990 <literal>$ </literal><emphasis role="bold"><literal>telnet server.example 25</literal></emphasis>
44991 <literal>Trying 192.168.34.25...</literal>
44992 <literal>Connected to server.example.</literal>
44993 <literal>Escape character is &#x0027;^]&#x0027;.</literal>
44994 <literal>220 server.example ESMTP Exim 4.20 ...</literal>
44995 <emphasis role="bold"><literal>ehlo client.example</literal></emphasis>
44996 <literal>250-server.example Hello client.example [10.8.4.5]</literal>
44997 <literal>250-SIZE 52428800</literal>
44998 <literal>250-PIPELINING</literal>
44999 <literal>250-AUTH PLAIN</literal>
45000 <literal>250 HELP</literal>
45001 </literallayout>
45002 <para>
45003 The second-last line of this example output shows that the server supports
45004 authentication using the PLAIN mechanism. In Exim, the different authentication
45005 mechanisms are configured by specifying <emphasis>authenticator</emphasis> drivers. Like the
45006 routers and transports, which authenticators are included in the binary is
45007 controlled by build-time definitions. The following are currently available,
45008 included by setting
45009 </para>
45010 <literallayout class="monospaced">
45011 AUTH_CRAM_MD5=yes
45012 AUTH_CYRUS_SASL=yes
45013 AUTH_PLAINTEXT=yes
45014 AUTH_SPA=yes
45015 </literallayout>
45016 <para>
45017 in <filename>Local/Makefile</filename>, respectively. The first of these supports the CRAM-MD5
45018 authentication mechanism (RFC 2195), and the second provides an interface to
45019 the Cyrus SASL authentication library. The third can be configured to support
45020 the PLAIN authentication mechanism (RFC 2595) or the LOGIN mechanism, which is
45021 not formally documented, but used by several MUAs. The fourth authenticator
45022 supports Microsoft&#x2019;s <emphasis>Secure Password Authentication</emphasis> mechanism.
45023 </para>
45024 <para>
45025 The authenticators are configured using the same syntax as other drivers (see
45026 section <xref linkend="SECTfordricon"/>). If no authenticators are required, no
45027 authentication section need be present in the configuration file. Each
45028 authenticator can in principle have both server and client functions. When Exim
45029 is receiving SMTP mail, it is acting as a server; when it is sending out
45030 messages over SMTP, it is acting as a client. Authenticator configuration
45031 options are provided for use in both these circumstances.
45032 </para>
45033 <para>
45034 To make it clear which options apply to which situation, the prefixes
45035 <option>server_</option> and <option>client_</option> are used on option names that are specific to
45036 either the server or the client function, respectively. Server and client
45037 functions are disabled if none of their options are set. If an authenticator is
45038 to be used for both server and client functions, a single definition, using
45039 both sets of options, is required. For example:
45040 </para>
45041 <literallayout class="monospaced">
45042 cram:
45043   driver = cram_md5
45044   public_name = CRAM-MD5
45045   server_secret = ${if eq{$auth1}{ph10}{secret1}fail}
45046   client_name = ph10
45047   client_secret = secret2
45048 </literallayout>
45049 <para>
45050 The <option>server_</option> option is used when Exim is acting as a server, and the
45051 <option>client_</option> options when it is acting as a client.
45052 </para>
45053 <para>
45054 Descriptions of the individual authenticators are given in subsequent chapters.
45055 The remainder of this chapter covers the generic options for the
45056 authenticators, followed by general discussion of the way authentication works
45057 in Exim.
45058 </para>
45059 <section id="SECID168">
45060 <title>Generic options for authenticators</title>
45061 <para>
45062 <indexterm role="concept">
45063 <primary>authentication</primary>
45064 <secondary>generic options</secondary>
45065 </indexterm>
45066 <indexterm role="concept">
45067 <primary>options</primary>
45068 <secondary>generic; for authenticators</secondary>
45069 </indexterm>
45070 </para>
45071 <para>
45072 <indexterm role="option">
45073 <primary><option>client_condition</option></primary>
45074 </indexterm>
45075 </para>
45076 <informaltable frame="all">
45077 <tgroup cols="4" colsep="0" rowsep="0">
45078 <colspec colwidth="8*" align="left"/>
45079 <colspec colwidth="6*" align="center"/>
45080 <colspec colwidth="6*" align="center"/>
45081 <colspec colwidth="6*" align="right"/>
45082 <tbody>
45083 <row>
45084 <entry><option>client_condition</option></entry>
45085 <entry>Use: <emphasis>authenticators</emphasis></entry>
45086 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
45087 <entry>Default: <emphasis>unset</emphasis></entry>
45088 </row>
45089 </tbody>
45090 </tgroup>
45091 </informaltable>
45092 <para>
45093 When Exim is authenticating as a client, it skips any authenticator whose
45094 <option>client_condition</option> expansion yields <quote>0</quote>, <quote>no</quote>, or <quote>false</quote>. This can be
45095 used, for example, to skip plain text authenticators when the connection is not
45096 encrypted by a setting such as:
45097 </para>
45098 <literallayout class="monospaced">
45099 client_condition = ${if !eq{$tls_cipher}{}}
45100 </literallayout>
45101 <para>
45102 (Older documentation incorrectly states that <varname>$tls_cipher</varname> contains the cipher
45103 used for incoming messages. In fact, during SMTP delivery, it contains the
45104 cipher used for the delivery.)
45105 </para>
45106 <para>
45107 <indexterm role="option">
45108 <primary><option>driver</option></primary>
45109 </indexterm>
45110 </para>
45111 <informaltable frame="all">
45112 <tgroup cols="4" colsep="0" rowsep="0">
45113 <colspec colwidth="8*" align="left"/>
45114 <colspec colwidth="6*" align="center"/>
45115 <colspec colwidth="6*" align="center"/>
45116 <colspec colwidth="6*" align="right"/>
45117 <tbody>
45118 <row>
45119 <entry><option>driver</option></entry>
45120 <entry>Use: <emphasis>authenticators</emphasis></entry>
45121 <entry>Type: <emphasis>string</emphasis></entry>
45122 <entry>Default: <emphasis>unset</emphasis></entry>
45123 </row>
45124 </tbody>
45125 </tgroup>
45126 </informaltable>
45127 <para>
45128 This option must always be set. It specifies which of the available
45129 authenticators is to be used.
45130 </para>
45131 <para>
45132 <indexterm role="option">
45133 <primary><option>public_name</option></primary>
45134 </indexterm>
45135 </para>
45136 <informaltable frame="all">
45137 <tgroup cols="4" colsep="0" rowsep="0">
45138 <colspec colwidth="8*" align="left"/>
45139 <colspec colwidth="6*" align="center"/>
45140 <colspec colwidth="6*" align="center"/>
45141 <colspec colwidth="6*" align="right"/>
45142 <tbody>
45143 <row>
45144 <entry><option>public_name</option></entry>
45145 <entry>Use: <emphasis>authenticators</emphasis></entry>
45146 <entry>Type: <emphasis>string</emphasis></entry>
45147 <entry>Default: <emphasis>unset</emphasis></entry>
45148 </row>
45149 </tbody>
45150 </tgroup>
45151 </informaltable>
45152 <para>
45153 This option specifies the name of the authentication mechanism that the driver
45154 implements, and by which it is known to the outside world. These names should
45155 contain only upper case letters, digits, underscores, and hyphens (RFC 2222),
45156 but Exim in fact matches them caselessly. If <option>public_name</option> is not set, it
45157 defaults to the driver&#x2019;s instance name.
45158 </para>
45159 <para>
45160 <indexterm role="option">
45161 <primary><option>server_advertise_condition</option></primary>
45162 </indexterm>
45163 </para>
45164 <informaltable frame="all">
45165 <tgroup cols="4" colsep="0" rowsep="0">
45166 <colspec colwidth="8*" align="left"/>
45167 <colspec colwidth="6*" align="center"/>
45168 <colspec colwidth="6*" align="center"/>
45169 <colspec colwidth="6*" align="right"/>
45170 <tbody>
45171 <row>
45172 <entry><option>server_advertise_condition</option></entry>
45173 <entry>Use: <emphasis>authenticators</emphasis></entry>
45174 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
45175 <entry>Default: <emphasis>unset</emphasis></entry>
45176 </row>
45177 </tbody>
45178 </tgroup>
45179 </informaltable>
45180 <para>
45181 When a server is about to advertise an authentication mechanism, the condition
45182 is expanded. If it yields the empty string, <quote>0</quote>, <quote>no</quote>, or <quote>false</quote>, the
45183 mechanism is not advertised.
45184 If the expansion fails, the mechanism is not advertised. If the failure was not
45185 forced, and was not caused by a lookup defer, the incident is logged.
45186 See section <xref linkend="SECTauthexiser"/> below for further discussion.
45187 </para>
45188 <para>
45189 <indexterm role="option">
45190 <primary><option>server_condition</option></primary>
45191 </indexterm>
45192 </para>
45193 <informaltable frame="all">
45194 <tgroup cols="4" colsep="0" rowsep="0">
45195 <colspec colwidth="8*" align="left"/>
45196 <colspec colwidth="6*" align="center"/>
45197 <colspec colwidth="6*" align="center"/>
45198 <colspec colwidth="6*" align="right"/>
45199 <tbody>
45200 <row>
45201 <entry><option>server_condition</option></entry>
45202 <entry>Use: <emphasis>authenticators</emphasis></entry>
45203 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
45204 <entry>Default: <emphasis>unset</emphasis></entry>
45205 </row>
45206 </tbody>
45207 </tgroup>
45208 </informaltable>
45209 <para>
45210 This option must be set for a <option>plaintext</option> server authenticator, where it
45211 is used directly to control authentication. See section <xref linkend="SECTplainserver"/>
45212 for details.
45213 </para>
45214 <para>
45215 For the other authenticators, <option>server_condition</option> can be used as an additional
45216 authentication or authorization mechanism that is applied after the other
45217 authenticator conditions succeed. If it is set, it is expanded when the
45218 authenticator would otherwise return a success code. If the expansion is forced
45219 to fail, authentication fails. Any other expansion failure causes a temporary
45220 error code to be returned. If the result of a successful expansion is an empty
45221 string, <quote>0</quote>, <quote>no</quote>, or <quote>false</quote>, authentication fails. If the result of the
45222 expansion is <quote>1</quote>, <quote>yes</quote>, or <quote>true</quote>, authentication succeeds. For any
45223 other result, a temporary error code is returned, with the expanded string as
45224 the error text.
45225 </para>
45226 <para>
45227 <indexterm role="option">
45228 <primary><option>server_debug_print</option></primary>
45229 </indexterm>
45230 </para>
45231 <informaltable frame="all">
45232 <tgroup cols="4" colsep="0" rowsep="0">
45233 <colspec colwidth="8*" align="left"/>
45234 <colspec colwidth="6*" align="center"/>
45235 <colspec colwidth="6*" align="center"/>
45236 <colspec colwidth="6*" align="right"/>
45237 <tbody>
45238 <row>
45239 <entry><option>server_debug_print</option></entry>
45240 <entry>Use: <emphasis>authenticators</emphasis></entry>
45241 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
45242 <entry>Default: <emphasis>unset</emphasis></entry>
45243 </row>
45244 </tbody>
45245 </tgroup>
45246 </informaltable>
45247 <para>
45248 If this option is set and authentication debugging is enabled (see the <option>-d</option>
45249 command line option), the string is expanded and included in the debugging
45250 output when the authenticator is run as a server. This can help with checking
45251 out the values of variables.
45252 If expansion of the string fails, the error message is written to the debugging
45253 output, and Exim carries on processing.
45254 </para>
45255 <para>
45256 <indexterm role="option">
45257 <primary><option>server_set_id</option></primary>
45258 </indexterm>
45259 </para>
45260 <informaltable frame="all">
45261 <tgroup cols="4" colsep="0" rowsep="0">
45262 <colspec colwidth="8*" align="left"/>
45263 <colspec colwidth="6*" align="center"/>
45264 <colspec colwidth="6*" align="center"/>
45265 <colspec colwidth="6*" align="right"/>
45266 <tbody>
45267 <row>
45268 <entry><option>server_set_id</option></entry>
45269 <entry>Use: <emphasis>authenticators</emphasis></entry>
45270 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
45271 <entry>Default: <emphasis>unset</emphasis></entry>
45272 </row>
45273 </tbody>
45274 </tgroup>
45275 </informaltable>
45276 <para>
45277 <indexterm role="variable">
45278 <primary><varname>$authenticated_id</varname></primary>
45279 </indexterm>
45280 When an Exim server successfully authenticates a client, this string is
45281 expanded using data from the authentication, and preserved for any incoming
45282 messages in the variable <varname>$authenticated_id</varname>. It is also included in the log
45283 lines for incoming messages. For example, a user/password authenticator
45284 configuration might preserve the user name that was used to authenticate, and
45285 refer to it subsequently during delivery of the message.
45286 If expansion fails, the option is ignored.
45287 </para>
45288 <para>
45289 <indexterm role="option">
45290 <primary><option>server_mail_auth_condition</option></primary>
45291 </indexterm>
45292 </para>
45293 <informaltable frame="all">
45294 <tgroup cols="4" colsep="0" rowsep="0">
45295 <colspec colwidth="8*" align="left"/>
45296 <colspec colwidth="6*" align="center"/>
45297 <colspec colwidth="6*" align="center"/>
45298 <colspec colwidth="6*" align="right"/>
45299 <tbody>
45300 <row>
45301 <entry><option>server_mail_auth_condition</option></entry>
45302 <entry>Use: <emphasis>authenticators</emphasis></entry>
45303 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
45304 <entry>Default: <emphasis>unset</emphasis></entry>
45305 </row>
45306 </tbody>
45307 </tgroup>
45308 </informaltable>
45309 <para>
45310 This option allows a server to discard authenticated sender addresses supplied
45311 as part of MAIL commands in SMTP connections that are authenticated by the
45312 driver on which <option>server_mail_auth_condition</option> is set. The option is not used
45313 as part of the authentication process; instead its (unexpanded) value is
45314 remembered for later use.
45315 How it is used is described in the following section.
45316 </para>
45317 </section>
45318 <section id="SECTauthparamail">
45319 <title>The AUTH parameter on MAIL commands</title>
45320 <para>
45321 <indexterm role="concept">
45322 <primary>authentication</primary>
45323 <secondary>sender; authenticated</secondary>
45324 </indexterm>
45325 <indexterm role="concept">
45326 <primary>AUTH</primary>
45327 <secondary>on MAIL command</secondary>
45328 </indexterm>
45329 When a client supplied an AUTH= item on a MAIL command, Exim applies
45330 the following checks before accepting it as the authenticated sender of the
45331 message:
45332 </para>
45333 <itemizedlist>
45334 <listitem>
45335 <para>
45336 If the connection is not using extended SMTP (that is, HELO was used rather
45337 than EHLO), the use of AUTH= is a syntax error.
45338 </para>
45339 </listitem>
45340 <listitem>
45341 <para>
45342 If the value of the AUTH= parameter is <quote>&lt;&gt;</quote>, it is ignored.
45343 </para>
45344 </listitem>
45345 <listitem>
45346 <para>
45347 <indexterm role="variable">
45348 <primary><varname>$authenticated_sender</varname></primary>
45349 </indexterm>
45350 If <option>acl_smtp_mailauth</option> is defined, the ACL it specifies is run. While it is
45351 running, the value of <varname>$authenticated_sender</varname> is set to the value obtained
45352 from the AUTH= parameter. If the ACL does not yield <quote>accept</quote>, the value of
45353 <varname>$authenticated_sender</varname> is deleted. The <option>acl_smtp_mailauth</option> ACL may not
45354 return <quote>drop</quote> or <quote>discard</quote>. If it defers, a temporary error code (451) is
45355 given for the MAIL command.
45356 </para>
45357 </listitem>
45358 <listitem>
45359 <para>
45360 If <option>acl_smtp_mailauth</option> is not defined, the value of the AUTH= parameter
45361 is accepted and placed in <varname>$authenticated_sender</varname> only if the client has
45362 authenticated.
45363 </para>
45364 </listitem>
45365 <listitem>
45366 <para>
45367 If the AUTH= value was accepted by either of the two previous rules, and
45368 the client has authenticated, and the authenticator has a setting for the
45369 <option>server_mail_auth_condition</option>, the condition is checked at this point. The
45370 valued that was saved from the authenticator is expanded. If the expansion
45371 fails, or yields an empty string, <quote>0</quote>, <quote>no</quote>, or <quote>false</quote>, the value of
45372 <varname>$authenticated_sender</varname> is deleted. If the expansion yields any other value,
45373 the value of <varname>$authenticated_sender</varname> is retained and passed on with the
45374 message.
45375 </para>
45376 </listitem>
45377 </itemizedlist>
45378 <para>
45379 When <varname>$authenticated_sender</varname> is set for a message, it is passed on to other
45380 hosts to which Exim authenticates as a client. Do not confuse this value with
45381 <varname>$authenticated_id</varname>, which is a string obtained from the authentication
45382 process, and which is not usually a complete email address.
45383 </para>
45384 <para>
45385 <indexterm role="variable">
45386 <primary><varname>$sender_address</varname></primary>
45387 </indexterm>
45388 Whenever an AUTH= value is ignored, the incident is logged. The ACL for
45389 MAIL, if defined, is run after AUTH= is accepted or ignored. It can
45390 therefore make use of <varname>$authenticated_sender</varname>. The converse is not true: the
45391 value of <varname>$sender_address</varname> is not yet set up when the <option>acl_smtp_mailauth</option>
45392 ACL is run.
45393 </para>
45394 </section>
45395 <section id="SECTauthexiser">
45396 <title>Authentication on an Exim server</title>
45397 <para>
45398 <indexterm role="concept">
45399 <primary>authentication</primary>
45400 <secondary>on an Exim server</secondary>
45401 </indexterm>
45402 When Exim receives an EHLO command, it advertises the public names of those
45403 authenticators that are configured as servers, subject to the following
45404 conditions:
45405 </para>
45406 <itemizedlist>
45407 <listitem>
45408 <para>
45409 The client host must match <option>auth_advertise_hosts</option> (default *).
45410 </para>
45411 </listitem>
45412 <listitem>
45413 <para>
45414 It the <option>server_advertise_condition</option> option is set, its expansion must not
45415 yield the empty string, <quote>0</quote>, <quote>no</quote>, or <quote>false</quote>.
45416 </para>
45417 </listitem>
45418 </itemizedlist>
45419 <para>
45420 The order in which the authenticators are defined controls the order in which
45421 the mechanisms are advertised.
45422 </para>
45423 <para>
45424 Some mail clients (for example, some versions of Netscape) require the user to
45425 provide a name and password for authentication whenever AUTH is advertised,
45426 even though authentication may not in fact be needed (for example, Exim may be
45427 set up to allow unconditional relaying from the client by an IP address check).
45428 You can make such clients more friendly by not advertising AUTH to them.
45429 For example, if clients on the 10.9.8.0/24 network are permitted (by the ACL
45430 that runs for RCPT) to relay without authentication, you should set
45431 </para>
45432 <literallayout class="monospaced">
45433 auth_advertise_hosts = ! 10.9.8.0/24
45434 </literallayout>
45435 <para>
45436 so that no authentication mechanisms are advertised to them.
45437 </para>
45438 <para>
45439 The <option>server_advertise_condition</option> controls the advertisement of individual
45440 authentication mechanisms. For example, it can be used to restrict the
45441 advertisement of a particular mechanism to encrypted connections, by a setting
45442 such as:
45443 </para>
45444 <literallayout class="monospaced">
45445 server_advertise_condition = ${if eq{$tls_cipher}{}{no}{yes}}
45446 </literallayout>
45447 <para>
45448 <indexterm role="variable">
45449 <primary><varname>$tls_cipher</varname></primary>
45450 </indexterm>
45451 If the session is encrypted, <varname>$tls_cipher</varname> is not empty, and so the expansion
45452 yields <quote>yes</quote>, which allows the advertisement to happen.
45453 </para>
45454 <para>
45455 When an Exim server receives an AUTH command from a client, it rejects it
45456 immediately if AUTH was not advertised in response to an earlier EHLO
45457 command. This is the case if
45458 </para>
45459 <itemizedlist>
45460 <listitem>
45461 <para>
45462 The client host does not match <option>auth_advertise_hosts</option>; or
45463 </para>
45464 </listitem>
45465 <listitem>
45466 <para>
45467 No authenticators are configured with server options; or
45468 </para>
45469 </listitem>
45470 <listitem>
45471 <para>
45472 Expansion of <option>server_advertise_condition</option> blocked the advertising of all the
45473 server authenticators.
45474 </para>
45475 </listitem>
45476 </itemizedlist>
45477 <para>
45478 Otherwise, Exim runs the ACL specified by <option>acl_smtp_auth</option> in order
45479 to decide whether to accept the command. If <option>acl_smtp_auth</option> is not set,
45480 AUTH is accepted from any client host.
45481 </para>
45482 <para>
45483 If AUTH is not rejected by the ACL, Exim searches its configuration for a
45484 server authentication mechanism that was advertised in response to EHLO and
45485 that matches the one named in the AUTH command. If it finds one, it runs
45486 the appropriate authentication protocol, and authentication either succeeds or
45487 fails. If there is no matching advertised mechanism, the AUTH command is
45488 rejected with a 504 error.
45489 </para>
45490 <para>
45491 <indexterm role="variable">
45492 <primary><varname>$received_protocol</varname></primary>
45493 </indexterm>
45494 <indexterm role="variable">
45495 <primary><varname>$sender_host_authenticated</varname></primary>
45496 </indexterm>
45497 When a message is received from an authenticated host, the value of
45498 <varname>$received_protocol</varname> is set to <quote>esmtpa</quote> or <quote>esmtpsa</quote> instead of <quote>esmtp</quote>
45499 or <quote>esmtps</quote>, and <varname>$sender_host_authenticated</varname> contains the name (not the
45500 public name) of the authenticator driver that successfully authenticated the
45501 client from which the message was received. This variable is empty if there was
45502 no successful authentication.
45503 </para>
45504 </section>
45505 <section id="SECID169">
45506 <title>Testing server authentication</title>
45507 <para>
45508 <indexterm role="concept">
45509 <primary>authentication</primary>
45510 <secondary>testing a server</secondary>
45511 </indexterm>
45512 <indexterm role="concept">
45513 <primary>AUTH</primary>
45514 <secondary>testing a server</secondary>
45515 </indexterm>
45516 <indexterm role="concept">
45517 <primary>base64 encoding</primary>
45518 <secondary>creating authentication test data</secondary>
45519 </indexterm>
45520 Exim&#x2019;s <option>-bh</option> option can be useful for testing server authentication
45521 configurations. The data for the AUTH command has to be sent using base64
45522 encoding. A quick way to produce such data for testing is the following Perl
45523 script:
45524 </para>
45525 <literallayout class="monospaced">
45526 use MIME::Base64;
45527 printf ("%s", encode_base64(eval "\"$ARGV[0]\""));
45528 </literallayout>
45529 <para>
45530 <indexterm role="concept">
45531 <primary>binary zero</primary>
45532 <secondary>in authentication data</secondary>
45533 </indexterm>
45534 This interprets its argument as a Perl string, and then encodes it. The
45535 interpretation as a Perl string allows binary zeros, which are required for
45536 some kinds of authentication, to be included in the data. For example, a
45537 command line to run this script on such data might be
45538 </para>
45539 <literallayout class="monospaced">
45540 encode '\0user\0password'
45541 </literallayout>
45542 <para>
45543 Note the use of single quotes to prevent the shell interpreting the
45544 backslashes, so that they can be interpreted by Perl to specify characters
45545 whose code value is zero.
45546 </para>
45547 <para>
45548 <emphasis role="bold">Warning 1</emphasis>: If either of the user or password strings starts with an octal
45549 digit, you must use three zeros instead of one after the leading backslash. If
45550 you do not, the octal digit that starts your string will be incorrectly
45551 interpreted as part of the code for the first character.
45552 </para>
45553 <para>
45554 <emphasis role="bold">Warning 2</emphasis>: If there are characters in the strings that Perl interprets
45555 specially, you must use a Perl escape to prevent them being misinterpreted. For
45556 example, a command such as
45557 </para>
45558 <literallayout class="monospaced">
45559 encode '\0user@domain.com\0pas$$word'
45560 </literallayout>
45561 <para>
45562 gives an incorrect answer because of the unescaped <quote>@</quote> and <quote>$</quote> characters.
45563 </para>
45564 <para>
45565 If you have the <option>mimencode</option> command installed, another way to do produce
45566 base64-encoded strings is to run the command
45567 </para>
45568 <literallayout class="monospaced">
45569 echo -e -n `\0user\0password' | mimencode
45570 </literallayout>
45571 <para>
45572 The <option>-e</option> option of <option>echo</option> enables the interpretation of backslash escapes
45573 in the argument, and the <option>-n</option> option specifies no newline at the end of its
45574 output. However, not all versions of <option>echo</option> recognize these options, so you
45575 should check your version before relying on this suggestion.
45576 </para>
45577 </section>
45578 <section id="SECID170">
45579 <title>Authentication by an Exim client</title>
45580 <para>
45581 <indexterm role="concept">
45582 <primary>authentication</primary>
45583 <secondary>on an Exim client</secondary>
45584 </indexterm>
45585 The <command>smtp</command> transport has two options called <option>hosts_require_auth</option> and
45586 <option>hosts_try_auth</option>. When the <command>smtp</command> transport connects to a server that
45587 announces support for authentication, and the host matches an entry in either
45588 of these options, Exim (as a client) tries to authenticate as follows:
45589 </para>
45590 <itemizedlist>
45591 <listitem>
45592 <para>
45593 For each authenticator that is configured as a client, in the order in which
45594 they are defined in the configuration, it searches the authentication
45595 mechanisms announced by the server for one whose name matches the public name
45596 of the authenticator.
45597 </para>
45598 </listitem>
45599 <listitem>
45600 <para>
45601 <indexterm role="variable">
45602 <primary><varname>$host</varname></primary>
45603 </indexterm>
45604 <indexterm role="variable">
45605 <primary><varname>$host_address</varname></primary>
45606 </indexterm>
45607 When it finds one that matches, it runs the authenticator&#x2019;s client code. The
45608 variables <varname>$host</varname> and <varname>$host_address</varname> are available for any string expansions
45609 that the client might do. They are set to the server&#x2019;s name and IP address. If
45610 any expansion is forced to fail, the authentication attempt is abandoned, and
45611 Exim moves on to the next authenticator. Otherwise an expansion failure causes
45612 delivery to be deferred.
45613 </para>
45614 </listitem>
45615 <listitem>
45616 <para>
45617 If the result of the authentication attempt is a temporary error or a timeout,
45618 Exim abandons trying to send the message to the host for the moment. It will
45619 try again later. If there are any backup hosts available, they are tried in the
45620 usual way.
45621 </para>
45622 </listitem>
45623 <listitem>
45624 <para>
45625 If the response to authentication is a permanent error (5<emphasis>xx</emphasis> code), Exim
45626 carries on searching the list of authenticators and tries another one if
45627 possible. If all authentication attempts give permanent errors, or if there are
45628 no attempts because no mechanisms match (or option expansions force failure),
45629 what happens depends on whether the host matches <option>hosts_require_auth</option> or
45630 <option>hosts_try_auth</option>. In the first case, a temporary error is generated, and
45631 delivery is deferred. The error can be detected in the retry rules, and thereby
45632 turned into a permanent error if you wish. In the second case, Exim tries to
45633 deliver the message unauthenticated.
45634 </para>
45635 </listitem>
45636 </itemizedlist>
45637 <para>
45638 <indexterm role="concept">
45639 <primary>AUTH</primary>
45640 <secondary>on MAIL command</secondary>
45641 </indexterm>
45642 When Exim has authenticated itself to a remote server, it adds the AUTH
45643 parameter to the MAIL commands it sends, if it has an authenticated sender for
45644 the message. If the message came from a remote host, the authenticated sender
45645 is the one that was receiving on an incoming MAIL command, provided that the
45646 incoming connection was authenticated and the <option>server_mail_auth</option> condition
45647 allowed the authenticated sender to be retained. If a local process calls Exim
45648 to send a message, the sender address that is built from the login name and
45649 <option>qualify_domain</option> is treated as authenticated. However, if the
45650 <option>authenticated_sender</option> option is set on the <command>smtp</command> transport, it overrides
45651 the authenticated sender that was received with the message.
45652 <indexterm role="concept" startref="IIDauthconf1" class="endofrange"/>
45653 <indexterm role="concept" startref="IIDauthconf2" class="endofrange"/>
45654 </para>
45655 </section>
45656 </chapter>
45657
45658 <chapter id="CHAPplaintext">
45659 <title>The plaintext authenticator</title>
45660 <para>
45661 <indexterm role="concept" id="IIDplaiauth1" class="startofrange">
45662 <primary><command>plaintext</command> authenticator</primary>
45663 </indexterm>
45664 <indexterm role="concept" id="IIDplaiauth2" class="startofrange">
45665 <primary>authenticators</primary>
45666 <secondary><command>plaintext</command></secondary>
45667 </indexterm>
45668 The <command>plaintext</command> authenticator can be configured to support the PLAIN and
45669 LOGIN authentication mechanisms, both of which transfer authentication data as
45670 plain (unencrypted) text (though base64 encoded). The use of plain text is a
45671 security risk; you are strongly advised to insist on the use of SMTP encryption
45672 (see chapter <xref linkend="CHAPTLS"/>) if you use the PLAIN or LOGIN mechanisms. If you do
45673 use unencrypted plain text, you should not use the same passwords for SMTP
45674 connections as you do for login accounts.
45675 </para>
45676 <section id="SECID171">
45677 <title>Plaintext options</title>
45678 <para>
45679 <indexterm role="concept">
45680 <primary>options</primary>
45681 <secondary><command>plaintext</command> authenticator (server)</secondary>
45682 </indexterm>
45683 When configured as a server, <command>plaintext</command> uses the following options:
45684 </para>
45685 <para>
45686 <indexterm role="option">
45687 <primary><option>server_condition</option></primary>
45688 </indexterm>
45689 </para>
45690 <informaltable frame="all">
45691 <tgroup cols="4" colsep="0" rowsep="0">
45692 <colspec colwidth="8*" align="left"/>
45693 <colspec colwidth="6*" align="center"/>
45694 <colspec colwidth="6*" align="center"/>
45695 <colspec colwidth="6*" align="right"/>
45696 <tbody>
45697 <row>
45698 <entry><option>server_condition</option></entry>
45699 <entry>Use: <emphasis>authenticators</emphasis></entry>
45700 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
45701 <entry>Default: <emphasis>unset</emphasis></entry>
45702 </row>
45703 </tbody>
45704 </tgroup>
45705 </informaltable>
45706 <para>
45707 This is actually a global authentication option, but it must be set in order to
45708 configure the <command>plaintext</command> driver as a server. Its use is described below.
45709 </para>
45710 <para>
45711 <indexterm role="option">
45712 <primary><option>server_prompts</option></primary>
45713 </indexterm>
45714 </para>
45715 <informaltable frame="all">
45716 <tgroup cols="4" colsep="0" rowsep="0">
45717 <colspec colwidth="8*" align="left"/>
45718 <colspec colwidth="6*" align="center"/>
45719 <colspec colwidth="6*" align="center"/>
45720 <colspec colwidth="6*" align="right"/>
45721 <tbody>
45722 <row>
45723 <entry><option>server_prompts</option></entry>
45724 <entry>Use: <emphasis>plaintext</emphasis></entry>
45725 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
45726 <entry>Default: <emphasis>unset</emphasis></entry>
45727 </row>
45728 </tbody>
45729 </tgroup>
45730 </informaltable>
45731 <para>
45732 The contents of this option, after expansion, must be a colon-separated list of
45733 prompt strings. If expansion fails, a temporary authentication rejection is
45734 given.
45735 </para>
45736 </section>
45737 <section id="SECTplainserver">
45738 <title>Using plaintext in a server</title>
45739 <para>
45740 <indexterm role="concept">
45741 <primary>AUTH</primary>
45742 <secondary>in <command>plaintext</command> authenticator</secondary>
45743 </indexterm>
45744 <indexterm role="concept">
45745 <primary>binary zero</primary>
45746 <secondary>in <command>plaintext</command> authenticator</secondary>
45747 </indexterm>
45748 <indexterm role="concept">
45749 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
45750 <secondary>in <command>plaintext</command> authenticator</secondary>
45751 </indexterm>
45752 <indexterm role="variable">
45753 <primary><varname>$auth1</varname>, <varname>$auth2</varname>, etc</primary>
45754 </indexterm>
45755 <indexterm role="concept">
45756 <primary>base64 encoding</primary>
45757 <secondary>in <command>plaintext</command> authenticator</secondary>
45758 </indexterm>
45759 </para>
45760 <para>
45761 When running as a server, <command>plaintext</command> performs the authentication test by
45762 expanding a string. The data sent by the client with the AUTH command, or in
45763 response to subsequent prompts, is base64 encoded, and so may contain any byte
45764 values when decoded. If any data is supplied with the command, it is treated as
45765 a list of strings, separated by NULs (binary zeros), the first three of which
45766 are placed in the expansion variables <varname>$auth1</varname>, <varname>$auth2</varname>, and <varname>$auth3</varname>
45767 (neither LOGIN nor PLAIN uses more than three strings).
45768 </para>
45769 <para>
45770 For compatibility with previous releases of Exim, the values are also placed in
45771 the expansion variables <varname>$1</varname>, <varname>$2</varname>, and <varname>$3</varname>. However, the use of these
45772 variables for this purpose is now deprecated, as it can lead to confusion in
45773 string expansions that also use them for other things.
45774 </para>
45775 <para>
45776 If there are more strings in <option>server_prompts</option> than the number of strings
45777 supplied with the AUTH command, the remaining prompts are used to obtain more
45778 data. Each response from the client may be a list of NUL-separated strings.
45779 </para>
45780 <para>
45781 <indexterm role="variable">
45782 <primary><varname>$authenticated_id</varname></primary>
45783 </indexterm>
45784 Once a sufficient number of data strings have been received,
45785 <option>server_condition</option> is expanded. If the expansion is forced to fail,
45786 authentication fails. Any other expansion failure causes a temporary error code
45787 to be returned. If the result of a successful expansion is an empty string,
45788 <quote>0</quote>, <quote>no</quote>, or <quote>false</quote>, authentication fails. If the result of the
45789 expansion is <quote>1</quote>, <quote>yes</quote>, or <quote>true</quote>, authentication succeeds and the
45790 generic <option>server_set_id</option> option is expanded and saved in <varname>$authenticated_id</varname>.
45791 For any other result, a temporary error code is returned, with the expanded
45792 string as the error text.
45793 </para>
45794 <para>
45795 <emphasis role="bold">Warning</emphasis>: If you use a lookup in the expansion to find the user&#x2019;s
45796 password, be sure to make the authentication fail if the user is unknown.
45797 There are good and bad examples at the end of the next section.
45798 </para>
45799 </section>
45800 <section id="SECID172">
45801 <title>The PLAIN authentication mechanism</title>
45802 <para>
45803 <indexterm role="concept">
45804 <primary>PLAIN authentication mechanism</primary>
45805 </indexterm>
45806 <indexterm role="concept">
45807 <primary>authentication</primary>
45808 <secondary>PLAIN mechanism</secondary>
45809 </indexterm>
45810 <indexterm role="concept">
45811 <primary>binary zero</primary>
45812 <secondary>in <command>plaintext</command> authenticator</secondary>
45813 </indexterm>
45814 The PLAIN authentication mechanism (RFC 2595) specifies that three strings be
45815 sent as one item of data (that is, one combined string containing two NUL
45816 separators). The data is sent either as part of the AUTH command, or
45817 subsequently in response to an empty prompt from the server.
45818 </para>
45819 <para>
45820 The second and third strings are a user name and a corresponding password.
45821 Using a single fixed user name and password as an example, this could be
45822 configured as follows:
45823 </para>
45824 <literallayout class="monospaced">
45825 fixed_plain:
45826   driver = plaintext
45827   public_name = PLAIN
45828   server_prompts = :
45829   server_condition = \
45830     ${if and {{eq{$auth2}{username}}{eq{$auth3}{mysecret}}}}
45831   server_set_id = $auth2
45832 </literallayout>
45833 <para>
45834 Note that the default result strings from <option>if</option> (<quote>true</quote> or an empty string)
45835 are exactly what we want here, so they need not be specified. Obviously, if the
45836 password contains expansion-significant characters such as dollar, backslash,
45837 or closing brace, they have to be escaped.
45838 </para>
45839 <para>
45840 The <option>server_prompts</option> setting specifies a single, empty prompt (empty items at
45841 the end of a string list are ignored). If all the data comes as part of the
45842 AUTH command, as is commonly the case, the prompt is not used. This
45843 authenticator is advertised in the response to EHLO as
45844 </para>
45845 <literallayout class="monospaced">
45846 250-AUTH PLAIN
45847 </literallayout>
45848 <para>
45849 and a client host can authenticate itself by sending the command
45850 </para>
45851 <literallayout class="monospaced">
45852 AUTH PLAIN AHVzZXJuYW1lAG15c2VjcmV0
45853 </literallayout>
45854 <para>
45855 As this contains three strings (more than the number of prompts), no further
45856 data is required from the client. Alternatively, the client may just send
45857 </para>
45858 <literallayout class="monospaced">
45859 AUTH PLAIN
45860 </literallayout>
45861 <para>
45862 to initiate authentication, in which case the server replies with an empty
45863 prompt. The client must respond with the combined data string.
45864 </para>
45865 <para>
45866 The data string is base64 encoded, as required by the RFC. This example,
45867 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;
45868 represents a zero byte. This is split up into three strings, the first of which
45869 is empty. The <option>server_condition</option> option in the authenticator checks that the
45870 second two are <literal>username</literal> and <literal>mysecret</literal> respectively.
45871 </para>
45872 <para>
45873 Having just one fixed user name and password, as in this example, is not very
45874 realistic, though for a small organization with only a handful of
45875 authenticating clients it could make sense.
45876 </para>
45877 <para>
45878 A more sophisticated instance of this authenticator could use the user name in
45879 <varname>$auth2</varname> to look up a password in a file or database, and maybe do an encrypted
45880 comparison (see <option>crypteq</option> in chapter <xref linkend="CHAPexpand"/>). Here is a example of
45881 this approach, where the passwords are looked up in a DBM file. <emphasis role="bold">Warning</emphasis>:
45882 This is an incorrect example:
45883 </para>
45884 <literallayout class="monospaced">
45885 server_condition = \
45886   ${if eq{$auth3}{${lookup{$auth2}dbm{/etc/authpwd}}}}
45887 </literallayout>
45888 <para>
45889 The expansion uses the user name (<varname>$auth2</varname>) as the key to look up a password,
45890 which it then compares to the supplied password (<varname>$auth3</varname>). Why is this example
45891 incorrect? It works fine for existing users, but consider what happens if a
45892 non-existent user name is given. The lookup fails, but as no success/failure
45893 strings are given for the lookup, it yields an empty string. Thus, to defeat
45894 the authentication, all a client has to do is to supply a non-existent user
45895 name and an empty password. The correct way of writing this test is:
45896 </para>
45897 <literallayout class="monospaced">
45898 server_condition = ${lookup{$auth2}dbm{/etc/authpwd}\
45899   {${if eq{$value}{$auth3}}} {false}}
45900 </literallayout>
45901 <para>
45902 In this case, if the lookup succeeds, the result is checked; if the lookup
45903 fails, <quote>false</quote> is returned and authentication fails. If <option>crypteq</option> is being
45904 used instead of <option>eq</option>, the first example is in fact safe, because <option>crypteq</option>
45905 always fails if its second argument is empty. However, the second way of
45906 writing the test makes the logic clearer.
45907 </para>
45908 </section>
45909 <section id="SECID173">
45910 <title>The LOGIN authentication mechanism</title>
45911 <para>
45912 <indexterm role="concept">
45913 <primary>LOGIN authentication mechanism</primary>
45914 </indexterm>
45915 <indexterm role="concept">
45916 <primary>authentication</primary>
45917 <secondary>LOGIN mechanism</secondary>
45918 </indexterm>
45919 The LOGIN authentication mechanism is not documented in any RFC, but is in use
45920 in a number of programs. No data is sent with the AUTH command. Instead, a
45921 user name and password are supplied separately, in response to prompts. The
45922 plaintext authenticator can be configured to support this as in this example:
45923 </para>
45924 <literallayout class="monospaced">
45925 fixed_login:
45926   driver = plaintext
45927   public_name = LOGIN
45928   server_prompts = User Name : Password
45929   server_condition = \
45930     ${if and {{eq{$auth1}{username}}{eq{$auth2}{mysecret}}}}
45931   server_set_id = $auth1
45932 </literallayout>
45933 <para>
45934 Because of the way plaintext operates, this authenticator accepts data supplied
45935 with the AUTH command (in contravention of the specification of LOGIN), but
45936 if the client does not supply it (as is the case for LOGIN clients), the prompt
45937 strings are used to obtain two data items.
45938 </para>
45939 <para revisionflag="changed">
45940 Some clients are very particular about the precise text of the prompts. For
45941 example, Outlook Express is reported to recognize only <quote>Username:</quote> and
45942 <quote>Password:</quote>. Here is an example of a LOGIN authenticator that uses those
45943 strings. It uses the <option>ldapauth</option> expansion condition to check the user
45944 name and password by binding to an LDAP server:
45945 </para>
45946 <literallayout class="monospaced" revisionflag="changed">
45947 login:
45948   driver = plaintext
45949   public_name = LOGIN
45950   server_prompts = Username:: : Password::
45951   server_condition = ${if and{{ \
45952     !eq{}{$auth1} }{ \
45953     ldapauth{user="cn=${quote_ldap_dn:$auth1},ou=people,o=example.org" \
45954              pass=${quote:$auth2} \
45955              ldap://ldap.example.org/} }} }
45956   server_set_id = uid=$auth1,ou=people,o=example.org
45957 </literallayout>
45958 <para revisionflag="changed">
45959 We have to check that the username is not empty before using it, because LDAP
45960 does not permit empty DN components. We must also use the <option>quote_ldap_dn</option>
45961 operator to correctly quote the DN for authentication. However, the basic
45962 <option>quote</option> operator, rather than any of the LDAP quoting operators, is the
45963 correct one to use for the password, because quoting is needed only to make
45964 the password conform to the Exim syntax. At the LDAP level, the password is an
45965 uninterpreted string.
45966 </para>
45967 </section>
45968 <section id="SECID174">
45969 <title>Support for different kinds of authentication</title>
45970 <para>
45971 A number of string expansion features are provided for the purpose of
45972 interfacing to different ways of user authentication. These include checking
45973 traditionally encrypted passwords from <filename>/etc/passwd</filename> (or equivalent), PAM,
45974 Radius, <option>ldapauth</option>, <emphasis>pwcheck</emphasis>, and <emphasis>saslauthd</emphasis>. For details see section
45975 <xref linkend="SECTexpcond"/>.
45976 </para>
45977 </section>
45978 <section id="SECID175">
45979 <title>Using plaintext in a client</title>
45980 <para>
45981 <indexterm role="concept">
45982 <primary>options</primary>
45983 <secondary><command>plaintext</command> authenticator (client)</secondary>
45984 </indexterm>
45985 The <command>plaintext</command> authenticator has two client options:
45986 </para>
45987 <para>
45988 <indexterm role="option">
45989 <primary><option>client_ignore_invalid_base64</option></primary>
45990 </indexterm>
45991 </para>
45992 <informaltable frame="all">
45993 <tgroup cols="4" colsep="0" rowsep="0">
45994 <colspec colwidth="8*" align="left"/>
45995 <colspec colwidth="6*" align="center"/>
45996 <colspec colwidth="6*" align="center"/>
45997 <colspec colwidth="6*" align="right"/>
45998 <tbody>
45999 <row>
46000 <entry><option>client_ignore_invalid_base64</option></entry>
46001 <entry>Use: <emphasis>plaintext</emphasis></entry>
46002 <entry>Type: <emphasis>boolean</emphasis></entry>
46003 <entry>Default: <emphasis>false</emphasis></entry>
46004 </row>
46005 </tbody>
46006 </tgroup>
46007 </informaltable>
46008 <para>
46009 If the client receives a server prompt that is not a valid base64 string,
46010 authentication is abandoned by default. However, if this option is set true,
46011 the error in the challenge is ignored and the client sends the response as
46012 usual.
46013 </para>
46014 <para>
46015 <indexterm role="option">
46016 <primary><option>client_send</option></primary>
46017 </indexterm>
46018 </para>
46019 <informaltable frame="all">
46020 <tgroup cols="4" colsep="0" rowsep="0">
46021 <colspec colwidth="8*" align="left"/>
46022 <colspec colwidth="6*" align="center"/>
46023 <colspec colwidth="6*" align="center"/>
46024 <colspec colwidth="6*" align="right"/>
46025 <tbody>
46026 <row>
46027 <entry><option>client_send</option></entry>
46028 <entry>Use: <emphasis>plaintext</emphasis></entry>
46029 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
46030 <entry>Default: <emphasis>unset</emphasis></entry>
46031 </row>
46032 </tbody>
46033 </tgroup>
46034 </informaltable>
46035 <para>
46036 The string is a colon-separated list of authentication data strings. Each
46037 string is independently expanded before being sent to the server. The first
46038 string is sent with the AUTH command; any more strings are sent in response
46039 to prompts from the server. Before each string is expanded, the value of the
46040 most recent prompt is placed in the next <varname>$auth</varname>&lt;<emphasis>n</emphasis>&gt; variable, starting
46041 with <varname>$auth1</varname> for the first prompt. Up to three prompts are stored in this
46042 way. Thus, the prompt that is received in response to sending the first string
46043 (with the AUTH command) can be used in the expansion of the second string, and
46044 so on. If an invalid base64 string is received when
46045 <option>client_ignore_invalid_base64</option> is set, an empty string is put in the
46046 <varname>$auth</varname>&lt;<emphasis>n</emphasis>&gt; variable.
46047 </para>
46048 <para>
46049 <emphasis role="bold">Note</emphasis>: You cannot use expansion to create multiple strings, because
46050 splitting takes priority and happens first.
46051 </para>
46052 <para>
46053 Because the PLAIN authentication mechanism requires NUL (binary zero) bytes in
46054 the data, further processing is applied to each string before it is sent. If
46055 there are any single circumflex characters in the string, they are converted to
46056 NULs. Should an actual circumflex be required as data, it must be doubled in
46057 the string.
46058 </para>
46059 <para>
46060 This is an example of a client configuration that implements the PLAIN
46061 authentication mechanism with a fixed user name and password:
46062 </para>
46063 <literallayout class="monospaced">
46064 fixed_plain:
46065   driver = plaintext
46066   public_name = PLAIN
46067   client_send = ^username^mysecret
46068 </literallayout>
46069 <para>
46070 The lack of colons means that the entire text is sent with the AUTH
46071 command, with the circumflex characters converted to NULs. A similar example
46072 that uses the LOGIN mechanism is:
46073 </para>
46074 <literallayout class="monospaced">
46075 fixed_login:
46076   driver = plaintext
46077   public_name = LOGIN
46078   client_send = : username : mysecret
46079 </literallayout>
46080 <para>
46081 The initial colon means that the first string is empty, so no data is sent with
46082 the AUTH command itself. The remaining strings are sent in response to
46083 prompts.
46084 <indexterm role="concept" startref="IIDplaiauth1" class="endofrange"/>
46085 <indexterm role="concept" startref="IIDplaiauth2" class="endofrange"/>
46086 </para>
46087 </section>
46088 </chapter>
46089
46090 <chapter id="CHID9">
46091 <title>The cram_md5 authenticator</title>
46092 <para>
46093 <indexterm role="concept" id="IIDcramauth1" class="startofrange">
46094 <primary><command>cram_md5</command> authenticator</primary>
46095 </indexterm>
46096 <indexterm role="concept" id="IIDcramauth2" class="startofrange">
46097 <primary>authenticators</primary>
46098 <secondary><command>cram_md5</command></secondary>
46099 </indexterm>
46100 <indexterm role="concept">
46101 <primary>CRAM-MD5 authentication mechanism</primary>
46102 </indexterm>
46103 <indexterm role="concept">
46104 <primary>authentication</primary>
46105 <secondary>CRAM-MD5 mechanism</secondary>
46106 </indexterm>
46107 The CRAM-MD5 authentication mechanism is described in RFC 2195. The server
46108 sends a challenge string to the client, and the response consists of a user
46109 name and the CRAM-MD5 digest of the challenge string combined with a secret
46110 string (password) which is known to both server and client. Thus, the secret
46111 is not sent over the network as plain text, which makes this authenticator more
46112 secure than <command>plaintext</command>. However, the downside is that the secret has to be
46113 available in plain text at either end.
46114 </para>
46115 <section id="SECID176">
46116 <title>Using cram_md5 as a server</title>
46117 <para>
46118 <indexterm role="concept">
46119 <primary>options</primary>
46120 <secondary><command>cram_md5</command> authenticator (server)</secondary>
46121 </indexterm>
46122 This authenticator has one server option, which must be set to configure the
46123 authenticator as a server:
46124 </para>
46125 <para>
46126 <indexterm role="option">
46127 <primary><option>server_secret</option></primary>
46128 </indexterm>
46129 </para>
46130 <informaltable frame="all">
46131 <tgroup cols="4" colsep="0" rowsep="0">
46132 <colspec colwidth="8*" align="left"/>
46133 <colspec colwidth="6*" align="center"/>
46134 <colspec colwidth="6*" align="center"/>
46135 <colspec colwidth="6*" align="right"/>
46136 <tbody>
46137 <row>
46138 <entry><option>server_secret</option></entry>
46139 <entry>Use: <emphasis>cram_md5</emphasis></entry>
46140 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
46141 <entry>Default: <emphasis>unset</emphasis></entry>
46142 </row>
46143 </tbody>
46144 </tgroup>
46145 </informaltable>
46146 <para>
46147 <indexterm role="concept">
46148 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
46149 <secondary>in <command>cram_md5</command> authenticator</secondary>
46150 </indexterm>
46151 When the server receives the client&#x2019;s response, the user name is placed in
46152 the expansion variable <varname>$auth1</varname>, and <option>server_secret</option> is expanded to
46153 obtain the password for that user. The server then computes the CRAM-MD5 digest
46154 that the client should have sent, and checks that it received the correct
46155 string. If the expansion of <option>server_secret</option> is forced to fail, authentication
46156 fails. If the expansion fails for some other reason, a temporary error code is
46157 returned to the client.
46158 </para>
46159 <para>
46160 For compatibility with previous releases of Exim, the user name is also placed
46161 in <varname>$1</varname>. However, the use of this variables for this purpose is now
46162 deprecated, as it can lead to confusion in string expansions that also use
46163 numeric variables for other things.
46164 </para>
46165 <para>
46166 For example, the following authenticator checks that the user name given by the
46167 client is <quote>ph10</quote>, and if so, uses <quote>secret</quote> as the password. For any other
46168 user name, authentication fails.
46169 </para>
46170 <literallayout class="monospaced">
46171 fixed_cram:
46172   driver = cram_md5
46173   public_name = CRAM-MD5
46174   server_secret = ${if eq{$auth1}{ph10}{secret}fail}
46175   server_set_id = $auth1
46176 </literallayout>
46177 <para>
46178 <indexterm role="variable">
46179 <primary><varname>$authenticated_id</varname></primary>
46180 </indexterm>
46181 If authentication succeeds, the setting of <option>server_set_id</option> preserves the user
46182 name in <varname>$authenticated_id</varname>. A more typical configuration might look up the
46183 secret string in a file, using the user name as the key. For example:
46184 </para>
46185 <literallayout class="monospaced">
46186 lookup_cram:
46187   driver = cram_md5
46188   public_name = CRAM-MD5
46189   server_secret = ${lookup{$auth1}lsearch{/etc/authpwd}\
46190                   {$value}fail}
46191   server_set_id = $auth1
46192 </literallayout>
46193 <para>
46194 Note that this expansion explicitly forces failure if the lookup fails
46195 because <varname>$auth1</varname> contains an unknown user name.
46196 </para>
46197 </section>
46198 <section id="SECID177">
46199 <title>Using cram_md5 as a client</title>
46200 <para>
46201 <indexterm role="concept">
46202 <primary>options</primary>
46203 <secondary><command>cram_md5</command> authenticator (client)</secondary>
46204 </indexterm>
46205 When used as a client, the <command>cram_md5</command> authenticator has two options:
46206 </para>
46207 <para>
46208 <indexterm role="option">
46209 <primary><option>client_name</option></primary>
46210 </indexterm>
46211 </para>
46212 <informaltable frame="all">
46213 <tgroup cols="4" colsep="0" rowsep="0">
46214 <colspec colwidth="8*" align="left"/>
46215 <colspec colwidth="6*" align="center"/>
46216 <colspec colwidth="6*" align="center"/>
46217 <colspec colwidth="6*" align="right"/>
46218 <tbody>
46219 <row>
46220 <entry><option>client_name</option></entry>
46221 <entry>Use: <emphasis>cram_md5</emphasis></entry>
46222 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
46223 <entry>Default: <emphasis>the primary host name</emphasis></entry>
46224 </row>
46225 </tbody>
46226 </tgroup>
46227 </informaltable>
46228 <para>
46229 This string is expanded, and the result used as the user name data when
46230 computing the response to the server&#x2019;s challenge.
46231 </para>
46232 <para>
46233 <indexterm role="option">
46234 <primary><option>client_secret</option></primary>
46235 </indexterm>
46236 </para>
46237 <informaltable frame="all">
46238 <tgroup cols="4" colsep="0" rowsep="0">
46239 <colspec colwidth="8*" align="left"/>
46240 <colspec colwidth="6*" align="center"/>
46241 <colspec colwidth="6*" align="center"/>
46242 <colspec colwidth="6*" align="right"/>
46243 <tbody>
46244 <row>
46245 <entry><option>client_secret</option></entry>
46246 <entry>Use: <emphasis>cram_md5</emphasis></entry>
46247 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
46248 <entry>Default: <emphasis>unset</emphasis></entry>
46249 </row>
46250 </tbody>
46251 </tgroup>
46252 </informaltable>
46253 <para>
46254 This option must be set for the authenticator to work as a client. Its value is
46255 expanded and the result used as the secret string when computing the response.
46256 </para>
46257 <para>
46258 <indexterm role="variable">
46259 <primary><varname>$host</varname></primary>
46260 </indexterm>
46261 <indexterm role="variable">
46262 <primary><varname>$host_address</varname></primary>
46263 </indexterm>
46264 Different user names and secrets can be used for different servers by referring
46265 to <varname>$host</varname> or <varname>$host_address</varname> in the options. Forced failure of either
46266 expansion string is treated as an indication that this authenticator is not
46267 prepared to handle this case. Exim moves on to the next configured client
46268 authenticator. Any other expansion failure causes Exim to give up trying to
46269 send the message to the current server.
46270 </para>
46271 <para>
46272 A simple example configuration of a <command>cram_md5</command> authenticator, using fixed
46273 strings, is:
46274 </para>
46275 <literallayout class="monospaced">
46276 fixed_cram:
46277   driver = cram_md5
46278   public_name = CRAM-MD5
46279   client_name = ph10
46280   client_secret = secret
46281 </literallayout>
46282 <para>
46283 <indexterm role="concept" startref="IIDcramauth1" class="endofrange"/>
46284 <indexterm role="concept" startref="IIDcramauth2" class="endofrange"/>
46285 </para>
46286 </section>
46287 </chapter>
46288
46289 <chapter id="CHID10">
46290 <title>The cyrus_sasl authenticator</title>
46291 <para>
46292 <indexterm role="concept" id="IIDcyrauth1" class="startofrange">
46293 <primary><command>cyrus_sasl</command> authenticator</primary>
46294 </indexterm>
46295 <indexterm role="concept" id="IIDcyrauth2" class="startofrange">
46296 <primary>authenticators</primary>
46297 <secondary><command>cyrus_sasl</command></secondary>
46298 </indexterm>
46299 <indexterm role="concept">
46300 <primary>Cyrus</primary>
46301 <secondary>SASL library</secondary>
46302 </indexterm>
46303 <indexterm role="concept">
46304 <primary>Kerberos</primary>
46305 </indexterm>
46306 The code for this authenticator was provided by Matthew Byng-Maddick of A L
46307 Digital Ltd (<emphasis role="bold"><ulink url="http://www.aldigital.co.uk">http://www.aldigital.co.uk</ulink></emphasis>).
46308 </para>
46309 <para>
46310 The <command>cyrus_sasl</command> authenticator provides server support for the Cyrus SASL
46311 library implementation of the RFC 2222 (<quote>Simple Authentication and Security
46312 Layer</quote>). This library supports a number of authentication mechanisms,
46313 including PLAIN and LOGIN, but also several others that Exim does not support
46314 directly. In particular, there is support for Kerberos authentication.
46315 </para>
46316 <para>
46317 The <command>cyrus_sasl</command> authenticator provides a gatewaying mechanism directly to
46318 the Cyrus interface, so if your Cyrus library can do, for example, CRAM-MD5,
46319 then so can the <command>cyrus_sasl</command> authenticator. By default it uses the public
46320 name of the driver to determine which mechanism to support.
46321 </para>
46322 <para>
46323 Where access to some kind of secret file is required, for example in GSSAPI
46324 or CRAM-MD5, it is worth noting that the authenticator runs as the Exim
46325 user, and that the Cyrus SASL library has no way of escalating privileges
46326 by default. You may also find you need to set environment variables,
46327 depending on the driver you are using.
46328 </para>
46329 <para>
46330 The application name provided by Exim is <quote>exim</quote>, so various SASL options may
46331 be set in <filename>exim.conf</filename> in your SASL directory. If you are using GSSAPI for
46332 Kerberos, note that because of limitations in the GSSAPI interface,
46333 changing the server keytab might need to be communicated down to the Kerberos
46334 layer independently. The mechanism for doing so is dependent upon the Kerberos
46335 implementation. For example, for Heimdal, the environment variable KRB5_KTNAME
46336 may be set to point to an alternative keytab file. Exim will pass this
46337 variable through from its own inherited environment when started as root or the
46338 Exim user. The keytab file needs to be readable by the Exim user.
46339 </para>
46340 <section id="SECID178">
46341 <title>Using cyrus_sasl as a server</title>
46342 <para>
46343 The <command>cyrus_sasl</command> authenticator has four private options. It puts the username
46344 (on a successful authentication) into <varname>$auth1</varname>. For compatibility with
46345 previous releases of Exim, the username is also placed in <varname>$1</varname>. However, the
46346 use of this variable for this purpose is now deprecated, as it can lead to
46347 confusion in string expansions that also use numeric variables for other
46348 things.
46349 </para>
46350 <para>
46351 <indexterm role="option">
46352 <primary><option>server_hostname</option></primary>
46353 </indexterm>
46354 </para>
46355 <informaltable frame="all">
46356 <tgroup cols="4" colsep="0" rowsep="0">
46357 <colspec colwidth="8*" align="left"/>
46358 <colspec colwidth="6*" align="center"/>
46359 <colspec colwidth="6*" align="center"/>
46360 <colspec colwidth="6*" align="right"/>
46361 <tbody>
46362 <row>
46363 <entry><option>server_hostname</option></entry>
46364 <entry>Use: <emphasis>cyrus_sasl</emphasis></entry>
46365 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
46366 <entry>Default: <emphasis>see below</emphasis></entry>
46367 </row>
46368 </tbody>
46369 </tgroup>
46370 </informaltable>
46371 <para>
46372 This option selects the hostname that is used when communicating with the
46373 library. The default value is <literal>$primary_hostname</literal>. It is up to the underlying
46374 SASL plug-in what it does with this data.
46375 </para>
46376 <para>
46377 <indexterm role="option">
46378 <primary><option>server_mech</option></primary>
46379 </indexterm>
46380 </para>
46381 <informaltable frame="all">
46382 <tgroup cols="4" colsep="0" rowsep="0">
46383 <colspec colwidth="8*" align="left"/>
46384 <colspec colwidth="6*" align="center"/>
46385 <colspec colwidth="6*" align="center"/>
46386 <colspec colwidth="6*" align="right"/>
46387 <tbody>
46388 <row>
46389 <entry><option>server_mech</option></entry>
46390 <entry>Use: <emphasis>cyrus_sasl</emphasis></entry>
46391 <entry>Type: <emphasis>string</emphasis></entry>
46392 <entry>Default: <emphasis>see below</emphasis></entry>
46393 </row>
46394 </tbody>
46395 </tgroup>
46396 </informaltable>
46397 <para>
46398 This option selects the authentication mechanism this driver should use. The
46399 default is the value of the generic <option>public_name</option> option. This option allows
46400 you to use a different underlying mechanism from the advertised name. For
46401 example:
46402 </para>
46403 <literallayout class="monospaced">
46404 sasl:
46405   driver = cyrus_sasl
46406   public_name = X-ANYTHING
46407   server_mech = CRAM-MD5
46408   server_set_id = $auth1
46409 </literallayout>
46410 <para>
46411 <indexterm role="option">
46412 <primary><option>server_realm</option></primary>
46413 </indexterm>
46414 </para>
46415 <informaltable frame="all">
46416 <tgroup cols="4" colsep="0" rowsep="0">
46417 <colspec colwidth="8*" align="left"/>
46418 <colspec colwidth="6*" align="center"/>
46419 <colspec colwidth="6*" align="center"/>
46420 <colspec colwidth="6*" align="right"/>
46421 <tbody>
46422 <row>
46423 <entry><option>server_realm</option></entry>
46424 <entry>Use: <emphasis>cyrus_sasl</emphasis></entry>
46425 <entry>Type: <emphasis>string</emphasis></entry>
46426 <entry>Default: <emphasis>unset</emphasis></entry>
46427 </row>
46428 </tbody>
46429 </tgroup>
46430 </informaltable>
46431 <para>
46432 This specifies the SASL realm that the server claims to be in.
46433 </para>
46434 <para>
46435 <indexterm role="option">
46436 <primary><option>server_service</option></primary>
46437 </indexterm>
46438 </para>
46439 <informaltable frame="all">
46440 <tgroup cols="4" colsep="0" rowsep="0">
46441 <colspec colwidth="8*" align="left"/>
46442 <colspec colwidth="6*" align="center"/>
46443 <colspec colwidth="6*" align="center"/>
46444 <colspec colwidth="6*" align="right"/>
46445 <tbody>
46446 <row>
46447 <entry><option>server_service</option></entry>
46448 <entry>Use: <emphasis>cyrus_sasl</emphasis></entry>
46449 <entry>Type: <emphasis>string</emphasis></entry>
46450 <entry>Default: <emphasis><literal>smtp</literal></emphasis></entry>
46451 </row>
46452 </tbody>
46453 </tgroup>
46454 </informaltable>
46455 <para>
46456 This is the SASL service that the server claims to implement.
46457 </para>
46458 <para>
46459 For straightforward cases, you do not need to set any of the authenticator&#x2019;s
46460 private options. All you need to do is to specify an appropriate mechanism as
46461 the public name. Thus, if you have a SASL library that supports CRAM-MD5 and
46462 PLAIN, you could have two authenticators as follows:
46463 </para>
46464 <literallayout class="monospaced">
46465 sasl_cram_md5:
46466   driver = cyrus_sasl
46467   public_name = CRAM-MD5
46468   server_set_id = $auth1
46469
46470 sasl_plain:
46471   driver = cyrus_sasl
46472   public_name = PLAIN
46473   server_set_id = $auth2
46474 </literallayout>
46475 <para>
46476 Cyrus SASL does implement the LOGIN authentication method, even though it is
46477 not a standard method. It is disabled by default in the source distribution,
46478 but it is present in many binary distributions.
46479 <indexterm role="concept" startref="IIDcyrauth1" class="endofrange"/>
46480 <indexterm role="concept" startref="IIDcyrauth2" class="endofrange"/>
46481 </para>
46482 </section>
46483 </chapter>
46484
46485 <chapter id="CHAPdovecot">
46486 <title>The dovecot authenticator</title>
46487 <para>
46488 <indexterm role="concept" id="IIDdcotauth1" class="startofrange">
46489 <primary><command>dovecot</command> authenticator</primary>
46490 </indexterm>
46491 <indexterm role="concept" id="IIDdcotauth2" class="startofrange">
46492 <primary>authenticators</primary>
46493 <secondary><command>dovecot</command></secondary>
46494 </indexterm>
46495 This authenticator is an interface to the authentication facility of the
46496 Dovecot POP/IMAP server, which can support a number of authentication methods.
46497 If you are using Dovecot to authenticate POP/IMAP clients, it might be helpful
46498 to use the same mechanisms for SMTP authentication. This is a server
46499 authenticator only. There is only one option:
46500 </para>
46501 <para>
46502 <indexterm role="option">
46503 <primary><option>server_socket</option></primary>
46504 </indexterm>
46505 </para>
46506 <informaltable frame="all">
46507 <tgroup cols="4" colsep="0" rowsep="0">
46508 <colspec colwidth="8*" align="left"/>
46509 <colspec colwidth="6*" align="center"/>
46510 <colspec colwidth="6*" align="center"/>
46511 <colspec colwidth="6*" align="right"/>
46512 <tbody>
46513 <row>
46514 <entry><option>server_socket</option></entry>
46515 <entry>Use: <emphasis>dovecot</emphasis></entry>
46516 <entry>Type: <emphasis>string</emphasis></entry>
46517 <entry>Default: <emphasis>unset</emphasis></entry>
46518 </row>
46519 </tbody>
46520 </tgroup>
46521 </informaltable>
46522 <para>
46523 This option must specify the socket that is the interface to Dovecot
46524 authentication. The <option>public_name</option> option must specify an authentication
46525 mechanism that Dovecot is configured to support. You can have several
46526 authenticators for different mechanisms. For example:
46527 </para>
46528 <literallayout class="monospaced">
46529 dovecot_plain:
46530   driver = dovecot
46531   public_name = PLAIN
46532   server_socket = /var/run/dovecot/auth-client
46533   server_set_id = $auth2
46534
46535 dovecot_ntlm:
46536   driver = dovecot
46537   public_name = NTLM
46538   server_socket = /var/run/dovecot/auth-client
46539   server_set_id = $auth1
46540 </literallayout>
46541 <para>
46542 If the SMTP connection is encrypted, or if <varname>$sender_host_address</varname> is equal to
46543 <varname>$received_ip_address</varname> (that is, the connection is local), the <quote>secured</quote>
46544 option is passed in the Dovecot authentication command. If, for a TLS
46545 connection, a client certificate has been verified, the <quote>valid-client-cert</quote>
46546 option is passed. When authentication succeeds, the identity of the user
46547 who authenticated is placed in <varname>$auth1</varname>.
46548 <indexterm role="concept" startref="IIDdcotauth1" class="endofrange"/>
46549 <indexterm role="concept" startref="IIDdcotauth2" class="endofrange"/>
46550 </para>
46551 </chapter>
46552
46553 <chapter id="CHAPspa">
46554 <title>The spa authenticator</title>
46555 <para>
46556 <indexterm role="concept" id="IIDspaauth1" class="startofrange">
46557 <primary><command>spa</command> authenticator</primary>
46558 </indexterm>
46559 <indexterm role="concept" id="IIDspaauth2" class="startofrange">
46560 <primary>authenticators</primary>
46561 <secondary><command>spa</command></secondary>
46562 </indexterm>
46563 <indexterm role="concept">
46564 <primary>authentication</primary>
46565 <secondary>Microsoft Secure Password</secondary>
46566 </indexterm>
46567 <indexterm role="concept">
46568 <primary>authentication</primary>
46569 <secondary>NTLM</secondary>
46570 </indexterm>
46571 <indexterm role="concept">
46572 <primary>Microsoft Secure Password Authentication</primary>
46573 </indexterm>
46574 <indexterm role="concept">
46575 <primary>NTLM authentication</primary>
46576 </indexterm>
46577 The <command>spa</command> authenticator provides client support for Microsoft&#x2019;s <emphasis>Secure
46578 Password Authentication</emphasis> mechanism,
46579 which is also sometimes known as NTLM (NT LanMan). The code for client side of
46580 this authenticator was contributed by Marc Prud&#x2019;hommeaux, and much of it is
46581 taken from the Samba project (<emphasis role="bold"><ulink url="http://www.samba.org">http://www.samba.org</ulink></emphasis>). The code for the
46582 server side was subsequently contributed by Tom Kistner. The mechanism works as
46583 follows:
46584 </para>
46585 <itemizedlist>
46586 <listitem>
46587 <para>
46588 After the AUTH command has been accepted, the client sends an SPA
46589 authentication request based on the user name and optional domain.
46590 </para>
46591 </listitem>
46592 <listitem>
46593 <para>
46594 The server sends back a challenge.
46595 </para>
46596 </listitem>
46597 <listitem>
46598 <para>
46599 The client builds a challenge response which makes use of the user&#x2019;s password
46600 and sends it to the server, which then accepts or rejects it.
46601 </para>
46602 </listitem>
46603 </itemizedlist>
46604 <para>
46605 Encryption is used to protect the password in transit.
46606 </para>
46607 <section id="SECID179">
46608 <title>Using spa as a server</title>
46609 <para>
46610 <indexterm role="concept">
46611 <primary>options</primary>
46612 <secondary><command>spa</command> authenticator (server)</secondary>
46613 </indexterm>
46614 The <command>spa</command> authenticator has just one server option:
46615 </para>
46616 <para>
46617 <indexterm role="option">
46618 <primary><option>server_password</option></primary>
46619 </indexterm>
46620 </para>
46621 <informaltable frame="all">
46622 <tgroup cols="4" colsep="0" rowsep="0">
46623 <colspec colwidth="8*" align="left"/>
46624 <colspec colwidth="6*" align="center"/>
46625 <colspec colwidth="6*" align="center"/>
46626 <colspec colwidth="6*" align="right"/>
46627 <tbody>
46628 <row>
46629 <entry><option>server_password</option></entry>
46630 <entry>Use: <emphasis>spa</emphasis></entry>
46631 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
46632 <entry>Default: <emphasis>unset</emphasis></entry>
46633 </row>
46634 </tbody>
46635 </tgroup>
46636 </informaltable>
46637 <para>
46638 <indexterm role="concept">
46639 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
46640 <secondary>in <command>spa</command> authenticator</secondary>
46641 </indexterm>
46642 This option is expanded, and the result must be the cleartext password for the
46643 authenticating user, whose name is at this point in <varname>$auth1</varname>. For
46644 compatibility with previous releases of Exim, the user name is also placed in
46645 <varname>$1</varname>. However, the use of this variable for this purpose is now deprecated, as
46646 it can lead to confusion in string expansions that also use numeric variables
46647 for other things. For example:
46648 </para>
46649 <literallayout class="monospaced">
46650 spa:
46651   driver = spa
46652   public_name = NTLM
46653   server_password = \
46654     ${lookup{$auth1}lsearch{/etc/exim/spa_clearpass}{$value}fail}
46655 </literallayout>
46656 <para>
46657 If the expansion is forced to fail, authentication fails. Any other expansion
46658 failure causes a temporary error code to be returned.
46659 </para>
46660 </section>
46661 <section id="SECID180">
46662 <title>Using spa as a client</title>
46663 <para>
46664 <indexterm role="concept">
46665 <primary>options</primary>
46666 <secondary><command>spa</command> authenticator (client)</secondary>
46667 </indexterm>
46668 The <command>spa</command> authenticator has the following client options:
46669 </para>
46670 <para>
46671 <indexterm role="option">
46672 <primary><option>client_domain</option></primary>
46673 </indexterm>
46674 </para>
46675 <informaltable frame="all">
46676 <tgroup cols="4" colsep="0" rowsep="0">
46677 <colspec colwidth="8*" align="left"/>
46678 <colspec colwidth="6*" align="center"/>
46679 <colspec colwidth="6*" align="center"/>
46680 <colspec colwidth="6*" align="right"/>
46681 <tbody>
46682 <row>
46683 <entry><option>client_domain</option></entry>
46684 <entry>Use: <emphasis>spa</emphasis></entry>
46685 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
46686 <entry>Default: <emphasis>unset</emphasis></entry>
46687 </row>
46688 </tbody>
46689 </tgroup>
46690 </informaltable>
46691 <para>
46692 This option specifies an optional domain for the authentication.
46693 </para>
46694 <para>
46695 <indexterm role="option">
46696 <primary><option>client_password</option></primary>
46697 </indexterm>
46698 </para>
46699 <informaltable frame="all">
46700 <tgroup cols="4" colsep="0" rowsep="0">
46701 <colspec colwidth="8*" align="left"/>
46702 <colspec colwidth="6*" align="center"/>
46703 <colspec colwidth="6*" align="center"/>
46704 <colspec colwidth="6*" align="right"/>
46705 <tbody>
46706 <row>
46707 <entry><option>client_password</option></entry>
46708 <entry>Use: <emphasis>spa</emphasis></entry>
46709 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
46710 <entry>Default: <emphasis>unset</emphasis></entry>
46711 </row>
46712 </tbody>
46713 </tgroup>
46714 </informaltable>
46715 <para>
46716 This option specifies the user&#x2019;s password, and must be set.
46717 </para>
46718 <para>
46719 <indexterm role="option">
46720 <primary><option>client_username</option></primary>
46721 </indexterm>
46722 </para>
46723 <informaltable frame="all">
46724 <tgroup cols="4" colsep="0" rowsep="0">
46725 <colspec colwidth="8*" align="left"/>
46726 <colspec colwidth="6*" align="center"/>
46727 <colspec colwidth="6*" align="center"/>
46728 <colspec colwidth="6*" align="right"/>
46729 <tbody>
46730 <row>
46731 <entry><option>client_username</option></entry>
46732 <entry>Use: <emphasis>spa</emphasis></entry>
46733 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
46734 <entry>Default: <emphasis>unset</emphasis></entry>
46735 </row>
46736 </tbody>
46737 </tgroup>
46738 </informaltable>
46739 <para>
46740 This option specifies the user name, and must be set. Here is an example of a
46741 configuration of this authenticator for use with the mail servers at
46742 <emphasis>msn.com</emphasis>:
46743 </para>
46744 <literallayout class="monospaced">
46745 msn:
46746   driver = spa
46747   public_name = MSN
46748   client_username = msn/msn_username
46749   client_password = msn_plaintext_password
46750   client_domain = DOMAIN_OR_UNSET
46751 </literallayout>
46752 <para>
46753 <indexterm role="concept" startref="IIDspaauth1" class="endofrange"/>
46754 <indexterm role="concept" startref="IIDspaauth2" class="endofrange"/>
46755 </para>
46756 </section>
46757 </chapter>
46758
46759 <chapter id="CHAPTLS">
46760 <title>Encrypted SMTP connections using TLS/SSL</title>
46761 <titleabbrev>Encrypted SMTP connections</titleabbrev>
46762 <para>
46763 <indexterm role="concept" id="IIDencsmtp1" class="startofrange">
46764 <primary>encryption</primary>
46765 <secondary>on SMTP connection</secondary>
46766 </indexterm>
46767 <indexterm role="concept" id="IIDencsmtp2" class="startofrange">
46768 <primary>SMTP</primary>
46769 <secondary>encryption</secondary>
46770 </indexterm>
46771 <indexterm role="concept">
46772 <primary>TLS</primary>
46773 <secondary>on SMTP connection</secondary>
46774 </indexterm>
46775 <indexterm role="concept">
46776 <primary>OpenSSL</primary>
46777 </indexterm>
46778 <indexterm role="concept">
46779 <primary>GnuTLS</primary>
46780 </indexterm>
46781 Support for TLS (Transport Layer Security), formerly known as SSL (Secure
46782 Sockets Layer), is implemented by making use of the OpenSSL library or the
46783 GnuTLS library (Exim requires GnuTLS release 1.0 or later). There is no
46784 cryptographic code in the Exim distribution itself for implementing TLS. In
46785 order to use this feature you must install OpenSSL or GnuTLS, and then build a
46786 version of Exim that includes TLS support (see section <xref linkend="SECTinctlsssl"/>).
46787 You also need to understand the basic concepts of encryption at a managerial
46788 level, and in particular, the way that public keys, private keys, and
46789 certificates are used.
46790 </para>
46791 <para>
46792 RFC 3207 defines how SMTP connections can make use of encryption. Once a
46793 connection is established, the client issues a STARTTLS command. If the
46794 server accepts this, the client and the server negotiate an encryption
46795 mechanism. If the negotiation succeeds, the data that subsequently passes
46796 between them is encrypted.
46797 </para>
46798 <para>
46799 Exim&#x2019;s ACLs can detect whether the current SMTP session is encrypted or not,
46800 and if so, what cipher suite is in use, whether the client supplied a
46801 certificate, and whether or not that certificate was verified. This makes it
46802 possible for an Exim server to deny or accept certain commands based on the
46803 encryption state.
46804 </para>
46805 <para>
46806 <emphasis role="bold">Warning</emphasis>: Certain types of firewall and certain anti-virus products can
46807 disrupt TLS connections. You need to turn off SMTP scanning for these products
46808 in order to get TLS to work.
46809 </para>
46810 <section id="SECID284">
46811 <title>Support for the legacy <quote>ssmtp</quote> (aka <quote>smtps</quote>) protocol</title>
46812 <para>
46813 <indexterm role="concept">
46814 <primary>ssmtp protocol</primary>
46815 </indexterm>
46816 <indexterm role="concept">
46817 <primary>smtps protocol</primary>
46818 </indexterm>
46819 <indexterm role="concept">
46820 <primary>SMTP</primary>
46821 <secondary>ssmtp protocol</secondary>
46822 </indexterm>
46823 <indexterm role="concept">
46824 <primary>SMTP</primary>
46825 <secondary>smtps protocol</secondary>
46826 </indexterm>
46827 Early implementations of encrypted SMTP used a different TCP port from normal
46828 SMTP, and expected an encryption negotiation to start immediately, instead of
46829 waiting for a STARTTLS command from the client using the standard SMTP
46830 port. The protocol was called <quote>ssmtp</quote> or <quote>smtps</quote>, and port 465 was
46831 allocated for this purpose.
46832 </para>
46833 <para>
46834 This approach was abandoned when encrypted SMTP was standardized, but there are
46835 still some legacy clients that use it. Exim supports these clients by means of
46836 the <option>tls_on_connect_ports</option> global option. Its value must be a list of port
46837 numbers; the most common use is expected to be:
46838 </para>
46839 <literallayout class="monospaced">
46840 tls_on_connect_ports = 465
46841 </literallayout>
46842 <para>
46843 The port numbers specified by this option apply to all SMTP connections, both
46844 via the daemon and via <emphasis>inetd</emphasis>. You still need to specify all the ports that
46845 the daemon uses (by setting <option>daemon_smtp_ports</option> or <option>local_interfaces</option> or
46846 the <option>-oX</option> command line option) because <option>tls_on_connect_ports</option> does not add
46847 an extra port &ndash; rather, it specifies different behaviour on a port that is
46848 defined elsewhere.
46849 </para>
46850 <para>
46851 There is also a <option>-tls-on-connect</option> command line option. This overrides
46852 <option>tls_on_connect_ports</option>; it forces the legacy behaviour for all ports.
46853 </para>
46854 </section>
46855 <section id="SECTopenvsgnu">
46856 <title>OpenSSL vs GnuTLS</title>
46857 <para>
46858 <indexterm role="concept">
46859 <primary>TLS</primary>
46860 <secondary>OpenSSL <emphasis>vs</emphasis> GnuTLS</secondary>
46861 </indexterm>
46862 The first TLS support in Exim was implemented using OpenSSL. Support for GnuTLS
46863 followed later, when the first versions of GnuTLS were released. To build Exim
46864 to use GnuTLS, you need to set
46865 </para>
46866 <literallayout class="monospaced">
46867 USE_GNUTLS=yes
46868 </literallayout>
46869 <para>
46870 in Local/Makefile, in addition to
46871 </para>
46872 <literallayout class="monospaced">
46873 SUPPORT_TLS=yes
46874 </literallayout>
46875 <para>
46876 You must also set TLS_LIBS and TLS_INCLUDE appropriately, so that the
46877 include files and libraries for GnuTLS can be found.
46878 </para>
46879 <para>
46880 There are some differences in usage when using GnuTLS instead of OpenSSL:
46881 </para>
46882 <itemizedlist>
46883 <listitem>
46884 <para>
46885 The <option>tls_verify_certificates</option> option must contain the name of a file, not the
46886 name of a directory (for OpenSSL it can be either).
46887 </para>
46888 </listitem>
46889 <listitem>
46890 <para>
46891 The <option>tls_dhparam</option> option is ignored, because early versions of GnuTLS had no
46892 facility for varying its Diffie-Hellman parameters. I understand that this has
46893 changed, but Exim has not been updated to provide this facility.
46894 </para>
46895 </listitem>
46896 <listitem>
46897 <para>
46898 <indexterm role="variable">
46899 <primary><varname>$tls_peerdn</varname></primary>
46900 </indexterm>
46901 Distinguished Name (DN) strings reported by the OpenSSL library use a slash for
46902 separating fields; GnuTLS uses commas, in accordance with RFC 2253. This
46903 affects the value of the <varname>$tls_peerdn</varname> variable.
46904 </para>
46905 </listitem>
46906 <listitem>
46907 <para>
46908 OpenSSL identifies cipher suites using hyphens as separators, for example:
46909 DES-CBC3-SHA. GnuTLS uses underscores, for example: RSA_ARCFOUR_SHA. What is
46910 more, OpenSSL complains if underscores are present in a cipher list. To make
46911 life simpler, Exim changes underscores to hyphens for OpenSSL and hyphens to
46912 underscores for GnuTLS when processing lists of cipher suites in the
46913 <option>tls_require_ciphers</option> options (the global option and the <command>smtp</command> transport
46914 option).
46915 </para>
46916 </listitem>
46917 <listitem>
46918 <para>
46919 The <option>tls_require_ciphers</option> options operate differently, as described in the
46920 sections <xref linkend="SECTreqciphssl"/> and <xref linkend="SECTreqciphgnu"/>.
46921 </para>
46922 </listitem>
46923 </itemizedlist>
46924 </section>
46925 <section id="SECID181">
46926 <title>GnuTLS parameter computation</title>
46927 <para>
46928 GnuTLS uses D-H parameters that may take a substantial amount of time
46929 to compute. It is unreasonable to re-compute them for every TLS session.
46930 Therefore, Exim keeps this data in a file in its spool directory, called
46931 <filename>gnutls-params</filename>. The file is owned by the Exim user and is readable only by
46932 its owner. Every Exim process that start up GnuTLS reads the D-H
46933 parameters from this file. If the file does not exist, the first Exim process
46934 that needs it computes the data and writes it to a temporary file which is
46935 renamed once it is complete. It does not matter if several Exim processes do
46936 this simultaneously (apart from wasting a few resources). Once a file is in
46937 place, new Exim processes immediately start using it.
46938 </para>
46939 <para>
46940 For maximum security, the parameters that are stored in this file should be
46941 recalculated periodically, the frequency depending on your paranoia level.
46942 Arranging this is easy in principle; just delete the file when you want new
46943 values to be computed. However, there may be a problem. The calculation of new
46944 parameters needs random numbers, and these are obtained from <filename>/dev/random</filename>.
46945 If the system is not very active, <filename>/dev/random</filename> may delay returning data
46946 until enough randomness (entropy) is available. This may cause Exim to hang for
46947 a substantial amount of time, causing timeouts on incoming connections.
46948 </para>
46949 <para>
46950 The solution is to generate the parameters externally to Exim. They are stored
46951 in <filename>gnutls-params</filename> in PEM format, which means that they can be generated
46952 externally using the <command>certtool</command> command that is part of GnuTLS.
46953 </para>
46954 <para>
46955 To replace the parameters with new ones, instead of deleting the file
46956 and letting Exim re-create it, you can generate new parameters using
46957 <command>certtool</command> and, when this has been done, replace Exim&#x2019;s cache file by
46958 renaming. The relevant commands are something like this:
46959 </para>
46960 <literallayout class="monospaced">
46961 # rm -f new-params
46962 # touch new-params
46963 # chown exim:exim new-params
46964 # chmod 0400 new-params
46965 # certtool --generate-privkey --bits 512 &gt;new-params
46966 # echo "" &gt;&gt;new-params
46967 # certtool --generate-dh-params --bits 1024 &gt;&gt; new-params
46968 # mv new-params gnutls-params
46969 </literallayout>
46970 <para>
46971 If Exim never has to generate the parameters itself, the possibility of
46972 stalling is removed.
46973 </para>
46974 </section>
46975 <section id="SECTreqciphssl">
46976 <title>Requiring specific ciphers in OpenSSL</title>
46977 <para>
46978 <indexterm role="concept">
46979 <primary>TLS</primary>
46980 <secondary>requiring specific ciphers (OpenSSL)</secondary>
46981 </indexterm>
46982 <indexterm role="option">
46983 <primary><option>tls_require_ciphers</option></primary>
46984 <secondary>OpenSSL</secondary>
46985 </indexterm>
46986 There is a function in the OpenSSL library that can be passed a list of cipher
46987 suites before the cipher negotiation takes place. This specifies which ciphers
46988 are acceptable. The list is colon separated and may contain names like
46989 DES-CBC3-SHA. Exim passes the expanded value of <option>tls_require_ciphers</option>
46990 directly to this function call. The following quotation from the OpenSSL
46991 documentation specifies what forms of item are allowed in the cipher string:
46992 </para>
46993 <itemizedlist>
46994 <listitem>
46995 <para>
46996 It can consist of a single cipher suite such as RC4-SHA.
46997 </para>
46998 </listitem>
46999 <listitem>
47000 <para>
47001 It can represent a list of cipher suites containing a certain algorithm,
47002 or cipher suites of a certain type. For example SHA1 represents all
47003 ciphers suites using the digest algorithm SHA1 and SSLv3 represents all
47004 SSL v3 algorithms.
47005 </para>
47006 </listitem>
47007 <listitem>
47008 <para>
47009 Lists of cipher suites can be combined in a single cipher string using
47010 the + character. This is used as a logical and operation. For example
47011 SHA1+DES represents all cipher suites containing the SHA1 and the DES
47012 algorithms.
47013 </para>
47014 </listitem>
47015 </itemizedlist>
47016 <para>
47017 Each cipher string can be optionally preceded by one of the characters <literal>!</literal>,
47018 <literal>-</literal> or <literal>+</literal>.
47019 </para>
47020 <itemizedlist>
47021 <listitem>
47022 <para>
47023 If <literal>!</literal> is used, the ciphers are permanently deleted from the list. The
47024 ciphers deleted can never reappear in the list even if they are explicitly
47025 stated.
47026 </para>
47027 </listitem>
47028 <listitem>
47029 <para>
47030 If <literal>-</literal> is used, the ciphers are deleted from the list, but some or all
47031 of the ciphers can be added again by later options.
47032 </para>
47033 </listitem>
47034 <listitem>
47035 <para>
47036 If <literal>+</literal> is used, the ciphers are moved to the end of the list. This
47037 option does not add any new ciphers; it just moves matching existing ones.
47038 </para>
47039 </listitem>
47040 </itemizedlist>
47041 <para>
47042 If none of these characters is present, the string is interpreted as
47043 a list of ciphers to be appended to the current preference list. If the list
47044 includes any ciphers already present they will be ignored: that is, they will
47045 not be moved to the end of the list.
47046 </para>
47047 </section>
47048 <section id="SECTreqciphgnu">
47049 <title>Requiring specific ciphers or other parameters in GnuTLS</title>
47050 <para>
47051 <indexterm role="concept">
47052 <primary>GnuTLS</primary>
47053 <secondary>specifying parameters for</secondary>
47054 </indexterm>
47055 <indexterm role="concept">
47056 <primary>TLS</primary>
47057 <secondary>specifying ciphers (GnuTLS)</secondary>
47058 </indexterm>
47059 <indexterm role="concept">
47060 <primary>TLS</primary>
47061 <secondary>specifying key exchange methods (GnuTLS)</secondary>
47062 </indexterm>
47063 <indexterm role="concept">
47064 <primary>TLS</primary>
47065 <secondary>specifying MAC algorithms (GnuTLS)</secondary>
47066 </indexterm>
47067 <indexterm role="concept">
47068 <primary>TLS</primary>
47069 <secondary>specifying protocols (GnuTLS)</secondary>
47070 </indexterm>
47071 <indexterm role="option">
47072 <primary><option>tls_require_ciphers</option></primary>
47073 <secondary>GnuTLS</secondary>
47074 </indexterm>
47075 The GnuTLS library allows the caller to specify separate lists of permitted key
47076 exchange methods, main cipher algorithms, MAC algorithms, and protocols.
47077 Unfortunately, these lists are numerical, and the library does not have a
47078 function for turning names into numbers. Consequently, lists of recognized
47079 names have to be built into the application. The permitted key exchange
47080 methods, ciphers, and MAC algorithms may be used in any combination to form a
47081 cipher suite. This is unlike OpenSSL, where complete cipher suite names are
47082 passed to its control function.
47083 </para>
47084 <para>
47085 For compatibility with OpenSSL, the <option>tls_require_ciphers</option> option can be set
47086 to complete cipher suite names such as RSA_ARCFOUR_SHA, but for GnuTLS this
47087 option controls only the cipher algorithms. Exim searches each item in the
47088 list for the name of an available algorithm. For example, if the list
47089 contains RSA_AES_SHA, then AES is recognized, and the behaviour is exactly
47090 the same as if just AES were given.
47091 </para>
47092 <para>
47093 <indexterm role="option">
47094 <primary><option>gnutls_require_kx</option></primary>
47095 </indexterm>
47096 <indexterm role="option">
47097 <primary><option>gnutls_require_mac</option></primary>
47098 </indexterm>
47099 <indexterm role="option">
47100 <primary><option>gnutls_require_protocols</option></primary>
47101 </indexterm>
47102 There are additional options called <option>gnutls_require_kx</option>,
47103 <option>gnutls_require_mac</option>, and <option>gnutls_require_protocols</option> that can be used to
47104 restrict the key exchange methods, MAC algorithms, and protocols, respectively.
47105 These options are ignored if OpenSSL is in use.
47106 </para>
47107 <para>
47108 All four options are available as global options, controlling how Exim
47109 behaves as a server, and also as options of the <command>smtp</command> transport, controlling
47110 how Exim behaves as a client. All the values are string expanded. After
47111 expansion, the values must be colon-separated lists, though the separator
47112 can be changed in the usual way.
47113 </para>
47114 <para>
47115 Each of the four lists starts out with a default set of algorithms. If the
47116 first item in a list does <emphasis>not</emphasis> start with an exclamation mark, all the
47117 default items are deleted. In this case, only those that are explicitly
47118 specified can be used. If the first item in a list <emphasis>does</emphasis> start with an
47119 exclamation mark, the defaults are left on the list.
47120 </para>
47121 <para>
47122 Then, any item that starts with an exclamation mark causes the relevant
47123 entry to be removed from the list, and any item that does not start with an
47124 exclamation mark causes a new entry to be added to the list. Unrecognized
47125 items in the list are ignored. Thus:
47126 </para>
47127 <literallayout class="monospaced">
47128 tls_require_ciphers = !ARCFOUR
47129 </literallayout>
47130 <para>
47131 allows all the defaults except ARCFOUR, whereas
47132 </para>
47133 <literallayout class="monospaced">
47134 tls_require_ciphers = AES : 3DES
47135 </literallayout>
47136 <para>
47137 allows only cipher suites that use AES or 3DES.
47138 </para>
47139 <para>
47140 For <option>tls_require_ciphers</option> the recognized names are AES_256, AES_128, AES
47141 (both of the preceding), 3DES, ARCFOUR_128, ARCFOUR_40, and ARCFOUR (both of
47142 the preceding). The default list does not contain all of these; it just has
47143 AES_256, AES_128, 3DES, and ARCFOUR_128.
47144 </para>
47145 <para>
47146 For <option>gnutls_require_kx</option>, the recognized names are DHE_RSA, RSA (which
47147 includes DHE_RSA), DHE_DSS, and DHE (which includes both DHE_RSA and
47148 DHE_DSS). The default list contains RSA, DHE_DSS, DHE_RSA.
47149 </para>
47150 <para>
47151 For <option>gnutls_require_mac</option>, the recognized names are SHA (synonym SHA1), and
47152 MD5. The default list contains SHA, MD5.
47153 </para>
47154 <para>
47155 For <option>gnutls_require_protocols</option>, the recognized names are TLS1 and SSL3.
47156 The default list contains TLS1, SSL3.
47157 </para>
47158 <para>
47159 In a server, the order of items in these lists is unimportant. The server
47160 advertises the availability of all the relevant cipher suites. However, in a
47161 client, the order in the <option>tls_require_ciphers</option> list specifies a preference
47162 order for the cipher algorithms. The first one in the client&#x2019;s list that is
47163 also advertised by the server is tried first. The default order is as listed
47164 above.
47165 </para>
47166 </section>
47167 <section id="SECID182">
47168 <title>Configuring an Exim server to use TLS</title>
47169 <para>
47170 <indexterm role="concept">
47171 <primary>TLS</primary>
47172 <secondary>configuring an Exim server</secondary>
47173 </indexterm>
47174 When Exim has been built with TLS support, it advertises the availability of
47175 the STARTTLS command to client hosts that match <option>tls_advertise_hosts</option>,
47176 but not to any others. The default value of this option is unset, which means
47177 that STARTTLS is not advertised at all. This default is chosen because you
47178 need to set some other options in order to make TLS available, and also it is
47179 sensible for systems that want to use TLS only as a client.
47180 </para>
47181 <para>
47182 If a client issues a STARTTLS command and there is some configuration
47183 problem in the server, the command is rejected with a 454 error. If the client
47184 persists in trying to issue SMTP commands, all except QUIT are rejected
47185 with the error
47186 </para>
47187 <literallayout class="monospaced">
47188 554 Security failure
47189 </literallayout>
47190 <para>
47191 If a STARTTLS command is issued within an existing TLS session, it is
47192 rejected with a 554 error code.
47193 </para>
47194 <para>
47195 To enable TLS operations on a server, you must set <option>tls_advertise_hosts</option> to
47196 match some hosts. You can, of course, set it to * to match all hosts.
47197 However, this is not all you need to do. TLS sessions to a server won&#x2019;t work
47198 without some further configuration at the server end.
47199 </para>
47200 <para>
47201 It is rumoured that all existing clients that support TLS/SSL use RSA
47202 encryption. To make this work you need to set, in the server,
47203 </para>
47204 <literallayout class="monospaced">
47205 tls_certificate = /some/file/name
47206 tls_privatekey = /some/file/name
47207 </literallayout>
47208 <para>
47209 These options are, in fact, expanded strings, so you can make them depend on
47210 the identity of the client that is connected if you wish. The first file
47211 contains the server&#x2019;s X509 certificate, and the second contains the private key
47212 that goes with it. These files need to be readable by the Exim user, and must
47213 always be given as full path names. They can be the same file if both the
47214 certificate and the key are contained within it. If <option>tls_privatekey</option> is not
47215 set, or if its expansion is forced to fail or results in an empty string, this
47216 is assumed to be the case. The certificate file may also contain intermediate
47217 certificates that need to be sent to the client to enable it to authenticate
47218 the server&#x2019;s certificate.
47219 </para>
47220 <para>
47221 If you do not understand about certificates and keys, please try to find a
47222 source of this background information, which is not Exim-specific. (There are a
47223 few comments below in section <xref linkend="SECTcerandall"/>.)
47224 </para>
47225 <para>
47226 <emphasis role="bold">Note</emphasis>: These options do not apply when Exim is operating as a client &ndash;
47227 they apply only in the case of a server. If you need to use a certificate in an
47228 Exim client, you must set the options of the same names in an <command>smtp</command>
47229 transport.
47230 </para>
47231 <para>
47232 With just these options, an Exim server will be able to use TLS. It does not
47233 require the client to have a certificate (but see below for how to insist on
47234 this). There is one other option that may be needed in other situations. If
47235 </para>
47236 <literallayout class="monospaced">
47237 tls_dhparam = /some/file/name
47238 </literallayout>
47239 <para>
47240 is set, the SSL library is initialized for the use of Diffie-Hellman ciphers
47241 with the parameters contained in the file. This increases the set of cipher
47242 suites that the server supports. See the command
47243 </para>
47244 <literallayout class="monospaced">
47245 openssl dhparam
47246 </literallayout>
47247 <para>
47248 for a way of generating this data. At present, <option>tls_dhparam</option> is used only
47249 when Exim is linked with OpenSSL. It is ignored if GnuTLS is being used.
47250 </para>
47251 <para>
47252 The strings supplied for these three options are expanded every time a client
47253 host connects. It is therefore possible to use different certificates and keys
47254 for different hosts, if you so wish, by making use of the client&#x2019;s IP address
47255 in <varname>$sender_host_address</varname> to control the expansion. If a string expansion is
47256 forced to fail, Exim behaves as if the option is not set.
47257 </para>
47258 <para>
47259 <indexterm role="concept">
47260 <primary>cipher</primary>
47261 <secondary>logging</secondary>
47262 </indexterm>
47263 <indexterm role="concept">
47264 <primary>log</primary>
47265 <secondary>TLS cipher</secondary>
47266 </indexterm>
47267 <indexterm role="variable">
47268 <primary><varname>$tls_cipher</varname></primary>
47269 </indexterm>
47270 The variable <varname>$tls_cipher</varname> is set to the cipher suite that was negotiated for
47271 an incoming TLS connection. It is included in the <emphasis>Received:</emphasis> header of an
47272 incoming message (by default &ndash; you can, of course, change this), and it is
47273 also included in the log line that records a message&#x2019;s arrival, keyed by
47274 <quote>X=</quote>, unless the <option>tls_cipher</option> log selector is turned off. The <option>encrypted</option>
47275 condition can be used to test for specific cipher suites in ACLs.
47276 (For outgoing SMTP deliveries, <varname>$tls_cipher</varname> is reset &ndash; see section
47277 <xref linkend="SECID185"/>.)
47278 </para>
47279 <para>
47280 Once TLS has been established, the ACLs that run for subsequent SMTP commands
47281 can check the name of the cipher suite and vary their actions accordingly. The
47282 cipher suite names vary, depending on which TLS library is being used. For
47283 example, OpenSSL uses the name DES-CBC3-SHA for the cipher suite which in other
47284 contexts is known as TLS_RSA_WITH_3DES_EDE_CBC_SHA. Check the OpenSSL or GnuTLS
47285 documentation for more details.
47286 </para>
47287 </section>
47288 <section id="SECID183">
47289 <title>Requesting and verifying client certificates</title>
47290 <para>
47291 <indexterm role="concept">
47292 <primary>certificate</primary>
47293 <secondary>verification of client</secondary>
47294 </indexterm>
47295 <indexterm role="concept">
47296 <primary>TLS</primary>
47297 <secondary>client certificate verification</secondary>
47298 </indexterm>
47299 If you want an Exim server to request a certificate when negotiating a TLS
47300 session with a client, you must set either <option>tls_verify_hosts</option> or
47301 <option>tls_try_verify_hosts</option>. You can, of course, set either of them to * to
47302 apply to all TLS connections. For any host that matches one of these options,
47303 Exim requests a certificate as part of the setup of the TLS session. The
47304 contents of the certificate are verified by comparing it with a list of
47305 expected certificates. These must be available in a file or,
47306 for OpenSSL only (not GnuTLS), a directory, identified by
47307 <option>tls_verify_certificates</option>.
47308 </para>
47309 <para>
47310 A file can contain multiple certificates, concatenated end to end. If a
47311 directory is used
47312 (OpenSSL only),
47313 each certificate must be in a separate file, with a name (or a symbolic link)
47314 of the form &lt;<emphasis>hash</emphasis>&gt;.0, where &lt;<emphasis>hash</emphasis>&gt; is a hash value constructed from the
47315 certificate. You can compute the relevant hash by running the command
47316 </para>
47317 <literallayout class="monospaced">
47318 openssl x509 -hash -noout -in /cert/file
47319 </literallayout>
47320 <para>
47321 where <filename>/cert/file</filename> contains a single certificate.
47322 </para>
47323 <para>
47324 The difference between <option>tls_verify_hosts</option> and <option>tls_try_verify_hosts</option> is
47325 what happens if the client does not supply a certificate, or if the certificate
47326 does not match any of the certificates in the collection named by
47327 <option>tls_verify_certificates</option>. If the client matches <option>tls_verify_hosts</option>, the
47328 attempt to set up a TLS session is aborted, and the incoming connection is
47329 dropped. If the client matches <option>tls_try_verify_hosts</option>, the (encrypted) SMTP
47330 session continues. ACLs that run for subsequent SMTP commands can detect the
47331 fact that no certificate was verified, and vary their actions accordingly. For
47332 example, you can insist on a certificate before accepting a message for
47333 relaying, but not when the message is destined for local delivery.
47334 </para>
47335 <para>
47336 <indexterm role="variable">
47337 <primary><varname>$tls_peerdn</varname></primary>
47338 </indexterm>
47339 When a client supplies a certificate (whether it verifies or not), the value of
47340 the Distinguished Name of the certificate is made available in the variable
47341 <varname>$tls_peerdn</varname> during subsequent processing of the message.
47342 </para>
47343 <para>
47344 <indexterm role="concept">
47345 <primary>log</primary>
47346 <secondary>distinguished name</secondary>
47347 </indexterm>
47348 Because it is often a long text string, it is not included in the log line or
47349 <emphasis>Received:</emphasis> header by default. You can arrange for it to be logged, keyed by
47350 <quote>DN=</quote>, by setting the <option>tls_peerdn</option> log selector, and you can use
47351 <option>received_header_text</option> to change the <emphasis>Received:</emphasis> header. When no
47352 certificate is supplied, <varname>$tls_peerdn</varname> is empty.
47353 </para>
47354 </section>
47355 <section id="SECID184">
47356 <title>Revoked certificates</title>
47357 <para>
47358 <indexterm role="concept">
47359 <primary>TLS</primary>
47360 <secondary>revoked certificates</secondary>
47361 </indexterm>
47362 <indexterm role="concept">
47363 <primary>revocation list</primary>
47364 </indexterm>
47365 <indexterm role="concept">
47366 <primary>certificate</primary>
47367 <secondary>revocation list</secondary>
47368 </indexterm>
47369 Certificate issuing authorities issue Certificate Revocation Lists (CRLs) when
47370 certificates are revoked. If you have such a list, you can pass it to an Exim
47371 server using the global option called <option>tls_crl</option> and to an Exim client using
47372 an identically named option for the <command>smtp</command> transport. In each case, the value
47373 of the option is expanded and must then be the name of a file that contains a
47374 CRL in PEM format.
47375 </para>
47376 </section>
47377 <section id="SECID185">
47378 <title>Configuring an Exim client to use TLS</title>
47379 <para>
47380 <indexterm role="concept">
47381 <primary>cipher</primary>
47382 <secondary>logging</secondary>
47383 </indexterm>
47384 <indexterm role="concept">
47385 <primary>log</primary>
47386 <secondary>TLS cipher</secondary>
47387 </indexterm>
47388 <indexterm role="concept">
47389 <primary>log</primary>
47390 <secondary>distinguished name</secondary>
47391 </indexterm>
47392 <indexterm role="concept">
47393 <primary>TLS</primary>
47394 <secondary>configuring an Exim client</secondary>
47395 </indexterm>
47396 The <option>tls_cipher</option> and <option>tls_peerdn</option> log selectors apply to outgoing SMTP
47397 deliveries as well as to incoming, the latter one causing logging of the
47398 server certificate&#x2019;s DN. The remaining client configuration for TLS is all
47399 within the <command>smtp</command> transport.
47400 </para>
47401 <para>
47402 It is not necessary to set any options to have TLS work in the <command>smtp</command>
47403 transport. If Exim is built with TLS support, and TLS is advertised by a
47404 server, the <command>smtp</command> transport always tries to start a TLS session. However,
47405 this can be prevented by setting <option>hosts_avoid_tls</option> (an option of the
47406 transport) to a list of server hosts for which TLS should not be used.
47407 </para>
47408 <para>
47409 If you do not want Exim to attempt to send messages unencrypted when an attempt
47410 to set up an encrypted connection fails in any way, you can set
47411 <option>hosts_require_tls</option> to a list of hosts for which encryption is mandatory. For
47412 those hosts, delivery is always deferred if an encrypted connection cannot be
47413 set up. If there are any other hosts for the address, they are tried in the
47414 usual way.
47415 </para>
47416 <para>
47417 When the server host is not in <option>hosts_require_tls</option>, Exim may try to deliver
47418 the message unencrypted. It always does this if the response to STARTTLS is
47419 a 5<emphasis>xx</emphasis> code. For a temporary error code, or for a failure to negotiate a TLS
47420 session after a success response code, what happens is controlled by the
47421 <option>tls_tempfail_tryclear</option> option of the <command>smtp</command> transport. If it is false,
47422 delivery to this host is deferred, and other hosts (if available) are tried. If
47423 it is true, Exim attempts to deliver unencrypted after a 4<emphasis>xx</emphasis> response to
47424 STARTTLS, and if STARTTLS is accepted, but the subsequent TLS
47425 negotiation fails, Exim closes the current connection (because it is in an
47426 unknown state), opens a new one to the same host, and then tries the delivery
47427 unencrypted.
47428 </para>
47429 <para>
47430 The <option>tls_certificate</option> and <option>tls_privatekey</option> options of the <command>smtp</command>
47431 transport provide the client with a certificate, which is passed to the server
47432 if it requests it. If the server is Exim, it will request a certificate only if
47433 <option>tls_verify_hosts</option> or <option>tls_try_verify_hosts</option> matches the client.
47434 </para>
47435 <para>
47436 If the <option>tls_verify_certificates</option> option is set on the <command>smtp</command> transport, it
47437 must name a file or,
47438 for OpenSSL only (not GnuTLS), a directory, that contains a collection of
47439 expected server certificates. The client verifies the server&#x2019;s certificate
47440 against this collection, taking into account any revoked certificates that are
47441 in the list defined by <option>tls_crl</option>.
47442 </para>
47443 <para>
47444 If
47445 <option>tls_require_ciphers</option> is set on the <command>smtp</command> transport, it must contain a
47446 list of permitted cipher suites. If either of these checks fails, delivery to
47447 the current host is abandoned, and the <command>smtp</command> transport tries to deliver to
47448 alternative hosts, if any.
47449 </para>
47450 <para>
47451  <emphasis role="bold">Note</emphasis>:
47452 These options must be set in the <command>smtp</command> transport for Exim to use TLS when it
47453 is operating as a client. Exim does not assume that a server certificate (set
47454 by the global options of the same name) should also be used when operating as a
47455 client.
47456 </para>
47457 <para>
47458 <indexterm role="variable">
47459 <primary><varname>$host</varname></primary>
47460 </indexterm>
47461 <indexterm role="variable">
47462 <primary><varname>$host_address</varname></primary>
47463 </indexterm>
47464 All the TLS options in the <command>smtp</command> transport are expanded before use, with
47465 <varname>$host</varname> and <varname>$host_address</varname> containing the name and address of the server to
47466 which the client is connected. Forced failure of an expansion causes Exim to
47467 behave as if the relevant option were unset.
47468 </para>
47469 <para>
47470 <indexterm role="variable">
47471 <primary><varname>$tls_cipher</varname></primary>
47472 </indexterm>
47473 <indexterm role="variable">
47474 <primary><varname>$tls_peerdn</varname></primary>
47475 </indexterm>
47476 Before an SMTP connection is established, the <varname>$tls_cipher</varname> and <varname>$tls_peerdn</varname>
47477 variables are emptied. (Until the first connection, they contain the values
47478 that were set when the message was received.) If STARTTLS is subsequently
47479 successfully obeyed, these variables are set to the relevant values for the
47480 outgoing connection.
47481 </para>
47482 </section>
47483 <section id="SECTmulmessam">
47484 <title>Multiple messages on the same encrypted TCP/IP connection</title>
47485 <para>
47486 <indexterm role="concept">
47487 <primary>multiple SMTP deliveries with TLS</primary>
47488 </indexterm>
47489 <indexterm role="concept">
47490 <primary>TLS</primary>
47491 <secondary>multiple message deliveries</secondary>
47492 </indexterm>
47493 Exim sends multiple messages down the same TCP/IP connection by starting up
47494 an entirely new delivery process for each message, passing the socket from
47495 one process to the next. This implementation does not fit well with the use
47496 of TLS, because there is quite a lot of state information associated with a TLS
47497 connection, not just a socket identification. Passing all the state information
47498 to a new process is not feasible. Consequently, Exim shuts down an existing TLS
47499 session before passing the socket to a new process. The new process may then
47500 try to start a new TLS session, and if successful, may try to re-authenticate
47501 if AUTH is in use, before sending the next message.
47502 </para>
47503 <para>
47504 The RFC is not clear as to whether or not an SMTP session continues in clear
47505 after TLS has been shut down, or whether TLS may be restarted again later, as
47506 just described. However, if the server is Exim, this shutdown and
47507 reinitialization works. It is not known which (if any) other servers operate
47508 successfully if the client closes a TLS session and continues with unencrypted
47509 SMTP, but there are certainly some that do not work. For such servers, Exim
47510 should not pass the socket to another process, because the failure of the
47511 subsequent attempt to use it would cause Exim to record a temporary host error,
47512 and delay other deliveries to that host.
47513 </para>
47514 <para>
47515 To test for this case, Exim sends an EHLO command to the server after
47516 closing down the TLS session. If this fails in any way, the connection is
47517 closed instead of being passed to a new delivery process, but no retry
47518 information is recorded.
47519 </para>
47520 <para>
47521 There is also a manual override; you can set <option>hosts_nopass_tls</option> on the
47522 <command>smtp</command> transport to match those hosts for which Exim should not pass
47523 connections to new processes if TLS has been used.
47524 </para>
47525 </section>
47526 <section id="SECTcerandall">
47527 <title>Certificates and all that</title>
47528 <para>
47529 <indexterm role="concept">
47530 <primary>certificate</primary>
47531 <secondary>references to discussion</secondary>
47532 </indexterm>
47533 In order to understand fully how TLS works, you need to know about
47534 certificates, certificate signing, and certificate authorities. This is not the
47535 place to give a tutorial, especially as I do not know very much about it
47536 myself. Some helpful introduction can be found in the FAQ for the SSL addition
47537 to Apache, currently at
47538 </para>
47539 <literallayout>
47540 <emphasis role="bold"><ulink url="http://www.modssl.org/docs/2.7/ssl_faq.html#ToC24">http://www.modssl.org/docs/2.7/ssl_faq.html#ToC24</ulink></emphasis>
47541 </literallayout>
47542 <para>
47543 Other parts of the <emphasis>modssl</emphasis> documentation are also helpful, and have
47544 links to further files.
47545 Eric Rescorla&#x2019;s book, <emphasis>SSL and TLS</emphasis>, published by Addison-Wesley (ISBN
47546 0-201-61598-3), contains both introductory and more in-depth descriptions.
47547 Some sample programs taken from the book are available from
47548 </para>
47549 <literallayout>
47550 <emphasis role="bold"><ulink url="http://www.rtfm.com/openssl-examples/">http://www.rtfm.com/openssl-examples/</ulink></emphasis>
47551 </literallayout>
47552 </section>
47553 <section id="SECID186">
47554 <title>Certificate chains</title>
47555 <para>
47556 The file named by <option>tls_certificate</option> may contain more than one
47557 certificate. This is useful in the case where the certificate that is being
47558 sent is validated by an intermediate certificate which the other end does
47559 not have. Multiple certificates must be in the correct order in the file.
47560 First the host&#x2019;s certificate itself, then the first intermediate
47561 certificate to validate the issuer of the host certificate, then the next
47562 intermediate certificate to validate the issuer of the first intermediate
47563 certificate, and so on, until finally (optionally) the root certificate.
47564 The root certificate must already be trusted by the recipient for
47565 validation to succeed, of course, but if it&#x2019;s not preinstalled, sending the
47566 root certificate along with the rest makes it available for the user to
47567 install if the receiving end is a client MUA that can interact with a user.
47568 </para>
47569 </section>
47570 <section id="SECID187">
47571 <title>Self-signed certificates</title>
47572 <para>
47573 <indexterm role="concept">
47574 <primary>certificate</primary>
47575 <secondary>self-signed</secondary>
47576 </indexterm>
47577 You can create a self-signed certificate using the <emphasis>req</emphasis> command provided
47578 with OpenSSL, like this:
47579 </para>
47580 <literallayout class="monospaced">
47581 openssl req -x509 -newkey rsa:1024 -keyout file1 -out file2 \
47582             -days 9999 -nodes
47583 </literallayout>
47584 <para>
47585 <filename>file1</filename> and <filename>file2</filename> can be the same file; the key and the certificate are
47586 delimited and so can be identified independently. The <option>-days</option> option
47587 specifies a period for which the certificate is valid. The <option>-nodes</option> option is
47588 important: if you do not set it, the key is encrypted with a passphrase
47589 that you are prompted for, and any use that is made of the key causes more
47590 prompting for the passphrase. This is not helpful if you are going to use
47591 this certificate and key in an MTA, where prompting is not possible.
47592 </para>
47593 <para>
47594 A self-signed certificate made in this way is sufficient for testing, and
47595 may be adequate for all your requirements if you are mainly interested in
47596 encrypting transfers, and not in secure identification.
47597 </para>
47598 <para>
47599 However, many clients require that the certificate presented by the server be a
47600 user (also called <quote>leaf</quote> or <quote>site</quote>) certificate, and not a self-signed
47601 certificate. In this situation, the self-signed certificate described above
47602 must be installed on the client host as a trusted root <emphasis>certification
47603 authority</emphasis> (CA), and the certificate used by Exim must be a user certificate
47604 signed with that self-signed certificate.
47605 </para>
47606 <para>
47607 For information on creating self-signed CA certificates and using them to sign
47608 user certificates, see the <emphasis>General implementation overview</emphasis> chapter of the
47609 Open-source PKI book, available online at
47610 <emphasis role="bold"><ulink url="http://ospkibook.sourceforge.net/">http://ospkibook.sourceforge.net/</ulink></emphasis>.
47611 <indexterm role="concept" startref="IIDencsmtp1" class="endofrange"/>
47612 <indexterm role="concept" startref="IIDencsmtp2" class="endofrange"/>
47613 </para>
47614 </section>
47615 </chapter>
47616
47617 <chapter id="CHAPACL">
47618 <title>Access control lists</title>
47619 <para>
47620 <indexterm role="concept" id="IIDacl" class="startofrange">
47621 <primary>access control lists (ACLs)</primary>
47622 <secondary>description</secondary>
47623 </indexterm>
47624 <indexterm role="concept">
47625 <primary>control of incoming mail</primary>
47626 </indexterm>
47627 <indexterm role="concept">
47628 <primary>message</primary>
47629 <secondary>controlling incoming</secondary>
47630 </indexterm>
47631 <indexterm role="concept">
47632 <primary>policy control</primary>
47633 <secondary>access control lists</secondary>
47634 </indexterm>
47635 Access Control Lists (ACLs) are defined in a separate section of the run time
47636 configuration file, headed by <quote>begin acl</quote>. Each ACL definition starts with a
47637 name, terminated by a colon. Here is a complete ACL section that contains just
47638 one very small ACL:
47639 </para>
47640 <literallayout class="monospaced">
47641 begin acl
47642 small_acl:
47643   accept   hosts = one.host.only
47644 </literallayout>
47645 <para>
47646 You can have as many lists as you like in the ACL section, and the order in
47647 which they appear does not matter. The lists are self-terminating.
47648 </para>
47649 <para>
47650 The majority of ACLs are used to control Exim&#x2019;s behaviour when it receives
47651 certain SMTP commands. This applies both to incoming TCP/IP connections, and
47652 when a local process submits a message using SMTP by specifying the <option>-bs</option>
47653 option. The most common use is for controlling which recipients are accepted
47654 in incoming messages. In addition, you can define an ACL that is used to check
47655 local non-SMTP messages. The default configuration file contains an example of
47656 a realistic ACL for checking RCPT commands. This is discussed in chapter
47657 <xref linkend="CHAPdefconfil"/>.
47658 </para>
47659 <section id="SECID188">
47660 <title>Testing ACLs</title>
47661 <para>
47662 The <option>-bh</option> command line option provides a way of testing your ACL
47663 configuration locally by running a fake SMTP session with which you interact.
47664 The host <emphasis>relay-test.mail-abuse.org</emphasis> provides a service for checking your
47665 relaying configuration (see section <xref linkend="SECTcheralcon"/> for more details).
47666 </para>
47667 </section>
47668 <section id="SECID189">
47669 <title>Specifying when ACLs are used</title>
47670 <para>
47671 <indexterm role="concept">
47672 <primary>access control lists (ACLs)</primary>
47673 <secondary>options for specifying</secondary>
47674 </indexterm>
47675 In order to cause an ACL to be used, you have to name it in one of the relevant
47676 options in the main part of the configuration. These options are:
47677 <indexterm role="concept">
47678 <primary>AUTH</primary>
47679 <secondary>ACL for</secondary>
47680 </indexterm>
47681 <indexterm role="concept">
47682 <primary>DATA</primary>
47683 <secondary>ACLs for</secondary>
47684 </indexterm>
47685 <indexterm role="concept">
47686 <primary>ETRN</primary>
47687 <secondary>ACL for</secondary>
47688 </indexterm>
47689 <indexterm role="concept">
47690 <primary>EXPN</primary>
47691 <secondary>ACL for</secondary>
47692 </indexterm>
47693 <indexterm role="concept">
47694 <primary>HELO</primary>
47695 <secondary>ACL for</secondary>
47696 </indexterm>
47697 <indexterm role="concept">
47698 <primary>EHLO</primary>
47699 <secondary>ACL for</secondary>
47700 </indexterm>
47701 <indexterm role="concept">
47702 <primary>MAIL</primary>
47703 <secondary>ACL for</secondary>
47704 </indexterm>
47705 <indexterm role="concept">
47706 <primary>QUIT, ACL for</primary>
47707 </indexterm>
47708 <indexterm role="concept">
47709 <primary>RCPT</primary>
47710 <secondary>ACL for</secondary>
47711 </indexterm>
47712 <indexterm role="concept">
47713 <primary>STARTTLS, ACL for</primary>
47714 </indexterm>
47715 <indexterm role="concept">
47716 <primary>VRFY</primary>
47717 <secondary>ACL for</secondary>
47718 </indexterm>
47719 <indexterm role="concept">
47720 <primary>SMTP</primary>
47721 <secondary>connection, ACL for</secondary>
47722 </indexterm>
47723 <indexterm role="concept">
47724 <primary>non-SMTP messages</primary>
47725 <secondary>ACLs for</secondary>
47726 </indexterm>
47727 <indexterm role="concept">
47728 <primary>MIME content scanning</primary>
47729 <secondary>ACL for</secondary>
47730 </indexterm>
47731 </para>
47732 <informaltable frame="none">
47733 <tgroup cols="2" colsep="0" rowsep="0">
47734 <colspec colwidth="140pt" align="left"/>
47735 <colspec colwidth="254pt" align="left"/>
47736 <tbody>
47737 <row>
47738 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_not_smtp</option></entry>
47739 <entry>ACL for non-SMTP messages</entry>
47740 </row>
47741 <row>
47742 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_not_smtp_mime</option></entry>
47743 <entry>ACL for non-SMTP MIME parts</entry>
47744 </row>
47745 <row>
47746 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_not_smtp_start</option></entry>
47747 <entry>ACL at start of non-SMTP message</entry>
47748 </row>
47749 <row>
47750 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_auth</option></entry>
47751 <entry>ACL for AUTH</entry>
47752 </row>
47753 <row>
47754 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_connect</option></entry>
47755 <entry>ACL for start of SMTP connection</entry>
47756 </row>
47757 <row>
47758 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_data</option></entry>
47759 <entry>ACL after DATA is complete</entry>
47760 </row>
47761 <row>
47762 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_etrn</option></entry>
47763 <entry>ACL for ETRN</entry>
47764 </row>
47765 <row>
47766 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_expn</option></entry>
47767 <entry>ACL for EXPN</entry>
47768 </row>
47769 <row>
47770 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_helo</option></entry>
47771 <entry>ACL for HELO or EHLO</entry>
47772 </row>
47773 <row>
47774 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_mail</option></entry>
47775 <entry>ACL for MAIL</entry>
47776 </row>
47777 <row>
47778 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_mailauth</option></entry>
47779 <entry>ACL for the AUTH parameter of MAIL</entry>
47780 </row>
47781 <row>
47782 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_mime</option></entry>
47783 <entry>ACL for content-scanning MIME parts</entry>
47784 </row>
47785 <row>
47786 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_notquit</option></entry>
47787 <entry>ACL for non-QUIT terminations</entry>
47788 </row>
47789 <row>
47790 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_predata</option></entry>
47791 <entry>ACL at start of DATA command</entry>
47792 </row>
47793 <row>
47794 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_quit</option></entry>
47795 <entry>ACL for QUIT</entry>
47796 </row>
47797 <row>
47798 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_rcpt</option></entry>
47799 <entry>ACL for RCPT</entry>
47800 </row>
47801 <row>
47802 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_starttls</option></entry>
47803 <entry>ACL for STARTTLS</entry>
47804 </row>
47805 <row>
47806 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<option>acl_smtp_vrfy</option></entry>
47807 <entry>ACL for VRFY</entry>
47808 </row>
47809 </tbody>
47810 </tgroup>
47811 </informaltable>
47812 <para>
47813 For example, if you set
47814 </para>
47815 <literallayout class="monospaced">
47816 acl_smtp_rcpt = small_acl
47817 </literallayout>
47818 <para>
47819 the little ACL defined above is used whenever Exim receives a RCPT command
47820 in an SMTP dialogue. The majority of policy tests on incoming messages can be
47821 done when RCPT commands arrive. A rejection of RCPT should cause the
47822 sending MTA to give up on the recipient address contained in the RCPT
47823 command, whereas rejection at other times may cause the client MTA to keep on
47824 trying to deliver the message. It is therefore recommended that you do as much
47825 testing as possible at RCPT time.
47826 </para>
47827 </section>
47828 <section id="SECID190">
47829 <title>The non-SMTP ACLs</title>
47830 <para>
47831 <indexterm role="concept">
47832 <primary>non-SMTP messages</primary>
47833 <secondary>ACLs for</secondary>
47834 </indexterm>
47835 The non-SMTP ACLs apply to all non-interactive incoming messages, that is, they
47836 apply to batched SMTP as well as to non-SMTP messages. (Batched SMTP is not
47837 really SMTP.) Many of the ACL conditions (for example, host tests, and tests on
47838 the state of the SMTP connection such as encryption and authentication) are not
47839 relevant and are forbidden in these ACLs. However, the sender and recipients
47840 are known, so the <option>senders</option> and <option>sender_domains</option> conditions and the
47841 <varname>$sender_address</varname> and <varname>$recipients</varname> variables can be used. Variables such as
47842 <varname>$authenticated_sender</varname> are also available. You can specify added header lines
47843 in any of these ACLs.
47844 </para>
47845 <para>
47846 The <option>acl_not_smtp_start</option> ACL is run right at the start of receiving a
47847 non-SMTP message, before any of the message has been read. (This is the
47848 analogue of the <option>acl_smtp_predata</option> ACL for SMTP input.) In the case of
47849 batched SMTP input, it runs after the DATA command has been reached. The
47850 result of this ACL is ignored; it cannot be used to reject a message. If you
47851 really need to, you could set a value in an ACL variable here and reject based
47852 on that in the <option>acl_not_smtp</option> ACL. However, this ACL can be used to set
47853 controls, and in particular, it can be used to set
47854 </para>
47855 <literallayout class="monospaced">
47856 control = suppress_local_fixups
47857 </literallayout>
47858 <para>
47859 This cannot be used in the other non-SMTP ACLs because by the time they are
47860 run, it is too late.
47861 </para>
47862 <para>
47863 The <option>acl_not_smtp_mime</option> ACL is available only when Exim is compiled with the
47864 content-scanning extension. For details, see chapter <xref linkend="CHAPexiscan"/>.
47865 </para>
47866 <para>
47867 The <option>acl_not_smtp</option> ACL is run just before the <function>local_scan()</function> function. Any
47868 kind of rejection is treated as permanent, because there is no way of sending a
47869 temporary error for these kinds of message.
47870 </para>
47871 </section>
47872 <section id="SECID191">
47873 <title>The SMTP connect ACL</title>
47874 <para>
47875 <indexterm role="concept">
47876 <primary>SMTP</primary>
47877 <secondary>connection, ACL for</secondary>
47878 </indexterm>
47879 <indexterm role="option">
47880 <primary><option>smtp_banner</option></primary>
47881 </indexterm>
47882 The ACL test specified by <option>acl_smtp_connect</option> happens at the start of an SMTP
47883 session, after the test specified by <option>host_reject_connection</option> (which is now
47884 an anomaly) and any TCP Wrappers testing (if configured). If the connection is
47885 accepted by an <option>accept</option> verb that has a <option>message</option> modifier, the contents of
47886 the message override the banner message that is otherwise specified by the
47887 <option>smtp_banner</option> option.
47888 </para>
47889 </section>
47890 <section id="SECID192">
47891 <title>The EHLO/HELO ACL</title>
47892 <para>
47893 <indexterm role="concept">
47894 <primary>EHLO</primary>
47895 <secondary>ACL for</secondary>
47896 </indexterm>
47897 <indexterm role="concept">
47898 <primary>HELO</primary>
47899 <secondary>ACL for</secondary>
47900 </indexterm>
47901 The ACL test specified by <option>acl_smtp_helo</option> happens when the client issues an
47902 EHLO or HELO command, after the tests specified by <option>helo_accept_junk_hosts</option>,
47903 <option>helo_allow_chars</option>, <option>helo_verify_hosts</option>, and <option>helo_try_verify_hosts</option>.
47904 Note that a client may issue more than one EHLO or HELO command in an SMTP
47905 session, and indeed is required to issue a new EHLO or HELO after successfully
47906 setting up encryption following a STARTTLS command.
47907 </para>
47908 <para>
47909 If the command is accepted by an <option>accept</option> verb that has a <option>message</option>
47910 modifier, the message may not contain more than one line (it will be truncated
47911 at the first newline and a panic logged if it does). Such a message cannot
47912 affect the EHLO options that are listed on the second and subsequent lines of
47913 an EHLO response.
47914 </para>
47915 </section>
47916 <section id="SECID193">
47917 <title>The DATA ACLs</title>
47918 <para>
47919 <indexterm role="concept">
47920 <primary>DATA</primary>
47921 <secondary>ACLs for</secondary>
47922 </indexterm>
47923 Two ACLs are associated with the DATA command, because it is two-stage
47924 command, with two responses being sent to the client.
47925 When the DATA command is received, the ACL defined by <option>acl_smtp_predata</option>
47926 is obeyed. This gives you control after all the RCPT commands, but before
47927 the message itself is received. It offers the opportunity to give a negative
47928 response to the DATA command before the data is transmitted. Header lines
47929 added by MAIL or RCPT ACLs are not visible at this time, but any that
47930 are defined here are visible when the <option>acl_smtp_data</option> ACL is run.
47931 </para>
47932 <para>
47933 You cannot test the contents of the message, for example, to verify addresses
47934 in the headers, at RCPT time or when the DATA command is received. Such
47935 tests have to appear in the ACL that is run after the message itself has been
47936 received, before the final response to the DATA command is sent. This is
47937 the ACL specified by <option>acl_smtp_data</option>, which is the second ACL that is
47938 associated with the DATA command.
47939 </para>
47940 <para>
47941 For both of these ACLs, it is not possible to reject individual recipients. An
47942 error response rejects the entire message. Unfortunately, it is known that some
47943 MTAs do not treat hard (5<emphasis>xx</emphasis>) responses to the DATA command (either
47944 before or after the data) correctly &ndash; they keep the message on their queues
47945 and try again later, but that is their problem, though it does waste some of
47946 your resources.
47947 </para>
47948 </section>
47949 <section id="SECTDKIMACL" revisionflag="changed">
47950 <title>The SMTP DKIM ACL</title>
47951 <para revisionflag="changed">
47952 The <option>acl_smtp_dkim</option> ACL is available only when Exim is compiled with DKIM support
47953 enabled (which is the default).
47954 </para>
47955 <para revisionflag="changed">
47956 The ACL test specified by <option>acl_smtp_dkim</option> happens after a message has been
47957 received, and is executed for each DKIM signature found in a message.  If not
47958 otherwise specified, the default action is to accept.
47959 </para>
47960 <para revisionflag="changed">
47961 For details on the operation of DKIM, see chapter <xref linkend="CHID12"/>.
47962 </para>
47963 </section>
47964 <section id="SECID194">
47965 <title>The SMTP MIME ACL</title>
47966 <para>
47967 The <option>acl_smtp_mime</option> option is available only when Exim is compiled with the
47968 content-scanning extension. For details, see chapter <xref linkend="CHAPexiscan"/>.
47969 </para>
47970 </section>
47971 <section id="SECTQUITACL">
47972 <title>The QUIT ACL</title>
47973 <para>
47974 <indexterm role="concept">
47975 <primary>QUIT, ACL for</primary>
47976 </indexterm>
47977 The ACL for the SMTP QUIT command is anomalous, in that the outcome of the ACL
47978 does not affect the response code to QUIT, which is always 221. Thus, the ACL
47979 does not in fact control any access. For this reason, the only verbs that are
47980 permitted are <option>accept</option> and <option>warn</option>.
47981 </para>
47982 <para>
47983 This ACL can be used for tasks such as custom logging at the end of an SMTP
47984 session. For example, you can use ACL variables in other ACLs to count
47985 messages, recipients, etc., and log the totals at QUIT time using one or
47986 more <option>logwrite</option> modifiers on a <option>warn</option> verb.
47987 </para>
47988 <para>
47989 <emphasis role="bold">Warning</emphasis>: Only the <varname>$acl_c</varname><emphasis>x</emphasis> variables can be used for this, because
47990 the <varname>$acl_m</varname><emphasis>x</emphasis> variables are reset at the end of each incoming message.
47991 </para>
47992 <para>
47993 You do not need to have a final <option>accept</option>, but if you do, you can use a
47994 <option>message</option> modifier to specify custom text that is sent as part of the 221
47995 response to QUIT.
47996 </para>
47997 <para>
47998 This ACL is run only for a <quote>normal</quote> QUIT. For certain kinds of disastrous
47999 failure (for example, failure to open a log file, or when Exim is bombing out
48000 because it has detected an unrecoverable error), all SMTP commands from the
48001 client are given temporary error responses until QUIT is received or the
48002 connection is closed. In these special cases, the QUIT ACL does not run.
48003 </para>
48004 </section>
48005 <section id="SECTNOTQUITACL">
48006 <title>The not-QUIT ACL</title>
48007 <para>
48008 <indexterm role="variable">
48009 <primary><varname>$acl_smtp_notquit</varname></primary>
48010 </indexterm>
48011 The not-QUIT ACL, specified by <option>acl_smtp_notquit</option>, is run in most cases when
48012 an SMTP session ends without sending QUIT. However, when Exim itself is is bad
48013 trouble, such as being unable to write to its log files, this ACL is not run,
48014 because it might try to do things (such as write to log files) that make the
48015 situation even worse.
48016 </para>
48017 <para>
48018 Like the QUIT ACL, this ACL is provided to make it possible to do customized
48019 logging or to gather statistics, and its outcome is ignored. The <option>delay</option>
48020 modifier is forbidden in this ACL, and the only permitted verbs are <option>accept</option>
48021 and <option>warn</option>.
48022 </para>
48023 <para>
48024 <indexterm role="variable">
48025 <primary><varname>$smtp_notquit_reason</varname></primary>
48026 </indexterm>
48027 When the not-QUIT ACL is running, the variable <varname>$smtp_notquit_reason</varname> is set
48028 to a string that indicates the reason for the termination of the SMTP
48029 connection. The possible values are:
48030 </para>
48031 <informaltable frame="none">
48032 <tgroup cols="2" colsep="0" rowsep="0">
48033 <colspec colwidth="196pt" align="left"/>
48034 <colspec colwidth="254pt" align="left"/>
48035 <tbody>
48036 <row>
48037 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>acl-drop</literal></entry>
48038 <entry>Another ACL issued a <option>drop</option> command</entry>
48039 </row>
48040 <row>
48041 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>bad-commands</literal></entry>
48042 <entry>Too many unknown or non-mail commands</entry>
48043 </row>
48044 <row>
48045 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>command-timeout</literal></entry>
48046 <entry>Timeout while reading SMTP commands</entry>
48047 </row>
48048 <row>
48049 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>connection-lost</literal></entry>
48050 <entry>The SMTP connection has been lost</entry>
48051 </row>
48052 <row>
48053 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>data-timeout</literal></entry>
48054 <entry>Timeout while reading message data</entry>
48055 </row>
48056 <row>
48057 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>local-scan-error</literal></entry>
48058 <entry>The <function>local_scan()</function> function crashed</entry>
48059 </row>
48060 <row>
48061 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>local-scan-timeout</literal></entry>
48062 <entry>The <function>local_scan()</function> function timed out</entry>
48063 </row>
48064 <row>
48065 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>signal-exit</literal></entry>
48066 <entry>SIGTERM or SIGINT</entry>
48067 </row>
48068 <row>
48069 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>synchronization-error</literal></entry>
48070 <entry>SMTP synchronization error</entry>
48071 </row>
48072 <row>
48073 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<literal>tls-failed</literal></entry>
48074 <entry>TLS failed to start</entry>
48075 </row>
48076 </tbody>
48077 </tgroup>
48078 </informaltable>
48079 <para>
48080 In most cases when an SMTP connection is closed without having received QUIT,
48081 Exim sends an SMTP response message before actually closing the connection.
48082 With the exception of the <literal>acl-drop</literal> case, the default message can be
48083 overridden by the <option>message</option> modifier in the not-QUIT ACL. In the case of a
48084 <option>drop</option> verb in another ACL, it is the message from the other ACL that is
48085 used.
48086 </para>
48087 </section>
48088 <section id="SECID195">
48089 <title>Finding an ACL to use</title>
48090 <para>
48091 <indexterm role="concept">
48092 <primary>access control lists (ACLs)</primary>
48093 <secondary>finding which to use</secondary>
48094 </indexterm>
48095 The value of an <option>acl_smtp_</option><emphasis>xxx</emphasis> option is expanded before use, so
48096 you can use different ACLs in different circumstances. For example,
48097 </para>
48098 <literallayout class="monospaced">
48099 acl_smtp_rcpt = ${if ={25}{$interface_port} \
48100                      {acl_check_rcpt} {acl_check_rcpt_submit} }
48101 </literallayout>
48102 <para>
48103 In the default configuration file there are some example settings for
48104 providing an RFC 4409 message submission service on port 587 and a
48105 non-standard <quote>smtps</quote> service on port 465. You can use a string
48106 expansion like this to choose an ACL for MUAs on these ports which is
48107 more appropriate for this purpose than the default ACL on port 25.
48108 </para>
48109 <para>
48110 The expanded string does not have to be the name of an ACL in the
48111 configuration file; there are other possibilities. Having expanded the
48112 string, Exim searches for an ACL as follows:
48113 </para>
48114 <itemizedlist>
48115 <listitem>
48116 <para>
48117 If the string begins with a slash, Exim uses it as a file name, and reads its
48118 contents as an ACL. The lines are processed in the same way as lines in the
48119 Exim configuration file. In particular, continuation lines are supported, blank
48120 lines are ignored, as are lines whose first non-whitespace character is <quote>#</quote>.
48121 If the file does not exist or cannot be read, an error occurs (typically
48122 causing a temporary failure of whatever caused the ACL to be run). For example:
48123 </para>
48124 <literallayout class="monospaced">
48125 acl_smtp_data = /etc/acls/\
48126   ${lookup{$sender_host_address}lsearch\
48127   {/etc/acllist}{$value}{default}}
48128 </literallayout>
48129 <para>
48130 This looks up an ACL file to use on the basis of the host&#x2019;s IP address, falling
48131 back to a default if the lookup fails. If an ACL is successfully read from a
48132 file, it is retained in memory for the duration of the Exim process, so that it
48133 can be re-used without having to re-read the file.
48134 </para>
48135 </listitem>
48136 <listitem>
48137 <para>
48138 If the string does not start with a slash, and does not contain any spaces,
48139 Exim searches the ACL section of the configuration for an ACL whose name
48140 matches the string.
48141 </para>
48142 </listitem>
48143 <listitem>
48144 <para>
48145 If no named ACL is found, or if the string contains spaces, Exim parses
48146 the string as an inline ACL. This can save typing in cases where you just
48147 want to have something like
48148 </para>
48149 <literallayout class="monospaced">
48150 acl_smtp_vrfy = accept
48151 </literallayout>
48152 <para>
48153 in order to allow free use of the VRFY command. Such a string may contain
48154 newlines; it is processed in the same way as an ACL that is read from a file.
48155 </para>
48156 </listitem>
48157 </itemizedlist>
48158 </section>
48159 <section id="SECID196">
48160 <title>ACL return codes</title>
48161 <para>
48162 <indexterm role="concept">
48163 <primary>access control lists (ACLs)</primary>
48164 <secondary>return codes</secondary>
48165 </indexterm>
48166 Except for the QUIT ACL, which does not affect the SMTP return code (see
48167 section <xref linkend="SECTQUITACL"/> above), the result of running an ACL is either
48168 <quote>accept</quote> or <quote>deny</quote>, or, if some test cannot be completed (for example, if a
48169 database is down), <quote>defer</quote>. These results cause 2<emphasis>xx</emphasis>, 5<emphasis>xx</emphasis>, and 4<emphasis>xx</emphasis>
48170 return codes, respectively, to be used in the SMTP dialogue. A fourth return,
48171 <quote>error</quote>, occurs when there is an error such as invalid syntax in the ACL.
48172 This also causes a 4<emphasis>xx</emphasis> return code.
48173 </para>
48174 <para>
48175 For the non-SMTP ACL, <quote>defer</quote> and <quote>error</quote> are treated in the same way as
48176 <quote>deny</quote>, because there is no mechanism for passing temporary errors to the
48177 submitters of non-SMTP messages.
48178 </para>
48179 <para>
48180 ACLs that are relevant to message reception may also return <quote>discard</quote>. This
48181 has the effect of <quote>accept</quote>, but causes either the entire message or an
48182 individual recipient address to be discarded. In other words, it is a
48183 blackholing facility. Use it with care.
48184 </para>
48185 <para>
48186 If the ACL for MAIL returns <quote>discard</quote>, all recipients are discarded, and no
48187 ACL is run for subsequent RCPT commands. The effect of <quote>discard</quote> in a
48188 RCPT ACL is to discard just the one recipient address. If there are no
48189 recipients left when the message&#x2019;s data is received, the DATA ACL is not
48190 run. A <quote>discard</quote> return from the DATA or the non-SMTP ACL discards all the
48191 remaining recipients. The <quote>discard</quote> return is not permitted for the
48192 <option>acl_smtp_predata</option> ACL.
48193 </para>
48194 <para>
48195 <indexterm role="concept">
48196 <primary><function>local_scan()</function> function</primary>
48197 <secondary>when all recipients discarded</secondary>
48198 </indexterm>
48199 The <function>local_scan()</function> function is always run, even if there are no remaining
48200 recipients; it may create new recipients.
48201 </para>
48202 </section>
48203 <section id="SECID197">
48204 <title>Unset ACL options</title>
48205 <para>
48206 <indexterm role="concept">
48207 <primary>access control lists (ACLs)</primary>
48208 <secondary>unset options</secondary>
48209 </indexterm>
48210 The default actions when any of the <option>acl_</option><emphasis>xxx</emphasis> options are unset are not
48211 all the same. <emphasis role="bold">Note</emphasis>: These defaults apply only when the relevant ACL is
48212 not defined at all. For any defined ACL, the default action when control
48213 reaches the end of the ACL statements is <quote>deny</quote>.
48214 </para>
48215 <para>
48216 For <option>acl_smtp_quit</option> and <option>acl_not_smtp_start</option> there is no default because
48217 these two are ACLs that are used only for their side effects. They cannot be
48218 used to accept or reject anything.
48219 </para>
48220 <para>
48221 For <option>acl_not_smtp</option>, <option>acl_smtp_auth</option>, <option>acl_smtp_connect</option>,
48222 <option>acl_smtp_data</option>, <option>acl_smtp_helo</option>, <option>acl_smtp_mail</option>, <option>acl_smtp_mailauth</option>,
48223 <option>acl_smtp_mime</option>, <option>acl_smtp_predata</option>, and <option>acl_smtp_starttls</option>, the action
48224 when the ACL is not defined is <quote>accept</quote>.
48225 </para>
48226 <para>
48227 For the others (<option>acl_smtp_etrn</option>, <option>acl_smtp_expn</option>, <option>acl_smtp_rcpt</option>, and
48228 <option>acl_smtp_vrfy</option>), the action when the ACL is not defined is <quote>deny</quote>.
48229 This means that <option>acl_smtp_rcpt</option> must be defined in order to receive any
48230 messages over an SMTP connection. For an example, see the ACL in the default
48231 configuration file.
48232 </para>
48233 </section>
48234 <section id="SECID198">
48235 <title>Data for message ACLs</title>
48236 <para>
48237 <indexterm role="concept">
48238 <primary>access control lists (ACLs)</primary>
48239 <secondary>data for message ACL</secondary>
48240 </indexterm>
48241 <indexterm role="variable">
48242 <primary><varname>$domain</varname></primary>
48243 </indexterm>
48244 <indexterm role="variable">
48245 <primary><varname>$local_part</varname></primary>
48246 </indexterm>
48247 <indexterm role="variable">
48248 <primary><varname>$sender_address</varname></primary>
48249 </indexterm>
48250 <indexterm role="variable">
48251 <primary><varname>$sender_host_address</varname></primary>
48252 </indexterm>
48253 <indexterm role="variable">
48254 <primary><varname>$smtp_command</varname></primary>
48255 </indexterm>
48256 When a MAIL or RCPT ACL, or either of the DATA ACLs, is running, the variables
48257 that contain information about the host and the message&#x2019;s sender (for example,
48258 <varname>$sender_host_address</varname> and <varname>$sender_address</varname>) are set, and can be used in ACL
48259 statements. In the case of RCPT (but not MAIL or DATA), <varname>$domain</varname> and
48260 <varname>$local_part</varname> are set from the argument address. The entire SMTP command
48261 is available in <varname>$smtp_command</varname>.
48262 </para>
48263 <para>
48264 When an ACL for the AUTH parameter of MAIL is running, the variables that
48265 contain information about the host are set, but <varname>$sender_address</varname> is not yet
48266 set. Section <xref linkend="SECTauthparamail"/> contains a discussion of this parameter and
48267 how it is used.
48268 </para>
48269 <para>
48270 <indexterm role="variable">
48271 <primary><varname>$message_size</varname></primary>
48272 </indexterm>
48273 The <varname>$message_size</varname> variable is set to the value of the SIZE parameter on
48274 the MAIL command at MAIL, RCPT and pre-data time, or to -1 if
48275 that parameter is not given. The value is updated to the true message size by
48276 the time the final DATA ACL is run (after the message data has been
48277 received).
48278 </para>
48279 <para>
48280 <indexterm role="variable">
48281 <primary><varname>$rcpt_count</varname></primary>
48282 </indexterm>
48283 <indexterm role="variable">
48284 <primary><varname>$recipients_count</varname></primary>
48285 </indexterm>
48286 The <varname>$rcpt_count</varname> variable increases by one for each RCPT command received.
48287 The <varname>$recipients_count</varname> variable increases by one each time a RCPT command is
48288 accepted, so while an ACL for RCPT is being processed, it contains the number
48289 of previously accepted recipients. At DATA time (for both the DATA ACLs),
48290 <varname>$rcpt_count</varname> contains the total number of RCPT commands, and
48291 <varname>$recipients_count</varname> contains the total number of accepted recipients.
48292 </para>
48293 </section>
48294 <section id="SECTdatfornon">
48295 <title>Data for non-message ACLs</title>
48296 <para>
48297 <indexterm role="concept">
48298 <primary>access control lists (ACLs)</primary>
48299 <secondary>data for non-message ACL</secondary>
48300 </indexterm>
48301 <indexterm role="variable">
48302 <primary><varname>$smtp_command_argument</varname></primary>
48303 </indexterm>
48304 <indexterm role="variable">
48305 <primary><varname>$smtp_command</varname></primary>
48306 </indexterm>
48307 When an ACL is being run for AUTH, EHLO, ETRN, EXPN, HELO, STARTTLS, or VRFY,
48308 the remainder of the SMTP command line is placed in <varname>$smtp_command_argument</varname>,
48309 and the entire SMTP command is available in <varname>$smtp_command</varname>.
48310 These variables can be tested using a <option>condition</option> condition. For example,
48311 here is an ACL for use with AUTH, which insists that either the session is
48312 encrypted, or the CRAM-MD5 authentication method is used. In other words, it
48313 does not permit authentication methods that use cleartext passwords on
48314 unencrypted connections.
48315 </para>
48316 <literallayout class="monospaced">
48317 acl_check_auth:
48318   accept encrypted = *
48319   accept condition = ${if eq{${uc:$smtp_command_argument}}\
48320                      {CRAM-MD5}}
48321   deny   message   = TLS encryption or CRAM-MD5 required
48322 </literallayout>
48323 <para>
48324 (Another way of applying this restriction is to arrange for the authenticators
48325 that use cleartext passwords not to be advertised when the connection is not
48326 encrypted. You can use the generic <option>server_advertise_condition</option> authenticator
48327 option to do this.)
48328 </para>
48329 </section>
48330 <section id="SECID199">
48331 <title>Format of an ACL</title>
48332 <para>
48333 <indexterm role="concept">
48334 <primary>access control lists (ACLs)</primary>
48335 <secondary>format of</secondary>
48336 </indexterm>
48337 <indexterm role="concept">
48338 <primary>access control lists (ACLs)</primary>
48339 <secondary>verbs, definition of</secondary>
48340 </indexterm>
48341 An individual ACL consists of a number of statements. Each statement starts
48342 with a verb, optionally followed by a number of conditions and <quote>modifiers</quote>.
48343 Modifiers can change the way the verb operates, define error and log messages,
48344 set variables, insert delays, and vary the processing of accepted messages.
48345 </para>
48346 <para>
48347 If all the conditions are met, the verb is obeyed. The same condition may be
48348 used (with different arguments) more than once in the same statement. This
48349 provides a means of specifying an <quote>and</quote> conjunction between conditions. For
48350 example:
48351 </para>
48352 <literallayout class="monospaced">
48353 deny  dnslists = list1.example
48354 dnslists = list2.example
48355 </literallayout>
48356 <para>
48357 If there are no conditions, the verb is always obeyed. Exim stops evaluating
48358 the conditions and modifiers when it reaches a condition that fails. What
48359 happens then depends on the verb (and in one case, on a special modifier). Not
48360 all the conditions make sense at every testing point. For example, you cannot
48361 test a sender address in the ACL that is run for a VRFY command.
48362 </para>
48363 </section>
48364 <section id="SECID200">
48365 <title>ACL verbs</title>
48366 <para>
48367 The ACL verbs are as follows:
48368 </para>
48369 <itemizedlist>
48370 <listitem>
48371 <para>
48372 <indexterm role="concept">
48373 <primary><option>accept</option> ACL verb</primary>
48374 </indexterm>
48375 <option>accept</option>: If all the conditions are met, the ACL returns <quote>accept</quote>. If any
48376 of the conditions are not met, what happens depends on whether <option>endpass</option>
48377 appears among the conditions (for syntax see below). If the failing condition
48378 is before <option>endpass</option>, control is passed to the next ACL statement; if it is
48379 after <option>endpass</option>, the ACL returns <quote>deny</quote>. Consider this statement, used to
48380 check a RCPT command:
48381 </para>
48382 <literallayout class="monospaced">
48383 accept domains = +local_domains
48384 endpass
48385 verify = recipient
48386 </literallayout>
48387 <para>
48388 If the recipient domain does not match the <option>domains</option> condition, control
48389 passes to the next statement. If it does match, the recipient is verified, and
48390 the command is accepted if verification succeeds. However, if verification
48391 fails, the ACL yields <quote>deny</quote>, because the failing condition is after
48392 <option>endpass</option>.
48393 </para>
48394 <para>
48395 The <option>endpass</option> feature has turned out to be confusing to many people, so its
48396 use is not recommended nowadays. It is always possible to rewrite an ACL so
48397 that <option>endpass</option> is not needed, and it is no longer used in the default
48398 configuration.
48399 </para>
48400 <para>
48401 <indexterm role="concept">
48402 <primary><option>message</option> ACL modifier</primary>
48403 <secondary>with <option>accept</option></secondary>
48404 </indexterm>
48405 If a <option>message</option> modifier appears on an <option>accept</option> statement, its action
48406 depends on whether or not <option>endpass</option> is present. In the absence of <option>endpass</option>
48407 (when an <option>accept</option> verb either accepts or passes control to the next
48408 statement), <option>message</option> can be used to vary the message that is sent when an
48409 SMTP command is accepted. For example, in a RCPT ACL you could have:
48410 </para>
48411 <literallayout>
48412 <literal>accept  </literal>&lt;<emphasis>some conditions</emphasis>&gt;
48413 <literal>        message = OK, I will allow you through today</literal>
48414 </literallayout>
48415 <para>
48416 You can specify an SMTP response code, optionally followed by an <quote>extended
48417 response code</quote> at the start of the message, but the first digit must be the
48418 same as would be sent by default, which is 2 for an <option>accept</option> verb.
48419 </para>
48420 <para>
48421 If <option>endpass</option> is present in an <option>accept</option> statement, <option>message</option> specifies
48422 an error message that is used when access is denied. This behaviour is retained
48423 for backward compatibility, but current <quote>best practice</quote> is to avoid the use
48424 of <option>endpass</option>.
48425 </para>
48426 </listitem>
48427 <listitem>
48428 <para>
48429 <indexterm role="concept">
48430 <primary><option>defer</option> ACL verb</primary>
48431 </indexterm>
48432 <option>defer</option>: If all the conditions are true, the ACL returns <quote>defer</quote> which, in
48433 an SMTP session, causes a 4<emphasis>xx</emphasis> response to be given. For a non-SMTP ACL,
48434 <option>defer</option> is the same as <option>deny</option>, because there is no way of sending a
48435 temporary error. For a RCPT command, <option>defer</option> is much the same as using a
48436 <command>redirect</command> router and <literal>:defer:</literal> while verifying, but the <option>defer</option> verb can
48437 be used in any ACL, and even for a recipient it might be a simpler approach.
48438 </para>
48439 </listitem>
48440 <listitem>
48441 <para>
48442 <indexterm role="concept">
48443 <primary><option>deny</option> ACL verb</primary>
48444 </indexterm>
48445 <option>deny</option>: If all the conditions are met, the ACL returns <quote>deny</quote>. If any of
48446 the conditions are not met, control is passed to the next ACL statement. For
48447 example,
48448 </para>
48449 <literallayout class="monospaced">
48450 deny dnslists = blackholes.mail-abuse.org
48451 </literallayout>
48452 <para>
48453 rejects commands from hosts that are on a DNS black list.
48454 </para>
48455 </listitem>
48456 <listitem>
48457 <para>
48458 <indexterm role="concept">
48459 <primary><option>discard</option> ACL verb</primary>
48460 </indexterm>
48461 <option>discard</option>: This verb behaves like <option>accept</option>, except that it returns
48462 <quote>discard</quote> from the ACL instead of <quote>accept</quote>. It is permitted only on ACLs
48463 that are concerned with receiving messages. When all the conditions are true,
48464 the sending entity receives a <quote>success</quote> response. However, <option>discard</option> causes
48465 recipients to be discarded. If it is used in an ACL for RCPT, just the one
48466 recipient is discarded; if used for MAIL, DATA or in the non-SMTP ACL, all the
48467 message&#x2019;s recipients are discarded. Recipients that are discarded before DATA
48468 do not appear in the log line when the <option>received_recipients</option> log selector is set.
48469 </para>
48470 <para>
48471 If the <option>log_message</option> modifier is set when <option>discard</option> operates,
48472 its contents are added to the line that is automatically written to the log.
48473 The <option>message</option> modifier operates exactly as it does for <option>accept</option>.
48474 </para>
48475 </listitem>
48476 <listitem>
48477 <para>
48478 <indexterm role="concept">
48479 <primary><option>drop</option> ACL verb</primary>
48480 </indexterm>
48481 <option>drop</option>: This verb behaves like <option>deny</option>, except that an SMTP connection is
48482 forcibly closed after the 5<emphasis>xx</emphasis> error message has been sent. For example:
48483 </para>
48484 <literallayout class="monospaced">
48485 drop   message   = I don't take more than 20 RCPTs
48486        condition = ${if &gt; {$rcpt_count}{20}}
48487 </literallayout>
48488 <para>
48489 There is no difference between <option>deny</option> and <option>drop</option> for the connect-time ACL.
48490 The connection is always dropped after sending a 550 response.
48491 </para>
48492 </listitem>
48493 <listitem>
48494 <para>
48495 <indexterm role="concept">
48496 <primary><option>require</option> ACL verb</primary>
48497 </indexterm>
48498 <option>require</option>: If all the conditions are met, control is passed to the next ACL
48499 statement. If any of the conditions are not met, the ACL returns <quote>deny</quote>. For
48500 example, when checking a RCPT command,
48501 </para>
48502 <literallayout class="monospaced">
48503 require message = Sender did not verify
48504         verify  = sender
48505 </literallayout>
48506 <para>
48507 passes control to subsequent statements only if the message&#x2019;s sender can be
48508 verified. Otherwise, it rejects the command. Note the positioning of the
48509 <option>message</option> modifier, before the <option>verify</option> condition. The reason for this is
48510 discussed in section <xref linkend="SECTcondmodproc"/>.
48511 </para>
48512 </listitem>
48513 <listitem>
48514 <para>
48515 <indexterm role="concept">
48516 <primary><option>warn</option> ACL verb</primary>
48517 </indexterm>
48518 <option>warn</option>: If all the conditions are true, a line specified by the
48519 <option>log_message</option> modifier is written to Exim&#x2019;s main log. Control always passes
48520 to the next ACL statement. If any condition is false, the log line is not
48521 written. If an identical log line is requested several times in the same
48522 message, only one copy is actually written to the log. If you want to force
48523 duplicates to be written, use the <option>logwrite</option> modifier instead.
48524 </para>
48525 <para>
48526 If <option>log_message</option> is not present, a <option>warn</option> verb just checks its conditions
48527 and obeys any <quote>immediate</quote> modifiers (such as <option>control</option>, <option>set</option>,
48528 <option>logwrite</option>, and <option>add_header</option>) that appear before the first failing
48529 condition. There is more about adding header lines in section
48530 <xref linkend="SECTaddheadacl"/>.
48531 </para>
48532 <para>
48533 If any condition on a <option>warn</option> statement cannot be completed (that is, there is
48534 some sort of defer), the log line specified by <option>log_message</option> is not written.
48535 This does not include the case of a forced failure from a lookup, which
48536 is considered to be a successful completion. After a defer, no further
48537 conditions or modifiers in the <option>warn</option> statement are processed. The incident
48538 is logged, and the ACL continues to be processed, from the next statement
48539 onwards.
48540 </para>
48541 <para>
48542 <indexterm role="variable">
48543 <primary><varname>$acl_verify_message</varname></primary>
48544 </indexterm>
48545 When one of the <option>warn</option> conditions is an address verification that fails, the
48546 text of the verification failure message is in <varname>$acl_verify_message</varname>. If you
48547 want this logged, you must set it up explicitly. For example:
48548 </para>
48549 <literallayout class="monospaced">
48550 warn   !verify = sender
48551        log_message = sender verify failed: $acl_verify_message
48552 </literallayout>
48553 </listitem>
48554 </itemizedlist>
48555 <para>
48556 At the end of each ACL there is an implicit unconditional <option>deny</option>.
48557 </para>
48558 <para>
48559 As you can see from the examples above, the conditions and modifiers are
48560 written one to a line, with the first one on the same line as the verb, and
48561 subsequent ones on following lines. If you have a very long condition, you can
48562 continue it onto several physical lines by the usual backslash continuation
48563 mechanism. It is conventional to align the conditions vertically.
48564 </para>
48565 </section>
48566 <section id="SECTaclvariables">
48567 <title>ACL variables</title>
48568 <para>
48569 <indexterm role="concept">
48570 <primary>access control lists (ACLs)</primary>
48571 <secondary>variables</secondary>
48572 </indexterm>
48573 There are some special variables that can be set during ACL processing. They
48574 can be used to pass information between different ACLs, different invocations
48575 of the same ACL in the same SMTP connection, and between ACLs and the routers,
48576 transports, and filters that are used to deliver a message. The names of these
48577 variables must begin with <varname>$acl_c</varname> or <varname>$acl_m</varname>, followed either by a digit or
48578 an underscore, but the remainder of the name can be any sequence of
48579 alphanumeric characters and underscores that you choose. There is no limit on
48580 the number of ACL variables. The two sets act as follows:
48581 </para>
48582 <itemizedlist>
48583 <listitem>
48584 <para>
48585 The values of those variables whose names begin with <varname>$acl_c</varname> persist
48586 throughout an SMTP connection. They are never reset. Thus, a value that is set
48587 while receiving one message is still available when receiving the next message
48588 on the same SMTP connection.
48589 </para>
48590 </listitem>
48591 <listitem>
48592 <para>
48593 The values of those variables whose names begin with <varname>$acl_m</varname> persist only
48594 while a message is being received. They are reset afterwards. They are also
48595 reset by MAIL, RSET, EHLO, HELO, and after starting up a TLS session.
48596 </para>
48597 </listitem>
48598 </itemizedlist>
48599 <para>
48600 When a message is accepted, the current values of all the ACL variables are
48601 preserved with the message and are subsequently made available at delivery
48602 time. The ACL variables are set by a modifier called <option>set</option>. For example:
48603 </para>
48604 <literallayout class="monospaced">
48605 accept hosts = whatever
48606        set acl_m4 = some value
48607 accept authenticated = *
48608        set acl_c_auth = yes
48609 </literallayout>
48610 <para>
48611 <emphasis role="bold">Note</emphasis>: A leading dollar sign is not used when naming a variable that is to
48612 be set. If you want to set a variable without taking any action, you can use a
48613 <option>warn</option> verb without any other modifiers or conditions.
48614 </para>
48615 <para>
48616 <indexterm role="option">
48617 <primary><option>strict_acl_vars</option></primary>
48618 </indexterm>
48619 What happens if a syntactically valid but undefined ACL variable is
48620 referenced depends on the setting of the <option>strict_acl_vars</option> option. If it is
48621 false (the default), an empty string is substituted; if it is true, an
48622 error is generated.
48623 </para>
48624 <para>
48625 Versions of Exim before 4.64 have a limited set of numbered variables, but
48626 their names are compatible, so there is no problem with upgrading.
48627 </para>
48628 </section>
48629 <section id="SECTcondmodproc">
48630 <title>Condition and modifier processing</title>
48631 <para>
48632 <indexterm role="concept">
48633 <primary>access control lists (ACLs)</primary>
48634 <secondary>conditions; processing</secondary>
48635 </indexterm>
48636 <indexterm role="concept">
48637 <primary>access control lists (ACLs)</primary>
48638 <secondary>modifiers; processing</secondary>
48639 </indexterm>
48640 An exclamation mark preceding a condition negates its result. For example:
48641 </para>
48642 <literallayout class="monospaced">
48643 deny   domains = *.dom.example
48644       !verify  = recipient
48645 </literallayout>
48646 <para>
48647 causes the ACL to return <quote>deny</quote> if the recipient domain ends in
48648 <emphasis>dom.example</emphasis> and the recipient address cannot be verified. Sometimes
48649 negation can be used on the right-hand side of a condition. For example, these
48650 two statements are equivalent:
48651 </para>
48652 <literallayout class="monospaced">
48653 deny  hosts = !192.168.3.4
48654 deny !hosts =  192.168.3.4
48655 </literallayout>
48656 <para>
48657 However, for many conditions (<option>verify</option> being a good example), only left-hand
48658 side negation of the whole condition is possible.
48659 </para>
48660 <para>
48661 The arguments of conditions and modifiers are expanded. A forced failure
48662 of an expansion causes a condition to be ignored, that is, it behaves as if the
48663 condition is true. Consider these two statements:
48664 </para>
48665 <literallayout class="monospaced">
48666 accept  senders = ${lookup{$host_name}lsearch\
48667                   {/some/file}{$value}fail}
48668 accept  senders = ${lookup{$host_name}lsearch\
48669                   {/some/file}{$value}{}}
48670 </literallayout>
48671 <para>
48672 Each attempts to look up a list of acceptable senders. If the lookup succeeds,
48673 the returned list is searched, but if the lookup fails the behaviour is
48674 different in the two cases. The <option>fail</option> in the first statement causes the
48675 condition to be ignored, leaving no further conditions. The <option>accept</option> verb
48676 therefore succeeds. The second statement, however, generates an empty list when
48677 the lookup fails. No sender can match an empty list, so the condition fails,
48678 and therefore the <option>accept</option> also fails.
48679 </para>
48680 <para>
48681 ACL modifiers appear mixed in with conditions in ACL statements. Some of them
48682 specify actions that are taken as the conditions for a statement are checked;
48683 others specify text for messages that are used when access is denied or a
48684 warning is generated. The <option>control</option> modifier affects the way an incoming
48685 message is handled.
48686 </para>
48687 <para>
48688 The positioning of the modifiers in an ACL statement important, because the
48689 processing of a verb ceases as soon as its outcome is known. Only those
48690 modifiers that have already been encountered will take effect. For example,
48691 consider this use of the <option>message</option> modifier:
48692 </para>
48693 <literallayout class="monospaced">
48694 require message = Can't verify sender
48695         verify  = sender
48696         message = Can't verify recipient
48697         verify  = recipient
48698         message = This message cannot be used
48699 </literallayout>
48700 <para>
48701 If sender verification fails, Exim knows that the result of the statement is
48702 <quote>deny</quote>, so it goes no further. The first <option>message</option> modifier has been seen,
48703 so its text is used as the error message. If sender verification succeeds, but
48704 recipient verification fails, the second message is used. If recipient
48705 verification succeeds, the third message becomes <quote>current</quote>, but is never used
48706 because there are no more conditions to cause failure.
48707 </para>
48708 <para>
48709 For the <option>deny</option> verb, on the other hand, it is always the last <option>message</option>
48710 modifier that is used, because all the conditions must be true for rejection to
48711 happen. Specifying more than one <option>message</option> modifier does not make sense, and
48712 the message can even be specified after all the conditions. For example:
48713 </para>
48714 <literallayout class="monospaced">
48715 deny   hosts = ...
48716       !senders = *@my.domain.example
48717        message = Invalid sender from client host
48718 </literallayout>
48719 <para>
48720 The <quote>deny</quote> result does not happen until the end of the statement is reached,
48721 by which time Exim has set up the message.
48722 </para>
48723 </section>
48724 <section id="SECTACLmodi">
48725 <title>ACL modifiers</title>
48726 <para>
48727 <indexterm role="concept">
48728 <primary>access control lists (ACLs)</primary>
48729 <secondary>modifiers; list of</secondary>
48730 </indexterm>
48731 The ACL modifiers are as follows:
48732 </para>
48733 <variablelist>
48734 <varlistentry>
48735 <term><emphasis role="bold">add_header</emphasis>&nbsp;=&nbsp;&lt;<emphasis>text</emphasis>&gt;</term>
48736 <listitem>
48737 <para>
48738 This modifier specifies one or more header lines that are to be added to an
48739 incoming message, assuming, of course, that the message is ultimately
48740 accepted. For details, see section <xref linkend="SECTaddheadacl"/>.
48741 </para>
48742 </listitem></varlistentry>
48743 <varlistentry>
48744 <term><emphasis role="bold">continue</emphasis>&nbsp;=&nbsp;&lt;<emphasis>text</emphasis>&gt;</term>
48745 <listitem>
48746 <para>
48747 <indexterm role="concept">
48748 <primary><option>continue</option> ACL modifier</primary>
48749 </indexterm>
48750 <indexterm role="concept">
48751 <primary>database</primary>
48752 <secondary>updating in ACL</secondary>
48753 </indexterm>
48754 This modifier does nothing of itself, and processing of the ACL always
48755 continues with the next condition or modifier. The value of <option>continue</option> is in
48756 the side effects of expanding its argument. Typically this could be used to
48757 update a database. It is really just a syntactic tidiness, to avoid having to
48758 write rather ugly lines like this:
48759 </para>
48760 <literallayout>
48761 <literal>condition = ${if eq{0}{</literal>&lt;<emphasis>some expansion</emphasis>&gt;<literal>}{true}{true}}</literal>
48762 </literallayout>
48763 <para>
48764 Instead, all you need is
48765 </para>
48766 <literallayout>
48767 <literal>continue = </literal>&lt;<emphasis>some expansion</emphasis>&gt;
48768 </literallayout>
48769 </listitem></varlistentry>
48770 <varlistentry>
48771 <term><emphasis role="bold">control</emphasis>&nbsp;=&nbsp;&lt;<emphasis>text</emphasis>&gt;</term>
48772 <listitem>
48773 <para>
48774 <indexterm role="concept">
48775 <primary><option>control</option> ACL modifier</primary>
48776 </indexterm>
48777 This modifier affects the subsequent processing of the SMTP connection or of an
48778 incoming message that is accepted. The effect of the first type of control
48779 lasts for the duration of the connection, whereas the effect of the second type
48780 lasts only until the current message has been received. The message-specific
48781 controls always apply to the whole message, not to individual recipients,
48782 even if the <option>control</option> modifier appears in a RCPT ACL.
48783 </para>
48784 <para>
48785 As there are now quite a few controls that can be applied, they are described
48786 separately in section <xref linkend="SECTcontrols"/>. The <option>control</option> modifier can be used
48787 in several different ways. For example:
48788 </para>
48789 <itemizedlist>
48790 <listitem>
48791 <para>
48792 It can be at the end of an <option>accept</option> statement:
48793 </para>
48794 <literallayout class="monospaced">
48795     accept  ...some conditions
48796             control = queue_only
48797 </literallayout>
48798 <para>
48799 In this case, the control is applied when this statement yields <quote>accept</quote>, in
48800 other words, when the conditions are all true.
48801 </para>
48802 </listitem>
48803 <listitem>
48804 <para>
48805 It can be in the middle of an <option>accept</option> statement:
48806 </para>
48807 <literallayout class="monospaced">
48808     accept  ...some conditions...
48809             control = queue_only
48810             ...some more conditions...
48811 </literallayout>
48812 <para>
48813 If the first set of conditions are true, the control is applied, even if the
48814 statement does not accept because one of the second set of conditions is false.
48815 In this case, some subsequent statement must yield <quote>accept</quote> for the control
48816 to be relevant.
48817 </para>
48818 </listitem>
48819 <listitem>
48820 <para>
48821 It can be used with <option>warn</option> to apply the control, leaving the
48822 decision about accepting or denying to a subsequent verb. For
48823 example:
48824 </para>
48825 <literallayout class="monospaced">
48826     warn    ...some conditions...
48827             control = freeze
48828     accept  ...
48829 </literallayout>
48830 <para>
48831 This example of <option>warn</option> does not contain <option>message</option>, <option>log_message</option>, or
48832 <option>logwrite</option>, so it does not add anything to the message and does not write a
48833 log entry.
48834 </para>
48835 </listitem>
48836 <listitem>
48837 <para>
48838 If you want to apply a control unconditionally, you can use it with a
48839 <option>require</option> verb. For example:
48840 </para>
48841 <literallayout class="monospaced">
48842     require  control = no_multiline_responses
48843 </literallayout>
48844 </listitem>
48845 </itemizedlist>
48846 </listitem></varlistentry>
48847 <varlistentry>
48848 <term><emphasis role="bold">delay</emphasis>&nbsp;=&nbsp;&lt;<emphasis>time</emphasis>&gt;</term>
48849 <listitem>
48850 <para>
48851 <indexterm role="concept">
48852 <primary><option>delay</option> ACL modifier</primary>
48853 </indexterm>
48854 <indexterm role="option">
48855 <primary><option>-bh</option></primary>
48856 </indexterm>
48857 This modifier may appear in any ACL. It causes Exim to wait for the time
48858 interval before proceeding. However, when testing Exim using the <option>-bh</option>
48859 option, the delay is not actually imposed (an appropriate message is output
48860 instead). The time is given in the usual Exim notation, and the delay happens
48861 as soon as the modifier is processed. In an SMTP session, pending output is
48862 flushed before the delay is imposed.
48863 </para>
48864 <para>
48865 Like <option>control</option>, <option>delay</option> can be used with <option>accept</option> or <option>deny</option>, for
48866 example:
48867 </para>
48868 <literallayout class="monospaced">
48869 deny    ...some conditions...
48870         delay = 30s
48871 </literallayout>
48872 <para>
48873 The delay happens if all the conditions are true, before the statement returns
48874 <quote>deny</quote>. Compare this with:
48875 </para>
48876 <literallayout class="monospaced">
48877 deny    delay = 30s
48878         ...some conditions...
48879 </literallayout>
48880 <para>
48881 which waits for 30s before processing the conditions. The <option>delay</option> modifier
48882 can also be used with <option>warn</option> and together with <option>control</option>:
48883 </para>
48884 <literallayout class="monospaced">
48885 warn    ...some conditions...
48886         delay = 2m
48887         control = freeze
48888 accept  ...
48889 </literallayout>
48890 <para>
48891 If <option>delay</option> is encountered when the SMTP PIPELINING extension is in use,
48892 responses to several commands are no longer buffered and sent in one packet (as
48893 they would normally be) because all output is flushed before imposing the
48894 delay. This optimization is disabled so that a number of small delays do not
48895 appear to the client as one large aggregated delay that might provoke an
48896 unwanted timeout. You can, however, disable output flushing for <option>delay</option> by
48897 using a <option>control</option> modifier to set <option>no_delay_flush</option>.
48898 </para>
48899 </listitem></varlistentry>
48900 <varlistentry>
48901 <term><emphasis role="bold">endpass</emphasis></term>
48902 <listitem>
48903 <para>
48904 <indexterm role="concept">
48905 <primary><option>endpass</option> ACL modifier</primary>
48906 </indexterm>
48907 This modifier, which has no argument, is recognized only in <option>accept</option> and
48908 <option>discard</option> statements. It marks the boundary between the conditions whose
48909 failure causes control to pass to the next statement, and the conditions whose
48910 failure causes the ACL to return <quote>deny</quote>. This concept has proved to be
48911 confusing to some people, so the use of <option>endpass</option> is no longer recommended as
48912 <quote>best practice</quote>. See the description of <option>accept</option> above for more details.
48913 </para>
48914 </listitem></varlistentry>
48915 <varlistentry>
48916 <term><emphasis role="bold">log_message</emphasis>&nbsp;=&nbsp;&lt;<emphasis>text</emphasis>&gt;</term>
48917 <listitem>
48918 <para>
48919 <indexterm role="concept">
48920 <primary><option>log_message</option> ACL modifier</primary>
48921 </indexterm>
48922 This modifier sets up a message that is used as part of the log message if the
48923 ACL denies access or a <option>warn</option> statement&#x2019;s conditions are true. For example:
48924 </para>
48925 <literallayout class="monospaced">
48926 require log_message = wrong cipher suite $tls_cipher
48927         encrypted   = DES-CBC3-SHA
48928 </literallayout>
48929 <para>
48930 <option>log_message</option> is also used when recipients are discarded by <option>discard</option>. For
48931 example:
48932 </para>
48933 <literallayout>
48934 <literal>discard </literal>&lt;<emphasis>some conditions</emphasis>&gt;
48935 <literal>        log_message = Discarded $local_part@$domain because...</literal>
48936 </literallayout>
48937 <para>
48938 When access is denied, <option>log_message</option> adds to any underlying error message
48939 that may exist because of a condition failure. For example, while verifying a
48940 recipient address, a <emphasis>:fail:</emphasis> redirection might have already set up a
48941 message.
48942 </para>
48943 <para>
48944 The message may be defined before the conditions to which it applies, because
48945 the string expansion does not happen until Exim decides that access is to be
48946 denied. This means that any variables that are set by the condition are
48947 available for inclusion in the message. For example, the <varname>$dnslist_</varname>&lt;<emphasis>xxx</emphasis>&gt;
48948 variables are set after a DNS black list lookup succeeds. If the expansion of
48949 <option>log_message</option> fails, or if the result is an empty string, the modifier is
48950 ignored.
48951 </para>
48952 <para>
48953 <indexterm role="variable">
48954 <primary><varname>$acl_verify_message</varname></primary>
48955 </indexterm>
48956 If you want to use a <option>warn</option> statement to log the result of an address
48957 verification, you can use <varname>$acl_verify_message</varname> to include the verification
48958 error message.
48959 </para>
48960 <para>
48961 If <option>log_message</option> is used with a <option>warn</option> statement, <quote>Warning:</quote> is added to
48962 the start of the logged message. If the same warning log message is requested
48963 more than once while receiving  a single email message, only one copy is
48964 actually logged. If you want to log multiple copies, use <option>logwrite</option> instead
48965 of <option>log_message</option>. In the absence of <option>log_message</option> and <option>logwrite</option>, nothing
48966 is logged for a successful <option>warn</option> statement.
48967 </para>
48968 <para>
48969 If <option>log_message</option> is not present and there is no underlying error message (for
48970 example, from the failure of address verification), but <option>message</option> is present,
48971 the <option>message</option> text is used for logging rejections. However, if any text for
48972 logging contains newlines, only the first line is logged. In the absence of
48973 both <option>log_message</option> and <option>message</option>, a default built-in message is used for
48974 logging rejections.
48975 </para>
48976 </listitem></varlistentry>
48977 <varlistentry>
48978 <term><emphasis role="bold">log_reject_target</emphasis>&nbsp;=&nbsp;&lt;<emphasis>log name list</emphasis>&gt;</term>
48979 <listitem>
48980 <para>
48981 <indexterm role="concept">
48982 <primary><option>log_reject_target</option> ACL modifier</primary>
48983 </indexterm>
48984 <indexterm role="concept">
48985 <primary>logging in ACL</primary>
48986 <secondary>specifying which log</secondary>
48987 </indexterm>
48988 This modifier makes it possible to specify which logs are used for messages
48989 about ACL rejections. Its argument is a colon-separated list of words that can
48990 be <quote>main</quote>, <quote>reject</quote>, or <quote>panic</quote>. The default is <literal>main:reject</literal>. The list
48991 may be empty, in which case a rejection is not logged at all. For example, this
48992 ACL fragment writes no logging information when access is denied:
48993 </para>
48994 <literallayout>
48995 <literal>deny </literal>&lt;<emphasis>some conditions</emphasis>&gt;
48996 <literal>     log_reject_target =</literal>
48997 </literallayout>
48998 <para>
48999 This modifier can be used in SMTP and non-SMTP ACLs. It applies to both
49000 permanent and temporary rejections. Its effect lasts for the rest of the
49001 current ACL.
49002 </para>
49003 </listitem></varlistentry>
49004 <varlistentry>
49005 <term><emphasis role="bold">logwrite</emphasis>&nbsp;=&nbsp;&lt;<emphasis>text</emphasis>&gt;</term>
49006 <listitem>
49007 <para>
49008 <indexterm role="concept">
49009 <primary><option>logwrite</option> ACL modifier</primary>
49010 </indexterm>
49011 <indexterm role="concept">
49012 <primary>logging in ACL</primary>
49013 <secondary>immediate</secondary>
49014 </indexterm>
49015 This modifier writes a message to a log file as soon as it is encountered when
49016 processing an ACL. (Compare <option>log_message</option>, which, except in the case of
49017 <option>warn</option> and <option>discard</option>, is used only if the ACL statement denies
49018 access.) The <option>logwrite</option> modifier can be used to log special incidents in
49019 ACLs. For example:
49020 </para>
49021 <literallayout>
49022 <literal>accept </literal>&lt;<emphasis>some special conditions</emphasis>&gt;
49023 <literal>       control  = freeze</literal>
49024 <literal>       logwrite = froze message because ...</literal>
49025 </literallayout>
49026 <para>
49027 By default, the message is written to the main log. However, it may begin
49028 with a colon, followed by a comma-separated list of log names, and then
49029 another colon, to specify exactly which logs are to be written. For
49030 example:
49031 </para>
49032 <literallayout class="monospaced">
49033 logwrite = :main,reject: text for main and reject logs
49034 logwrite = :panic: text for panic log only
49035 </literallayout>
49036 </listitem></varlistentry>
49037 <varlistentry>
49038 <term><emphasis role="bold">message</emphasis>&nbsp;=&nbsp;&lt;<emphasis>text</emphasis>&gt;</term>
49039 <listitem>
49040 <para>
49041 <indexterm role="concept">
49042 <primary><option>message</option> ACL modifier</primary>
49043 </indexterm>
49044 This modifier sets up a text string that is expanded and used as a response
49045 message when an ACL statement terminates the ACL with an <quote>accept</quote>, <quote>deny</quote>,
49046 or <quote>defer</quote> response. (In the case of the <option>accept</option> and <option>discard</option> verbs,
49047 there is some complication if <option>endpass</option> is involved; see the description of
49048 <option>accept</option> for details.)
49049 </para>
49050 <para>
49051 The expansion of the message happens at the time Exim decides that the ACL is
49052 to end, not at the time it processes <option>message</option>. If the expansion fails, or
49053 generates an empty string, the modifier is ignored. Here is an example where
49054 <option>message</option> must be specified first, because the ACL ends with a rejection if
49055 the <option>hosts</option> condition fails:
49056 </para>
49057 <literallayout class="monospaced">
49058 require  message = Host not recognized
49059          hosts = 10.0.0.0/8
49060 </literallayout>
49061 <para>
49062 (Once a condition has failed, no further conditions or modifiers are
49063 processed.)
49064 </para>
49065 <para>
49066 <indexterm role="concept">
49067 <primary>SMTP</primary>
49068 <secondary>error codes</secondary>
49069 </indexterm>
49070 <indexterm role="option">
49071 <primary><option>smtp_banner</option></primary>
49072 </indexterm>
49073 For ACLs that are triggered by SMTP commands, the message is returned as part
49074 of the SMTP response. The use of <option>message</option> with <option>accept</option> (or <option>discard</option>)
49075 is meaningful only for SMTP, as no message is returned when a non-SMTP message
49076 is accepted. In the case of the connect ACL, accepting with a message modifier
49077 overrides the value of <option>smtp_banner</option>. For the EHLO/HELO ACL, a customized
49078 accept message may not contain more than one line (otherwise it will be
49079 truncated at the first newline and a panic logged), and it cannot affect the
49080 EHLO options.
49081 </para>
49082 <para>
49083 When SMTP is involved, the message may begin with an overriding response code,
49084 consisting of three digits optionally followed by an <quote>extended response code</quote>
49085 of the form <emphasis>n.n.n</emphasis>, each code being followed by a space. For example:
49086 </para>
49087 <literallayout class="monospaced">
49088 deny  message = 599 1.2.3 Host not welcome
49089       hosts = 192.168.34.0/24
49090 </literallayout>
49091 <para>
49092 The first digit of the supplied response code must be the same as would be sent
49093 by default. A panic occurs if it is not. Exim uses a 550 code when it denies
49094 access, but for the predata ACL, note that the default success code is 354, not
49095 2<emphasis>xx</emphasis>.
49096 </para>
49097 <para>
49098 Notwithstanding the previous paragraph, for the QUIT ACL, unlike the others,
49099 the message modifier cannot override the 221 response code.
49100 </para>
49101 <para>
49102 The text in a <option>message</option> modifier is literal; any quotes are taken as
49103 literals, but because the string is expanded, backslash escapes are processed
49104 anyway. If the message contains newlines, this gives rise to a multi-line SMTP
49105 response.
49106 </para>
49107 <para>
49108 <indexterm role="variable">
49109 <primary><varname>$acl_verify_message</varname></primary>
49110 </indexterm>
49111 If <option>message</option> is used on a statement that verifies an address, the message
49112 specified overrides any message that is generated by the verification process.
49113 However, the original message is available in the variable
49114 <varname>$acl_verify_message</varname>, so you can incorporate it into your message if you
49115 wish. In particular, if you want the text from <option>:fail:</option> items in <command>redirect</command>
49116 routers to be passed back as part of the SMTP response, you should either not
49117 use a <option>message</option> modifier, or make use of <varname>$acl_verify_message</varname>.
49118 </para>
49119 <para>
49120 For compatibility with previous releases of Exim, a <option>message</option> modifier that
49121 is used with a <option>warn</option> verb behaves in a similar way to the <option>add_header</option>
49122 modifier, but this usage is now deprecated. However, <option>message</option> acts only when
49123 all the conditions are true, wherever it appears in an ACL command, whereas
49124 <option>add_header</option> acts as soon as it is encountered. If <option>message</option> is used with
49125 <option>warn</option> in an ACL that is not concerned with receiving a message, it has no
49126 effect.
49127 </para>
49128 </listitem></varlistentry>
49129 <varlistentry>
49130 <term><emphasis role="bold">set</emphasis>&nbsp;&lt;<emphasis>acl_name</emphasis>&gt;&nbsp;=&nbsp;&lt;<emphasis>value</emphasis>&gt;</term>
49131 <listitem>
49132 <para>
49133 <indexterm role="concept">
49134 <primary><option>set</option> ACL modifier</primary>
49135 </indexterm>
49136 This modifier puts a value into one of the ACL variables (see section
49137 <xref linkend="SECTaclvariables"/>).
49138 </para>
49139 </listitem></varlistentry>
49140 </variablelist>
49141 </section>
49142 <section id="SECTcontrols">
49143 <title>Use of the control modifier</title>
49144 <para>
49145 <indexterm role="concept">
49146 <primary><option>control</option> ACL modifier</primary>
49147 </indexterm>
49148 The <option>control</option> modifier supports the following settings:
49149 </para>
49150 <variablelist>
49151 <varlistentry>
49152 <term><emphasis role="bold">control&nbsp;=&nbsp;allow_auth_unadvertised</emphasis></term>
49153 <listitem>
49154 <para>
49155 This modifier allows a client host to use the SMTP AUTH command even when it
49156 has not been advertised in response to EHLO. Furthermore, because there are
49157 apparently some really broken clients that do this, Exim will accept AUTH after
49158 HELO (rather than EHLO) when this control is set. It should be used only if you
49159 really need it, and you should limit its use to those broken clients that do
49160 not work without it. For example:
49161 </para>
49162 <literallayout class="monospaced">
49163 warn hosts   = 192.168.34.25
49164      control = allow_auth_unadvertised
49165 </literallayout>
49166 <para>
49167 Normally, when an Exim server receives an AUTH command, it checks the name of
49168 the authentication mechanism that is given in the command to ensure that it
49169 matches an advertised mechanism. When this control is set, the check that a
49170 mechanism has been advertised is bypassed. Any configured mechanism can be used
49171 by the client. This control is permitted only in the connection and HELO ACLs.
49172 </para>
49173 </listitem></varlistentry>
49174 <varlistentry>
49175 <term><emphasis role="bold">control&nbsp;=&nbsp;caseful_local_part</emphasis></term>
49176 <term><emphasis role="bold">control&nbsp;=&nbsp;caselower_local_part</emphasis></term>
49177 <listitem>
49178 <para>
49179 <indexterm role="concept">
49180 <primary>access control lists (ACLs)</primary>
49181 <secondary>case of local part in</secondary>
49182 </indexterm>
49183 <indexterm role="concept">
49184 <primary>case of local parts</primary>
49185 </indexterm>
49186 <indexterm role="variable">
49187 <primary><varname>$local_part</varname></primary>
49188 </indexterm>
49189 These two controls are permitted only in the ACL specified by <option>acl_smtp_rcpt</option>
49190 (that is, during RCPT processing). By default, the contents of <varname>$local_part</varname>
49191 are lower cased before ACL processing. If <quote>caseful_local_part</quote> is specified,
49192 any uppercase letters in the original local part are restored in <varname>$local_part</varname>
49193 for the rest of the ACL, or until a control that sets <quote>caselower_local_part</quote>
49194 is encountered.
49195 </para>
49196 <para>
49197 These controls affect only the current recipient. Moreover, they apply only to
49198 local part handling that takes place directly in the ACL (for example, as a key
49199 in lookups). If a test to verify the recipient is obeyed, the case-related
49200 handling of the local part during the verification is controlled by the router
49201 configuration (see the <option>caseful_local_part</option> generic router option).
49202 </para>
49203 <para>
49204 This facility could be used, for example, to add a spam score to local parts
49205 containing upper case letters. For example, using <varname>$acl_m4</varname> to accumulate the
49206 spam score:
49207 </para>
49208 <literallayout class="monospaced">
49209 warn  control = caseful_local_part
49210       set acl_m4 = ${eval:\
49211                      $acl_m4 + \
49212                      ${if match{$local_part}{[A-Z]}{1}{0}}\
49213                     }
49214       control = caselower_local_part
49215 </literallayout>
49216 <para>
49217 Notice that we put back the lower cased version afterwards, assuming that
49218 is what is wanted for subsequent tests.
49219 </para>
49220 </listitem></varlistentry>
49221 <varlistentry revisionflag="changed">
49222 <term><emphasis role="bold">control&nbsp;=&nbsp;debug/</emphasis>&lt;<emphasis>options</emphasis>&gt;</term>
49223 <listitem>
49224 <para revisionflag="changed">
49225 <indexterm role="concept">
49226 <primary>access control lists (ACLs)</primary>
49227 <secondary>enabling debug logging</secondary>
49228 </indexterm>
49229 <indexterm role="concept">
49230 <primary>debugging</primary>
49231 <secondary>enabling from an ACL</secondary>
49232 </indexterm>
49233 This control turns on debug logging, almost as though Exim had been invoked
49234 with <literal>-d</literal>, with the output going to a new logfile, by default called
49235 <emphasis>debuglog</emphasis>.  The filename can be adjusted with the <emphasis>tag</emphasis> option, which
49236 may access any variables already defined.  The logging may be adjusted with
49237 the <emphasis>opts</emphasis> option, which takes the same values as the <literal>-d</literal> command-line
49238 option.  Some examples (which depend on variables that don&#x2019;t exist in all
49239 contexts):
49240 </para>
49241 <literallayout class="monospaced" revisionflag="changed">
49242       control = debug
49243       control = debug/tag=.$sender_host_address
49244       control = debug/opts=+expand+acl
49245       control = debug/tag=.$message_exim_id/opts=+expand
49246 </literallayout>
49247 </listitem></varlistentry>
49248 <varlistentry>
49249 <term><emphasis role="bold">control&nbsp;=&nbsp;enforce_sync</emphasis></term>
49250 <term><emphasis role="bold">control&nbsp;=&nbsp;no_enforce_sync</emphasis></term>
49251 <listitem>
49252 <para>
49253 <indexterm role="concept">
49254 <primary>SMTP</primary>
49255 <secondary>synchronization checking</secondary>
49256 </indexterm>
49257 <indexterm role="concept">
49258 <primary>synchronization checking in SMTP</primary>
49259 </indexterm>
49260 These controls make it possible to be selective about when SMTP synchronization
49261 is enforced. The global option <option>smtp_enforce_sync</option> specifies the initial
49262 state of the switch (it is true by default). See the description of this option
49263 in chapter <xref linkend="CHAPmainconfig"/> for details of SMTP synchronization checking.
49264 </para>
49265 <para>
49266 The effect of these two controls lasts for the remainder of the SMTP
49267 connection. They can appear in any ACL except the one for the non-SMTP
49268 messages. The most straightforward place to put them is in the ACL defined by
49269 <option>acl_smtp_connect</option>, which is run at the start of an incoming SMTP connection,
49270 before the first synchronization check. The expected use is to turn off the
49271 synchronization checks for badly-behaved hosts that you nevertheless need to
49272 work with.
49273 </para>
49274 </listitem></varlistentry>
49275 <varlistentry>
49276 <term><emphasis role="bold">control&nbsp;=&nbsp;fakedefer/</emphasis>&lt;<emphasis>message</emphasis>&gt;</term>
49277 <listitem>
49278 <para>
49279 <indexterm role="concept">
49280 <primary>fake defer</primary>
49281 </indexterm>
49282 <indexterm role="concept">
49283 <primary>defer, fake</primary>
49284 </indexterm>
49285 This control works in exactly the same way as <option>fakereject</option> (described below)
49286 except that it causes an SMTP 450 response after the message data instead of a
49287 550 response. You must take care when using <option>fakedefer</option> because it causes the
49288 messages to be duplicated when the sender retries. Therefore, you should not
49289 use <option>fakedefer</option> if the message is to be delivered normally.
49290 </para>
49291 </listitem></varlistentry>
49292 <varlistentry>
49293 <term><emphasis role="bold">control&nbsp;=&nbsp;fakereject/</emphasis>&lt;<emphasis>message</emphasis>&gt;</term>
49294 <listitem>
49295 <para>
49296 <indexterm role="concept">
49297 <primary>fake rejection</primary>
49298 </indexterm>
49299 <indexterm role="concept">
49300 <primary>rejection, fake</primary>
49301 </indexterm>
49302 This control is permitted only for the MAIL, RCPT, and DATA ACLs, in other
49303 words, only when an SMTP message is being received. If Exim accepts the
49304 message, instead the final 250 response, a 550 rejection message is sent.
49305 However, Exim proceeds to deliver the message as normal. The control applies
49306 only to the current message, not to any subsequent ones that may be received in
49307 the same SMTP connection.
49308 </para>
49309 <para>
49310 The text for the 550 response is taken from the <option>control</option> modifier. If no
49311 message is supplied, the following is used:
49312 </para>
49313 <literallayout class="monospaced">
49314 550-Your message has been rejected but is being
49315 550-kept for evaluation.
49316 550-If it was a legitimate message, it may still be
49317 550 delivered to the target recipient(s).
49318 </literallayout>
49319 <para>
49320 This facility should be used with extreme caution.
49321 </para>
49322 </listitem></varlistentry>
49323 <varlistentry>
49324 <term><emphasis role="bold">control&nbsp;=&nbsp;freeze</emphasis></term>
49325 <listitem>
49326 <para>
49327 <indexterm role="concept">
49328 <primary>frozen messages</primary>
49329 <secondary>forcing in ACL</secondary>
49330 </indexterm>
49331 This control is permitted only for the MAIL, RCPT, DATA, and non-SMTP ACLs, in
49332 other words, only when a message is being received. If the message is accepted,
49333 it is placed on Exim&#x2019;s queue and frozen. The control applies only to the
49334 current message, not to any subsequent ones that may be received in the same
49335 SMTP connection.
49336 </para>
49337 <para>
49338 This modifier can optionally be followed by <literal>/no_tell</literal>. If the global option
49339 <option>freeze_tell</option> is set, it is ignored for the current message (that is, nobody
49340 is told about the freezing), provided all the <emphasis role="bold">control=freeze</emphasis> modifiers that
49341 are obeyed for the current message have the <literal>/no_tell</literal> option.
49342 </para>
49343 </listitem></varlistentry>
49344 <varlistentry>
49345 <term><emphasis role="bold">control&nbsp;=&nbsp;no_delay_flush</emphasis></term>
49346 <listitem>
49347 <para>
49348 <indexterm role="concept">
49349 <primary>SMTP</primary>
49350 <secondary>output flushing, disabling for delay</secondary>
49351 </indexterm>
49352 Exim normally flushes SMTP output before implementing a delay in an ACL, to
49353 avoid unexpected timeouts in clients when the SMTP PIPELINING extension is in
49354 use. This control, as long as it is encountered before the <option>delay</option> modifier,
49355 disables such output flushing.
49356 </para>
49357 </listitem></varlistentry>
49358 <varlistentry>
49359 <term><emphasis role="bold">control&nbsp;=&nbsp;no_callout_flush</emphasis></term>
49360 <listitem>
49361 <para>
49362 <indexterm role="concept">
49363 <primary>SMTP</primary>
49364 <secondary>output flushing, disabling for callout</secondary>
49365 </indexterm>
49366 Exim normally flushes SMTP output before performing a callout in an ACL, to
49367 avoid unexpected timeouts in clients when the SMTP PIPELINING extension is in
49368 use. This control, as long as it is encountered before the <option>verify</option> condition
49369 that causes the callout, disables such output flushing.
49370 </para>
49371 </listitem></varlistentry>
49372 <varlistentry>
49373 <term><emphasis role="bold">control&nbsp;=&nbsp;no_mbox_unspool</emphasis></term>
49374 <listitem>
49375 <para>
49376 This control is available when Exim is compiled with the content scanning
49377 extension. Content scanning may require a copy of the current message, or parts
49378 of it, to be written in <quote>mbox format</quote> to a spool file, for passing to a virus
49379 or spam scanner. Normally, such copies are deleted when they are no longer
49380 needed. If this control is set, the copies are not deleted. The control applies
49381 only to the current message, not to any subsequent ones that may be received in
49382 the same SMTP connection. It is provided for debugging purposes and is unlikely
49383 to be useful in production.
49384 </para>
49385 </listitem></varlistentry>
49386 <varlistentry>
49387 <term><emphasis role="bold">control&nbsp;=&nbsp;no_multiline_responses</emphasis></term>
49388 <listitem>
49389 <para>
49390 <indexterm role="concept">
49391 <primary>multiline responses, suppressing</primary>
49392 </indexterm>
49393 This control is permitted for any ACL except the one for non-SMTP messages.
49394 It seems that there are broken clients in use that cannot handle multiline
49395 SMTP responses, despite the fact that RFC 821 defined them over 20 years ago.
49396 </para>
49397 <para>
49398 If this control is set, multiline SMTP responses from ACL rejections are
49399 suppressed. One way of doing this would have been to put out these responses as
49400 one long line. However, RFC 2821 specifies a maximum of 512 bytes per response
49401 (<quote>use multiline responses for more</quote> it says &ndash; ha!), and some of the
49402 responses might get close to that. So this facility, which is after all only a
49403 sop to broken clients, is implemented by doing two very easy things:
49404 </para>
49405 <itemizedlist>
49406 <listitem>
49407 <para>
49408 Extra information that is normally output as part of a rejection caused by
49409 sender verification failure is omitted. Only the final line (typically <quote>sender
49410 verification failed</quote>) is sent.
49411 </para>
49412 </listitem>
49413 <listitem>
49414 <para>
49415 If a <option>message</option> modifier supplies a multiline response, only the first
49416 line is output.
49417 </para>
49418 </listitem>
49419 </itemizedlist>
49420 <para>
49421 The setting of the switch can, of course, be made conditional on the
49422 calling host. Its effect lasts until the end of the SMTP connection.
49423 </para>
49424 </listitem></varlistentry>
49425 <varlistentry>
49426 <term><emphasis role="bold">control&nbsp;=&nbsp;no_pipelining</emphasis></term>
49427 <listitem>
49428 <para>
49429 <indexterm role="concept">
49430 <primary>PIPELINING</primary>
49431 <secondary>suppressing advertising</secondary>
49432 </indexterm>
49433 This control turns off the advertising of the PIPELINING extension to SMTP in
49434 the current session. To be useful, it must be obeyed before Exim sends its
49435 response to an EHLO command. Therefore, it should normally appear in an ACL
49436 controlled by <option>acl_smtp_connect</option> or <option>acl_smtp_helo</option>. See also
49437 <option>pipelining_advertise_hosts</option>.
49438 </para>
49439 </listitem></varlistentry>
49440 <varlistentry>
49441 <term><emphasis role="bold">control&nbsp;=&nbsp;queue_only</emphasis></term>
49442 <listitem>
49443 <para>
49444 <indexterm role="option">
49445 <primary><option>queue_only</option></primary>
49446 </indexterm>
49447 <indexterm role="concept">
49448 <primary>queueing incoming messages</primary>
49449 </indexterm>
49450 This control is permitted only for the MAIL, RCPT, DATA, and non-SMTP ACLs, in
49451 other words, only when a message is being received. If the message is accepted,
49452 it is placed on Exim&#x2019;s queue and left there for delivery by a subsequent queue
49453 runner. No immediate delivery process is started. In other words, it has the
49454 effect as the <option>queue_only</option> global option. However, the control applies only
49455 to the current message, not to any subsequent ones that may be received in the
49456 same SMTP connection.
49457 </para>
49458 </listitem></varlistentry>
49459 <varlistentry>
49460 <term><emphasis role="bold">control&nbsp;=&nbsp;submission/</emphasis>&lt;<emphasis>options</emphasis>&gt;</term>
49461 <listitem>
49462 <para>
49463 <indexterm role="concept">
49464 <primary>message</primary>
49465 <secondary>submission</secondary>
49466 </indexterm>
49467 <indexterm role="concept">
49468 <primary>submission mode</primary>
49469 </indexterm>
49470 This control is permitted only for the MAIL, RCPT, and start of data ACLs (the
49471 latter is the one defined by <option>acl_smtp_predata</option>). Setting it tells Exim that
49472 the current message is a submission from a local MUA. In this case, Exim
49473 operates in <quote>submission mode</quote>, and applies certain fixups to the message if
49474 necessary. For example, it adds a <emphasis>Date:</emphasis> header line if one is not present.
49475 This control is not permitted in the <option>acl_smtp_data</option> ACL, because that is too
49476 late (the message has already been created).
49477 </para>
49478 <para>
49479 Chapter <xref linkend="CHAPmsgproc"/> describes the processing that Exim applies to
49480 messages. Section <xref linkend="SECTsubmodnon"/> covers the processing that happens in
49481 submission mode; the available options for this control are described there.
49482 The control applies only to the current message, not to any subsequent ones
49483 that may be received in the same SMTP connection.
49484 </para>
49485 </listitem></varlistentry>
49486 <varlistentry>
49487 <term><emphasis role="bold">control&nbsp;=&nbsp;suppress_local_fixups</emphasis></term>
49488 <listitem>
49489 <para>
49490 <indexterm role="concept">
49491 <primary>submission fixups, suppressing</primary>
49492 </indexterm>
49493 This control applies to locally submitted (non TCP/IP) messages, and is the
49494 complement of <literal>control = submission</literal>. It disables the fixups that are
49495 normally applied to locally-submitted messages. Specifically:
49496 </para>
49497 <itemizedlist>
49498 <listitem>
49499 <para>
49500 Any <emphasis>Sender:</emphasis> header line is left alone (in this respect, it is a
49501 dynamic version of <option>local_sender_retain</option>).
49502 </para>
49503 </listitem>
49504 <listitem>
49505 <para>
49506 No <emphasis>Message-ID:</emphasis>, <emphasis>From:</emphasis>, or <emphasis>Date:</emphasis> header lines are added.
49507 </para>
49508 </listitem>
49509 <listitem>
49510 <para>
49511 There is no check that <emphasis>From:</emphasis> corresponds to the actual sender.
49512 </para>
49513 </listitem>
49514 </itemizedlist>
49515 <para>
49516 This control may be useful when a remotely-originated message is accepted,
49517 passed to some scanning program, and then re-submitted for delivery. It can be
49518 used only in the <option>acl_smtp_mail</option>, <option>acl_smtp_rcpt</option>, <option>acl_smtp_predata</option>,
49519 and <option>acl_not_smtp_start</option> ACLs, because it has to be set before the message&#x2019;s
49520 data is read.
49521 </para>
49522 <para>
49523 <emphasis role="bold">Note:</emphasis> This control applies only to the current message, not to any others
49524 that are being submitted at the same time using <option>-bs</option> or <option>-bS</option>.
49525 </para>
49526 </listitem></varlistentry>
49527 </variablelist>
49528 </section>
49529 <section id="SECTsummesfix">
49530 <title>Summary of message fixup control</title>
49531 <para>
49532 All four possibilities for message fixups can be specified:
49533 </para>
49534 <itemizedlist>
49535 <listitem>
49536 <para>
49537 Locally submitted, fixups applied: the default.
49538 </para>
49539 </listitem>
49540 <listitem>
49541 <para>
49542 Locally submitted, no fixups applied: use
49543 <literal>control = suppress_local_fixups</literal>.
49544 </para>
49545 </listitem>
49546 <listitem>
49547 <para>
49548 Remotely submitted, no fixups applied: the default.
49549 </para>
49550 </listitem>
49551 <listitem>
49552 <para>
49553 Remotely submitted, fixups applied: use <literal>control = submission</literal>.
49554 </para>
49555 </listitem>
49556 </itemizedlist>
49557 </section>
49558 <section id="SECTaddheadacl">
49559 <title>Adding header lines in ACLs</title>
49560 <para>
49561 <indexterm role="concept">
49562 <primary>header lines</primary>
49563 <secondary>adding in an ACL</secondary>
49564 </indexterm>
49565 <indexterm role="concept">
49566 <primary>header lines</primary>
49567 <secondary>position of added lines</secondary>
49568 </indexterm>
49569 <indexterm role="concept">
49570 <primary><option>message</option> ACL modifier</primary>
49571 </indexterm>
49572 The <option>add_header</option> modifier can be used to add one or more extra header lines
49573 to an incoming message, as in this example:
49574 </para>
49575 <literallayout class="monospaced">
49576 warn dnslists = sbl.spamhaus.org : \
49577                 dialup.mail-abuse.org
49578      add_header = X-blacklisted-at: $dnslist_domain
49579 </literallayout>
49580 <para>
49581 The <option>add_header</option> modifier is permitted in the MAIL, RCPT, PREDATA, DATA,
49582 MIME, and non-SMTP ACLs (in other words, those that are concerned with
49583 receiving a message). The message must ultimately be accepted for
49584 <option>add_header</option> to have any significant effect. You can use <option>add_header</option> with
49585 any ACL verb, including <option>deny</option> (though this is potentially useful only in a
49586 RCPT ACL).
49587 </para>
49588 <para>
49589 If the data for the <option>add_header</option> modifier contains one or more newlines that
49590 are not followed by a space or a tab, it is assumed to contain multiple header
49591 lines. Each one is checked for valid syntax; <literal>X-ACL-Warn:</literal> is added to the
49592 front of any line that is not a valid header line.
49593 </para>
49594 <para>
49595 Added header lines are accumulated during the MAIL, RCPT, and predata ACLs.
49596 They are added to the message before processing the DATA and MIME ACLs.
49597 However, if an identical header line is requested more than once, only one copy
49598 is actually added to the message. Further header lines may be accumulated
49599 during the DATA and MIME ACLs, after which they are added to the message, again
49600 with duplicates suppressed. Thus, it is possible to add two identical header
49601 lines to an SMTP message, but only if one is added before DATA and one after.
49602 In the case of non-SMTP messages, new headers are accumulated during the
49603 non-SMTP ACLs, and are added to the message after all the ACLs have run. If a
49604 message is rejected after DATA or by the non-SMTP ACL, all added header lines
49605 are included in the entry that is written to the reject log.
49606 </para>
49607 <para>
49608 <indexterm role="concept">
49609 <primary>header lines</primary>
49610 <secondary>added; visibility of</secondary>
49611 </indexterm>
49612 Header lines are not visible in string expansions until they are added to the
49613 message. It follows that header lines defined in the MAIL, RCPT, and predata
49614 ACLs are not visible until the DATA ACL and MIME ACLs are run. Similarly,
49615 header lines that are added by the DATA or MIME ACLs are not visible in those
49616 ACLs. Because of this restriction, you cannot use header lines as a way of
49617 passing data between (for example) the MAIL and RCPT ACLs. If you want to do
49618 this, you can use ACL variables, as described in section
49619 <xref linkend="SECTaclvariables"/>.
49620 </para>
49621 <para>
49622 The <option>add_header</option> modifier acts immediately it is encountered during the
49623 processing of an ACL. Notice the difference between these two cases:
49624 </para>
49625 <literallayout>
49626 <literal>accept add_header = ADDED: some text</literal>
49627 <literal>       </literal>&lt;<emphasis>some condition</emphasis>&gt;
49628
49629 <literal>accept </literal>&lt;<emphasis>some condition</emphasis>&gt;
49630 <literal>       add_header = ADDED: some text</literal>
49631 </literallayout>
49632 <para>
49633 In the first case, the header line is always added, whether or not the
49634 condition is true. In the second case, the header line is added only if the
49635 condition is true. Multiple occurrences of <option>add_header</option> may occur in the same
49636 ACL statement. All those that are encountered before a condition fails are
49637 honoured.
49638 </para>
49639 <para>
49640 <indexterm role="concept">
49641 <primary><option>warn</option> ACL verb</primary>
49642 </indexterm>
49643 For compatibility with previous versions of Exim, a <option>message</option> modifier for a
49644 <option>warn</option> verb acts in the same way as <option>add_header</option>, except that it takes
49645 effect only if all the conditions are true, even if it appears before some of
49646 them. Furthermore, only the last occurrence of <option>message</option> is honoured. This
49647 usage of <option>message</option> is now deprecated. If both <option>add_header</option> and <option>message</option>
49648 are present on a <option>warn</option> verb, both are processed according to their
49649 specifications.
49650 </para>
49651 <para>
49652 By default, new header lines are added to a message at the end of the existing
49653 header lines. However, you can specify that any particular header line should
49654 be added right at the start (before all the <emphasis>Received:</emphasis> lines), immediately
49655 after the first block of <emphasis>Received:</emphasis> lines, or immediately before any line
49656 that is not a <emphasis>Received:</emphasis> or <emphasis>Resent-something:</emphasis> header.
49657 </para>
49658 <para>
49659 This is done by specifying <quote>:at_start:</quote>, <quote>:after_received:</quote>, or
49660 <quote>:at_start_rfc:</quote> (or, for completeness, <quote>:at_end:</quote>) before the text of the
49661 header line, respectively. (Header text cannot start with a colon, as there has
49662 to be a header name first.) For example:
49663 </para>
49664 <literallayout class="monospaced">
49665 warn add_header = \
49666        :after_received:X-My-Header: something or other...
49667 </literallayout>
49668 <para>
49669 If more than one header line is supplied in a single <option>add_header</option> modifier,
49670 each one is treated independently and can therefore be placed differently. If
49671 you add more than one line at the start, or after the Received: block, they end
49672 up in reverse order.
49673 </para>
49674 <para>
49675 <emphasis role="bold">Warning</emphasis>: This facility currently applies only to header lines that are
49676 added in an ACL. It does NOT work for header lines that are added in a
49677 system filter or in a router or transport.
49678 </para>
49679 </section>
49680 <section id="SECTaclconditions">
49681 <title>ACL conditions</title>
49682 <para>
49683 <indexterm role="concept">
49684 <primary>access control lists (ACLs)</primary>
49685 <secondary>conditions; list of</secondary>
49686 </indexterm>
49687 Some of conditions listed in this section are available only when Exim is
49688 compiled with the content-scanning extension. They are included here briefly
49689 for completeness. More detailed descriptions can be found in the discussion on
49690 content scanning in chapter <xref linkend="CHAPexiscan"/>.
49691 </para>
49692 <para>
49693 Not all conditions are relevant in all circumstances. For example, testing
49694 senders and recipients does not make sense in an ACL that is being run as the
49695 result of the arrival of an ETRN command, and checks on message headers can be
49696 done only in the ACLs specified by <option>acl_smtp_data</option> and <option>acl_not_smtp</option>. You
49697 can use the same condition (with different parameters) more than once in the
49698 same ACL statement. This provides a way of specifying an <quote>and</quote> conjunction.
49699 The conditions are as follows:
49700 </para>
49701 <variablelist>
49702 <varlistentry>
49703 <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>
49704 <listitem>
49705 <para>
49706 <indexterm role="concept">
49707 <primary>access control lists (ACLs)</primary>
49708 <secondary>nested</secondary>
49709 </indexterm>
49710 <indexterm role="concept">
49711 <primary>access control lists (ACLs)</primary>
49712 <secondary>indirect</secondary>
49713 </indexterm>
49714 <indexterm role="concept">
49715 <primary><option>acl</option> ACL condition</primary>
49716 </indexterm>
49717 The possible values of the argument are the same as for the
49718 <option>acl_smtp_</option><emphasis>xxx</emphasis> options. The named or inline ACL is run. If it returns
49719 <quote>accept</quote> the condition is true; if it returns <quote>deny</quote> the condition is
49720 false. If it returns <quote>defer</quote>, the current ACL returns <quote>defer</quote> unless the
49721 condition is on a <option>warn</option> verb. In that case, a <quote>defer</quote> return makes the
49722 condition false. This means that further processing of the <option>warn</option> verb
49723 ceases, but processing of the ACL continues.
49724 </para>
49725 <para>
49726 If the nested <option>acl</option> returns <quote>drop</quote> and the outer condition denies access,
49727 the connection is dropped. If it returns <quote>discard</quote>, the verb must be
49728 <option>accept</option> or <option>discard</option>, and the action is taken immediately &ndash; no further
49729 conditions are tested.
49730 </para>
49731 <para>
49732 ACLs may be nested up to 20 deep; the limit exists purely to catch runaway
49733 loops. This condition allows you to use different ACLs in different
49734 circumstances. For example, different ACLs can be used to handle RCPT commands
49735 for different local users or different local domains.
49736 </para>
49737 </listitem></varlistentry>
49738 <varlistentry>
49739 <term><emphasis role="bold">authenticated&nbsp;=&nbsp;</emphasis>&lt;<emphasis>string&nbsp;list</emphasis>&gt;</term>
49740 <listitem>
49741 <para>
49742 <indexterm role="concept">
49743 <primary><option>authenticated</option> ACL condition</primary>
49744 </indexterm>
49745 <indexterm role="concept">
49746 <primary>authentication</primary>
49747 <secondary>ACL checking</secondary>
49748 </indexterm>
49749 <indexterm role="concept">
49750 <primary>access control lists (ACLs)</primary>
49751 <secondary>testing for authentication</secondary>
49752 </indexterm>
49753 If the SMTP connection is not authenticated, the condition is false. Otherwise,
49754 the name of the authenticator is tested against the list. To test for
49755 authentication by any authenticator, you can set
49756 </para>
49757 <literallayout class="monospaced">
49758 authenticated = *
49759 </literallayout>
49760 </listitem></varlistentry>
49761 <varlistentry>
49762 <term><emphasis role="bold">condition&nbsp;=&nbsp;</emphasis>&lt;<emphasis>string</emphasis>&gt;</term>
49763 <listitem>
49764 <para>
49765 <indexterm role="concept">
49766 <primary><option>condition</option> ACL condition</primary>
49767 </indexterm>
49768 <indexterm role="concept">
49769 <primary>customizing</primary>
49770 <secondary>ACL condition</secondary>
49771 </indexterm>
49772 <indexterm role="concept">
49773 <primary>access control lists (ACLs)</primary>
49774 <secondary>customized test</secondary>
49775 </indexterm>
49776 <indexterm role="concept">
49777 <primary>access control lists (ACLs)</primary>
49778 <secondary>testing, customized</secondary>
49779 </indexterm>
49780 This feature allows you to make up custom conditions. If the result of
49781 expanding the string is an empty string, the number zero, or one of the strings
49782 <quote>no</quote> or <quote>false</quote>, the condition is false. If the result is any non-zero
49783 number, or one of the strings <quote>yes</quote> or <quote>true</quote>, the condition is true. For
49784 any other value, some error is assumed to have occurred, and the ACL returns
49785 <quote>defer</quote>. However, if the expansion is forced to fail, the condition is
49786 ignored. The effect is to treat it as true, whether it is positive or
49787 negative.
49788 </para>
49789 </listitem></varlistentry>
49790 <varlistentry>
49791 <term><emphasis role="bold">decode&nbsp;=&nbsp;</emphasis>&lt;<emphasis>location</emphasis>&gt;</term>
49792 <listitem>
49793 <para>
49794 <indexterm role="concept">
49795 <primary><option>decode</option> ACL condition</primary>
49796 </indexterm>
49797 This condition is available only when Exim is compiled with the
49798 content-scanning extension, and it is allowed only in the ACL defined by
49799 <option>acl_smtp_mime</option>. It causes the current MIME part to be decoded into a file.
49800 If all goes well, the condition is true. It is false only if there are
49801 problems such as a syntax error or a memory shortage. For more details, see
49802 chapter <xref linkend="CHAPexiscan"/>.
49803 </para>
49804 </listitem></varlistentry>
49805 <varlistentry>
49806 <term><emphasis role="bold">demime&nbsp;=&nbsp;</emphasis>&lt;<emphasis>extension&nbsp;list</emphasis>&gt;</term>
49807 <listitem>
49808 <para>
49809 <indexterm role="concept">
49810 <primary><option>demime</option> ACL condition</primary>
49811 </indexterm>
49812 This condition is available only when Exim is compiled with the
49813 content-scanning extension. Its use is described in section
49814 <xref linkend="SECTdemimecond"/>.
49815 </para>
49816 </listitem></varlistentry>
49817 <varlistentry>
49818 <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>
49819 <listitem>
49820 <para>
49821 <indexterm role="concept">
49822 <primary><option>dnslists</option> ACL condition</primary>
49823 </indexterm>
49824 <indexterm role="concept">
49825 <primary>DNS list</primary>
49826 <secondary>in ACL</secondary>
49827 </indexterm>
49828 <indexterm role="concept">
49829 <primary>black list (DNS)</primary>
49830 </indexterm>
49831 <indexterm role="concept">
49832 <primary>access control lists (ACLs)</primary>
49833 <secondary>testing a DNS list</secondary>
49834 </indexterm>
49835 This condition checks for entries in DNS black lists. These are also known as
49836 <quote>RBL lists</quote>, after the original Realtime Blackhole List, but note that the
49837 use of the lists at <emphasis>mail-abuse.org</emphasis> now carries a charge. There are too many
49838 different variants of this condition to describe briefly here. See sections
49839 <xref linkend="SECTmorednslists"/>&ndash;<xref linkend="SECTmorednslistslast"/> for details.
49840 </para>
49841 </listitem></varlistentry>
49842 <varlistentry>
49843 <term><emphasis role="bold">domains&nbsp;=&nbsp;</emphasis>&lt;<emphasis>domain&nbsp;list</emphasis>&gt;</term>
49844 <listitem>
49845 <para>
49846 <indexterm role="concept">
49847 <primary><option>domains</option> ACL condition</primary>
49848 </indexterm>
49849 <indexterm role="concept">
49850 <primary>domain</primary>
49851 <secondary>ACL checking</secondary>
49852 </indexterm>
49853 <indexterm role="concept">
49854 <primary>access control lists (ACLs)</primary>
49855 <secondary>testing a recipient domain</secondary>
49856 </indexterm>
49857 <indexterm role="variable">
49858 <primary><varname>$domain_data</varname></primary>
49859 </indexterm>
49860 This condition is relevant only after a RCPT command. It checks that the domain
49861 of the recipient address is in the domain list. If percent-hack processing is
49862 enabled, it is done before this test is done. If the check succeeds with a
49863 lookup, the result of the lookup is placed in <varname>$domain_data</varname> until the next
49864 <option>domains</option> test.
49865 </para>
49866 <para>
49867 <emphasis role="bold">Note carefully</emphasis> (because many people seem to fall foul of this): you cannot
49868 use <option>domains</option> in a DATA ACL.
49869 </para>
49870 </listitem></varlistentry>
49871 <varlistentry>
49872 <term><emphasis role="bold">encrypted&nbsp;=&nbsp;</emphasis>&lt;<emphasis>string&nbsp;list</emphasis>&gt;</term>
49873 <listitem>
49874 <para>
49875 <indexterm role="concept">
49876 <primary><option>encrypted</option> ACL condition</primary>
49877 </indexterm>
49878 <indexterm role="concept">
49879 <primary>encryption</primary>
49880 <secondary>checking in an ACL</secondary>
49881 </indexterm>
49882 <indexterm role="concept">
49883 <primary>access control lists (ACLs)</primary>
49884 <secondary>testing for encryption</secondary>
49885 </indexterm>
49886 If the SMTP connection is not encrypted, the condition is false. Otherwise, the
49887 name of the cipher suite in use is tested against the list. To test for
49888 encryption without testing for any specific cipher suite(s), set
49889 </para>
49890 <literallayout class="monospaced">
49891 encrypted = *
49892 </literallayout>
49893 </listitem></varlistentry>
49894 <varlistentry>
49895 <term><emphasis role="bold">hosts&nbsp;=&nbsp;</emphasis>&lt;<emphasis>&nbsp;host&nbsp;list</emphasis>&gt;</term>
49896 <listitem>
49897 <para>
49898 <indexterm role="concept">
49899 <primary><option>hosts</option> ACL condition</primary>
49900 </indexterm>
49901 <indexterm role="concept">
49902 <primary>host</primary>
49903 <secondary>ACL checking</secondary>
49904 </indexterm>
49905 <indexterm role="concept">
49906 <primary>access control lists (ACLs)</primary>
49907 <secondary>testing the client host</secondary>
49908 </indexterm>
49909 This condition tests that the calling host matches the host list. If you have
49910 name lookups or wildcarded host names and IP addresses in the same host list,
49911 you should normally put the IP addresses first. For example, you could have:
49912 </para>
49913 <literallayout class="monospaced">
49914 accept hosts = 10.9.8.7 : dbm;/etc/friendly/hosts
49915 </literallayout>
49916 <para>
49917 The lookup in this example uses the host name for its key. This is implied by
49918 the lookup type <quote>dbm</quote>. (For a host address lookup you would use <quote>net-dbm</quote>
49919 and it wouldn&#x2019;t matter which way round you had these two items.)
49920 </para>
49921 <para>
49922 The reason for the problem with host names lies in the left-to-right way that
49923 Exim processes lists. It can test IP addresses without doing any DNS lookups,
49924 but when it reaches an item that requires a host name, it fails if it cannot
49925 find a host name to compare with the pattern. If the above list is given in the
49926 opposite order, the <option>accept</option> statement fails for a host whose name cannot be
49927 found, even if its IP address is 10.9.8.7.
49928 </para>
49929 <para>
49930 If you really do want to do the name check first, and still recognize the IP
49931 address even if the name lookup fails, you can rewrite the ACL like this:
49932 </para>
49933 <literallayout class="monospaced">
49934 accept hosts = dbm;/etc/friendly/hosts
49935 accept hosts = 10.9.8.7
49936 </literallayout>
49937 <para>
49938 The default action on failing to find the host name is to assume that the host
49939 is not in the list, so the first <option>accept</option> statement fails. The second
49940 statement can then check the IP address.
49941 </para>
49942 <para>
49943 <indexterm role="variable">
49944 <primary><varname>$host_data</varname></primary>
49945 </indexterm>
49946 If a <option>hosts</option> condition is satisfied by means of a lookup, the result
49947 of the lookup is made available in the <varname>$host_data</varname> variable. This
49948 allows you, for example, to set up a statement like this:
49949 </para>
49950 <literallayout class="monospaced">
49951 deny  hosts = net-lsearch;/some/file
49952 message = $host_data
49953 </literallayout>
49954 <para>
49955 which gives a custom error message for each denied host.
49956 </para>
49957 </listitem></varlistentry>
49958 <varlistentry>
49959 <term><emphasis role="bold">local_parts&nbsp;=&nbsp;</emphasis>&lt;<emphasis>local&nbsp;part&nbsp;list</emphasis>&gt;</term>
49960 <listitem>
49961 <para>
49962 <indexterm role="concept">
49963 <primary><option>local_parts</option> ACL condition</primary>
49964 </indexterm>
49965 <indexterm role="concept">
49966 <primary>local part</primary>
49967 <secondary>ACL checking</secondary>
49968 </indexterm>
49969 <indexterm role="concept">
49970 <primary>access control lists (ACLs)</primary>
49971 <secondary>testing a local part</secondary>
49972 </indexterm>
49973 <indexterm role="variable">
49974 <primary><varname>$local_part_data</varname></primary>
49975 </indexterm>
49976 This condition is relevant only after a RCPT command. It checks that the local
49977 part of the recipient address is in the list. If percent-hack processing is
49978 enabled, it is done before this test. If the check succeeds with a lookup, the
49979 result of the lookup is placed in <varname>$local_part_data</varname>, which remains set until
49980 the next <option>local_parts</option> test.
49981 </para>
49982 </listitem></varlistentry>
49983 <varlistentry>
49984 <term><emphasis role="bold">malware&nbsp;=&nbsp;</emphasis>&lt;<emphasis>option</emphasis>&gt;</term>
49985 <listitem>
49986 <para>
49987 <indexterm role="concept">
49988 <primary><option>malware</option> ACL condition</primary>
49989 </indexterm>
49990 <indexterm role="concept">
49991 <primary>access control lists (ACLs)</primary>
49992 <secondary>virus scanning</secondary>
49993 </indexterm>
49994 <indexterm role="concept">
49995 <primary>access control lists (ACLs)</primary>
49996 <secondary>scanning for viruses</secondary>
49997 </indexterm>
49998 This condition is available only when Exim is compiled with the
49999 content-scanning extension. It causes the incoming message to be scanned for
50000 viruses. For details, see chapter <xref linkend="CHAPexiscan"/>.
50001 </para>
50002 </listitem></varlistentry>
50003 <varlistentry>
50004 <term><emphasis role="bold">mime_regex&nbsp;=&nbsp;</emphasis>&lt;<emphasis>list&nbsp;of&nbsp;regular&nbsp;expressions</emphasis>&gt;</term>
50005 <listitem>
50006 <para>
50007 <indexterm role="concept">
50008 <primary><option>mime_regex</option> ACL condition</primary>
50009 </indexterm>
50010 <indexterm role="concept">
50011 <primary>access control lists (ACLs)</primary>
50012 <secondary>testing by regex matching</secondary>
50013 </indexterm>
50014 This condition is available only when Exim is compiled with the
50015 content-scanning extension, and it is allowed only in the ACL defined by
50016 <option>acl_smtp_mime</option>. It causes the current MIME part to be scanned for a match
50017 with any of the regular expressions. For details, see chapter
50018 <xref linkend="CHAPexiscan"/>.
50019 </para>
50020 </listitem></varlistentry>
50021 <varlistentry>
50022 <term><emphasis role="bold">ratelimit&nbsp;=&nbsp;</emphasis>&lt;<emphasis>parameters</emphasis>&gt;</term>
50023 <listitem>
50024 <para>
50025 <indexterm role="concept">
50026 <primary>rate limiting</primary>
50027 </indexterm>
50028 This condition can be used to limit the rate at which a user or host submits
50029 messages. Details are given in section <xref linkend="SECTratelimiting"/>.
50030 </para>
50031 </listitem></varlistentry>
50032 <varlistentry>
50033 <term><emphasis role="bold">recipients&nbsp;=&nbsp;</emphasis>&lt;<emphasis>address&nbsp;list</emphasis>&gt;</term>
50034 <listitem>
50035 <para>
50036 <indexterm role="concept">
50037 <primary><option>recipients</option> ACL condition</primary>
50038 </indexterm>
50039 <indexterm role="concept">
50040 <primary>recipient</primary>
50041 <secondary>ACL checking</secondary>
50042 </indexterm>
50043 <indexterm role="concept">
50044 <primary>access control lists (ACLs)</primary>
50045 <secondary>testing a recipient</secondary>
50046 </indexterm>
50047 This condition is relevant only after a RCPT command. It checks the entire
50048 recipient address against a list of recipients.
50049 </para>
50050 </listitem></varlistentry>
50051 <varlistentry>
50052 <term><emphasis role="bold">regex&nbsp;=&nbsp;</emphasis>&lt;<emphasis>list&nbsp;of&nbsp;regular&nbsp;expressions</emphasis>&gt;</term>
50053 <listitem>
50054 <para>
50055 <indexterm role="concept">
50056 <primary><option>regex</option> ACL condition</primary>
50057 </indexterm>
50058 <indexterm role="concept">
50059 <primary>access control lists (ACLs)</primary>
50060 <secondary>testing by regex matching</secondary>
50061 </indexterm>
50062 This condition is available only when Exim is compiled with the
50063 content-scanning extension, and is available only in the DATA, MIME, and
50064 non-SMTP ACLs. It causes the incoming message to be scanned for a match with
50065 any of the regular expressions. For details, see chapter <xref linkend="CHAPexiscan"/>.
50066 </para>
50067 </listitem></varlistentry>
50068 <varlistentry>
50069 <term><emphasis role="bold">sender_domains&nbsp;=&nbsp;</emphasis>&lt;<emphasis>domain&nbsp;list</emphasis>&gt;</term>
50070 <listitem>
50071 <para>
50072 <indexterm role="concept">
50073 <primary><option>sender_domains</option> ACL condition</primary>
50074 </indexterm>
50075 <indexterm role="concept">
50076 <primary>sender</primary>
50077 <secondary>ACL checking</secondary>
50078 </indexterm>
50079 <indexterm role="concept">
50080 <primary>access control lists (ACLs)</primary>
50081 <secondary>testing a sender domain</secondary>
50082 </indexterm>
50083 <indexterm role="variable">
50084 <primary><varname>$domain</varname></primary>
50085 </indexterm>
50086 <indexterm role="variable">
50087 <primary><varname>$sender_address_domain</varname></primary>
50088 </indexterm>
50089 This condition tests the domain of the sender of the message against the given
50090 domain list. <emphasis role="bold">Note</emphasis>: The domain of the sender address is in
50091 <varname>$sender_address_domain</varname>. It is <emphasis>not</emphasis> put in <varname>$domain</varname> during the testing
50092 of this condition. This is an exception to the general rule for testing domain
50093 lists. It is done this way so that, if this condition is used in an ACL for a
50094 RCPT command, the recipient&#x2019;s domain (which is in <varname>$domain</varname>) can be used to
50095 influence the sender checking.
50096 </para>
50097 <para>
50098 <emphasis role="bold">Warning</emphasis>: It is a bad idea to use this condition on its own as a control on
50099 relaying, because sender addresses are easily, and commonly, forged.
50100 </para>
50101 </listitem></varlistentry>
50102 <varlistentry>
50103 <term><emphasis role="bold">senders&nbsp;=&nbsp;</emphasis>&lt;<emphasis>address&nbsp;list</emphasis>&gt;</term>
50104 <listitem>
50105 <para>
50106 <indexterm role="concept">
50107 <primary><option>senders</option> ACL condition</primary>
50108 </indexterm>
50109 <indexterm role="concept">
50110 <primary>sender</primary>
50111 <secondary>ACL checking</secondary>
50112 </indexterm>
50113 <indexterm role="concept">
50114 <primary>access control lists (ACLs)</primary>
50115 <secondary>testing a sender</secondary>
50116 </indexterm>
50117 This condition tests the sender of the message against the given list. To test
50118 for a bounce message, which has an empty sender, set
50119 </para>
50120 <literallayout class="monospaced">
50121 senders = :
50122 </literallayout>
50123 <para>
50124 <emphasis role="bold">Warning</emphasis>: It is a bad idea to use this condition on its own as a control on
50125 relaying, because sender addresses are easily, and commonly, forged.
50126 </para>
50127 </listitem></varlistentry>
50128 <varlistentry>
50129 <term><emphasis role="bold">spam&nbsp;=&nbsp;</emphasis>&lt;<emphasis>username</emphasis>&gt;</term>
50130 <listitem>
50131 <para>
50132 <indexterm role="concept">
50133 <primary><option>spam</option> ACL condition</primary>
50134 </indexterm>
50135 <indexterm role="concept">
50136 <primary>access control lists (ACLs)</primary>
50137 <secondary>scanning for spam</secondary>
50138 </indexterm>
50139 This condition is available only when Exim is compiled with the
50140 content-scanning extension. It causes the incoming message to be scanned by
50141 SpamAssassin. For details, see chapter <xref linkend="CHAPexiscan"/>.
50142 </para>
50143 </listitem></varlistentry>
50144 <varlistentry>
50145 <term><emphasis role="bold">verify&nbsp;=&nbsp;certificate</emphasis></term>
50146 <listitem>
50147 <para>
50148 <indexterm role="concept">
50149 <primary><option>verify</option> ACL condition</primary>
50150 </indexterm>
50151 <indexterm role="concept">
50152 <primary>TLS</primary>
50153 <secondary>client certificate verification</secondary>
50154 </indexterm>
50155 <indexterm role="concept">
50156 <primary>certificate</primary>
50157 <secondary>verification of client</secondary>
50158 </indexterm>
50159 <indexterm role="concept">
50160 <primary>access control lists (ACLs)</primary>
50161 <secondary>certificate verification</secondary>
50162 </indexterm>
50163 <indexterm role="concept">
50164 <primary>access control lists (ACLs)</primary>
50165 <secondary>testing a TLS certificate</secondary>
50166 </indexterm>
50167 This condition is true in an SMTP session if the session is encrypted, and a
50168 certificate was received from the client, and the certificate was verified. The
50169 server requests a certificate only if the client matches <option>tls_verify_hosts</option>
50170 or <option>tls_try_verify_hosts</option> (see chapter <xref linkend="CHAPTLS"/>).
50171 </para>
50172 </listitem></varlistentry>
50173 <varlistentry>
50174 <term><emphasis role="bold">verify&nbsp;=&nbsp;csa</emphasis></term>
50175 <listitem>
50176 <para>
50177 <indexterm role="concept">
50178 <primary>CSA verification</primary>
50179 </indexterm>
50180 This condition checks whether the sending host (the client) is authorized to
50181 send email. Details of how this works are given in section
50182 <xref linkend="SECTverifyCSA"/>.
50183 </para>
50184 </listitem></varlistentry>
50185 <varlistentry>
50186 <term><emphasis role="bold">verify&nbsp;=&nbsp;header_sender/</emphasis>&lt;<emphasis>options</emphasis>&gt;</term>
50187 <listitem>
50188 <para>
50189 <indexterm role="concept">
50190 <primary><option>verify</option> ACL condition</primary>
50191 </indexterm>
50192 <indexterm role="concept">
50193 <primary>access control lists (ACLs)</primary>
50194 <secondary>verifying sender in the header</secondary>
50195 </indexterm>
50196 <indexterm role="concept">
50197 <primary>header lines</primary>
50198 <secondary>verifying the sender in</secondary>
50199 </indexterm>
50200 <indexterm role="concept">
50201 <primary>sender</primary>
50202 <secondary>verifying in header</secondary>
50203 </indexterm>
50204 <indexterm role="concept">
50205 <primary>verifying</primary>
50206 <secondary>sender in header</secondary>
50207 </indexterm>
50208 This condition is relevant only in an ACL that is run after a message has been
50209 received, that is, in an ACL specified by <option>acl_smtp_data</option> or
50210 <option>acl_not_smtp</option>. It checks that there is a verifiable address in at least one
50211 of the <emphasis>Sender:</emphasis>, <emphasis>Reply-To:</emphasis>, or <emphasis>From:</emphasis> header lines. Such an address
50212 is loosely thought of as a <quote>sender</quote> address (hence the name of the test).
50213 However, an address that appears in one of these headers need not be an address
50214 that accepts bounce messages; only sender addresses in envelopes are required
50215 to accept bounces. Therefore, if you use the callout option on this check, you
50216 might want to arrange for a non-empty address in the MAIL command.
50217 </para>
50218 <para>
50219 Details of address verification and the options are given later, starting at
50220 section <xref linkend="SECTaddressverification"/> (callouts are described in section
50221 <xref linkend="SECTcallver"/>). You can combine this condition with the <option>senders</option>
50222 condition to restrict it to bounce messages only:
50223 </para>
50224 <literallayout class="monospaced">
50225 deny    senders = :
50226         message = A valid sender header is required for bounces
50227        !verify  = header_sender
50228 </literallayout>
50229 </listitem></varlistentry>
50230 <varlistentry>
50231 <term><emphasis role="bold">verify&nbsp;=&nbsp;header_syntax</emphasis></term>
50232 <listitem>
50233 <para>
50234 <indexterm role="concept">
50235 <primary><option>verify</option> ACL condition</primary>
50236 </indexterm>
50237 <indexterm role="concept">
50238 <primary>access control lists (ACLs)</primary>
50239 <secondary>verifying header syntax</secondary>
50240 </indexterm>
50241 <indexterm role="concept">
50242 <primary>header lines</primary>
50243 <secondary>verifying syntax</secondary>
50244 </indexterm>
50245 <indexterm role="concept">
50246 <primary>verifying</primary>
50247 <secondary>header syntax</secondary>
50248 </indexterm>
50249 This condition is relevant only in an ACL that is run after a message has been
50250 received, that is, in an ACL specified by <option>acl_smtp_data</option> or
50251 <option>acl_not_smtp</option>. It checks the syntax of all header lines that can contain
50252 lists of addresses (<emphasis>Sender:</emphasis>, <emphasis>From:</emphasis>, <emphasis>Reply-To:</emphasis>, <emphasis>To:</emphasis>, <emphasis>Cc:</emphasis>,
50253 and <emphasis>Bcc:</emphasis>). Unqualified addresses (local parts without domains) are
50254 permitted only in locally generated messages and from hosts that match
50255 <option>sender_unqualified_hosts</option> or <option>recipient_unqualified_hosts</option>, as
50256 appropriate.
50257 </para>
50258 <para>
50259 Note that this condition is a syntax check only. However, a common spamming
50260 ploy used to be to send syntactically invalid headers such as
50261 </para>
50262 <literallayout class="monospaced">
50263 To: @
50264 </literallayout>
50265 <para>
50266 and this condition can be used to reject such messages, though they are not as
50267 common as they used to be.
50268 </para>
50269 </listitem></varlistentry>
50270 <varlistentry>
50271 <term><emphasis role="bold">verify&nbsp;=&nbsp;helo</emphasis></term>
50272 <listitem>
50273 <para>
50274 <indexterm role="concept">
50275 <primary><option>verify</option> ACL condition</primary>
50276 </indexterm>
50277 <indexterm role="concept">
50278 <primary>access control lists (ACLs)</primary>
50279 <secondary>verifying HELO/EHLO</secondary>
50280 </indexterm>
50281 <indexterm role="concept">
50282 <primary>HELO</primary>
50283 <secondary>verifying</secondary>
50284 </indexterm>
50285 <indexterm role="concept">
50286 <primary>EHLO</primary>
50287 <secondary>verifying</secondary>
50288 </indexterm>
50289 <indexterm role="concept">
50290 <primary>verifying</primary>
50291 <secondary>EHLO</secondary>
50292 </indexterm>
50293 <indexterm role="concept">
50294 <primary>verifying</primary>
50295 <secondary>HELO</secondary>
50296 </indexterm>
50297 This condition is true if a HELO or EHLO command has been received from the
50298 client host, and its contents have been verified. If there has been no previous
50299 attempt to verify the HELO/EHLO contents, it is carried out when this
50300 condition is encountered. See the description of the <option>helo_verify_hosts</option> and
50301 <option>helo_try_verify_hosts</option> options for details of how to request verification
50302 independently of this condition.
50303 </para>
50304 <para>
50305 For SMTP input that does not come over TCP/IP (the <option>-bs</option> command line
50306 option), this condition is always true.
50307 </para>
50308 </listitem></varlistentry>
50309 <varlistentry>
50310 <term><emphasis role="bold">verify&nbsp;=&nbsp;not_blind</emphasis></term>
50311 <listitem>
50312 <para>
50313 <indexterm role="concept">
50314 <primary>verifying</primary>
50315 <secondary>not blind</secondary>
50316 </indexterm>
50317 <indexterm role="concept">
50318 <primary>bcc recipients, verifying none</primary>
50319 </indexterm>
50320 This condition checks that there are no blind (bcc) recipients in the message.
50321 Every envelope recipient must appear either in a <emphasis>To:</emphasis> header line or in a
50322 <emphasis>Cc:</emphasis> header line for this condition to be true. Local parts are checked
50323 case-sensitively; domains are checked case-insensitively. If <emphasis>Resent-To:</emphasis> or
50324 <emphasis>Resent-Cc:</emphasis> header lines exist, they are also checked. This condition can be
50325 used only in a DATA or non-SMTP ACL.
50326 </para>
50327 <para>
50328 There are, of course, many legitimate messages that make use of blind (bcc)
50329 recipients. This check should not be used on its own for blocking messages.
50330 </para>
50331 </listitem></varlistentry>
50332 <varlistentry>
50333 <term><emphasis role="bold">verify&nbsp;=&nbsp;recipient/</emphasis>&lt;<emphasis>options</emphasis>&gt;</term>
50334 <listitem>
50335 <para>
50336 <indexterm role="concept">
50337 <primary><option>verify</option> ACL condition</primary>
50338 </indexterm>
50339 <indexterm role="concept">
50340 <primary>access control lists (ACLs)</primary>
50341 <secondary>verifying recipient</secondary>
50342 </indexterm>
50343 <indexterm role="concept">
50344 <primary>recipient</primary>
50345 <secondary>verifying</secondary>
50346 </indexterm>
50347 <indexterm role="concept">
50348 <primary>verifying</primary>
50349 <secondary>recipient</secondary>
50350 </indexterm>
50351 <indexterm role="variable">
50352 <primary><varname>$address_data</varname></primary>
50353 </indexterm>
50354 This condition is relevant only after a RCPT command. It verifies the current
50355 recipient. Details of address verification are given later, starting at section
50356 <xref linkend="SECTaddressverification"/>. After a recipient has been verified, the value
50357 of <varname>$address_data</varname> is the last value that was set while routing the address.
50358 This applies even if the verification fails. When an address that is being
50359 verified is redirected to a single address, verification continues with the new
50360 address, and in that case, the subsequent value of <varname>$address_data</varname> is the
50361 value for the child address.
50362 </para>
50363 </listitem></varlistentry>
50364 <varlistentry>
50365 <term><emphasis role="bold">verify&nbsp;=&nbsp;reverse_host_lookup</emphasis></term>
50366 <listitem>
50367 <para>
50368 <indexterm role="concept">
50369 <primary><option>verify</option> ACL condition</primary>
50370 </indexterm>
50371 <indexterm role="concept">
50372 <primary>access control lists (ACLs)</primary>
50373 <secondary>verifying host reverse lookup</secondary>
50374 </indexterm>
50375 <indexterm role="concept">
50376 <primary>host</primary>
50377 <secondary>verifying reverse lookup</secondary>
50378 </indexterm>
50379 This condition ensures that a verified host name has been looked up from the IP
50380 address of the client host. (This may have happened already if the host name
50381 was needed for checking a host list, or if the host matched <option>host_lookup</option>.)
50382 Verification ensures that the host name obtained from a reverse DNS lookup, or
50383 one of its aliases, does, when it is itself looked up in the DNS, yield the
50384 original IP address.
50385 </para>
50386 <para>
50387 If this condition is used for a locally generated message (that is, when there
50388 is no client host involved), it always succeeds.
50389 </para>
50390 </listitem></varlistentry>
50391 <varlistentry>
50392 <term><emphasis role="bold">verify&nbsp;=&nbsp;sender/</emphasis>&lt;<emphasis>options</emphasis>&gt;</term>
50393 <listitem>
50394 <para>
50395 <indexterm role="concept">
50396 <primary><option>verify</option> ACL condition</primary>
50397 </indexterm>
50398 <indexterm role="concept">
50399 <primary>access control lists (ACLs)</primary>
50400 <secondary>verifying sender</secondary>
50401 </indexterm>
50402 <indexterm role="concept">
50403 <primary>sender</primary>
50404 <secondary>verifying</secondary>
50405 </indexterm>
50406 <indexterm role="concept">
50407 <primary>verifying</primary>
50408 <secondary>sender</secondary>
50409 </indexterm>
50410 This condition is relevant only after a MAIL or RCPT command, or after a
50411 message has been received (the <option>acl_smtp_data</option> or <option>acl_not_smtp</option> ACLs). If
50412 the message&#x2019;s sender is empty (that is, this is a bounce message), the
50413 condition is true. Otherwise, the sender address is verified.
50414 </para>
50415 <para>
50416 <indexterm role="variable">
50417 <primary><varname>$address_data</varname></primary>
50418 </indexterm>
50419 <indexterm role="variable">
50420 <primary><varname>$sender_address_data</varname></primary>
50421 </indexterm>
50422 If there is data in the <varname>$address_data</varname> variable at the end of routing, its
50423 value is placed in <varname>$sender_address_data</varname> at the end of verification. This
50424 value can be used in subsequent conditions and modifiers in the same ACL
50425 statement. It does not persist after the end of the current statement. If you
50426 want to preserve the value for longer, you can save it in an ACL variable.
50427 </para>
50428 <para>
50429 Details of verification are given later, starting at section
50430 <xref linkend="SECTaddressverification"/>. Exim caches the result of sender verification,
50431 to avoid doing it more than once per message.
50432 </para>
50433 </listitem></varlistentry>
50434 <varlistentry>
50435 <term><emphasis role="bold">verify&nbsp;=&nbsp;sender=</emphasis>&lt;<emphasis>address</emphasis>&gt;<emphasis role="bold">/</emphasis>&lt;<emphasis>options</emphasis>&gt;</term>
50436 <listitem>
50437 <para>
50438 <indexterm role="concept">
50439 <primary><option>verify</option> ACL condition</primary>
50440 </indexterm>
50441 This is a variation of the previous option, in which a modified address is
50442 verified as a sender.
50443 </para>
50444 </listitem></varlistentry>
50445 </variablelist>
50446 </section>
50447 <section id="SECTmorednslists">
50448 <title>Using DNS lists</title>
50449 <para>
50450 <indexterm role="concept">
50451 <primary>DNS list</primary>
50452 <secondary>in ACL</secondary>
50453 </indexterm>
50454 <indexterm role="concept">
50455 <primary>black list (DNS)</primary>
50456 </indexterm>
50457 <indexterm role="concept">
50458 <primary>access control lists (ACLs)</primary>
50459 <secondary>testing a DNS list</secondary>
50460 </indexterm>
50461 In its simplest form, the <option>dnslists</option> condition tests whether the calling host
50462 is on at least one of a number of DNS lists by looking up the inverted IP
50463 address in one or more DNS domains. (Note that DNS list domains are not mail
50464 domains, so the <literal>+</literal> syntax for named lists doesn&#x2019;t work - it is used for
50465 special options instead.) For example, if the calling host&#x2019;s IP
50466 address is 192.168.62.43, and the ACL statement is
50467 </para>
50468 <literallayout class="monospaced">
50469 deny dnslists = blackholes.mail-abuse.org : \
50470                 dialups.mail-abuse.org
50471 </literallayout>
50472 <para>
50473 the following records are looked up:
50474 </para>
50475 <literallayout class="monospaced">
50476 43.62.168.192.blackholes.mail-abuse.org
50477 43.62.168.192.dialups.mail-abuse.org
50478 </literallayout>
50479 <para>
50480 As soon as Exim finds an existing DNS record, processing of the list stops.
50481 Thus, multiple entries on the list provide an <quote>or</quote> conjunction. If you want
50482 to test that a host is on more than one list (an <quote>and</quote> conjunction), you can
50483 use two separate conditions:
50484 </para>
50485 <literallayout class="monospaced">
50486 deny dnslists = blackholes.mail-abuse.org
50487      dnslists = dialups.mail-abuse.org
50488 </literallayout>
50489 <para>
50490 If a DNS lookup times out or otherwise fails to give a decisive answer, Exim
50491 behaves as if the host does not match the list item, that is, as if the DNS
50492 record does not exist. If there are further items in the DNS list, they are
50493 processed.
50494 </para>
50495 <para>
50496 This is usually the required action when <option>dnslists</option> is used with <option>deny</option>
50497 (which is the most common usage), because it prevents a DNS failure from
50498 blocking mail. However, you can change this behaviour by putting one of the
50499 following special items in the list:
50500 </para>
50501 <literallayout>
50502 <literal>+include_unknown </literal>   behave as if the item is on the list
50503 <literal>+exclude_unknown </literal>   behave as if the item is not on the list (default)
50504 <literal>+defer_unknown   </literal>   give a temporary error
50505 </literallayout>
50506 <para>
50507 <indexterm role="concept">
50508 <primary><literal>+include_unknown</literal></primary>
50509 </indexterm>
50510 <indexterm role="concept">
50511 <primary><literal>+exclude_unknown</literal></primary>
50512 </indexterm>
50513 <indexterm role="concept">
50514 <primary><literal>+defer_unknown</literal></primary>
50515 </indexterm>
50516 Each of these applies to any subsequent items on the list. For example:
50517 </para>
50518 <literallayout class="monospaced">
50519 deny dnslists = +defer_unknown : foo.bar.example
50520 </literallayout>
50521 <para>
50522 Testing the list of domains stops as soon as a match is found. If you want to
50523 warn for one list and block for another, you can use two different statements:
50524 </para>
50525 <literallayout class="monospaced">
50526 deny  dnslists = blackholes.mail-abuse.org
50527 warn  message  = X-Warn: sending host is on dialups list
50528       dnslists = dialups.mail-abuse.org
50529 </literallayout>
50530 <para>
50531 DNS list lookups are cached by Exim for the duration of the SMTP session,
50532 so a lookup based on the IP address is done at most once for any incoming
50533 connection. Exim does not share information between multiple incoming
50534 connections (but your local name server cache should be active).
50535 </para>
50536 </section>
50537 <section id="SECID201">
50538 <title>Specifying the IP address for a DNS list lookup</title>
50539 <para>
50540 <indexterm role="concept">
50541 <primary>DNS list</primary>
50542 <secondary>keyed by explicit IP address</secondary>
50543 </indexterm>
50544 By default, the IP address that is used in a DNS list lookup is the IP address
50545 of the calling host. However, you can specify another IP address by listing it
50546 after the domain name, introduced by a slash. For example:
50547 </para>
50548 <literallayout class="monospaced">
50549 deny dnslists = black.list.tld/192.168.1.2
50550 </literallayout>
50551 <para>
50552 This feature is not very helpful with explicit IP addresses; it is intended for
50553 use with IP addresses that are looked up, for example, the IP addresses of the
50554 MX hosts or nameservers of an email sender address. For an example, see section
50555 <xref linkend="SECTmulkeyfor"/> below.
50556 </para>
50557 </section>
50558 <section id="SECID202">
50559 <title>DNS lists keyed on domain names</title>
50560 <para>
50561 <indexterm role="concept">
50562 <primary>DNS list</primary>
50563 <secondary>keyed by domain name</secondary>
50564 </indexterm>
50565 There are some lists that are keyed on domain names rather than inverted IP
50566 addresses (see for example the <emphasis>domain based zones</emphasis> link at
50567 <emphasis role="bold"><ulink url="http://www.rfc-ignorant.org/">http://www.rfc-ignorant.org/</ulink></emphasis>). No reversing of components is used
50568 with these lists. You can change the name that is looked up in a DNS list by
50569 listing it after the domain name, introduced by a slash. For example,
50570 </para>
50571 <literallayout class="monospaced">
50572 deny  message  = Sender's domain is listed at $dnslist_domain
50573       dnslists = dsn.rfc-ignorant.org/$sender_address_domain
50574 </literallayout>
50575 <para>
50576 This particular example is useful only in ACLs that are obeyed after the
50577 RCPT or DATA commands, when a sender address is available. If (for
50578 example) the message&#x2019;s sender is <emphasis>user@tld.example</emphasis> the name that is looked
50579 up by this example is
50580 </para>
50581 <literallayout class="monospaced">
50582 tld.example.dsn.rfc-ignorant.org
50583 </literallayout>
50584 <para>
50585 A single <option>dnslists</option> condition can contain entries for both names and IP
50586 addresses. For example:
50587 </para>
50588 <literallayout class="monospaced">
50589 deny dnslists = sbl.spamhaus.org : \
50590                 dsn.rfc-ignorant.org/$sender_address_domain
50591 </literallayout>
50592 <para>
50593 The first item checks the sending host&#x2019;s IP address; the second checks a domain
50594 name. The whole condition is true if either of the DNS lookups succeeds.
50595 </para>
50596 </section>
50597 <section id="SECTmulkeyfor">
50598 <title>Multiple explicit keys for a DNS list</title>
50599 <para>
50600 <indexterm role="concept">
50601 <primary>DNS list</primary>
50602 <secondary>multiple keys for</secondary>
50603 </indexterm>
50604 The syntax described above for looking up explicitly-defined values (either
50605 names or IP addresses) in a DNS blacklist is a simplification. After the domain
50606 name for the DNS list, what follows the slash can in fact be a list of items.
50607 As with all lists in Exim, the default separator is a colon. However, because
50608 this is a sublist within the list of DNS blacklist domains, it is necessary
50609 either to double the separators like this:
50610 </para>
50611 <literallayout class="monospaced">
50612 dnslists = black.list.tld/name.1::name.2
50613 </literallayout>
50614 <para>
50615 or to change the separator character, like this:
50616 </para>
50617 <literallayout class="monospaced">
50618 dnslists = black.list.tld/&lt;;name.1;name.2
50619 </literallayout>
50620 <para>
50621 If an item in the list is an IP address, it is inverted before the DNS
50622 blacklist domain is appended. If it is not an IP address, no inversion
50623 occurs. Consider this condition:
50624 </para>
50625 <literallayout class="monospaced">
50626 dnslists = black.list.tld/&lt;;192.168.1.2;a.domain
50627 </literallayout>
50628 <para>
50629 The DNS lookups that occur are:
50630 </para>
50631 <literallayout class="monospaced">
50632 2.1.168.192.black.list.tld
50633 a.domain.black.list.tld
50634 </literallayout>
50635 <para>
50636 Once a DNS record has been found (that matches a specific IP return
50637 address, if specified &ndash; see section <xref linkend="SECTaddmatcon"/>), no further lookups
50638 are done. If there is a temporary DNS error, the rest of the sublist of domains
50639 or IP addresses is tried. A temporary error for the whole dnslists item occurs
50640 only if no other DNS lookup in this sublist succeeds. In other words, a
50641 successful lookup for any of the items in the sublist overrides a temporary
50642 error for a previous item.
50643 </para>
50644 <para>
50645 The ability to supply a list of items after the slash is in some sense just a
50646 syntactic convenience. These two examples have the same effect:
50647 </para>
50648 <literallayout class="monospaced">
50649 dnslists = black.list.tld/a.domain : black.list.tld/b.domain
50650 dnslists = black.list.tld/a.domain::b.domain
50651 </literallayout>
50652 <para>
50653 However, when the data for the list is obtained from a lookup, the second form
50654 is usually much more convenient. Consider this example:
50655 </para>
50656 <literallayout class="monospaced">
50657 deny message  = The mail servers for the domain \
50658                 $sender_address_domain \
50659                 are listed at $dnslist_domain ($dnslist_value); \
50660                 see $dnslist_text.
50661      dnslists = sbl.spamhaus.org/&lt;|${lookup dnsdb {&gt;|a=&lt;|\
50662                                    ${lookup dnsdb {&gt;|mxh=\
50663                                    $sender_address_domain} }} }
50664 </literallayout>
50665 <para>
50666 Note the use of <literal>&gt;|</literal> in the dnsdb lookup to specify the separator for
50667 multiple DNS records. The inner dnsdb lookup produces a list of MX hosts
50668 and the outer dnsdb lookup finds the IP addresses for these hosts. The result
50669 of expanding the condition might be something like this:
50670 </para>
50671 <literallayout class="monospaced">
50672 dnslists = sbl.spahmaus.org/&lt;|192.168.2.3|192.168.5.6|...
50673 </literallayout>
50674 <para>
50675 Thus, this example checks whether or not the IP addresses of the sender
50676 domain&#x2019;s mail servers are on the Spamhaus black list.
50677 </para>
50678 <para>
50679 The key that was used for a successful DNS list lookup is put into the variable
50680 <varname>$dnslist_matched</varname> (see section <xref linkend="SECID204"/>).
50681 </para>
50682 </section>
50683 <section id="SECID203">
50684 <title>Data returned by DNS lists</title>
50685 <para>
50686 <indexterm role="concept">
50687 <primary>DNS list</primary>
50688 <secondary>data returned from</secondary>
50689 </indexterm>
50690 DNS lists are constructed using address records in the DNS. The original RBL
50691 just used the address 127.0.0.1 on the right hand side of each record, but the
50692 RBL+ list and some other lists use a number of values with different meanings.
50693 The values used on the RBL+ list are:
50694 </para>
50695 <literallayout>
50696 127.1.0.1  RBL
50697 127.1.0.2  DUL
50698 127.1.0.3  DUL and RBL
50699 127.1.0.4  RSS
50700 127.1.0.5  RSS and RBL
50701 127.1.0.6  RSS and DUL
50702 127.1.0.7  RSS and DUL and RBL
50703 </literallayout>
50704 <para>
50705 Section <xref linkend="SECTaddmatcon"/> below describes how you can distinguish between
50706 different values. Some DNS lists may return more than one address record;
50707 see section <xref linkend="SECThanmuldnsrec"/> for details of how they are checked.
50708 </para>
50709 </section>
50710 <section id="SECID204">
50711 <title>Variables set from DNS lists</title>
50712 <para>
50713 <indexterm role="concept">
50714 <primary>expansion</primary>
50715 <secondary>variables, set from DNS list</secondary>
50716 </indexterm>
50717 <indexterm role="concept">
50718 <primary>DNS list</primary>
50719 <secondary>variables set from</secondary>
50720 </indexterm>
50721 <indexterm role="variable">
50722 <primary><varname>$dnslist_domain</varname></primary>
50723 </indexterm>
50724 <indexterm role="variable">
50725 <primary><varname>$dnslist_matched</varname></primary>
50726 </indexterm>
50727 <indexterm role="variable">
50728 <primary><varname>$dnslist_text</varname></primary>
50729 </indexterm>
50730 <indexterm role="variable">
50731 <primary><varname>$dnslist_value</varname></primary>
50732 </indexterm>
50733 When an entry is found in a DNS list, the variable <varname>$dnslist_domain</varname> contains
50734 the name of the overall domain that matched (for example,
50735 <literal>spamhaus.example</literal>), <varname>$dnslist_matched</varname> contains the key within that domain
50736 (for example, <literal>192.168.5.3</literal>), and <varname>$dnslist_value</varname> contains the data from
50737 the DNS record. When the key is an IP address, it is not reversed in
50738 <varname>$dnslist_matched</varname> (though it is, of course, in the actual lookup). In simple
50739 cases, for example:
50740 </para>
50741 <literallayout class="monospaced">
50742 deny dnslists = spamhaus.example
50743 </literallayout>
50744 <para>
50745 the key is also available in another variable (in this case,
50746 <varname>$sender_host_address</varname>). In more complicated cases, however, this is not true.
50747 For example, using a data lookup (as described in section <xref linkend="SECTmulkeyfor"/>)
50748 might generate a dnslists lookup like this:
50749 </para>
50750 <literallayout class="monospaced">
50751 deny dnslists = spamhaus.example/&lt;|192.168.1.2|192.168.6.7|...
50752 </literallayout>
50753 <para>
50754 If this condition succeeds, the value in <varname>$dnslist_matched</varname> might be
50755 <literal>192.168.6.7</literal> (for example).
50756 </para>
50757 <para>
50758 If more than one address record is returned by the DNS lookup, all the IP
50759 addresses are included in <varname>$dnslist_value</varname>, separated by commas and spaces.
50760 The variable <varname>$dnslist_text</varname> contains the contents of any associated TXT
50761 record. For lists such as RBL+ the TXT record for a merged entry is often not
50762 very meaningful. See section <xref linkend="SECTmordetinf"/> for a way of obtaining more
50763 information.
50764 </para>
50765 <para>
50766 You can use the DNS list variables in <option>message</option> or <option>log_message</option> modifiers
50767 &ndash; although these appear before the condition in the ACL, they are not
50768 expanded until after it has failed. For example:
50769 </para>
50770 <literallayout class="monospaced">
50771 deny    hosts = !+local_networks
50772         message = $sender_host_address is listed \
50773                   at $dnslist_domain
50774         dnslists = rbl-plus.mail-abuse.example
50775 </literallayout>
50776 </section>
50777 <section id="SECTaddmatcon">
50778 <title>Additional matching conditions for DNS lists</title>
50779 <para>
50780 <indexterm role="concept">
50781 <primary>DNS list</primary>
50782 <secondary>matching specific returned data</secondary>
50783 </indexterm>
50784 You can add an equals sign and an IP address after a <option>dnslists</option> domain name
50785 in order to restrict its action to DNS records with a matching right hand side.
50786 For example,
50787 </para>
50788 <literallayout class="monospaced">
50789 deny dnslists = rblplus.mail-abuse.org=127.0.0.2
50790 </literallayout>
50791 <para>
50792 rejects only those hosts that yield 127.0.0.2. Without this additional data,
50793 any address record is considered to be a match. For the moment, we assume
50794 that the DNS lookup returns just one record. Section <xref linkend="SECThanmuldnsrec"/>
50795 describes how multiple records are handled.
50796 </para>
50797 <para>
50798 More than one IP address may be given for checking, using a comma as a
50799 separator. These are alternatives &ndash; if any one of them matches, the
50800 <option>dnslists</option> condition is true. For example:
50801 </para>
50802 <literallayout class="monospaced">
50803 deny  dnslists = a.b.c=127.0.0.2,127.0.0.3
50804 </literallayout>
50805 <para>
50806 If you want to specify a constraining address list and also specify names or IP
50807 addresses to be looked up, the constraining address list must be specified
50808 first. For example:
50809 </para>
50810 <literallayout class="monospaced">
50811 deny dnslists = dsn.rfc-ignorant.org\
50812                 =127.0.0.2/$sender_address_domain
50813 </literallayout>
50814 <para>
50815 If the character <literal>&amp;</literal> is used instead of <literal>=</literal>, the comparison for each
50816 listed IP address is done by a bitwise <quote>and</quote> instead of by an equality test.
50817 In other words, the listed addresses are used as bit masks. The comparison is
50818 true if all the bits in the mask are present in the address that is being
50819 tested. For example:
50820 </para>
50821 <literallayout class="monospaced">
50822 dnslists = a.b.c&amp;0.0.0.3
50823 </literallayout>
50824 <para>
50825 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
50826 want to test whether one bit or another bit is present (as opposed to both
50827 being present), you must use multiple values. For example:
50828 </para>
50829 <literallayout class="monospaced">
50830 dnslists = a.b.c&amp;0.0.0.1,0.0.0.2
50831 </literallayout>
50832 <para>
50833 matches if the final component of the address is an odd number or two times
50834 an odd number.
50835 </para>
50836 </section>
50837 <section id="SECID205">
50838 <title>Negated DNS matching conditions</title>
50839 <para>
50840 You can supply a negative list of IP addresses as part of a <option>dnslists</option>
50841 condition. Whereas
50842 </para>
50843 <literallayout class="monospaced">
50844 deny  dnslists = a.b.c=127.0.0.2,127.0.0.3
50845 </literallayout>
50846 <para>
50847 means <quote>deny if the host is in the black list at the domain <emphasis>a.b.c</emphasis> and the
50848 IP address yielded by the list is either 127.0.0.2 or 127.0.0.3</quote>,
50849 </para>
50850 <literallayout class="monospaced">
50851 deny  dnslists = a.b.c!=127.0.0.2,127.0.0.3
50852 </literallayout>
50853 <para>
50854 means <quote>deny if the host is in the black list at the domain <emphasis>a.b.c</emphasis> and the
50855 IP address yielded by the list is not 127.0.0.2 and not 127.0.0.3</quote>. In other
50856 words, the result of the test is inverted if an exclamation mark appears before
50857 the <literal>=</literal> (or the <literal>&amp;</literal>) sign.
50858 </para>
50859 <para>
50860 <emphasis role="bold">Note</emphasis>: This kind of negation is not the same as negation in a domain,
50861 host, or address list (which is why the syntax is different).
50862 </para>
50863 <para>
50864 If you are using just one list, the negation syntax does not gain you much. The
50865 previous example is precisely equivalent to
50866 </para>
50867 <literallayout class="monospaced">
50868 deny  dnslists = a.b.c
50869      !dnslists = a.b.c=127.0.0.2,127.0.0.3
50870 </literallayout>
50871 <para>
50872 However, if you are using multiple lists, the negation syntax is clearer.
50873 Consider this example:
50874 </para>
50875 <literallayout class="monospaced">
50876 deny  dnslists = sbl.spamhaus.org : \
50877                  list.dsbl.org : \
50878                  dnsbl.njabl.org!=127.0.0.3 : \
50879                  relays.ordb.org
50880 </literallayout>
50881 <para>
50882 Using only positive lists, this would have to be:
50883 </para>
50884 <literallayout class="monospaced">
50885 deny  dnslists = sbl.spamhaus.org : \
50886                  list.dsbl.org
50887 deny  dnslists = dnsbl.njabl.org
50888      !dnslists = dnsbl.njabl.org=127.0.0.3
50889 deny  dnslists = relays.ordb.org
50890 </literallayout>
50891 <para>
50892 which is less clear, and harder to maintain.
50893 </para>
50894 </section>
50895 <section id="SECThanmuldnsrec">
50896 <title>Handling multiple DNS records from a DNS list</title>
50897 <para>
50898 A DNS lookup for a <option>dnslists</option> condition may return more than one DNS record,
50899 thereby providing more than one IP address. When an item in a <option>dnslists</option> list
50900 is followed by <literal>=</literal> or <literal>&amp;</literal> and a list of IP addresses, in order to restrict
50901 the match to specific results from the DNS lookup, there are two ways in which
50902 the checking can be handled. For example, consider the condition:
50903 </para>
50904 <literallayout class="monospaced">
50905 dnslists = a.b.c=127.0.0.1
50906 </literallayout>
50907 <para>
50908 What happens if the DNS lookup for the incoming IP address yields both
50909 127.0.0.1 and 127.0.0.2 by means of two separate DNS records? Is the
50910 condition true because at least one given value was found, or is it false
50911 because at least one of the found values was not listed? And how does this
50912 affect negated conditions? Both possibilities are provided for with the help of
50913 additional separators <literal>==</literal> and <literal>=&amp;</literal>.
50914 </para>
50915 <itemizedlist>
50916 <listitem>
50917 <para>
50918 If <literal>=</literal> or <literal>&amp;</literal> is used, the condition is true if any one of the looked up
50919 IP addresses matches one of the listed addresses. For the example above, the
50920 condition is true because 127.0.0.1 matches.
50921 </para>
50922 </listitem>
50923 <listitem>
50924 <para>
50925 If <literal>==</literal> or <literal>=&amp;</literal> is used, the condition is true only if every one of the
50926 looked up IP addresses matches one of the listed addresses. If the condition is
50927 changed to:
50928 </para>
50929 <literallayout class="monospaced">
50930 dnslists = a.b.c==127.0.0.1
50931 </literallayout>
50932 <para>
50933 and the DNS lookup yields both 127.0.0.1 and 127.0.0.2, the condition is
50934 false because 127.0.0.2 is not listed. You would need to have:
50935 </para>
50936 <literallayout class="monospaced">
50937 dnslists = a.b.c==127.0.0.1,127.0.0.2
50938 </literallayout>
50939 <para>
50940 for the condition to be true.
50941 </para>
50942 </listitem>
50943 </itemizedlist>
50944 <para>
50945 When <literal>!</literal> is used to negate IP address matching, it inverts the result, giving
50946 the precise opposite of the behaviour above. Thus:
50947 </para>
50948 <itemizedlist>
50949 <listitem>
50950 <para>
50951 If <literal>!=</literal> or <literal>!&amp;</literal> is used, the condition is true if none of the looked up IP
50952 addresses matches one of the listed addresses. Consider:
50953 </para>
50954 <literallayout class="monospaced">
50955 dnslists = a.b.c!&amp;0.0.0.1
50956 </literallayout>
50957 <para>
50958 If the DNS lookup yields both 127.0.0.1 and 127.0.0.2, the condition is
50959 false because 127.0.0.1 matches.
50960 </para>
50961 </listitem>
50962 <listitem>
50963 <para>
50964 If <literal>!==</literal> or <literal>!=&amp;</literal> is used, the condition is true there is at least one
50965 looked up IP address that does not match. Consider:
50966 </para>
50967 <literallayout class="monospaced">
50968 dnslists = a.b.c!=&amp;0.0.0.1
50969 </literallayout>
50970 <para>
50971 If the DNS lookup yields both 127.0.0.1 and 127.0.0.2, the condition is
50972 true, because 127.0.0.2 does not match. You would need to have:
50973 </para>
50974 <literallayout class="monospaced">
50975 dnslists = a.b.c!=&amp;0.0.0.1,0.0.0.2
50976 </literallayout>
50977 <para>
50978 for the condition to be false.
50979 </para>
50980 </listitem>
50981 </itemizedlist>
50982 <para>
50983 When the DNS lookup yields only a single IP address, there is no difference
50984 between <literal>=</literal> and <literal>==</literal> and between <literal>&amp;</literal> and <literal>=&amp;</literal>.
50985 </para>
50986 </section>
50987 <section id="SECTmordetinf">
50988 <title>Detailed information from merged DNS lists</title>
50989 <para>
50990 <indexterm role="concept">
50991 <primary>DNS list</primary>
50992 <secondary>information from merged</secondary>
50993 </indexterm>
50994 When the facility for restricting the matching IP values in a DNS list is used,
50995 the text from the TXT record that is set in <varname>$dnslist_text</varname> may not reflect
50996 the true reason for rejection. This happens when lists are merged and the IP
50997 address in the A record is used to distinguish them; unfortunately there is
50998 only one TXT record. One way round this is not to use merged lists, but that
50999 can be inefficient because it requires multiple DNS lookups where one would do
51000 in the vast majority of cases when the host of interest is not on any of the
51001 lists.
51002 </para>
51003 <para>
51004 A less inefficient way of solving this problem is available. If
51005 two domain names, comma-separated, are given, the second is used first to
51006 do an initial check, making use of any IP value restrictions that are set.
51007 If there is a match, the first domain is used, without any IP value
51008 restrictions, to get the TXT record. As a byproduct of this, there is also
51009 a check that the IP being tested is indeed on the first list. The first
51010 domain is the one that is put in <varname>$dnslist_domain</varname>. For example:
51011 </para>
51012 <literallayout class="monospaced">
51013 reject message  = \
51014          rejected because $sender_host_address is blacklisted \
51015          at $dnslist_domain\n$dnslist_text
51016        dnslists = \
51017          sbl.spamhaus.org,sbl-xbl.spamhaus.org=127.0.0.2 : \
51018          dul.dnsbl.sorbs.net,dnsbl.sorbs.net=127.0.0.10
51019 </literallayout>
51020 <para>
51021 For the first blacklist item, this starts by doing a lookup in
51022 <emphasis>sbl-xbl.spamhaus.org</emphasis> and testing for a 127.0.0.2 return. If there is a
51023 match, it then looks in <emphasis>sbl.spamhaus.org</emphasis>, without checking the return
51024 value, and as long as something is found, it looks for the corresponding TXT
51025 record. If there is no match in <emphasis>sbl-xbl.spamhaus.org</emphasis>, nothing more is done.
51026 The second blacklist item is processed similarly.
51027 </para>
51028 <para>
51029 If you are interested in more than one merged list, the same list must be
51030 given several times, but because the results of the DNS lookups are cached,
51031 the DNS calls themselves are not repeated. For example:
51032 </para>
51033 <literallayout class="monospaced">
51034 reject dnslists = \
51035          http.dnsbl.sorbs.net,dnsbl.sorbs.net=127.0.0.2 : \
51036          socks.dnsbl.sorbs.net,dnsbl.sorbs.net=127.0.0.3 : \
51037          misc.dnsbl.sorbs.net,dnsbl.sorbs.net=127.0.0.4 : \
51038          dul.dnsbl.sorbs.net,dnsbl.sorbs.net=127.0.0.10
51039 </literallayout>
51040 <para>
51041 In this case there is one lookup in <emphasis>dnsbl.sorbs.net</emphasis>, and if none of the IP
51042 values matches (or if no record is found), this is the only lookup that is
51043 done. Only if there is a match is one of the more specific lists consulted.
51044 </para>
51045 </section>
51046 <section id="SECTmorednslistslast">
51047 <title>DNS lists and IPv6</title>
51048 <para>
51049 <indexterm role="concept">
51050 <primary>IPv6</primary>
51051 <secondary>DNS black lists</secondary>
51052 </indexterm>
51053 <indexterm role="concept">
51054 <primary>DNS list</primary>
51055 <secondary>IPv6 usage</secondary>
51056 </indexterm>
51057 If Exim is asked to do a dnslist lookup for an IPv6 address, it inverts it
51058 nibble by nibble. For example, if the calling host&#x2019;s IP address is
51059 3ffe:ffff:836f:0a00:000a:0800:200a:c031, Exim might look up
51060 </para>
51061 <literallayout class="monospaced">
51062 1.3.0.c.a.0.0.2.0.0.8.0.a.0.0.0.0.0.a.0.f.6.3.8.
51063   f.f.f.f.e.f.f.3.blackholes.mail-abuse.org
51064 </literallayout>
51065 <para>
51066 (split over two lines here to fit on the page). Unfortunately, some of the DNS
51067 lists contain wildcard records, intended for IPv4, that interact badly with
51068 IPv6. For example, the DNS entry
51069 </para>
51070 <literallayout class="monospaced">
51071 *.3.some.list.example.    A    127.0.0.1
51072 </literallayout>
51073 <para>
51074 is probably intended to put the entire 3.0.0.0/8 IPv4 network on the list.
51075 Unfortunately, it also matches the entire 3::/4 IPv6 network.
51076 </para>
51077 <para>
51078 You can exclude IPv6 addresses from DNS lookups by making use of a suitable
51079 <option>condition</option> condition, as in this example:
51080 </para>
51081 <literallayout class="monospaced">
51082 deny   condition = ${if isip4{$sender_host_address}}
51083        dnslists  = some.list.example
51084 </literallayout>
51085 </section>
51086 <section id="SECTratelimiting">
51087 <title>Rate limiting incoming messages</title>
51088 <para>
51089 <indexterm role="concept">
51090 <primary>rate limiting</primary>
51091 <secondary>client sending</secondary>
51092 </indexterm>
51093 <indexterm role="concept">
51094 <primary>limiting client sending rates</primary>
51095 </indexterm>
51096 <indexterm role="option">
51097 <primary><option>smtp_ratelimit_*</option></primary>
51098 </indexterm>
51099 The <option>ratelimit</option> ACL condition can be used to measure and control the rate at
51100 which clients can send email. This is more powerful than the
51101 <option>smtp_ratelimit_*</option> options, because those options control the rate of
51102 commands in a single SMTP session only, whereas the <option>ratelimit</option> condition
51103 works across all connections (concurrent and sequential) from the same client
51104 host. The syntax of the <option>ratelimit</option> condition is:
51105 </para>
51106 <literallayout>
51107 <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;
51108 </literallayout>
51109 <para>
51110 If the average client sending rate is less than <emphasis>m</emphasis> messages per time
51111 period <emphasis>p</emphasis> then the condition is false; otherwise it is true.
51112 </para>
51113 <para>
51114 As a side-effect, the <option>ratelimit</option> condition sets the expansion variable
51115 <varname>$sender_rate</varname> to the client&#x2019;s computed rate, <varname>$sender_rate_limit</varname> to the
51116 configured value of <emphasis>m</emphasis>, and <varname>$sender_rate_period</varname> to the configured value
51117 of <emphasis>p</emphasis>.
51118 </para>
51119 <para>
51120 The parameter <emphasis>p</emphasis> is the smoothing time constant, in the form of an Exim
51121 time interval, for example, <literal>8h</literal> for eight hours. A larger time constant
51122 means that it takes Exim longer to forget a client&#x2019;s past behaviour. The
51123 parameter <emphasis>m</emphasis> is the maximum number of messages that a client is permitted to
51124 send in each time interval. It also specifies the number of messages permitted
51125 in a fast burst. By increasing both <emphasis>m</emphasis> and <emphasis>p</emphasis> but keeping <emphasis>m/p</emphasis>
51126 constant, you can allow a client to send more messages in a burst without
51127 changing its long-term sending rate limit. Conversely, if <emphasis>m</emphasis> and <emphasis>p</emphasis> are
51128 both small, messages must be sent at an even rate.
51129 </para>
51130 <para>
51131 There is a script in <filename>util/ratelimit.pl</filename> which extracts sending rates from
51132 log files, to assist with choosing appropriate settings for <emphasis>m</emphasis> and <emphasis>p</emphasis>
51133 when deploying the <option>ratelimit</option> ACL condition. The script prints usage
51134 instructions when it is run with no arguments.
51135 </para>
51136 <para>
51137 The key is used to look up the data for calculating the client&#x2019;s average
51138 sending rate. This data is stored in Exim&#x2019;s spool directory, alongside the
51139 retry and other hints databases. The default key is <varname>$sender_host_address</varname>,
51140 which means Exim computes the sending rate of each client host IP address.
51141 By changing the key you can change how Exim identifies clients for the purpose
51142 of ratelimiting. For example, to limit the sending rate of each authenticated
51143 user, independent of the computer they are sending from, set the key to
51144 <varname>$authenticated_id</varname>. You must ensure that the lookup key is meaningful; for
51145 example, <varname>$authenticated_id</varname> is only meaningful if the client has
51146 authenticated (which you can check with the <option>authenticated</option> ACL condition).
51147 </para>
51148 <para>
51149 The lookup key does not have to identify clients: If you want to limit the
51150 rate at which a recipient receives messages, you can use the key
51151 <literal>$local_part@$domain</literal> with the <option>per_rcpt</option> option (see below) in a RCPT
51152 ACL.
51153 </para>
51154 <para>
51155 Internally, Exim appends the smoothing constant <emphasis>p</emphasis> and the options onto the
51156 lookup key because they alter the meaning of the stored data. This is not true
51157 for the limit <emphasis>m</emphasis>, so you can alter the configured maximum rate and Exim will
51158 still remember clients&#x2019; past behaviour, but if you alter the other ratelimit
51159 parameters Exim forgets past behaviour.
51160 </para>
51161 <para>
51162 Each <option>ratelimit</option> condition can have up to three options. One option
51163 specifies what Exim measures the rate of, and the second specifies how Exim
51164 handles excessively fast clients. The third option can be <literal>noupdate</literal>, to
51165 disable updating of the ratelimiting database (see section <xref linkend="rearatdat"/>).
51166 The options are separated by a slash, like the other parameters. They may
51167 appear in any order.
51168 </para>
51169 </section>
51170 <section id="ratoptmea">
51171 <title>Ratelimit options for what is being measured</title>
51172 <para>
51173 The <option>per_conn</option> option limits the client&#x2019;s connection rate.
51174 </para>
51175 <para>
51176 The <option>per_mail</option> option limits the client&#x2019;s rate of sending messages. This is
51177 the default if none of the <option>per_*</option> options is specified.
51178 </para>
51179 <para>
51180 The <option>per_byte</option> option limits the sender&#x2019;s email bandwidth. Note that it is
51181 best to use this option in the DATA ACL; if it is used in an earlier ACL it
51182 relies on the SIZE parameter specified by the client in its MAIL command,
51183 which may be inaccurate or completely missing. You can follow the limit <emphasis>m</emphasis>
51184 in the configuration with K, M, or G to specify limits in kilobytes,
51185 megabytes, or gigabytes, respectively.
51186 </para>
51187 <para>
51188 The <option>per_rcpt</option> option causes Exim to limit the rate at which
51189 recipients are accepted. To be effective, it would need to be used in
51190 either the <option>acl_smtp_rcpt</option> or the <option>acl_not_smtp</option> ACL. In the
51191 <option>acl_smtp_rcpt</option> ACL, the number of recipients is incremented by one.
51192 In the case of a locally submitted message in the <option>acl_not_smtp</option> ACL,
51193 the number of recipients is incremented by the <option>$recipients_count</option>
51194 for the entire message. Note that in either case the rate limiting
51195 engine will see a message with many recipients as a large high-speed
51196 burst.
51197 </para>
51198 <para>
51199 The <option>per_cmd</option> option causes Exim to recompute the rate every time the
51200 condition is processed. This can be used to limit the SMTP command rate.
51201 This command is essentially an alias of <option>per_rcpt</option> to make it clear
51202 that the effect is to limit the rate at which individual commands,
51203 rather than recipients, are accepted.
51204 </para>
51205 </section>
51206 <section id="ratophanfas">
51207 <title>Ratelimit options for handling fast clients</title>
51208 <para>
51209 If a client&#x2019;s average rate is greater than the maximum, the rate limiting
51210 engine can react in two possible ways, depending on the presence of the
51211 <option>strict</option> or <option>leaky</option> options. This is independent of the other
51212 counter-measures (such as rejecting the message) that may be specified by the
51213 rest of the ACL. The default mode is leaky, which avoids a sender&#x2019;s
51214 over-aggressive retry rate preventing it from getting any email through.
51215 </para>
51216 <para>
51217 The <option>strict</option> option means that the client&#x2019;s recorded rate is always
51218 updated. The effect of this is that Exim measures the client&#x2019;s average rate
51219 of attempts to send email, which can be much higher than the maximum it is
51220 actually allowed. If the client is over the limit it may be subjected to
51221 counter-measures by the ACL until it slows down below the maximum rate. If
51222 the client stops attempting to send email for the time specified in the <emphasis>p</emphasis>
51223 parameter then its computed rate will decay exponentially to 37% of its peak
51224 value. You can work out the time (the number of smoothing periods) that a
51225 client is subjected to counter-measures after an over-limit burst with this
51226 formula:
51227 </para>
51228 <literallayout class="monospaced">
51229         ln(peakrate/maxrate)
51230 </literallayout>
51231 <para>
51232 The <option>leaky</option> (default) option means that the client&#x2019;s recorded rate is not
51233 updated if it is above the limit. The effect of this is that Exim measures the
51234 client&#x2019;s average rate of successfully sent email, which cannot be greater than
51235 the maximum allowed. If the client is over the limit it may suffer some
51236 counter-measures (as specified in the ACL), but it will still be able to send
51237 email at the configured maximum rate, whatever the rate of its attempts. This
51238 is generally the better choice if you have clients that retry automatically.
51239 </para>
51240 </section>
51241 <section id="useratlim">
51242 <title>Using rate limiting</title>
51243 <para>
51244 Exim&#x2019;s other ACL facilities are used to define what counter-measures are taken
51245 when the rate limit is exceeded. This might be anything from logging a warning
51246 (for example, while measuring existing sending rates in order to define
51247 policy), through time delays to slow down fast senders, up to rejecting the
51248 message. For example:
51249 </para>
51250 <literallayout class="monospaced">
51251 # Log all senders' rates
51252 warn ratelimit = 0 / 1h / strict
51253      log_message = Sender rate $sender_rate / $sender_rate_period
51254
51255 # Slow down fast senders; note the need to truncate $sender_rate
51256 # at the decimal point.
51257 warn ratelimit = 100 / 1h / per_rcpt / strict
51258      delay     = ${eval: ${sg{$sender_rate}{[.].*}{}} - \
51259                    $sender_rate_limit }s
51260
51261 # Keep authenticated users under control
51262 deny authenticated = *
51263      ratelimit = 100 / 1d / strict / $authenticated_id
51264
51265 # System-wide rate limit
51266 defer message = Sorry, too busy. Try again later.
51267      ratelimit = 10 / 1s / $primary_hostname
51268
51269 # Restrict incoming rate from each host, with a default
51270 # set using a macro and special cases looked up in a table.
51271 defer message = Sender rate exceeds $sender_rate_limit \
51272                messages per $sender_rate_period
51273      ratelimit = ${lookup {$sender_host_address} \
51274                    cdb {DB/ratelimits.cdb} \
51275                    {$value} {RATELIMIT} }
51276 </literallayout>
51277 <para>
51278 <emphasis role="bold">Warning</emphasis>: If you have a busy server with a lot of <option>ratelimit</option> tests,
51279 especially with the <option>per_rcpt</option> option, you may suffer from a performance
51280 bottleneck caused by locking on the ratelimit hints database. Apart from
51281 making your ACLs less complicated, you can reduce the problem by using a
51282 RAM disk for Exim&#x2019;s hints directory (usually <filename>/var/spool/exim/db/</filename>). However
51283 this means that Exim will lose its hints data after a reboot (including retry
51284 hints, the callout cache, and ratelimit data).
51285 </para>
51286 </section>
51287 <section id="rearatdat">
51288 <title>Reading ratelimit data without updating</title>
51289 <para>
51290 <indexterm role="concept">
51291 <primary>rate limitint</primary>
51292 <secondary>reading data without updating</secondary>
51293 </indexterm>
51294 If the <option>noupdate</option> option is present on a <option>ratelimit</option> ACL condition, Exim
51295 computes the rate and checks the limit as normal, but it does not update the
51296 saved data. This means that, in relevant ACLs, it is possible to lookup the
51297 existence of a specified (or auto-generated) ratelimit key without incrementing
51298 the ratelimit counter for that key. In order for this to be useful, another ACL
51299 entry must set the rate for the same key (otherwise it will always be zero).
51300 For example:
51301 </para>
51302 <literallayout class="monospaced">
51303 acl_check_connect:
51304   deny ratelimit = 100 / 5m / strict / per_cmd / noupdate
51305        log_message = RATE: $sender_rate/$sender_rate_period \
51306                      (max $sender_rate_limit)
51307 </literallayout>
51308 <literallayout>
51309 <emphasis>... some other logic and tests...</emphasis>
51310 </literallayout>
51311 <literallayout class="monospaced">
51312 acl_check_mail:
51313   warn ratelimit = 100 / 5m / strict / per_cmd
51314        condition = ${if le{$sender_rate}{$sender_rate_limit}}
51315        logwrite  = RATE UPDATE: $sender_rate/$sender_rate_period \
51316                      (max $sender_rate_limit)
51317 </literallayout>
51318 <para>
51319 In this example, the rate is tested and used to deny access (when it is too
51320 high) in the connect ACL, but the actual computation of the remembered rate
51321 happens later, on a per-command basis, in another ACL.
51322 </para>
51323 </section>
51324 <section id="SECTaddressverification">
51325 <title>Address verification</title>
51326 <para>
51327 <indexterm role="concept">
51328 <primary>verifying address</primary>
51329 <secondary>options for</secondary>
51330 </indexterm>
51331 <indexterm role="concept">
51332 <primary>policy control</primary>
51333 <secondary>address verification</secondary>
51334 </indexterm>
51335 Several of the <option>verify</option> conditions described in section
51336 <xref linkend="SECTaclconditions"/> cause addresses to be verified. Section
51337 <xref linkend="SECTsenaddver"/> discusses the reporting of sender verification failures.
51338 The verification conditions can be followed by options that modify the
51339 verification process. The options are separated from the keyword and from each
51340 other by slashes, and some of them contain parameters. For example:
51341 </para>
51342 <literallayout class="monospaced">
51343 verify = sender/callout
51344 verify = recipient/defer_ok/callout=10s,defer_ok
51345 </literallayout>
51346 <para>
51347 The first stage of address verification, which always happens, is to run the
51348 address through the routers, in <quote>verify mode</quote>. Routers can detect the
51349 difference between verification and routing for delivery, and their actions can
51350 be varied by a number of generic options such as <option>verify</option> and <option>verify_only</option>
51351 (see chapter <xref linkend="CHAProutergeneric"/>). If routing fails, verification fails.
51352 The available options are as follows:
51353 </para>
51354 <itemizedlist>
51355 <listitem>
51356 <para>
51357 If the <option>callout</option> option is specified, successful routing to one or more
51358 remote hosts is followed by a <quote>callout</quote> to those hosts as an additional
51359 check. Callouts and their sub-options are discussed in the next section.
51360 </para>
51361 </listitem>
51362 <listitem>
51363 <para>
51364 If there is a defer error while doing verification routing, the ACL
51365 normally returns <quote>defer</quote>. However, if you include <option>defer_ok</option> in the
51366 options, the condition is forced to be true instead. Note that this is a main
51367 verification option as well as a suboption for callouts.
51368 </para>
51369 </listitem>
51370 <listitem>
51371 <para>
51372 The <option>no_details</option> option is covered in section <xref linkend="SECTsenaddver"/>, which
51373 discusses the reporting of sender address verification failures.
51374 </para>
51375 </listitem>
51376 <listitem>
51377 <para>
51378 The <option>success_on_redirect</option> option causes verification always to succeed
51379 immediately after a successful redirection. By default, if a redirection
51380 generates just one address, that address is also verified. See further
51381 discussion in section <xref linkend="SECTredirwhilveri"/>.
51382 </para>
51383 </listitem>
51384 </itemizedlist>
51385 <para>
51386 <indexterm role="concept">
51387 <primary>verifying address</primary>
51388 <secondary>differentiating failures</secondary>
51389 </indexterm>
51390 <indexterm role="variable">
51391 <primary><varname>$recipient_verify_failure</varname></primary>
51392 </indexterm>
51393 <indexterm role="variable">
51394 <primary><varname>$sender_verify_failure</varname></primary>
51395 </indexterm>
51396 <indexterm role="variable">
51397 <primary><varname>$acl_verify_message</varname></primary>
51398 </indexterm>
51399 After an address verification failure, <varname>$acl_verify_message</varname> contains the
51400 error message that is associated with the failure. It can be preserved by
51401 coding like this:
51402 </para>
51403 <literallayout class="monospaced">
51404 warn  !verify = sender
51405        set acl_m0 = $acl_verify_message
51406 </literallayout>
51407 <para>
51408 If you are writing your own custom rejection message or log message when
51409 denying access, you can use this variable to include information about the
51410 verification failure.
51411 </para>
51412 <para>
51413 In addition, <varname>$sender_verify_failure</varname> or <varname>$recipient_verify_failure</varname> (as
51414 appropriate) contains one of the following words:
51415 </para>
51416 <itemizedlist>
51417 <listitem>
51418 <para>
51419 <option>qualify</option>: The address was unqualified (no domain), and the message
51420 was neither local nor came from an exempted host.
51421 </para>
51422 </listitem>
51423 <listitem>
51424 <para>
51425 <option>route</option>: Routing failed.
51426 </para>
51427 </listitem>
51428 <listitem>
51429 <para>
51430 <option>mail</option>: Routing succeeded, and a callout was attempted; rejection
51431 occurred at or before the MAIL command (that is, on initial
51432 connection, HELO, or MAIL).
51433 </para>
51434 </listitem>
51435 <listitem>
51436 <para>
51437 <option>recipient</option>: The RCPT command in a callout was rejected.
51438 </para>
51439 </listitem>
51440 <listitem>
51441 <para>
51442 <option>postmaster</option>: The postmaster check in a callout was rejected.
51443 </para>
51444 </listitem>
51445 </itemizedlist>
51446 <para>
51447 The main use of these variables is expected to be to distinguish between
51448 rejections of MAIL and rejections of RCPT in callouts.
51449 </para>
51450 </section>
51451 <section id="SECTcallver">
51452 <title>Callout verification</title>
51453 <para>
51454 <indexterm role="concept">
51455 <primary>verifying address</primary>
51456 <secondary>by callout</secondary>
51457 </indexterm>
51458 <indexterm role="concept">
51459 <primary>callout</primary>
51460 <secondary>verification</secondary>
51461 </indexterm>
51462 <indexterm role="concept">
51463 <primary>SMTP</primary>
51464 <secondary>callout verification</secondary>
51465 </indexterm>
51466 For non-local addresses, routing verifies the domain, but is unable to do any
51467 checking of the local part. There are situations where some means of verifying
51468 the local part is desirable. One way this can be done is to make an SMTP
51469 <emphasis>callback</emphasis> to a delivery host for the sender address or a <emphasis>callforward</emphasis> to
51470 a subsequent host for a recipient address, to see if the host accepts the
51471 address. We use the term <emphasis>callout</emphasis> to cover both cases. Note that for a
51472 sender address, the callback is not to the client host that is trying to
51473 deliver the message, but to one of the hosts that accepts incoming mail for the
51474 sender&#x2019;s domain.
51475 </para>
51476 <para>
51477 Exim does not do callouts by default. If you want them to happen, you must
51478 request them by setting appropriate options on the <option>verify</option> condition, as
51479 described below. This facility should be used with care, because it can add a
51480 lot of resource usage to the cost of verifying an address. However, Exim does
51481 cache the results of callouts, which helps to reduce the cost. Details of
51482 caching are in section <xref linkend="SECTcallvercache"/>.
51483 </para>
51484 <para>
51485 Recipient callouts are usually used only between hosts that are controlled by
51486 the same administration. For example, a corporate gateway host could use
51487 callouts to check for valid recipients on an internal mailserver. A successful
51488 callout does not guarantee that a real delivery to the address would succeed;
51489 on the other hand, a failing callout does guarantee that a delivery would fail.
51490 </para>
51491 <para>
51492 If the <option>callout</option> option is present on a condition that verifies an address, a
51493 second stage of verification occurs if the address is successfully routed to
51494 one or more remote hosts. The usual case is routing by a <command>dnslookup</command> or a
51495 <command>manualroute</command> router, where the router specifies the hosts. However, if a
51496 router that does not set up hosts routes to an <command>smtp</command> transport with a
51497 <option>hosts</option> setting, the transport&#x2019;s hosts are used. If an <command>smtp</command> transport has
51498 <option>hosts_override</option> set, its hosts are always used, whether or not the router
51499 supplies a host list.
51500 </para>
51501 <para>
51502 The port that is used is taken from the transport, if it is specified and is a
51503 remote transport. (For routers that do verification only, no transport need be
51504 specified.) Otherwise, the default SMTP port is used. If a remote transport
51505 specifies an outgoing interface, this is used; otherwise the interface is not
51506 specified. Likewise, the text that is used for the HELO command is taken from
51507 the transport&#x2019;s <option>helo_data</option> option; if there is no transport, the value of
51508 <varname>$smtp_active_hostname</varname> is used.
51509 </para>
51510 <para>
51511 For a sender callout check, Exim makes SMTP connections to the remote hosts, to
51512 test whether a bounce message could be delivered to the sender address. The
51513 following SMTP commands are sent:
51514 </para>
51515 <literallayout>
51516 <literal>HELO </literal>&lt;<emphasis>local host name</emphasis>&gt;
51517 <literal>MAIL FROM:&lt;&gt;</literal>
51518 <literal>RCPT TO:</literal>&lt;<emphasis>the address to be tested</emphasis>&gt;
51519 <literal>QUIT</literal>
51520 </literallayout>
51521 <para>
51522 LHLO is used instead of HELO if the transport&#x2019;s <option>protocol</option> option is
51523 set to <quote>lmtp</quote>.
51524 </para>
51525 <para>
51526 A recipient callout check is similar. By default, it also uses an empty address
51527 for the sender. This default is chosen because most hosts do not make use of
51528 the sender address when verifying a recipient. Using the same address means
51529 that a single cache entry can be used for each recipient. Some sites, however,
51530 do make use of the sender address when verifying. These are catered for by the
51531 <option>use_sender</option> and <option>use_postmaster</option> options, described in the next section.
51532 </para>
51533 <para>
51534 If the response to the RCPT command is a 2<emphasis>xx</emphasis> code, the verification
51535 succeeds. If it is 5<emphasis>xx</emphasis>, the verification fails. For any other condition,
51536 Exim tries the next host, if any. If there is a problem with all the remote
51537 hosts, the ACL yields <quote>defer</quote>, unless the <option>defer_ok</option> parameter of the
51538 <option>callout</option> option is given, in which case the condition is forced to succeed.
51539 </para>
51540 <para>
51541 <indexterm role="concept">
51542 <primary>SMTP</primary>
51543 <secondary>output flushing, disabling for callout</secondary>
51544 </indexterm>
51545 A callout may take a little time. For this reason, Exim normally flushes SMTP
51546 output before performing a callout in an ACL, to avoid unexpected timeouts in
51547 clients when the SMTP PIPELINING extension is in use. The flushing can be
51548 disabled by using a <option>control</option> modifier to set <option>no_callout_flush</option>.
51549 </para>
51550 </section>
51551 <section id="CALLaddparcall">
51552 <title>Additional parameters for callouts</title>
51553 <para>
51554 <indexterm role="concept">
51555 <primary>callout</primary>
51556 <secondary>additional parameters for</secondary>
51557 </indexterm>
51558 The <option>callout</option> option can be followed by an equals sign and a number of
51559 optional parameters, separated by commas. For example:
51560 </para>
51561 <literallayout class="monospaced">
51562 verify = recipient/callout=10s,defer_ok
51563 </literallayout>
51564 <para>
51565 The old syntax, which had <option>callout_defer_ok</option> and <option>check_postmaster</option> as
51566 separate verify options, is retained for backwards compatibility, but is now
51567 deprecated. The additional parameters for <option>callout</option> are as follows:
51568 </para>
51569 <variablelist>
51570 <varlistentry>
51571 <term>&lt;<emphasis>a&nbsp;time&nbsp;interval</emphasis>&gt;</term>
51572 <listitem>
51573 <para>
51574 <indexterm role="concept">
51575 <primary>callout</primary>
51576 <secondary>timeout, specifying</secondary>
51577 </indexterm>
51578 This specifies the timeout that applies for the callout attempt to each host.
51579 For example:
51580 </para>
51581 <literallayout class="monospaced">
51582 verify = sender/callout=5s
51583 </literallayout>
51584 <para>
51585 The default is 30 seconds. The timeout is used for each response from the
51586 remote host. It is also used for the initial connection, unless overridden by
51587 the <option>connect</option> parameter.
51588 </para>
51589 </listitem></varlistentry>
51590 <varlistentry>
51591 <term><emphasis role="bold">connect&nbsp;=&nbsp;</emphasis>&lt;<emphasis>time&nbsp;interval</emphasis>&gt;</term>
51592 <listitem>
51593 <para>
51594 <indexterm role="concept">
51595 <primary>callout</primary>
51596 <secondary>connection timeout, specifying</secondary>
51597 </indexterm>
51598 This parameter makes it possible to set a different (usually smaller) timeout
51599 for making the SMTP connection. For example:
51600 </para>
51601 <literallayout class="monospaced">
51602 verify = sender/callout=5s,connect=1s
51603 </literallayout>
51604 <para>
51605 If not specified, this timeout defaults to the general timeout value.
51606 </para>
51607 </listitem></varlistentry>
51608 <varlistentry>
51609 <term><emphasis role="bold">defer_ok</emphasis></term>
51610 <listitem>
51611 <para>
51612 <indexterm role="concept">
51613 <primary>callout</primary>
51614 <secondary>defer, action on</secondary>
51615 </indexterm>
51616 When this parameter is present, failure to contact any host, or any other kind
51617 of temporary error, is treated as success by the ACL. However, the cache is not
51618 updated in this circumstance.
51619 </para>
51620 </listitem></varlistentry>
51621 <varlistentry>
51622 <term><emphasis role="bold">fullpostmaster</emphasis></term>
51623 <listitem>
51624 <para>
51625 <indexterm role="concept">
51626 <primary>callout</primary>
51627 <secondary>full postmaster check</secondary>
51628 </indexterm>
51629 This operates like the <option>postmaster</option> option (see below), but if the check for
51630 <emphasis>postmaster@domain</emphasis> fails, it tries just <emphasis>postmaster</emphasis>, without a domain, in
51631 accordance with the specification in RFC 2821. The RFC states that the
51632 unqualified address <emphasis>postmaster</emphasis> should be accepted.
51633 </para>
51634 </listitem></varlistentry>
51635 <varlistentry>
51636 <term><emphasis role="bold">mailfrom&nbsp;=&nbsp;</emphasis>&lt;<emphasis>email&nbsp;address</emphasis>&gt;</term>
51637 <listitem>
51638 <para>
51639 <indexterm role="concept">
51640 <primary>callout</primary>
51641 <secondary>sender when verifying header</secondary>
51642 </indexterm>
51643 When verifying addresses in header lines using the <option>header_sender</option>
51644 verification option, Exim behaves by default as if the addresses are envelope
51645 sender addresses from a message. Callout verification therefore tests to see
51646 whether a bounce message could be delivered, by using an empty address in the
51647 MAIL command. However, it is arguable that these addresses might never be used
51648 as envelope senders, and could therefore justifiably reject bounce messages
51649 (empty senders). The <option>mailfrom</option> callout parameter allows you to specify what
51650 address to use in the MAIL command. For example:
51651 </para>
51652 <literallayout class="monospaced">
51653 require  verify = header_sender/callout=mailfrom=abcd@x.y.z
51654 </literallayout>
51655 <para>
51656 This parameter is available only for the <option>header_sender</option> verification option.
51657 </para>
51658 </listitem></varlistentry>
51659 <varlistentry>
51660 <term><emphasis role="bold">maxwait&nbsp;=&nbsp;</emphasis>&lt;<emphasis>time&nbsp;interval</emphasis>&gt;</term>
51661 <listitem>
51662 <para>
51663 <indexterm role="concept">
51664 <primary>callout</primary>
51665 <secondary>overall timeout, specifying</secondary>
51666 </indexterm>
51667 This parameter sets an overall timeout for performing a callout verification.
51668 For example:
51669 </para>
51670 <literallayout class="monospaced">
51671 verify = sender/callout=5s,maxwait=30s
51672 </literallayout>
51673 <para>
51674 This timeout defaults to four times the callout timeout for individual SMTP
51675 commands. The overall timeout applies when there is more than one host that can
51676 be tried. The timeout is checked before trying the next host. This prevents
51677 very long delays if there are a large number of hosts and all are timing out
51678 (for example, when network connections are timing out).
51679 </para>
51680 </listitem></varlistentry>
51681 <varlistentry>
51682 <term><emphasis role="bold">no_cache</emphasis></term>
51683 <listitem>
51684 <para>
51685 <indexterm role="concept">
51686 <primary>callout</primary>
51687 <secondary>cache, suppressing</secondary>
51688 </indexterm>
51689 <indexterm role="concept">
51690 <primary>caching callout, suppressing</primary>
51691 </indexterm>
51692 When this parameter is given, the callout cache is neither read nor updated.
51693 </para>
51694 </listitem></varlistentry>
51695 <varlistentry>
51696 <term><emphasis role="bold">postmaster</emphasis></term>
51697 <listitem>
51698 <para>
51699 <indexterm role="concept">
51700 <primary>callout</primary>
51701 <secondary>postmaster; checking</secondary>
51702 </indexterm>
51703 When this parameter is set, a successful callout check is followed by a similar
51704 check for the local part <emphasis>postmaster</emphasis> at the same domain. If this address is
51705 rejected, the callout fails (but see <option>fullpostmaster</option> above). The result of
51706 the postmaster check is recorded in a cache record; if it is a failure, this is
51707 used to fail subsequent callouts for the domain without a connection being
51708 made, until the cache record expires.
51709 </para>
51710 </listitem></varlistentry>
51711 <varlistentry>
51712 <term><emphasis role="bold">postmaster_mailfrom&nbsp;=&nbsp;</emphasis>&lt;<emphasis>email&nbsp;address</emphasis>&gt;</term>
51713 <listitem>
51714 <para>
51715 The postmaster check uses an empty sender in the MAIL command by default.
51716 You can use this parameter to do a postmaster check using a different address.
51717 For example:
51718 </para>
51719 <literallayout class="monospaced">
51720 require  verify = sender/callout=postmaster_mailfrom=abc@x.y.z
51721 </literallayout>
51722 <para>
51723 If both <option>postmaster</option> and <option>postmaster_mailfrom</option> are present, the rightmost
51724 one overrides. The <option>postmaster</option> parameter is equivalent to this example:
51725 </para>
51726 <literallayout class="monospaced">
51727 require  verify = sender/callout=postmaster_mailfrom=
51728 </literallayout>
51729 <para>
51730 <emphasis role="bold">Warning</emphasis>: The caching arrangements for postmaster checking do not take
51731 account of the sender address. It is assumed that either the empty address or
51732 a fixed non-empty address will be used. All that Exim remembers is that the
51733 postmaster check for the domain succeeded or failed.
51734 </para>
51735 </listitem></varlistentry>
51736 <varlistentry>
51737 <term><emphasis role="bold">random</emphasis></term>
51738 <listitem>
51739 <para>
51740 <indexterm role="concept">
51741 <primary>callout</primary>
51742 <secondary><quote>random</quote> check</secondary>
51743 </indexterm>
51744 When this parameter is set, before doing the normal callout check, Exim does a
51745 check for a <quote>random</quote> local part at the same domain. The local part is not
51746 really random &ndash; it is defined by the expansion of the option
51747 <option>callout_random_local_part</option>, which defaults to
51748 </para>
51749 <literallayout class="monospaced">
51750 $primary_host_name-$tod_epoch-testing
51751 </literallayout>
51752 <para>
51753 The idea here is to try to determine whether the remote host accepts all local
51754 parts without checking. If it does, there is no point in doing callouts for
51755 specific local parts. If the <quote>random</quote> check succeeds, the result is saved in
51756 a cache record, and used to force the current and subsequent callout checks to
51757 succeed without a connection being made, until the cache record expires.
51758 </para>
51759 </listitem></varlistentry>
51760 <varlistentry>
51761 <term><emphasis role="bold">use_postmaster</emphasis></term>
51762 <listitem>
51763 <para>
51764 <indexterm role="concept">
51765 <primary>callout</primary>
51766 <secondary>sender for recipient check</secondary>
51767 </indexterm>
51768 This parameter applies to recipient callouts only. For example:
51769 </para>
51770 <literallayout class="monospaced">
51771 deny  !verify = recipient/callout=use_postmaster
51772 </literallayout>
51773 <para>
51774 <indexterm role="variable">
51775 <primary><varname>$qualify_domain</varname></primary>
51776 </indexterm>
51777 It causes a non-empty postmaster address to be used in the MAIL command when
51778 performing the callout for the recipient, and also for a <quote>random</quote> check if
51779 that is configured. The local part of the address is <literal>postmaster</literal> and the
51780 domain is the contents of <varname>$qualify_domain</varname>.
51781 </para>
51782 </listitem></varlistentry>
51783 <varlistentry>
51784 <term><emphasis role="bold">use_sender</emphasis></term>
51785 <listitem>
51786 <para>
51787 This option applies to recipient callouts only. For example:
51788 </para>
51789 <literallayout class="monospaced">
51790 require  verify = recipient/callout=use_sender
51791 </literallayout>
51792 <para>
51793 It causes the message&#x2019;s actual sender address to be used in the MAIL
51794 command when performing the callout, instead of an empty address. There is no
51795 need to use this option unless you know that the called hosts make use of the
51796 sender when checking recipients. If used indiscriminately, it reduces the
51797 usefulness of callout caching.
51798 </para>
51799 </listitem></varlistentry>
51800 </variablelist>
51801 <para>
51802 If you use any of the parameters that set a non-empty sender for the MAIL
51803 command (<option>mailfrom</option>, <option>postmaster_mailfrom</option>, <option>use_postmaster</option>, or
51804 <option>use_sender</option>), you should think about possible loops. Recipient checking is
51805 usually done between two hosts that are under the same management, and the host
51806 that receives the callouts is not normally configured to do callouts itself.
51807 Therefore, it is normally safe to use <option>use_postmaster</option> or <option>use_sender</option> in
51808 these circumstances.
51809 </para>
51810 <para>
51811 However, if you use a non-empty sender address for a callout to an arbitrary
51812 host, there is the likelihood that the remote host will itself initiate a
51813 callout check back to your host. As it is checking what appears to be a message
51814 sender, it is likely to use an empty address in MAIL, thus avoiding a
51815 callout loop. However, to be on the safe side it would be best to set up your
51816 own ACLs so that they do not do sender verification checks when the recipient
51817 is the address you use for header sender or postmaster callout checking.
51818 </para>
51819 <para>
51820 Another issue to think about when using non-empty senders for callouts is
51821 caching. When you set <option>mailfrom</option> or <option>use_sender</option>, the cache record is keyed
51822 by the sender/recipient combination; thus, for any given recipient, many more
51823 actual callouts are performed than when an empty sender or postmaster is used.
51824 </para>
51825 </section>
51826 <section id="SECTcallvercache">
51827 <title>Callout caching</title>
51828 <para>
51829 <indexterm role="concept">
51830 <primary>hints database</primary>
51831 <secondary>callout cache</secondary>
51832 </indexterm>
51833 <indexterm role="concept">
51834 <primary>callout</primary>
51835 <secondary>cache, description of</secondary>
51836 </indexterm>
51837 <indexterm role="concept">
51838 <primary>caching</primary>
51839 <secondary>callout</secondary>
51840 </indexterm>
51841 Exim caches the results of callouts in order to reduce the amount of resources
51842 used, unless you specify the <option>no_cache</option> parameter with the <option>callout</option>
51843 option. A hints database called <quote>callout</quote> is used for the cache. Two
51844 different record types are used: one records the result of a callout check for
51845 a specific address, and the other records information that applies to the
51846 entire domain (for example, that it accepts the local part <emphasis>postmaster</emphasis>).
51847 </para>
51848 <para>
51849 When an original callout fails, a detailed SMTP error message is given about
51850 the failure. However, for subsequent failures use the cache data, this message
51851 is not available.
51852 </para>
51853 <para>
51854 The expiry times for negative and positive address cache records are
51855 independent, and can be set by the global options <option>callout_negative_expire</option>
51856 (default 2h) and <option>callout_positive_expire</option> (default 24h), respectively.
51857 </para>
51858 <para>
51859 If a host gives a negative response to an SMTP connection, or rejects any
51860 commands up to and including
51861 </para>
51862 <literallayout class="monospaced">
51863 MAIL FROM:&lt;&gt;
51864 </literallayout>
51865 <para>
51866 (but not including the MAIL command with a non-empty address),
51867 any callout attempt is bound to fail. Exim remembers such failures in a
51868 domain cache record, which it uses to fail callouts for the domain without
51869 making new connections, until the domain record times out. There are two
51870 separate expiry times for domain cache records:
51871 <option>callout_domain_negative_expire</option> (default 3h) and
51872 <option>callout_domain_positive_expire</option> (default 7d).
51873 </para>
51874 <para>
51875 Domain records expire when the negative expiry time is reached if callouts
51876 cannot be made for the domain, or if the postmaster check failed.
51877 Otherwise, they expire when the positive expiry time is reached. This
51878 ensures that, for example, a host that stops accepting <quote>random</quote> local parts
51879 will eventually be noticed.
51880 </para>
51881 <para>
51882 The callout caching mechanism is based on the domain of the address that is
51883 being tested. If the domain routes to several hosts, it is assumed that their
51884 behaviour will be the same.
51885 </para>
51886 </section>
51887 <section id="SECTsenaddver">
51888 <title>Sender address verification reporting</title>
51889 <para>
51890 <indexterm role="concept">
51891 <primary>verifying</primary>
51892 <secondary>suppressing error details</secondary>
51893 </indexterm>
51894 See section <xref linkend="SECTaddressverification"/> for a general discussion of
51895 verification. When sender verification fails in an ACL, the details of the
51896 failure are given as additional output lines before the 550 response to the
51897 relevant SMTP command (RCPT or DATA). For example, if sender callout is in use,
51898 you might see:
51899 </para>
51900 <literallayout class="monospaced">
51901 MAIL FROM:&lt;xyz@abc.example&gt;
51902 250 OK
51903 RCPT TO:&lt;pqr@def.example&gt;
51904 550-Verification failed for &lt;xyz@abc.example&gt;
51905 550-Called:   192.168.34.43
51906 550-Sent:     RCPT TO:&lt;xyz@abc.example&gt;
51907 550-Response: 550 Unknown local part xyz in &lt;xyz@abc.example&gt;
51908 550 Sender verification failed
51909 </literallayout>
51910 <para>
51911 If more than one RCPT command fails in the same way, the details are given
51912 only for the first of them. However, some administrators do not want to send
51913 out this much information. You can suppress the details by adding
51914 <literal>/no_details</literal> to the ACL statement that requests sender verification. For
51915 example:
51916 </para>
51917 <literallayout class="monospaced">
51918 verify = sender/no_details
51919 </literallayout>
51920 </section>
51921 <section id="SECTredirwhilveri">
51922 <title>Redirection while verifying</title>
51923 <para>
51924 <indexterm role="concept">
51925 <primary>verifying</primary>
51926 <secondary>redirection while</secondary>
51927 </indexterm>
51928 <indexterm role="concept">
51929 <primary>address redirection</primary>
51930 <secondary>while verifying</secondary>
51931 </indexterm>
51932 A dilemma arises when a local address is redirected by aliasing or forwarding
51933 during verification: should the generated addresses themselves be verified,
51934 or should the successful expansion of the original address be enough to verify
51935 it? By default, Exim takes the following pragmatic approach:
51936 </para>
51937 <itemizedlist>
51938 <listitem>
51939 <para>
51940 When an incoming address is redirected to just one child address, verification
51941 continues with the child address, and if that fails to verify, the original
51942 verification also fails.
51943 </para>
51944 </listitem>
51945 <listitem>
51946 <para>
51947 When an incoming address is redirected to more than one child address,
51948 verification does not continue. A success result is returned.
51949 </para>
51950 </listitem>
51951 </itemizedlist>
51952 <para>
51953 This seems the most reasonable behaviour for the common use of aliasing as a
51954 way of redirecting different local parts to the same mailbox. It means, for
51955 example, that a pair of alias entries of the form
51956 </para>
51957 <literallayout class="monospaced">
51958 A.Wol:   aw123
51959 aw123:   :fail: Gone away, no forwarding address
51960 </literallayout>
51961 <para>
51962 work as expected, with both local parts causing verification failure. When a
51963 redirection generates more than one address, the behaviour is more like a
51964 mailing list, where the existence of the alias itself is sufficient for
51965 verification to succeed.
51966 </para>
51967 <para>
51968 It is possible, however, to change the default behaviour so that all successful
51969 redirections count as successful verifications, however many new addresses are
51970 generated. This is specified by the <option>success_on_redirect</option> verification
51971 option. For example:
51972 </para>
51973 <literallayout class="monospaced">
51974 require verify = recipient/success_on_redirect/callout=10s
51975 </literallayout>
51976 <para>
51977 In this example, verification succeeds if a router generates a new address, and
51978 the callout does not occur, because no address was routed to a remote host.
51979 </para>
51980 <para>
51981 When verification is being tested via the <option>-bv</option> option, the treatment of
51982 redirections is as just described, unless the <option>-v</option> or any debugging option is
51983 also specified. In that case, full verification is done for every generated
51984 address and a report is output for each of them.
51985 </para>
51986 </section>
51987 <section id="SECTverifyCSA">
51988 <title>Client SMTP authorization (CSA)</title>
51989 <para>
51990 <indexterm role="concept">
51991 <primary>CSA</primary>
51992 <secondary>verifying</secondary>
51993 </indexterm>
51994 Client SMTP Authorization is a system that allows a site to advertise
51995 which machines are and are not permitted to send email. This is done by placing
51996 special SRV records in the DNS; these are looked up using the client&#x2019;s HELO
51997 domain. At the time of writing, CSA is still an Internet Draft. Client SMTP
51998 Authorization checks in Exim are performed by the ACL condition:
51999 </para>
52000 <literallayout class="monospaced">
52001 verify = csa
52002 </literallayout>
52003 <para>
52004 This fails if the client is not authorized. If there is a DNS problem, or if no
52005 valid CSA SRV record is found, or if the client is authorized, the condition
52006 succeeds. These three cases can be distinguished using the expansion variable
52007 <varname>$csa_status</varname>, which can take one of the values <quote>fail</quote>, <quote>defer</quote>,
52008 <quote>unknown</quote>, or <quote>ok</quote>. The condition does not itself defer because that would
52009 be likely to cause problems for legitimate email.
52010 </para>
52011 <para>
52012 The error messages produced by the CSA code include slightly more
52013 detail. If <varname>$csa_status</varname> is <quote>defer</quote>, this may be because of problems
52014 looking up the CSA SRV record, or problems looking up the CSA target
52015 address record. There are four reasons for <varname>$csa_status</varname> being <quote>fail</quote>:
52016 </para>
52017 <itemizedlist>
52018 <listitem>
52019 <para>
52020 The client&#x2019;s host name is explicitly not authorized.
52021 </para>
52022 </listitem>
52023 <listitem>
52024 <para>
52025 The client&#x2019;s IP address does not match any of the CSA target IP addresses.
52026 </para>
52027 </listitem>
52028 <listitem>
52029 <para>
52030 The client&#x2019;s host name is authorized but it has no valid target IP addresses
52031 (for example, the target&#x2019;s addresses are IPv6 and the client is using IPv4).
52032 </para>
52033 </listitem>
52034 <listitem>
52035 <para>
52036 The client&#x2019;s host name has no CSA SRV record but a parent domain has asserted
52037 that all subdomains must be explicitly authorized.
52038 </para>
52039 </listitem>
52040 </itemizedlist>
52041 <para>
52042 The <option>csa</option> verification condition can take an argument which is the domain to
52043 use for the DNS query. The default is:
52044 </para>
52045 <literallayout class="monospaced">
52046 verify = csa/$sender_helo_name
52047 </literallayout>
52048 <para>
52049 This implementation includes an extension to CSA. If the query domain
52050 is an address literal such as [192.0.2.95], or if it is a bare IP
52051 address, Exim searches for CSA SRV records in the reverse DNS as if
52052 the HELO domain was (for example) <emphasis>95.2.0.192.in-addr.arpa</emphasis>. Therefore it is
52053 meaningful to say:
52054 </para>
52055 <literallayout class="monospaced">
52056 verify = csa/$sender_host_address
52057 </literallayout>
52058 <para>
52059 In fact, this is the check that Exim performs if the client does not say HELO.
52060 This extension can be turned off by setting the main configuration option
52061 <option>dns_csa_use_reverse</option> to be false.
52062 </para>
52063 <para>
52064 If a CSA SRV record is not found for the domain itself, a search
52065 is performed through its parent domains for a record which might be
52066 making assertions about subdomains. The maximum depth of this search is limited
52067 using the main configuration option <option>dns_csa_search_limit</option>, which is 5 by
52068 default. Exim does not look for CSA SRV records in a top level domain, so the
52069 default settings handle HELO domains as long as seven
52070 (<emphasis>hostname.five.four.three.two.one.com</emphasis>). This encompasses the vast majority
52071 of legitimate HELO domains.
52072 </para>
52073 <para>
52074 The <emphasis>dnsdb</emphasis> lookup also has support for CSA. Although <emphasis>dnsdb</emphasis> also supports
52075 direct SRV lookups, this is not sufficient because of the extra parent domain
52076 search behaviour of CSA, and (as with PTR lookups) <emphasis>dnsdb</emphasis> also turns IP
52077 addresses into lookups in the reverse DNS space. The result of a successful
52078 lookup such as:
52079 </para>
52080 <literallayout class="monospaced">
52081 ${lookup dnsdb {csa=$sender_helo_name}}
52082 </literallayout>
52083 <para>
52084 has two space-separated fields: an authorization code and a target host name.
52085 The authorization code can be <quote>Y</quote> for yes, <quote>N</quote> for no, <quote>X</quote> for explicit
52086 authorization required but absent, or <quote>?</quote> for unknown.
52087 </para>
52088 </section>
52089 <section id="SECTverifyPRVS">
52090 <title>Bounce address tag validation</title>
52091 <para>
52092 <indexterm role="concept">
52093 <primary>BATV, verifying</primary>
52094 </indexterm>
52095 Bounce address tag validation (BATV) is a scheme whereby the envelope senders
52096 of outgoing messages have a cryptographic, timestamped <quote>tag</quote> added to them.
52097 Genuine incoming bounce messages should therefore always be addressed to
52098 recipients that have a valid tag. This scheme is a way of detecting unwanted
52099 bounce messages caused by sender address forgeries (often called <quote>collateral
52100 spam</quote>), because the recipients of such messages do not include valid tags.
52101 </para>
52102 <para>
52103 There are two expansion items to help with the implementation of the BATV
52104 <quote>prvs</quote> (private signature) scheme in an Exim configuration. This scheme signs
52105 the original envelope sender address by using a simple key to add a hash of the
52106 address and some time-based randomizing information. The <option>prvs</option> expansion
52107 item creates a signed address, and the <option>prvscheck</option> expansion item checks one.
52108 The syntax of these expansion items is described in section
52109 <xref linkend="SECTexpansionitems"/>.
52110 </para>
52111 <para>
52112 As an example, suppose the secret per-address keys are stored in an MySQL
52113 database. A query to look up the key for an address could be defined as a macro
52114 like this:
52115 </para>
52116 <literallayout class="monospaced">
52117 PRVSCHECK_SQL = ${lookup mysql{SELECT secret FROM batv_prvs \
52118                 WHERE sender='${quote_mysql:$prvscheck_address}'\
52119                 }{$value}}
52120 </literallayout>
52121 <para>
52122 Suppose also that the senders who make use of BATV are defined by an address
52123 list called <option>batv_senders</option>. Then, in the ACL for RCPT commands, you could
52124 use this:
52125 </para>
52126 <literallayout class="monospaced">
52127 # Bounces: drop unsigned addresses for BATV senders
52128 deny message = This address does not send an unsigned reverse path
52129      senders = :
52130      recipients = +batv_senders
52131
52132 # Bounces: In case of prvs-signed address, check signature.
52133 deny message = Invalid reverse path signature.
52134      senders = :
52135      condition  = ${prvscheck {$local_part@$domain}\
52136                   {PRVSCHECK_SQL}{1}}
52137      !condition = $prvscheck_result
52138 </literallayout>
52139 <para>
52140 The first statement rejects recipients for bounce messages that are addressed
52141 to plain BATV sender addresses, because it is known that BATV senders do not
52142 send out messages with plain sender addresses. The second statement rejects
52143 recipients that are prvs-signed, but with invalid signatures (either because
52144 the key is wrong, or the signature has timed out).
52145 </para>
52146 <para>
52147 A non-prvs-signed address is not rejected by the second statement, because the
52148 <option>prvscheck</option> expansion yields an empty string if its first argument is not a
52149 prvs-signed address, thus causing the <option>condition</option> condition to be false. If
52150 the first argument is a syntactically valid prvs-signed address, the yield is
52151 the third string (in this case <quote>1</quote>), whether or not the cryptographic and
52152 timeout checks succeed. The <varname>$prvscheck_result</varname> variable contains the result
52153 of the checks (empty for failure, <quote>1</quote> for success).
52154 </para>
52155 <para>
52156 There is one more issue you must consider when implementing prvs-signing:
52157 you have to ensure that the routers accept prvs-signed addresses and
52158 deliver them correctly. The easiest way to handle this is to use a <command>redirect</command>
52159 router to remove the signature with a configuration along these lines:
52160 </para>
52161 <literallayout class="monospaced">
52162 batv_redirect:
52163   driver = redirect
52164   data = ${prvscheck {$local_part@$domain}{PRVSCHECK_SQL}}
52165 </literallayout>
52166 <para>
52167 This works because, if the third argument of <option>prvscheck</option> is empty, the result
52168 of the expansion of a prvs-signed address is the decoded value of the original
52169 address. This router should probably be the first of your routers that handles
52170 local addresses.
52171 </para>
52172 <para>
52173 To create BATV-signed addresses in the first place, a transport of this form
52174 can be used:
52175 </para>
52176 <literallayout class="monospaced">
52177 external_smtp_batv:
52178   driver = smtp
52179   return_path = ${prvs {$return_path} \
52180                        {${lookup mysql{SELECT \
52181                        secret FROM batv_prvs WHERE \
52182                        sender='${quote_mysql:$sender_address}'} \
52183                        {$value}fail}}}
52184 </literallayout>
52185 <para>
52186 If no key can be found for the existing return path, no signing takes place.
52187 </para>
52188 </section>
52189 <section id="SECTrelaycontrol">
52190 <title>Using an ACL to control relaying</title>
52191 <para>
52192 <indexterm role="concept">
52193 <primary>access control lists (ACLs)</primary>
52194 <secondary>relay control</secondary>
52195 </indexterm>
52196 <indexterm role="concept">
52197 <primary>relaying</primary>
52198 <secondary>control by ACL</secondary>
52199 </indexterm>
52200 <indexterm role="concept">
52201 <primary>policy control</primary>
52202 <secondary>relay control</secondary>
52203 </indexterm>
52204 An MTA is said to <emphasis>relay</emphasis> a message if it receives it from some host and
52205 delivers it directly to another host as a result of a remote address contained
52206 within it. Redirecting a local address via an alias or forward file and then
52207 passing the message on to another host is not relaying,
52208 <indexterm role="concept">
52209 <primary><quote>percent hack</quote></primary>
52210 </indexterm>
52211 but a redirection as a result of the <quote>percent hack</quote> is.
52212 </para>
52213 <para>
52214 Two kinds of relaying exist, which are termed <quote>incoming</quote> and <quote>outgoing</quote>.
52215 A host which is acting as a gateway or an MX backup is concerned with incoming
52216 relaying from arbitrary hosts to a specific set of domains. On the other hand,
52217 a host which is acting as a smart host for a number of clients is concerned
52218 with outgoing relaying from those clients to the Internet at large. Often the
52219 same host is fulfilling both functions,
52220 but in principle these two kinds of relaying are entirely independent. What is
52221 not wanted is the transmission of mail from arbitrary remote hosts through your
52222 system to arbitrary domains.
52223 </para>
52224 <para>
52225 You can implement relay control by means of suitable statements in the ACL that
52226 runs for each RCPT command. For convenience, it is often easiest to use
52227 Exim&#x2019;s named list facility to define the domains and hosts involved. For
52228 example, suppose you want to do the following:
52229 </para>
52230 <itemizedlist>
52231 <listitem>
52232 <para>
52233 Deliver a number of domains to mailboxes on the local host (or process them
52234 locally in some other way). Let&#x2019;s say these are <emphasis>my.dom1.example</emphasis> and
52235 <emphasis>my.dom2.example</emphasis>.
52236 </para>
52237 </listitem>
52238 <listitem>
52239 <para>
52240 Relay mail for a number of other domains for which you are the secondary MX.
52241 These might be <emphasis>friend1.example</emphasis> and <emphasis>friend2.example</emphasis>.
52242 </para>
52243 </listitem>
52244 <listitem>
52245 <para>
52246 Relay mail from the hosts on your local LAN, to whatever domains are involved.
52247 Suppose your LAN is 192.168.45.0/24.
52248 </para>
52249 </listitem>
52250 </itemizedlist>
52251 <para>
52252 In the main part of the configuration, you put the following definitions:
52253 </para>
52254 <literallayout class="monospaced">
52255 domainlist local_domains = my.dom1.example : my.dom2.example
52256 domainlist relay_domains = friend1.example : friend2.example
52257 hostlist   relay_hosts   = 192.168.45.0/24
52258 </literallayout>
52259 <para>
52260 Now you can use these definitions in the ACL that is run for every RCPT
52261 command:
52262 </para>
52263 <literallayout class="monospaced">
52264 acl_check_rcpt:
52265   accept domains = +local_domains : +relay_domains
52266   accept hosts   = +relay_hosts
52267 </literallayout>
52268 <para>
52269 The first statement accepts any RCPT command that contains an address in
52270 the local or relay domains. For any other domain, control passes to the second
52271 statement, which accepts the command only if it comes from one of the relay
52272 hosts. In practice, you will probably want to make your ACL more sophisticated
52273 than this, for example, by including sender and recipient verification. The
52274 default configuration includes a more comprehensive example, which is described
52275 in chapter <xref linkend="CHAPdefconfil"/>.
52276 </para>
52277 </section>
52278 <section id="SECTcheralcon">
52279 <title>Checking a relay configuration</title>
52280 <para>
52281 <indexterm role="concept">
52282 <primary>relaying</primary>
52283 <secondary>checking control of</secondary>
52284 </indexterm>
52285 You can check the relay characteristics of your configuration in the same way
52286 that you can test any ACL behaviour for an incoming SMTP connection, by using
52287 the <option>-bh</option> option to run a fake SMTP session with which you interact.
52288 </para>
52289 <para>
52290 For specifically testing for unwanted relaying, the host
52291 <emphasis>relay-test.mail-abuse.org</emphasis> provides a useful service. If you telnet to this
52292 host from the host on which Exim is running, using the normal telnet port, you
52293 will see a normal telnet connection message and then quite a long delay. Be
52294 patient. The remote host is making an SMTP connection back to your host, and
52295 trying a number of common probes to test for open relay vulnerability. The
52296 results of the tests will eventually appear on your terminal.
52297 <indexterm role="concept" startref="IIDacl" class="endofrange"/>
52298 </para>
52299 </section>
52300 </chapter>
52301
52302 <chapter id="CHAPexiscan">
52303 <title>Content scanning at ACL time</title>
52304 <para>
52305 <indexterm role="concept" id="IIDcosca" class="startofrange">
52306 <primary>content scanning</primary>
52307 <secondary>at ACL time</secondary>
52308 </indexterm>
52309 The extension of Exim to include content scanning at ACL time, formerly known
52310 as <quote>exiscan</quote>, was originally implemented as a patch by Tom Kistner. The code
52311 was integrated into the main source for Exim release 4.50, and Tom continues to
52312 maintain it. Most of the wording of this chapter is taken from Tom&#x2019;s
52313 specification.
52314 </para>
52315 <para>
52316 It is also possible to scan the content of messages at other times. The
52317 <function>local_scan()</function> function (see chapter <xref linkend="CHAPlocalscan"/>) allows for content
52318 scanning after all the ACLs have run. A transport filter can be used to scan
52319 messages at delivery time (see the <option>transport_filter</option> option, described in
52320 chapter <xref linkend="CHAPtransportgeneric"/>).
52321 </para>
52322 <para>
52323 If you want to include the ACL-time content-scanning features when you compile
52324 Exim, you need to arrange for WITH_CONTENT_SCAN to be defined in your
52325 <filename>Local/Makefile</filename>. When you do that, the Exim binary is built with:
52326 </para>
52327 <itemizedlist>
52328 <listitem>
52329 <para>
52330 Two additional ACLs (<option>acl_smtp_mime</option> and <option>acl_not_smtp_mime</option>) that are run
52331 for all MIME parts for SMTP and non-SMTP messages, respectively.
52332 </para>
52333 </listitem>
52334 <listitem>
52335 <para>
52336 Additional ACL conditions and modifiers: <option>decode</option>, <option>malware</option>,
52337 <option>mime_regex</option>, <option>regex</option>, and <option>spam</option>. These can be used in the ACL that is
52338 run at the end of message reception (the <option>acl_smtp_data</option> ACL).
52339 </para>
52340 </listitem>
52341 <listitem>
52342 <para>
52343 An additional control feature (<quote>no_mbox_unspool</quote>) that saves spooled copies
52344 of messages, or parts of messages, for debugging purposes.
52345 </para>
52346 </listitem>
52347 <listitem>
52348 <para>
52349 Additional expansion variables that are set in the new ACL and by the new
52350 conditions.
52351 </para>
52352 </listitem>
52353 <listitem>
52354 <para>
52355 Two new main configuration options: <option>av_scanner</option> and <option>spamd_address</option>.
52356 </para>
52357 </listitem>
52358 </itemizedlist>
52359 <para>
52360 There is another content-scanning configuration option for <filename>Local/Makefile</filename>,
52361 called WITH_OLD_DEMIME. If this is set, the old, deprecated <option>demime</option> ACL
52362 condition is compiled, in addition to all the other content-scanning features.
52363 </para>
52364 <para>
52365 Content-scanning is continually evolving, and new features are still being
52366 added. While such features are still unstable and liable to incompatible
52367 changes, they are made available in Exim by setting options whose names begin
52368 EXPERIMENTAL_ in <filename>Local/Makefile</filename>. Such features are not documented in
52369 this manual. You can find out about them by reading the file called
52370 <filename>doc/experimental.txt</filename>.
52371 </para>
52372 <para>
52373 All the content-scanning facilities work on a MBOX copy of the message that is
52374 temporarily created in a file called:
52375 </para>
52376 <literallayout>
52377 &lt;<emphasis>spool_directory</emphasis>&gt;<literal>/scan/</literal>&lt;<emphasis>message_id</emphasis>&gt;/&lt;<emphasis>message_id</emphasis>&gt;<literal>.eml</literal>
52378 </literallayout>
52379 <para>
52380 The <filename>.eml</filename> extension is a friendly hint to virus scanners that they can
52381 expect an MBOX-like structure inside that file. The file is created when the
52382 first content scanning facility is called. Subsequent calls to content
52383 scanning conditions open the same file again. The directory is recursively
52384 removed when the <option>acl_smtp_data</option> ACL has finished running, unless
52385 </para>
52386 <literallayout class="monospaced">
52387 control = no_mbox_unspool
52388 </literallayout>
52389 <para>
52390 has been encountered. When the MIME ACL decodes files, they are put into the
52391 same directory by default.
52392 </para>
52393 <section id="SECTscanvirus">
52394 <title>Scanning for viruses</title>
52395 <para>
52396 <indexterm role="concept">
52397 <primary>virus scanning</primary>
52398 </indexterm>
52399 <indexterm role="concept">
52400 <primary>content scanning</primary>
52401 <secondary>for viruses</secondary>
52402 </indexterm>
52403 <indexterm role="concept">
52404 <primary>content scanning</primary>
52405 <secondary>the <option>malware</option> condition</secondary>
52406 </indexterm>
52407 The <option>malware</option> ACL condition lets you connect virus scanner software to Exim.
52408 It supports a <quote>generic</quote> interface to scanners called via the shell, and
52409 specialized interfaces for <quote>daemon</quote> type virus scanners, which are resident
52410 in memory and thus are much faster.
52411 </para>
52412 <para revisionflag="changed">
52413 <indexterm role="option">
52414 <primary><option>av_scanner</option></primary>
52415 </indexterm>
52416 You can set the <option>av_scanner</option> option in first part of the Exim configuration
52417 file to specify which scanner to use, together with any additional options that
52418 are needed. The basic syntax is as follows:
52419 </para>
52420 <literallayout revisionflag="changed">
52421 <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>
52422 </literallayout>
52423 <para revisionflag="changed">
52424 If you do not set <option>av_scanner</option>, it defaults to
52425 </para>
52426 <literallayout class="monospaced" revisionflag="changed">
52427 av_scanner = sophie:/var/run/sophie
52428 </literallayout>
52429 <para revisionflag="changed">
52430 If the value of <option>av_scanner</option> starts with a dollar character, it is expanded
52431 before use. The following scanner types are supported in this release:
52432 </para>
52433 <variablelist>
52434 <varlistentry>
52435 <term><option>aveserver</option></term>
52436 <listitem>
52437 <para>
52438 <indexterm role="concept">
52439 <primary>virus scanners</primary>
52440 <secondary>Kaspersky</secondary>
52441 </indexterm>
52442 This is the scanner daemon of Kaspersky Version 5. You can get a trial version
52443 at <emphasis role="bold"><ulink url="http://www.kaspersky.com">http://www.kaspersky.com</ulink></emphasis>. This scanner type takes one option,
52444 which is the path to the daemon&#x2019;s UNIX socket. The default is shown in this
52445 example:
52446 </para>
52447 <literallayout class="monospaced">
52448 av_scanner = aveserver:/var/run/aveserver
52449 </literallayout>
52450 </listitem></varlistentry>
52451 <varlistentry revisionflag="changed">
52452 <term><option>clamd</option></term>
52453 <listitem>
52454 <para revisionflag="changed">
52455 <indexterm role="concept">
52456 <primary>virus scanners</primary>
52457 <secondary>clamd</secondary>
52458 </indexterm>
52459 This daemon-type scanner is GPL and free. You can get it at
52460 <emphasis role="bold"><ulink url="http://www.clamav.net/">http://www.clamav.net/</ulink></emphasis>. Some older versions of clamd do not seem to
52461 unpack MIME containers, so it used to be recommended to unpack MIME attachments
52462 in the MIME ACL. This no longer believed to be necessary. One option is
52463 required: either the path and name of a UNIX socket file, or a hostname or IP
52464 number, and a port, separated by space, as in the second of these examples:
52465 </para>
52466 <literallayout class="monospaced" revisionflag="changed">
52467 av_scanner = clamd:/opt/clamd/socket
52468 av_scanner = clamd:192.0.2.3 1234
52469 av_scanner = clamd:192.0.2.3 1234:local
52470 </literallayout>
52471 <para revisionflag="changed">
52472 If the value of av_scanner points to a UNIX socket file or contains the local
52473 keyword, then the ClamAV interface will pass a filename containing the data
52474 to be scanned, which will should normally result in less I/O happening and be
52475 more efficient.  Normally in the TCP case, the data is streamed to ClamAV as
52476 Exim does not assume that there is a common filesystem with the remote host.
52477 There is an option WITH_OLD_CLAMAV_STREAM in <filename>src/EDITME</filename> available, should
52478 you be running a version of ClamAV prior to 0.95.
52479 If the option is unset, the default is <filename>/tmp/clamd</filename>. Thanks to David Saez for
52480 contributing the code for this scanner.
52481 </para>
52482 </listitem></varlistentry>
52483 <varlistentry>
52484 <term><option>cmdline</option></term>
52485 <listitem>
52486 <para>
52487 <indexterm role="concept">
52488 <primary>virus scanners</primary>
52489 <secondary>command line interface</secondary>
52490 </indexterm>
52491 This is the keyword for the generic command line scanner interface. It can be
52492 used to attach virus scanners that are invoked from the shell. This scanner
52493 type takes 3 mandatory options:
52494 </para>
52495 <orderedlist numeration="arabic">
52496 <listitem>
52497 <para>
52498 The full path and name of the scanner binary, with all command line options,
52499 and a placeholder (<literal>%s</literal>) for the directory to scan.
52500 </para>
52501 </listitem>
52502 <listitem>
52503 <para>
52504 A regular expression to match against the STDOUT and STDERR output of the
52505 virus scanner. If the expression matches, a virus was found. You must make
52506 absolutely sure that this expression matches on <quote>virus found</quote>. This is called
52507 the <quote>trigger</quote> expression.
52508 </para>
52509 </listitem>
52510 <listitem>
52511 <para>
52512 Another regular expression, containing exactly one pair of parentheses, to
52513 match the name of the virus found in the scanners output. This is called the
52514 <quote>name</quote> expression.
52515 </para>
52516 </listitem>
52517 </orderedlist>
52518 <para>
52519 For example, Sophos Sweep reports a virus on a line like this:
52520 </para>
52521 <literallayout class="monospaced">
52522 Virus 'W32/Magistr-B' found in file ./those.bat
52523 </literallayout>
52524 <para>
52525 For the trigger expression, we can match the phrase <quote>found in file</quote>. For the
52526 name expression, we want to extract the W32/Magistr-B string, so we can match
52527 for the single quotes left and right of it. Altogether, this makes the
52528 configuration setting:
52529 </para>
52530 <literallayout class="monospaced">
52531 av_scanner = cmdline:\
52532              /path/to/sweep -ss -all -rec -archive %s:\
52533              found in file:'(.+)'
52534 </literallayout>
52535 </listitem></varlistentry>
52536 <varlistentry>
52537 <term><option>drweb</option></term>
52538 <listitem>
52539 <para>
52540 <indexterm role="concept">
52541 <primary>virus scanners</primary>
52542 <secondary>DrWeb</secondary>
52543 </indexterm>
52544 The DrWeb daemon scanner (<emphasis role="bold"><ulink url="http://www.sald.com/">http://www.sald.com/</ulink></emphasis>) interface takes one
52545 argument, either a full path to a UNIX socket, or an IP address and port
52546 separated by white space, as in these examples:
52547 </para>
52548 <literallayout class="monospaced">
52549 av_scanner = drweb:/var/run/drwebd.sock
52550 av_scanner = drweb:192.168.2.20 31337
52551 </literallayout>
52552 <para>
52553 If you omit the argument, the default path <filename>/usr/local/drweb/run/drwebd.sock</filename>
52554 is used. Thanks to Alex Miller for contributing the code for this scanner.
52555 </para>
52556 </listitem></varlistentry>
52557 <varlistentry>
52558 <term><option>fsecure</option></term>
52559 <listitem>
52560 <para>
52561 <indexterm role="concept">
52562 <primary>virus scanners</primary>
52563 <secondary>F-Secure</secondary>
52564 </indexterm>
52565 The F-Secure daemon scanner (<emphasis role="bold"><ulink url="http://www.f-secure.com">http://www.f-secure.com</ulink></emphasis>) takes one
52566 argument which is the path to a UNIX socket. For example:
52567 </para>
52568 <literallayout class="monospaced">
52569 av_scanner = fsecure:/path/to/.fsav
52570 </literallayout>
52571 <para>
52572 If no argument is given, the default is <filename>/var/run/.fsav</filename>. Thanks to Johan
52573 Thelmen for contributing the code for this scanner.
52574 </para>
52575 </listitem></varlistentry>
52576 <varlistentry>
52577 <term><option>kavdaemon</option></term>
52578 <listitem>
52579 <para>
52580 <indexterm role="concept">
52581 <primary>virus scanners</primary>
52582 <secondary>Kaspersky</secondary>
52583 </indexterm>
52584 This is the scanner daemon of Kaspersky Version 4. This version of the
52585 Kaspersky scanner is outdated. Please upgrade (see <option>aveserver</option> above). This
52586 scanner type takes one option, which is the path to the daemon&#x2019;s UNIX socket.
52587 For example:
52588 </para>
52589 <literallayout class="monospaced">
52590 av_scanner = kavdaemon:/opt/AVP/AvpCtl
52591 </literallayout>
52592 <para>
52593 The default path is <filename>/var/run/AvpCtl</filename>.
52594 </para>
52595 </listitem></varlistentry>
52596 <varlistentry>
52597 <term><option>mksd</option></term>
52598 <listitem>
52599 <para>
52600 <indexterm role="concept">
52601 <primary>virus scanners</primary>
52602 <secondary>mksd</secondary>
52603 </indexterm>
52604 This is a daemon type scanner that is aimed mainly at Polish users, though some
52605 parts of documentation are now available in English. You can get it at
52606 <emphasis role="bold"><ulink url="http://linux.mks.com.pl/">http://linux.mks.com.pl/</ulink></emphasis>. The only option for this scanner type is
52607 the maximum number of processes used simultaneously to scan the attachments,
52608 provided that the demime facility is employed and also provided that mksd has
52609 been run with at least the same number of child processes. For example:
52610 </para>
52611 <literallayout class="monospaced">
52612 av_scanner = mksd:2
52613 </literallayout>
52614 <para>
52615 You can safely omit this option (the default value is 1).
52616 </para>
52617 </listitem></varlistentry>
52618 <varlistentry>
52619 <term><option>sophie</option></term>
52620 <listitem>
52621 <para>
52622 <indexterm role="concept">
52623 <primary>virus scanners</primary>
52624 <secondary>Sophos and Sophie</secondary>
52625 </indexterm>
52626 Sophie is a daemon that uses Sophos&#x2019; <option>libsavi</option> library to scan for viruses.
52627 You can get Sophie at <emphasis role="bold"><ulink url="http://www.clanfield.info/sophie/">http://www.clanfield.info/sophie/</ulink></emphasis>. The only option
52628 for this scanner type is the path to the UNIX socket that Sophie uses for
52629 client communication. For example:
52630 </para>
52631 <literallayout class="monospaced">
52632 av_scanner = sophie:/tmp/sophie
52633 </literallayout>
52634 <para>
52635 The default path is <filename>/var/run/sophie</filename>, so if you are using this, you can omit
52636 the option.
52637 </para>
52638 </listitem></varlistentry>
52639 </variablelist>
52640 <para>
52641 When <option>av_scanner</option> is correctly set, you can use the <option>malware</option> condition in
52642 the DATA ACL. <emphasis role="bold">Note</emphasis>: You cannot use the <option>malware</option> condition in the MIME
52643 ACL.
52644 </para>
52645 <para>
52646 The <option>av_scanner</option> option is expanded each time <option>malware</option> is called. This
52647 makes it possible to use different scanners. See further below for an example.
52648 The <option>malware</option> condition caches its results, so when you use it multiple times
52649 for the same message, the actual scanning process is only carried out once.
52650 However, using expandable items in <option>av_scanner</option> disables this caching, in
52651 which case each use of the <option>malware</option> condition causes a new scan of the
52652 message.
52653 </para>
52654 <para>
52655 The <option>malware</option> condition takes a right-hand argument that is expanded before
52656 use. It can then be one of
52657 </para>
52658 <itemizedlist>
52659 <listitem>
52660 <para>
52661 <quote>true</quote>, <quote>*</quote>, or <quote>1</quote>, in which case the message is scanned for viruses.
52662 The condition succeeds if a virus was found, and fail otherwise. This is the
52663 recommended usage.
52664 </para>
52665 </listitem>
52666 <listitem>
52667 <para>
52668 <quote>false</quote> or <quote>0</quote> or an empty string, in which case no scanning is done and
52669 the condition fails immediately.
52670 </para>
52671 </listitem>
52672 <listitem>
52673 <para>
52674 A regular expression, in which case the message is scanned for viruses. The
52675 condition succeeds if a virus is found and its name matches the regular
52676 expression. This allows you to take special actions on certain types of virus.
52677 </para>
52678 </listitem>
52679 </itemizedlist>
52680 <para>
52681 You can append <literal>/defer_ok</literal> to the <option>malware</option> condition to accept messages
52682 even if there is a problem with the virus scanner. Otherwise, such a problem
52683 causes the ACL to defer.
52684 </para>
52685 <para>
52686 <indexterm role="variable">
52687 <primary><varname>$malware_name</varname></primary>
52688 </indexterm>
52689 When a virus is found, the condition sets up an expansion variable called
52690 <varname>$malware_name</varname> that contains the name of the virus. You can use it in a
52691 <option>message</option> modifier that specifies the error returned to the sender, and/or in
52692 logging data.
52693 </para>
52694 <para>
52695 If your virus scanner cannot unpack MIME and TNEF containers itself, you should
52696 use the <option>demime</option> condition (see section <xref linkend="SECTdemimecond"/>) before the
52697 <option>malware</option> condition.
52698 </para>
52699 <para revisionflag="changed">
52700 Beware the interaction of Exim&#x2019;s <option>message_size_limit</option> with any size limits
52701 imposed by your anti-virus scanner.
52702 </para>
52703 <para>
52704 Here is a very simple scanning example:
52705 </para>
52706 <literallayout class="monospaced">
52707 deny message = This message contains malware ($malware_name)
52708      demime = *
52709      malware = *
52710 </literallayout>
52711 <para>
52712 The next example accepts messages when there is a problem with the scanner:
52713 </para>
52714 <literallayout class="monospaced">
52715 deny message = This message contains malware ($malware_name)
52716      demime = *
52717      malware = */defer_ok
52718 </literallayout>
52719 <para>
52720 The next example shows how to use an ACL variable to scan with both sophie and
52721 aveserver. It assumes you have set:
52722 </para>
52723 <literallayout class="monospaced">
52724 av_scanner = $acl_m0
52725 </literallayout>
52726 <para>
52727 in the main Exim configuration.
52728 </para>
52729 <literallayout class="monospaced">
52730 deny message = This message contains malware ($malware_name)
52731      set acl_m0 = sophie
52732      malware = *
52733
52734 deny message = This message contains malware ($malware_name)
52735      set acl_m0 = aveserver
52736      malware = *
52737 </literallayout>
52738 </section>
52739 <section id="SECTscanspamass">
52740 <title>Scanning with SpamAssassin</title>
52741 <para>
52742 <indexterm role="concept">
52743 <primary>content scanning</primary>
52744 <secondary>for spam</secondary>
52745 </indexterm>
52746 <indexterm role="concept">
52747 <primary>spam scanning</primary>
52748 </indexterm>
52749 <indexterm role="concept">
52750 <primary>SpamAssassin</primary>
52751 </indexterm>
52752 The <option>spam</option> ACL condition calls SpamAssassin&#x2019;s <option>spamd</option> daemon to get a spam
52753 score and a report for the message. You can get SpamAssassin at
52754 <emphasis role="bold"><ulink url="http://www.spamassassin.org">http://www.spamassassin.org</ulink></emphasis>, or, if you have a working Perl
52755 installation, you can use CPAN by running:
52756 </para>
52757 <literallayout class="monospaced">
52758 perl -MCPAN -e 'install Mail::SpamAssassin'
52759 </literallayout>
52760 <para>
52761 SpamAssassin has its own set of configuration files. Please review its
52762 documentation to see how you can tweak it. The default installation should work
52763 nicely, however.
52764 </para>
52765 <para>
52766 <indexterm role="option">
52767 <primary><option>spamd_address</option></primary>
52768 </indexterm>
52769 After having installed and configured SpamAssassin, start the <option>spamd</option> daemon.
52770 By default, it listens on 127.0.0.1, TCP port 783. If you use another host or
52771 port for <option>spamd</option>, you must set the <option>spamd_address</option> option in the global
52772 part of the Exim configuration as follows (example):
52773 </para>
52774 <literallayout class="monospaced">
52775 spamd_address = 192.168.99.45 387
52776 </literallayout>
52777 <para>
52778 You do not need to set this option if you use the default. As of version 2.60,
52779 <option>spamd</option> also supports communication over UNIX sockets. If you want to use
52780 these, supply <option>spamd_address</option> with an absolute file name instead of a
52781 address/port pair:
52782 </para>
52783 <literallayout class="monospaced">
52784 spamd_address = /var/run/spamd_socket
52785 </literallayout>
52786 <para>
52787 You can have multiple <option>spamd</option> servers to improve scalability. These can
52788 reside on other hardware reachable over the network. To specify multiple
52789 <option>spamd</option> servers, put multiple address/port pairs in the <option>spamd_address</option>
52790 option, separated with colons:
52791 </para>
52792 <literallayout class="monospaced">
52793 spamd_address = 192.168.2.10 783 : \
52794                 192.168.2.11 783 : \
52795                 192.168.2.12 783
52796 </literallayout>
52797 <para>
52798 Up to 32 <option>spamd</option> servers are supported. The servers are queried in a random
52799 fashion. When a server fails to respond to the connection attempt, all other
52800 servers are tried until one succeeds. If no server responds, the <option>spam</option>
52801 condition defers.
52802 </para>
52803 <para>
52804 <emphasis role="bold">Warning</emphasis>: It is not possible to use the UNIX socket connection method with
52805 multiple <option>spamd</option> servers.
52806 </para>
52807 <para>
52808 The <option>spamd_address</option> variable is expanded before use if it starts with
52809 a dollar sign. In this case, the expansion may return a string that is
52810 used as the list so that multiple spamd servers can be the result of an
52811 expansion.
52812 </para>
52813 </section>
52814 <section id="SECID206">
52815 <title>Calling SpamAssassin from an Exim ACL</title>
52816 <para>
52817 Here is a simple example of the use of the <option>spam</option> condition in a DATA ACL:
52818 </para>
52819 <literallayout class="monospaced">
52820 deny message = This message was classified as SPAM
52821      spam = joe
52822 </literallayout>
52823 <para>
52824 The right-hand side of the <option>spam</option> condition specifies a name. This is
52825 relevant if you have set up multiple SpamAssassin profiles. If you do not want
52826 to scan using a specific profile, but rather use the SpamAssassin system-wide
52827 default profile, you can scan for an unknown name, or simply use <quote>nobody</quote>.
52828 However, you must put something on the right-hand side.
52829 </para>
52830 <para>
52831 The name allows you to use per-domain or per-user antispam profiles in
52832 principle, but this is not straightforward in practice, because a message may
52833 have multiple recipients, not necessarily all in the same domain. Because the
52834 <option>spam</option> condition has to be called from a DATA ACL in order to be able to
52835 read the contents of the message, the variables <varname>$local_part</varname> and <varname>$domain</varname>
52836 are not set.
52837 </para>
52838 <para>
52839 The right-hand side of the <option>spam</option> condition is expanded before being used, so
52840 you can put lookups or conditions there. When the right-hand side evaluates to
52841 <quote>0</quote> or <quote>false</quote>, no scanning is done and the condition fails immediately.
52842 </para>
52843 <para>
52844 Scanning with SpamAssassin uses a lot of resources. If you scan every message,
52845 large ones may cause significant performance degradation. As most spam messages
52846 are quite small, it is recommended that you do not scan the big ones. For
52847 example:
52848 </para>
52849 <literallayout class="monospaced">
52850 deny message = This message was classified as SPAM
52851      condition = ${if &lt; {$message_size}{10K}}
52852      spam = nobody
52853 </literallayout>
52854 <para>
52855 The <option>spam</option> condition returns true if the threshold specified in the user&#x2019;s
52856 SpamAssassin profile has been matched or exceeded. If you want to use the
52857 <option>spam</option> condition for its side effects (see the variables below), you can make
52858 it always return <quote>true</quote> by appending <literal>:true</literal> to the username.
52859 </para>
52860 <para revisionflag="changed">
52861 <indexterm role="concept">
52862 <primary>spam scanning</primary>
52863 <secondary>returned variables</secondary>
52864 </indexterm>
52865 When the <option>spam</option> condition is run, it sets up a number of expansion
52866 variables. These variables are saved with the received message, thus they are
52867 available for use at delivery time.
52868 </para>
52869 <variablelist>
52870 <varlistentry>
52871 <term><varname>$spam_score</varname></term>
52872 <listitem>
52873 <para>
52874 The spam score of the message, for example <quote>3.4</quote> or <quote>30.5</quote>. This is useful
52875 for inclusion in log or reject messages.
52876 </para>
52877 </listitem></varlistentry>
52878 <varlistentry revisionflag="changed">
52879 <term><varname>$spam_score_int</varname></term>
52880 <listitem>
52881 <para revisionflag="changed">
52882 The spam score of the message, multiplied by ten, as an integer value. For
52883 example <quote>34</quote> or <quote>305</quote>. It may appear to disagree with <varname>$spam_score</varname>
52884 because <varname>$spam_score</varname> is rounded and <varname>$spam_score_int</varname> is truncated.
52885 The integer value is useful for numeric comparisons in conditions.
52886 </para>
52887 </listitem></varlistentry>
52888 <varlistentry>
52889 <term><varname>$spam_bar</varname></term>
52890 <listitem>
52891 <para>
52892 A string consisting of a number of <quote>+</quote> or <quote>-</quote> characters, representing the
52893 integer part of the spam score value. A spam score of 4.4 would have a
52894 <varname>$spam_bar</varname> value of <quote>++++</quote>. This is useful for inclusion in warning
52895 headers, since MUAs can match on such strings.
52896 </para>
52897 </listitem></varlistentry>
52898 <varlistentry>
52899 <term><varname>$spam_report</varname></term>
52900 <listitem>
52901 <para>
52902 A multiline text table, containing the full SpamAssassin report for the
52903 message. Useful for inclusion in headers or reject messages.
52904 </para>
52905 </listitem></varlistentry>
52906 </variablelist>
52907 <para>
52908 The <option>spam</option> condition caches its results unless expansion in
52909 spamd_address was used. If you call it again with the same user name, it
52910 does not scan again, but rather returns the same values as before.
52911 </para>
52912 <para>
52913 The <option>spam</option> condition returns DEFER if there is any error while running
52914 the message through SpamAssassin or if the expansion of spamd_address
52915 failed. If you want to treat DEFER as FAIL (to pass on to the next ACL
52916 statement block), append <literal>/defer_ok</literal> to the right-hand side of the
52917 spam condition, like this:
52918 </para>
52919 <literallayout class="monospaced">
52920 deny message = This message was classified as SPAM
52921      spam    = joe/defer_ok
52922 </literallayout>
52923 <para>
52924 This causes messages to be accepted even if there is a problem with <option>spamd</option>.
52925 </para>
52926 <para>
52927 Here is a longer, commented example of the use of the <option>spam</option>
52928 condition:
52929 </para>
52930 <literallayout class="monospaced">
52931 # put headers in all messages (no matter if spam or not)
52932 warn  spam = nobody:true
52933       add_header = X-Spam-Score: $spam_score ($spam_bar)
52934       add_header = X-Spam-Report: $spam_report
52935
52936 # add second subject line with *SPAM* marker when message
52937 # is over threshold
52938 warn  spam = nobody
52939       add_header = Subject: *SPAM* $h_Subject:
52940
52941 # reject spam at high scores (&gt; 12)
52942 deny  message = This message scored $spam_score spam points.
52943       spam = nobody:true
52944       condition = ${if &gt;{$spam_score_int}{120}{1}{0}}
52945 </literallayout>
52946 </section>
52947 <section id="SECTscanmimepart">
52948 <title>Scanning MIME parts</title>
52949 <para>
52950 <indexterm role="concept">
52951 <primary>content scanning</primary>
52952 <secondary>MIME parts</secondary>
52953 </indexterm>
52954 <indexterm role="concept">
52955 <primary>MIME content scanning</primary>
52956 </indexterm>
52957 <indexterm role="option">
52958 <primary><option>acl_smtp_mime</option></primary>
52959 </indexterm>
52960 <indexterm role="option">
52961 <primary><option>acl_not_smtp_mime</option></primary>
52962 </indexterm>
52963 The <option>acl_smtp_mime</option> global option specifies an ACL that is called once for
52964 each MIME part of an SMTP message, including multipart types, in the sequence
52965 of their position in the message. Similarly, the <option>acl_not_smtp_mime</option> option
52966 specifies an ACL that is used for the MIME parts of non-SMTP messages. These
52967 options may both refer to the same ACL if you want the same processing in both
52968 cases.
52969 </para>
52970 <para>
52971 These ACLs are called (possibly many times) just before the <option>acl_smtp_data</option>
52972 ACL in the case of an SMTP message, or just before the <option>acl_not_smtp</option> ACL in
52973 the case of a non-SMTP message. However, a MIME ACL is called only if the
52974 message contains a <emphasis>Content-Type:</emphasis> header line. When a call to a MIME
52975 ACL does not yield <quote>accept</quote>, ACL processing is aborted and the appropriate
52976 result code is sent to the client. In the case of an SMTP message, the
52977 <option>acl_smtp_data</option> ACL is not called when this happens.
52978 </para>
52979 <para>
52980 You cannot use the <option>malware</option> or <option>spam</option> conditions in a MIME ACL; these can
52981 only be used in the DATA or non-SMTP ACLs. However, you can use the <option>regex</option>
52982 condition to match against the raw MIME part. You can also use the
52983 <option>mime_regex</option> condition to match against the decoded MIME part (see section
52984 <xref linkend="SECTscanregex"/>).
52985 </para>
52986 <para>
52987 At the start of a MIME ACL, a number of variables are set from the header
52988 information for the relevant MIME part. These are described below. The contents
52989 of the MIME part are not by default decoded into a disk file except for MIME
52990 parts whose content-type is <quote>message/rfc822</quote>. If you want to decode a MIME
52991 part into a disk file, you can use the <option>decode</option> condition. The general
52992 syntax is:
52993 </para>
52994 <literallayout>
52995 <literal>decode = [/</literal>&lt;<emphasis>path</emphasis>&gt;<literal>/]</literal>&lt;<emphasis>filename</emphasis>&gt;
52996 </literallayout>
52997 <para>
52998 The right hand side is expanded before use. After expansion,
52999 the value can be:
53000 </para>
53001 <orderedlist numeration="arabic">
53002 <listitem>
53003 <para>
53004 <quote>0</quote> or <quote>false</quote>, in which case no decoding is done.
53005 </para>
53006 </listitem>
53007 <listitem>
53008 <para>
53009 The string <quote>default</quote>. In that case, the file is put in the temporary
53010 <quote>default</quote> directory &lt;<emphasis>spool_directory</emphasis>&gt;<filename>/scan/</filename>&lt;<emphasis>message_id</emphasis>&gt;<filename>/</filename> with
53011 a sequential file name consisting of the message id and a sequence number. The
53012 full path and name is available in <varname>$mime_decoded_filename</varname> after decoding.
53013 </para>
53014 </listitem>
53015 <listitem>
53016 <para>
53017 A full path name starting with a slash. If the full name is an existing
53018 directory, it is used as a replacement for the default directory. The filename
53019 is then sequentially assigned. If the path does not exist, it is used as
53020 the full path and file name.
53021 </para>
53022 </listitem>
53023 <listitem>
53024 <para>
53025 If the string does not start with a slash, it is used as the
53026 filename, and the default path is then used.
53027 </para>
53028 </listitem>
53029 </orderedlist>
53030 <para>
53031 The <option>decode</option> condition normally succeeds. It is only false for syntax
53032 errors or unusual circumstances such as memory shortages. You can easily decode
53033 a file with its original, proposed filename using
53034 </para>
53035 <literallayout class="monospaced">
53036 decode = $mime_filename
53037 </literallayout>
53038 <para>
53039 However, you should keep in mind that <varname>$mime_filename</varname> might contain
53040 anything. If you place files outside of the default path, they are not
53041 automatically unlinked.
53042 </para>
53043 <para>
53044 For RFC822 attachments (these are messages attached to messages, with a
53045 content-type of <quote>message/rfc822</quote>), the ACL is called again in the same manner
53046 as for the primary message, only that the <varname>$mime_is_rfc822</varname> expansion
53047 variable is set (see below). Attached messages are always decoded to disk
53048 before being checked, and the files are unlinked once the check is done.
53049 </para>
53050 <para>
53051 The MIME ACL supports the <option>regex</option> and <option>mime_regex</option> conditions. These can be
53052 used to match regular expressions against raw and decoded MIME parts,
53053 respectively. They are described in section <xref linkend="SECTscanregex"/>.
53054 </para>
53055 <para>
53056 <indexterm role="concept">
53057 <primary>MIME content scanning</primary>
53058 <secondary>returned variables</secondary>
53059 </indexterm>
53060 The following list describes all expansion variables that are
53061 available in the MIME ACL:
53062 </para>
53063 <variablelist>
53064 <varlistentry>
53065 <term><varname>$mime_boundary</varname></term>
53066 <listitem>
53067 <para>
53068 If the current part is a multipart (see <varname>$mime_is_multipart</varname>) below, it should
53069 have a boundary string, which is stored in this variable. If the current part
53070 has no boundary parameter in the <emphasis>Content-Type:</emphasis> header, this variable
53071 contains the empty string.
53072 </para>
53073 </listitem></varlistentry>
53074 <varlistentry>
53075 <term><varname>$mime_charset</varname></term>
53076 <listitem>
53077 <para>
53078 This variable contains the character set identifier, if one was found in the
53079 <emphasis>Content-Type:</emphasis> header. Examples for charset identifiers are:
53080 </para>
53081 <literallayout class="monospaced">
53082 us-ascii
53083 gb2312 (Chinese)
53084 iso-8859-1
53085 </literallayout>
53086 <para>
53087 Please note that this value is not normalized, so you should do matches
53088 case-insensitively.
53089 </para>
53090 </listitem></varlistentry>
53091 <varlistentry>
53092 <term><varname>$mime_content_description</varname></term>
53093 <listitem>
53094 <para>
53095 This variable contains the normalized content of the <emphasis>Content-Description:</emphasis>
53096 header. It can contain a human-readable description of the parts content. Some
53097 implementations repeat the filename for attachments here, but they are usually
53098 only used for display purposes.
53099 </para>
53100 </listitem></varlistentry>
53101 <varlistentry>
53102 <term><varname>$mime_content_disposition</varname></term>
53103 <listitem>
53104 <para>
53105 This variable contains the normalized content of the <emphasis>Content-Disposition:</emphasis>
53106 header. You can expect strings like <quote>attachment</quote> or <quote>inline</quote> here.
53107 </para>
53108 </listitem></varlistentry>
53109 <varlistentry>
53110 <term><varname>$mime_content_id</varname></term>
53111 <listitem>
53112 <para>
53113 This variable contains the normalized content of the <emphasis>Content-ID:</emphasis> header.
53114 This is a unique ID that can be used to reference a part from another part.
53115 </para>
53116 </listitem></varlistentry>
53117 <varlistentry>
53118 <term><varname>$mime_content_size</varname></term>
53119 <listitem>
53120 <para>
53121 This variable is set only after the <option>decode</option> modifier (see above) has been
53122 successfully run. It contains the size of the decoded part in kilobytes. The
53123 size is always rounded up to full kilobytes, so only a completely empty part
53124 has a <varname>$mime_content_size</varname> of zero.
53125 </para>
53126 </listitem></varlistentry>
53127 <varlistentry>
53128 <term><varname>$mime_content_transfer_encoding</varname></term>
53129 <listitem>
53130 <para>
53131 This variable contains the normalized content of the
53132 <emphasis>Content-transfer-encoding:</emphasis> header. This is a symbolic name for an encoding
53133 type. Typical values are <quote>base64</quote> and <quote>quoted-printable</quote>.
53134 </para>
53135 </listitem></varlistentry>
53136 <varlistentry>
53137 <term><varname>$mime_content_type</varname></term>
53138 <listitem>
53139 <para>
53140 If the MIME part has a <emphasis>Content-Type:</emphasis> header, this variable contains its
53141 value, lowercased, and without any options (like <quote>name</quote> or <quote>charset</quote>). Here
53142 are some examples of popular MIME types, as they may appear in this variable:
53143 </para>
53144 <literallayout class="monospaced">
53145 text/plain
53146 text/html
53147 application/octet-stream
53148 image/jpeg
53149 audio/midi
53150 </literallayout>
53151 <para>
53152 If the MIME part has no <emphasis>Content-Type:</emphasis> header, this variable contains the
53153 empty string.
53154 </para>
53155 </listitem></varlistentry>
53156 <varlistentry>
53157 <term><varname>$mime_decoded_filename</varname></term>
53158 <listitem>
53159 <para>
53160 This variable is set only after the <option>decode</option> modifier (see above) has been
53161 successfully run. It contains the full path and file name of the file
53162 containing the decoded data.
53163 </para>
53164 </listitem></varlistentry>
53165 </variablelist>
53166 <para>
53167 <indexterm role="concept">
53168 <primary>RFC 2047</primary>
53169 </indexterm>
53170 </para>
53171 <variablelist>
53172 <varlistentry>
53173 <term><varname>$mime_filename</varname></term>
53174 <listitem>
53175 <para>
53176 This is perhaps the most important of the MIME variables. It contains a
53177 proposed filename for an attachment, if one was found in either the
53178 <emphasis>Content-Type:</emphasis> or <emphasis>Content-Disposition:</emphasis> headers. The filename will be
53179 RFC2047 decoded, but no additional sanity checks are done. If no filename was
53180 found, this variable contains the empty string.
53181 </para>
53182 </listitem></varlistentry>
53183 <varlistentry>
53184 <term><varname>$mime_is_coverletter</varname></term>
53185 <listitem>
53186 <para>
53187 This variable attempts to differentiate the <quote>cover letter</quote> of an e-mail from
53188 attached data. It can be used to clamp down on flashy or unnecessarily encoded
53189 content in the cover letter, while not restricting attachments at all.
53190 </para>
53191 <para>
53192 The variable contains 1 (true) for a MIME part believed to be part of the
53193 cover letter, and 0 (false) for an attachment. At present, the algorithm is as
53194 follows:
53195 </para>
53196 <orderedlist numeration="arabic">
53197 <listitem>
53198 <para>
53199 The outermost MIME part of a message is always a cover letter.
53200 </para>
53201 </listitem>
53202 <listitem>
53203 <para>
53204 If a multipart/alternative or multipart/related MIME part is a cover letter,
53205 so are all MIME subparts within that multipart.
53206 </para>
53207 </listitem>
53208 <listitem>
53209 <para>
53210 If any other multipart is a cover letter, the first subpart is a cover letter,
53211 and the rest are attachments.
53212 </para>
53213 </listitem>
53214 <listitem>
53215 <para>
53216 All parts contained within an attachment multipart are attachments.
53217 </para>
53218 </listitem>
53219 </orderedlist>
53220 <para>
53221 As an example, the following will ban <quote>HTML mail</quote> (including that sent with
53222 alternative plain text), while allowing HTML files to be attached. HTML
53223 coverletter mail attached to non-HMTL coverletter mail will also be allowed:
53224 </para>
53225 <literallayout class="monospaced">
53226 deny message = HTML mail is not accepted here
53227 !condition = $mime_is_rfc822
53228 condition = $mime_is_coverletter
53229 condition = ${if eq{$mime_content_type}{text/html}{1}{0}}
53230 </literallayout>
53231 </listitem></varlistentry>
53232 <varlistentry>
53233 <term><varname>$mime_is_multipart</varname></term>
53234 <listitem>
53235 <para>
53236 This variable has the value 1 (true) when the current part has the main type
53237 <quote>multipart</quote>, for example <quote>multipart/alternative</quote> or <quote>multipart/mixed</quote>.
53238 Since multipart entities only serve as containers for other parts, you may not
53239 want to carry out specific actions on them.
53240 </para>
53241 </listitem></varlistentry>
53242 <varlistentry>
53243 <term><varname>$mime_is_rfc822</varname></term>
53244 <listitem>
53245 <para>
53246 This variable has the value 1 (true) if the current part is not a part of the
53247 checked message itself, but part of an attached message. Attached message
53248 decoding is fully recursive.
53249 </para>
53250 </listitem></varlistentry>
53251 <varlistentry>
53252 <term><varname>$mime_part_count</varname></term>
53253 <listitem>
53254 <para>
53255 This variable is a counter that is raised for each processed MIME part. It
53256 starts at zero for the very first part (which is usually a multipart). The
53257 counter is per-message, so it is reset when processing RFC822 attachments (see
53258 <varname>$mime_is_rfc822</varname>). The counter stays set after <option>acl_smtp_mime</option> is
53259 complete, so you can use it in the DATA ACL to determine the number of MIME
53260 parts of a message. For non-MIME messages, this variable contains the value -1.
53261 </para>
53262 </listitem></varlistentry>
53263 </variablelist>
53264 </section>
53265 <section id="SECTscanregex">
53266 <title>Scanning with regular expressions</title>
53267 <para>
53268 <indexterm role="concept">
53269 <primary>content scanning</primary>
53270 <secondary>with regular expressions</secondary>
53271 </indexterm>
53272 <indexterm role="concept">
53273 <primary>regular expressions</primary>
53274 <secondary>content scanning with</secondary>
53275 </indexterm>
53276 You can specify your own custom regular expression matches on the full body of
53277 the message, or on individual MIME parts.
53278 </para>
53279 <para>
53280 The <option>regex</option> condition takes one or more regular expressions as arguments and
53281 matches them against the full message (when called in the DATA ACL) or a raw
53282 MIME part (when called in the MIME ACL). The <option>regex</option> condition matches
53283 linewise, with a maximum line length of 32K characters. That means you cannot
53284 have multiline matches with the <option>regex</option> condition.
53285 </para>
53286 <para>
53287 The <option>mime_regex</option> condition can be called only in the MIME ACL. It matches up
53288 to 32K of decoded content (the whole content at once, not linewise). If the
53289 part has not been decoded with the <option>decode</option> modifier earlier in the ACL, it
53290 is decoded automatically when <option>mime_regex</option> is executed (using default path
53291 and filename values). If the decoded data is larger than  32K, only the first
53292 32K characters are checked.
53293 </para>
53294 <para>
53295 The regular expressions are passed as a colon-separated list. To include a
53296 literal colon, you must double it. Since the whole right-hand side string is
53297 expanded before being used, you must also escape dollar signs and backslashes
53298 with more backslashes, or use the <literal>\N</literal> facility to disable expansion.
53299 Here is a simple example that contains two regular expressions:
53300 </para>
53301 <literallayout class="monospaced">
53302 deny message = contains blacklisted regex ($regex_match_string)
53303      regex = [Mm]ortgage : URGENT BUSINESS PROPOSAL
53304 </literallayout>
53305 <para>
53306 The conditions returns true if any one of the regular expressions matches. The
53307 <varname>$regex_match_string</varname> expansion variable is then set up and contains the
53308 matching regular expression.
53309 </para>
53310 <para>
53311 <emphasis role="bold">Warning</emphasis>: With large messages, these conditions can be fairly
53312 CPU-intensive.
53313 </para>
53314 </section>
53315 <section id="SECTdemimecond">
53316 <title>The demime condition</title>
53317 <para>
53318 <indexterm role="concept">
53319 <primary>content scanning</primary>
53320 <secondary>MIME checking</secondary>
53321 </indexterm>
53322 <indexterm role="concept">
53323 <primary>MIME content scanning</primary>
53324 </indexterm>
53325 The <option>demime</option> ACL condition provides MIME unpacking, sanity checking and file
53326 extension blocking. It is usable only in the DATA and non-SMTP ACLs. The
53327 <option>demime</option> condition uses a simpler interface to MIME decoding than the MIME
53328 ACL functionality, but provides no additional facilities. Please note that this
53329 condition is deprecated and kept only for backward compatibility. You must set
53330 the WITH_OLD_DEMIME option in <filename>Local/Makefile</filename> at build time to be able to
53331 use the <option>demime</option> condition.
53332 </para>
53333 <para>
53334 The <option>demime</option> condition unpacks MIME containers in the message. It detects
53335 errors in MIME containers and can match file extensions found in the message
53336 against a list. Using this facility produces files containing the unpacked MIME
53337 parts of the message in the temporary scan directory. If you do antivirus
53338 scanning, it is recommended that you use the <option>demime</option> condition before the
53339 antivirus (<option>malware</option>) condition.
53340 </para>
53341 <para>
53342 On the right-hand side of the <option>demime</option> condition you can pass a
53343 colon-separated list of file extensions that it should match against. For
53344 example:
53345 </para>
53346 <literallayout class="monospaced">
53347 deny message = Found blacklisted file attachment
53348      demime  = vbs:com:bat:pif:prf:lnk
53349 </literallayout>
53350 <para>
53351 If one of the file extensions is found, the condition is true, otherwise it is
53352 false. If there is a temporary error while demimeing (for example, <quote>disk
53353 full</quote>), the condition defers, and the message is temporarily rejected (unless
53354 the condition is on a <option>warn</option> verb).
53355 </para>
53356 <para>
53357 The right-hand side is expanded before being treated as a list, so you can have
53358 conditions and lookups there. If it expands to an empty string, <quote>false</quote>, or
53359 zero (<quote>0</quote>), no demimeing is done and the condition is false.
53360 </para>
53361 <para>
53362 The <option>demime</option> condition set the following variables:
53363 </para>
53364 <variablelist>
53365 <varlistentry>
53366 <term><varname>$demime_errorlevel</varname></term>
53367 <listitem>
53368 <para>
53369 <indexterm role="variable">
53370 <primary><varname>$demime_errorlevel</varname></primary>
53371 </indexterm>
53372 When an error is detected in a MIME container, this variable contains the
53373 severity of the error, as an integer number. The higher the value, the more
53374 severe the error (the current maximum value is 3). If this variable is unset or
53375 zero, no error occurred.
53376 </para>
53377 </listitem></varlistentry>
53378 <varlistentry>
53379 <term><varname>$demime_reason</varname></term>
53380 <listitem>
53381 <para>
53382 <indexterm role="variable">
53383 <primary><varname>$demime_reason</varname></primary>
53384 </indexterm>
53385 When <varname>$demime_errorlevel</varname> is greater than zero, this variable contains a
53386 human-readable text string describing the MIME error that occurred.
53387 </para>
53388 </listitem></varlistentry>
53389 </variablelist>
53390 <variablelist>
53391 <varlistentry>
53392 <term><varname>$found_extension</varname></term>
53393 <listitem>
53394 <para>
53395 <indexterm role="variable">
53396 <primary><varname>$found_extension</varname></primary>
53397 </indexterm>
53398 When the <option>demime</option> condition is true, this variable contains the file
53399 extension it found.
53400 </para>
53401 </listitem></varlistentry>
53402 </variablelist>
53403 <para>
53404 Both <varname>$demime_errorlevel</varname> and <varname>$demime_reason</varname> are set by the first call of
53405 the <option>demime</option> condition, and are not changed on subsequent calls.
53406 </para>
53407 <para>
53408 If you do not want to check for file extensions, but rather use the <option>demime</option>
53409 condition for unpacking or error checking purposes, pass <quote>*</quote> as the
53410 right-hand side value. Here is a more elaborate example of how to use this
53411 facility:
53412 </para>
53413 <literallayout class="monospaced">
53414 # Reject messages with serious MIME container errors
53415 deny  message = Found MIME error ($demime_reason).
53416       demime = *
53417       condition = ${if &gt;{$demime_errorlevel}{2}{1}{0}}
53418
53419 # Reject known virus spreading file extensions.
53420 # Accepting these is pretty much braindead.
53421 deny  message = contains $found_extension file (blacklisted).
53422       demime  = com:vbs:bat:pif:scr
53423
53424 # Freeze .exe and .doc files. Postmaster can
53425 # examine them and eventually thaw them.
53426 deny  log_message = Another $found_extension file.
53427       demime = exe:doc
53428       control = freeze
53429 </literallayout>
53430 <para>
53431 <indexterm role="concept" startref="IIDcosca" class="endofrange"/>
53432 </para>
53433 </section>
53434 </chapter>
53435
53436 <chapter id="CHAPlocalscan">
53437 <title>Adding a local scan function to Exim</title>
53438 <titleabbrev>Local scan function</titleabbrev>
53439 <para>
53440 <indexterm role="concept" id="IIDlosca" class="startofrange">
53441 <primary><function>local_scan()</function> function</primary>
53442 <secondary>description of</secondary>
53443 </indexterm>
53444 <indexterm role="concept">
53445 <primary>customizing</primary>
53446 <secondary>input scan using C function</secondary>
53447 </indexterm>
53448 <indexterm role="concept">
53449 <primary>policy control</primary>
53450 <secondary>by local scan function</secondary>
53451 </indexterm>
53452 In these days of email worms, viruses, and ever-increasing spam, some sites
53453 want to apply a lot of checking to messages before accepting them.
53454 </para>
53455 <para>
53456 The content scanning extension (chapter <xref linkend="CHAPexiscan"/>) has facilities for
53457 passing messages to external virus and spam scanning software. You can also do
53458 a certain amount in Exim itself through string expansions and the <option>condition</option>
53459 condition in the ACL that runs after the SMTP DATA command or the ACL for
53460 non-SMTP messages (see chapter <xref linkend="CHAPACL"/>), but this has its limitations.
53461 </para>
53462 <para>
53463 To allow for further customization to a site&#x2019;s own requirements, there is the
53464 possibility of linking Exim with a private message scanning function, written
53465 in C. If you want to run code that is written in something other than C, you
53466 can of course use a little C stub to call it.
53467 </para>
53468 <para>
53469 The local scan function is run once for every incoming message, at the point
53470 when Exim is just about to accept the message.
53471 It can therefore be used to control non-SMTP messages from local processes as
53472 well as messages arriving via SMTP.
53473 </para>
53474 <para>
53475 Exim applies a timeout to calls of the local scan function, and there is an
53476 option called <option>local_scan_timeout</option> for setting it. The default is 5 minutes.
53477 Zero means <quote>no timeout</quote>.
53478 Exim also sets up signal handlers for SIGSEGV, SIGILL, SIGFPE, and SIGBUS
53479 before calling the local scan function, so that the most common types of crash
53480 are caught. If the timeout is exceeded or one of those signals is caught, the
53481 incoming message is rejected with a temporary error if it is an SMTP message.
53482 For a non-SMTP message, the message is dropped and Exim ends with a non-zero
53483 code. The incident is logged on the main and reject logs.
53484 </para>
53485 <section id="SECID207">
53486 <title>Building Exim to use a local scan function</title>
53487 <para>
53488 <indexterm role="concept">
53489 <primary><function>local_scan()</function> function</primary>
53490 <secondary>building Exim to use</secondary>
53491 </indexterm>
53492 To make use of the local scan function feature, you must tell Exim where your
53493 function is before building Exim, by setting LOCAL_SCAN_SOURCE in your
53494 <filename>Local/Makefile</filename>. A recommended place to put it is in the <filename>Local</filename>
53495 directory, so you might set
53496 </para>
53497 <literallayout class="monospaced">
53498 LOCAL_SCAN_SOURCE=Local/local_scan.c
53499 </literallayout>
53500 <para>
53501 for example. The function must be called <function>local_scan()</function>. It is called by
53502 Exim after it has received a message, when the success return code is about to
53503 be sent. This is after all the ACLs have been run. The return code from your
53504 function controls whether the message is actually accepted or not. There is a
53505 commented template function (that just accepts the message) in the file
53506 _src/local_scan.c_.
53507 </para>
53508 <para>
53509 If you want to make use of Exim&#x2019;s run time configuration file to set options
53510 for your <function>local_scan()</function> function, you must also set
53511 </para>
53512 <literallayout class="monospaced">
53513 LOCAL_SCAN_HAS_OPTIONS=yes
53514 </literallayout>
53515 <para>
53516 in <filename>Local/Makefile</filename> (see section <xref linkend="SECTconoptloc"/> below).
53517 </para>
53518 </section>
53519 <section id="SECTapiforloc">
53520 <title>API for local_scan()</title>
53521 <para>
53522 <indexterm role="concept">
53523 <primary><function>local_scan()</function> function</primary>
53524 <secondary>API description</secondary>
53525 </indexterm>
53526 You must include this line near the start of your code:
53527 </para>
53528 <literallayout class="monospaced">
53529 #include "local_scan.h"
53530 </literallayout>
53531 <para>
53532 This header file defines a number of variables and other values, and the
53533 prototype for the function itself. Exim is coded to use unsigned char values
53534 almost exclusively, and one of the things this header defines is a shorthand
53535 for <literal>unsigned char</literal> called <literal>uschar</literal>.
53536 It also contains the following macro definitions, to simplify casting character
53537 strings and pointers to character strings:
53538 </para>
53539 <literallayout class="monospaced">
53540 #define CS   (char *)
53541 #define CCS  (const char *)
53542 #define CSS  (char **)
53543 #define US   (unsigned char *)
53544 #define CUS  (const unsigned char *)
53545 #define USS  (unsigned char **)
53546 </literallayout>
53547 <para>
53548 The function prototype for <function>local_scan()</function> is:
53549 </para>
53550 <literallayout class="monospaced">
53551 extern int local_scan(int fd, uschar **return_text);
53552 </literallayout>
53553 <para>
53554 The arguments are as follows:
53555 </para>
53556 <itemizedlist>
53557 <listitem>
53558 <para>
53559 <option>fd</option> is a file descriptor for the file that contains the body of the message
53560 (the -D file). The file is open for reading and writing, but updating it is not
53561 recommended. <emphasis role="bold">Warning</emphasis>: You must <emphasis>not</emphasis> close this file descriptor.
53562 </para>
53563 <para>
53564 The descriptor is positioned at character 19 of the file, which is the first
53565 character of the body itself, because the first 19 characters are the message
53566 id followed by <literal>-D</literal> and a newline. If you rewind the file, you should use the
53567 macro SPOOL_DATA_START_OFFSET to reset to the start of the data, just in
53568 case this changes in some future version.
53569 </para>
53570 </listitem>
53571 <listitem>
53572 <para>
53573 <option>return_text</option> is an address which you can use to return a pointer to a text
53574 string at the end of the function. The value it points to on entry is NULL.
53575 </para>
53576 </listitem>
53577 </itemizedlist>
53578 <para>
53579 The function must return an <option>int</option> value which is one of the following macros:
53580 </para>
53581 <variablelist>
53582 <varlistentry>
53583 <term><literal>LOCAL_SCAN_ACCEPT</literal></term>
53584 <listitem>
53585 <para>
53586 <indexterm role="variable">
53587 <primary><varname>$local_scan_data</varname></primary>
53588 </indexterm>
53589 The message is accepted. If you pass back a string of text, it is saved with
53590 the message, and made available in the variable <varname>$local_scan_data</varname>. No
53591 newlines are permitted (if there are any, they are turned into spaces) and the
53592 maximum length of text is 1000 characters.
53593 </para>
53594 </listitem></varlistentry>
53595 <varlistentry>
53596 <term><literal>LOCAL_SCAN_ACCEPT_FREEZE</literal></term>
53597 <listitem>
53598 <para>
53599 This behaves as LOCAL_SCAN_ACCEPT, except that the accepted message is
53600 queued without immediate delivery, and is frozen.
53601 </para>
53602 </listitem></varlistentry>
53603 <varlistentry>
53604 <term><literal>LOCAL_SCAN_ACCEPT_QUEUE</literal></term>
53605 <listitem>
53606 <para>
53607 This behaves as LOCAL_SCAN_ACCEPT, except that the accepted message is
53608 queued without immediate delivery.
53609 </para>
53610 </listitem></varlistentry>
53611 <varlistentry>
53612 <term><literal>LOCAL_SCAN_REJECT</literal></term>
53613 <listitem>
53614 <para>
53615 The message is rejected; the returned text is used as an error message which is
53616 passed back to the sender and which is also logged. Newlines are permitted &ndash;
53617 they cause a multiline response for SMTP rejections, but are converted to
53618 <literal>\n</literal> in log lines. If no message is given, <quote>Administrative prohibition</quote> is
53619 used.
53620 </para>
53621 </listitem></varlistentry>
53622 <varlistentry>
53623 <term><literal>LOCAL_SCAN_TEMPREJECT</literal></term>
53624 <listitem>
53625 <para>
53626 The message is temporarily rejected; the returned text is used as an error
53627 message as for LOCAL_SCAN_REJECT. If no message is given, <quote>Temporary local
53628 problem</quote> is used.
53629 </para>
53630 </listitem></varlistentry>
53631 <varlistentry>
53632 <term><literal>LOCAL_SCAN_REJECT_NOLOGHDR</literal></term>
53633 <listitem>
53634 <para>
53635 This behaves as LOCAL_SCAN_REJECT, except that the header of the rejected
53636 message is not written to the reject log. It has the effect of unsetting the
53637 <option>rejected_header</option> log selector for just this rejection. If
53638 <option>rejected_header</option> is already unset (see the discussion of the
53639 <option>log_selection</option> option in section <xref linkend="SECTlogselector"/>), this code is the
53640 same as LOCAL_SCAN_REJECT.
53641 </para>
53642 </listitem></varlistentry>
53643 <varlistentry>
53644 <term><literal>LOCAL_SCAN_TEMPREJECT_NOLOGHDR</literal></term>
53645 <listitem>
53646 <para>
53647 This code is a variation of LOCAL_SCAN_TEMPREJECT in the same way that
53648 LOCAL_SCAN_REJECT_NOLOGHDR is a variation of LOCAL_SCAN_REJECT.
53649 </para>
53650 </listitem></varlistentry>
53651 </variablelist>
53652 <para>
53653 If the message is not being received by interactive SMTP, rejections are
53654 reported by writing to <option>stderr</option> or by sending an email, as configured by the
53655 <option>-oe</option> command line options.
53656 </para>
53657 </section>
53658 <section id="SECTconoptloc">
53659 <title>Configuration options for local_scan()</title>
53660 <para>
53661 <indexterm role="concept">
53662 <primary><function>local_scan()</function> function</primary>
53663 <secondary>configuration options</secondary>
53664 </indexterm>
53665 It is possible to have option settings in the main configuration file
53666 that set values in static variables in the <function>local_scan()</function> module. If you
53667 want to do this, you must have the line
53668 </para>
53669 <literallayout class="monospaced">
53670 LOCAL_SCAN_HAS_OPTIONS=yes
53671 </literallayout>
53672 <para>
53673 in your <filename>Local/Makefile</filename> when you build Exim. (This line is in
53674 <filename>OS/Makefile-Default</filename>, commented out). Then, in the <function>local_scan()</function> source
53675 file, you must define static variables to hold the option values, and a table
53676 to define them.
53677 </para>
53678 <para>
53679 The table must be a vector called <option>local_scan_options</option>, of type
53680 <literal>optionlist</literal>. Each entry is a triplet, consisting of a name, an option type,
53681 and a pointer to the variable that holds the value. The entries must appear in
53682 alphabetical order. Following <option>local_scan_options</option> you must also define a
53683 variable called <option>local_scan_options_count</option> that contains the number of
53684 entries in the table. Here is a short example, showing two kinds of option:
53685 </para>
53686 <literallayout class="monospaced">
53687 static int my_integer_option = 42;
53688 static uschar *my_string_option = US"a default string";
53689
53690 optionlist local_scan_options[] = {
53691   { "my_integer", opt_int,       &amp;my_integer_option },
53692   { "my_string",  opt_stringptr, &amp;my_string_option }
53693 };
53694
53695 int local_scan_options_count =
53696   sizeof(local_scan_options)/sizeof(optionlist);
53697 </literallayout>
53698 <para>
53699 The values of the variables can now be changed from Exim&#x2019;s runtime
53700 configuration file by including a local scan section as in this example:
53701 </para>
53702 <literallayout class="monospaced">
53703 begin local_scan
53704 my_integer = 99
53705 my_string = some string of text...
53706 </literallayout>
53707 <para>
53708 The available types of option data are as follows:
53709 </para>
53710 <variablelist>
53711 <varlistentry>
53712 <term><emphasis role="bold">opt_bool</emphasis></term>
53713 <listitem>
53714 <para>
53715 This specifies a boolean (true/false) option. The address should point to a
53716 variable of type <literal>BOOL</literal>, which will be set to TRUE or FALSE, which are macros
53717 that are defined as <quote>1</quote> and <quote>0</quote>, respectively. If you want to detect
53718 whether such a variable has been set at all, you can initialize it to
53719 TRUE_UNSET. (BOOL variables are integers underneath, so can hold more than two
53720 values.)
53721 </para>
53722 </listitem></varlistentry>
53723 <varlistentry>
53724 <term><emphasis role="bold">opt_fixed</emphasis></term>
53725 <listitem>
53726 <para>
53727 This specifies a fixed point number, such as is used for load averages.
53728 The address should point to a variable of type <literal>int</literal>. The value is stored
53729 multiplied by 1000, so, for example, 1.4142 is truncated and stored as 1414.
53730 </para>
53731 </listitem></varlistentry>
53732 <varlistentry>
53733 <term><emphasis role="bold">opt_int</emphasis></term>
53734 <listitem>
53735 <para>
53736 This specifies an integer; the address should point to a variable of type
53737 <literal>int</literal>. The value may be specified in any of the integer formats accepted by
53738 Exim.
53739 </para>
53740 </listitem></varlistentry>
53741 <varlistentry>
53742 <term><emphasis role="bold">opt_mkint</emphasis></term>
53743 <listitem>
53744 <para>
53745 This is the same as <option>opt_int</option>, except that when such a value is output in a
53746 <option>-bP</option> listing, if it is an exact number of kilobytes or megabytes, it is
53747 printed with the suffix K or M.
53748 </para>
53749 </listitem></varlistentry>
53750 <varlistentry>
53751 <term><emphasis role="bold">opt_octint</emphasis></term>
53752 <listitem>
53753 <para>
53754 This also specifies an integer, but the value is always interpreted as an
53755 octal integer, whether or not it starts with the digit zero, and it is
53756 always output in octal.
53757 </para>
53758 </listitem></varlistentry>
53759 <varlistentry>
53760 <term><emphasis role="bold">opt_stringptr</emphasis></term>
53761 <listitem>
53762 <para>
53763 This specifies a string value; the address must be a pointer to a
53764 variable that points to a string (for example, of type <literal>uschar *</literal>).
53765 </para>
53766 </listitem></varlistentry>
53767 <varlistentry>
53768 <term><emphasis role="bold">opt_time</emphasis></term>
53769 <listitem>
53770 <para>
53771 This specifies a time interval value. The address must point to a variable of
53772 type <literal>int</literal>. The value that is placed there is a number of seconds.
53773 </para>
53774 </listitem></varlistentry>
53775 </variablelist>
53776 <para>
53777 If the <option>-bP</option> command line option is followed by <literal>local_scan</literal>, Exim prints
53778 out the values of all the <function>local_scan()</function> options.
53779 </para>
53780 </section>
53781 <section id="SECID208">
53782 <title>Available Exim variables</title>
53783 <para>
53784 <indexterm role="concept">
53785 <primary><function>local_scan()</function> function</primary>
53786 <secondary>available Exim variables</secondary>
53787 </indexterm>
53788 The header <filename>local_scan.h</filename> gives you access to a number of C variables. These
53789 are the only ones that are guaranteed to be maintained from release to release.
53790 Note, however, that you can obtain the value of any Exim expansion variable,
53791 including <varname>$recipients</varname>, by calling <emphasis>expand_string()</emphasis>. The exported
53792 C variables are as follows:
53793 </para>
53794 <variablelist>
53795 <varlistentry>
53796 <term><emphasis role="bold">int&nbsp;body_linecount</emphasis></term>
53797 <listitem>
53798 <para>
53799 This variable contains the number of lines in the message&#x2019;s body.
53800 </para>
53801 </listitem></varlistentry>
53802 <varlistentry>
53803 <term><emphasis role="bold">int&nbsp;body_zerocount</emphasis></term>
53804 <listitem>
53805 <para>
53806 This variable contains the number of binary zero bytes in the message&#x2019;s body.
53807 </para>
53808 </listitem></varlistentry>
53809 <varlistentry>
53810 <term><emphasis role="bold">unsigned&nbsp;int&nbsp;debug_selector</emphasis></term>
53811 <listitem>
53812 <para>
53813 This variable is set to zero when no debugging is taking place. Otherwise, it
53814 is a bitmap of debugging selectors. Two bits are identified for use in
53815 <function>local_scan()</function>; they are defined as macros:
53816 </para>
53817 <itemizedlist>
53818 <listitem>
53819 <para>
53820 The <literal>D_v</literal> bit is set when <option>-v</option> was present on the command line. This is a
53821 testing option that is not privileged &ndash; any caller may set it. All the
53822 other selector bits can be set only by admin users.
53823 </para>
53824 </listitem>
53825 <listitem>
53826 <para>
53827 The <literal>D_local_scan</literal> bit is provided for use by <function>local_scan()</function>; it is set
53828 by the <literal>+local_scan</literal> debug selector. It is not included in the default set
53829 of debugging bits.
53830 </para>
53831 </listitem>
53832 </itemizedlist>
53833 <para>
53834 Thus, to write to the debugging output only when <literal>+local_scan</literal> has been
53835 selected, you should use code like this:
53836 </para>
53837 <literallayout class="monospaced">
53838 if ((debug_selector &amp; D_local_scan) != 0)
53839   debug_printf("xxx", ...);
53840 </literallayout>
53841 </listitem></varlistentry>
53842 <varlistentry>
53843 <term><emphasis role="bold">uschar&nbsp;*expand_string_message</emphasis></term>
53844 <listitem>
53845 <para>
53846 After a failing call to <emphasis>expand_string()</emphasis> (returned value NULL), the
53847 variable <option>expand_string_message</option> contains the error message, zero-terminated.
53848 </para>
53849 </listitem></varlistentry>
53850 <varlistentry>
53851 <term><emphasis role="bold">header_line&nbsp;*header_list</emphasis></term>
53852 <listitem>
53853 <para>
53854 A pointer to a chain of header lines. The <option>header_line</option> structure is
53855 discussed below.
53856 </para>
53857 </listitem></varlistentry>
53858 <varlistentry>
53859 <term><emphasis role="bold">header_line&nbsp;*header_last</emphasis></term>
53860 <listitem>
53861 <para>
53862 A pointer to the last of the header lines.
53863 </para>
53864 </listitem></varlistentry>
53865 <varlistentry>
53866 <term><emphasis role="bold">uschar&nbsp;*headers_charset</emphasis></term>
53867 <listitem>
53868 <para>
53869 The value of the <option>headers_charset</option> configuration option.
53870 </para>
53871 </listitem></varlistentry>
53872 <varlistentry>
53873 <term><emphasis role="bold">BOOL&nbsp;host_checking</emphasis></term>
53874 <listitem>
53875 <para>
53876 This variable is TRUE during a host checking session that is initiated by the
53877 <option>-bh</option> command line option.
53878 </para>
53879 </listitem></varlistentry>
53880 <varlistentry>
53881 <term><emphasis role="bold">uschar&nbsp;*interface_address</emphasis></term>
53882 <listitem>
53883 <para>
53884 The IP address of the interface that received the message, as a string. This
53885 is NULL for locally submitted messages.
53886 </para>
53887 </listitem></varlistentry>
53888 <varlistentry>
53889 <term><emphasis role="bold">int&nbsp;interface_port</emphasis></term>
53890 <listitem>
53891 <para>
53892 The port on which this message was received. When testing with the <option>-bh</option>
53893 command line option, the value of this variable is -1 unless a port has been
53894 specified via the <option>-oMi</option> option.
53895 </para>
53896 </listitem></varlistentry>
53897 <varlistentry>
53898 <term><emphasis role="bold">uschar&nbsp;*message_id</emphasis></term>
53899 <listitem>
53900 <para>
53901 This variable contains Exim&#x2019;s message id for the incoming message (the value of
53902 <varname>$message_exim_id</varname>) as a zero-terminated string.
53903 </para>
53904 </listitem></varlistentry>
53905 <varlistentry>
53906 <term><emphasis role="bold">uschar&nbsp;*received_protocol</emphasis></term>
53907 <listitem>
53908 <para>
53909 The name of the protocol by which the message was received.
53910 </para>
53911 </listitem></varlistentry>
53912 <varlistentry>
53913 <term><emphasis role="bold">int&nbsp;recipients_count</emphasis></term>
53914 <listitem>
53915 <para>
53916 The number of accepted recipients.
53917 </para>
53918 </listitem></varlistentry>
53919 <varlistentry>
53920 <term><emphasis role="bold">recipient_item&nbsp;*recipients_list</emphasis></term>
53921 <listitem>
53922 <para>
53923 <indexterm role="concept">
53924 <primary>recipient</primary>
53925 <secondary>adding in local scan</secondary>
53926 </indexterm>
53927 <indexterm role="concept">
53928 <primary>recipient</primary>
53929 <secondary>removing in local scan</secondary>
53930 </indexterm>
53931 The list of accepted recipients, held in a vector of length
53932 <option>recipients_count</option>. The <option>recipient_item</option> structure is discussed below. You
53933 can add additional recipients by calling <emphasis>receive_add_recipient()</emphasis> (see
53934 below). You can delete recipients by removing them from the vector and
53935 adjusting the value in <option>recipients_count</option>. In particular, by setting
53936 <option>recipients_count</option> to zero you remove all recipients. If you then return the
53937 value <literal>LOCAL_SCAN_ACCEPT</literal>, the message is accepted, but immediately
53938 blackholed. To replace the recipients, you can set <option>recipients_count</option> to zero
53939 and then call <emphasis>receive_add_recipient()</emphasis> as often as needed.
53940 </para>
53941 </listitem></varlistentry>
53942 <varlistentry>
53943 <term><emphasis role="bold">uschar&nbsp;*sender_address</emphasis></term>
53944 <listitem>
53945 <para>
53946 The envelope sender address. For bounce messages this is the empty string.
53947 </para>
53948 </listitem></varlistentry>
53949 <varlistentry>
53950 <term><emphasis role="bold">uschar&nbsp;*sender_host_address</emphasis></term>
53951 <listitem>
53952 <para>
53953 The IP address of the sending host, as a string. This is NULL for
53954 locally-submitted messages.
53955 </para>
53956 </listitem></varlistentry>
53957 <varlistentry>
53958 <term><emphasis role="bold">uschar&nbsp;*sender_host_authenticated</emphasis></term>
53959 <listitem>
53960 <para>
53961 The name of the authentication mechanism that was used, or NULL if the message
53962 was not received over an authenticated SMTP connection.
53963 </para>
53964 </listitem></varlistentry>
53965 <varlistentry>
53966 <term><emphasis role="bold">uschar&nbsp;*sender_host_name</emphasis></term>
53967 <listitem>
53968 <para>
53969 The name of the sending host, if known.
53970 </para>
53971 </listitem></varlistentry>
53972 <varlistentry>
53973 <term><emphasis role="bold">int&nbsp;sender_host_port</emphasis></term>
53974 <listitem>
53975 <para>
53976 The port on the sending host.
53977 </para>
53978 </listitem></varlistentry>
53979 <varlistentry>
53980 <term><emphasis role="bold">BOOL&nbsp;smtp_input</emphasis></term>
53981 <listitem>
53982 <para>
53983 This variable is TRUE for all SMTP input, including BSMTP.
53984 </para>
53985 </listitem></varlistentry>
53986 <varlistentry>
53987 <term><emphasis role="bold">BOOL&nbsp;smtp_batched_input</emphasis></term>
53988 <listitem>
53989 <para>
53990 This variable is TRUE for BSMTP input.
53991 </para>
53992 </listitem></varlistentry>
53993 <varlistentry>
53994 <term><emphasis role="bold">int&nbsp;store_pool</emphasis></term>
53995 <listitem>
53996 <para>
53997 The contents of this variable control which pool of memory is used for new
53998 requests. See section <xref linkend="SECTmemhanloc"/> for details.
53999 </para>
54000 </listitem></varlistentry>
54001 </variablelist>
54002 </section>
54003 <section id="SECID209">
54004 <title>Structure of header lines</title>
54005 <para>
54006 The <option>header_line</option> structure contains the members listed below.
54007 You can add additional header lines by calling the <emphasis>header_add()</emphasis> function
54008 (see below). You can cause header lines to be ignored (deleted) by setting
54009 their type to *.
54010 </para>
54011 <variablelist>
54012 <varlistentry>
54013 <term><emphasis role="bold">struct&nbsp;header_line&nbsp;*next</emphasis></term>
54014 <listitem>
54015 <para>
54016 A pointer to the next header line, or NULL for the last line.
54017 </para>
54018 </listitem></varlistentry>
54019 <varlistentry>
54020 <term><emphasis role="bold">int&nbsp;type</emphasis></term>
54021 <listitem>
54022 <para>
54023 A code identifying certain headers that Exim recognizes. The codes are printing
54024 characters, and are documented in chapter <xref linkend="CHAPspool"/> of this manual.
54025 Notice in particular that any header line whose type is * is not transmitted
54026 with the message. This flagging is used for header lines that have been
54027 rewritten, or are to be removed (for example, <emphasis>Envelope-sender:</emphasis> header
54028 lines.) Effectively, * means <quote>deleted</quote>.
54029 </para>
54030 </listitem></varlistentry>
54031 <varlistentry>
54032 <term><emphasis role="bold">int&nbsp;slen</emphasis></term>
54033 <listitem>
54034 <para>
54035 The number of characters in the header line, including the terminating and any
54036 internal newlines.
54037 </para>
54038 </listitem></varlistentry>
54039 <varlistentry>
54040 <term><emphasis role="bold">uschar&nbsp;*text</emphasis></term>
54041 <listitem>
54042 <para>
54043 A pointer to the text of the header. It always ends with a newline, followed by
54044 a zero byte. Internal newlines are preserved.
54045 </para>
54046 </listitem></varlistentry>
54047 </variablelist>
54048 </section>
54049 <section id="SECID210">
54050 <title>Structure of recipient items</title>
54051 <para>
54052 The <option>recipient_item</option> structure contains these members:
54053 </para>
54054 <variablelist>
54055 <varlistentry>
54056 <term><emphasis role="bold">uschar&nbsp;*address</emphasis></term>
54057 <listitem>
54058 <para>
54059 This is a pointer to the recipient address as it was received.
54060 </para>
54061 </listitem></varlistentry>
54062 <varlistentry>
54063 <term><emphasis role="bold">int&nbsp;pno</emphasis></term>
54064 <listitem>
54065 <para>
54066 This is used in later Exim processing when top level addresses are created by
54067 the <option>one_time</option> option. It is not relevant at the time <function>local_scan()</function> is run
54068 and must always contain -1 at this stage.
54069 </para>
54070 </listitem></varlistentry>
54071 <varlistentry>
54072 <term><emphasis role="bold">uschar&nbsp;*errors_to</emphasis></term>
54073 <listitem>
54074 <para>
54075 If this value is not NULL, bounce messages caused by failing to deliver to the
54076 recipient are sent to the address it contains. In other words, it overrides the
54077 envelope sender for this one recipient. (Compare the <option>errors_to</option> generic
54078 router option.) If a <function>local_scan()</function> function sets an <option>errors_to</option> field to
54079 an unqualified address, Exim qualifies it using the domain from
54080 <option>qualify_recipient</option>. When <function>local_scan()</function> is called, the <option>errors_to</option> field
54081 is NULL for all recipients.
54082 </para>
54083 </listitem></varlistentry>
54084 </variablelist>
54085 </section>
54086 <section id="SECID211">
54087 <title>Available Exim functions</title>
54088 <para>
54089 <indexterm role="concept">
54090 <primary><function>local_scan()</function> function</primary>
54091 <secondary>available Exim functions</secondary>
54092 </indexterm>
54093 The header <filename>local_scan.h</filename> gives you access to a number of Exim functions.
54094 These are the only ones that are guaranteed to be maintained from release to
54095 release:
54096 </para>
54097 <variablelist>
54098 <varlistentry>
54099 <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>
54100 <listitem>
54101 <para>
54102 This function creates a child process that runs the command specified by
54103 <option>argv</option>. The environment for the process is specified by <option>envp</option>, which can
54104 be NULL if no environment variables are to be passed. A new umask is supplied
54105 for the process in <option>newumask</option>.
54106 </para>
54107 <para>
54108 Pipes to the standard input and output of the new process are set up
54109 and returned to the caller via the <option>infdptr</option> and <option>outfdptr</option> arguments. The
54110 standard error is cloned to the standard output. If there are any file
54111 descriptors <quote>in the way</quote> in the new process, they are closed. If the final
54112 argument is TRUE, the new process is made into a process group leader.
54113 </para>
54114 <para>
54115 The function returns the pid of the new process, or -1 if things go wrong.
54116 </para>
54117 </listitem></varlistentry>
54118 <varlistentry>
54119 <term><emphasis role="bold">int&nbsp;child_close(pid_t&nbsp;pid,&nbsp;int&nbsp;timeout)</emphasis></term>
54120 <listitem>
54121 <para>
54122 This function waits for a child process to terminate, or for a timeout (in
54123 seconds) to expire. A timeout value of zero means wait as long as it takes. The
54124 return value is as follows:
54125 </para>
54126 <itemizedlist>
54127 <listitem>
54128 <para>
54129 &gt;= 0
54130 </para>
54131 <para>
54132 The process terminated by a normal exit and the value is the process
54133 ending status.
54134 </para>
54135 </listitem>
54136 <listitem>
54137 <para>
54138 &lt; 0 and &gt; &ndash;256
54139 </para>
54140 <para>
54141 The process was terminated by a signal and the value is the negation of the
54142 signal number.
54143 </para>
54144 </listitem>
54145 <listitem>
54146 <para>
54147 &ndash;256
54148 </para>
54149 <para>
54150 The process timed out.
54151 </para>
54152 </listitem>
54153 <listitem>
54154 <para>
54155 &ndash;257
54156 </para>
54157 <para>
54158 The was some other error in wait(); <option>errno</option> is still set.
54159 </para>
54160 </listitem>
54161 </itemizedlist>
54162 </listitem></varlistentry>
54163 <varlistentry>
54164 <term><emphasis role="bold">pid_t&nbsp;child_open_exim(int&nbsp;*fd)</emphasis></term>
54165 <listitem>
54166 <para>
54167 This function provide you with a means of submitting a new message to
54168 Exim. (Of course, you can also call <filename>/usr/sbin/sendmail</filename> yourself if you
54169 want, but this packages it all up for you.) The function creates a pipe,
54170 forks a subprocess that is running
54171 </para>
54172 <literallayout class="monospaced">
54173 exim -t -oem -oi -f &lt;&gt;
54174 </literallayout>
54175 <para>
54176 and returns to you (via the <literal>int *</literal> argument) a file descriptor for the pipe
54177 that is connected to the standard input. The yield of the function is the PID
54178 of the subprocess. You can then write a message to the file descriptor, with
54179 recipients in <emphasis>To:</emphasis>, <emphasis>Cc:</emphasis>, and/or <emphasis>Bcc:</emphasis> header lines.
54180 </para>
54181 <para>
54182 When you have finished, call <emphasis>child_close()</emphasis> to wait for the process to
54183 finish and to collect its ending status. A timeout value of zero is usually
54184 fine in this circumstance. Unless you have made a mistake with the recipient
54185 addresses, you should get a return code of zero.
54186 </para>
54187 </listitem></varlistentry>
54188 <varlistentry>
54189 <term><emphasis role="bold">pid_t&nbsp;child_open_exim2(int&nbsp;*fd,&nbsp;uschar&nbsp;*sender,&nbsp;uschar&nbsp;*sender_authentication)</emphasis></term>
54190 <listitem>
54191 <para>
54192 This function is a more sophisticated version of <emphasis>child_open()</emphasis>. The command
54193 that it runs is:
54194 </para>
54195 <literallayout>
54196 <literal>exim -t -oem -oi -f </literal><emphasis>sender</emphasis><literal> -oMas </literal><emphasis>sender_authentication</emphasis>
54197 </literallayout>
54198 <para>
54199 The third argument may be NULL, in which case the <option>-oMas</option> option is omitted.
54200 </para>
54201 </listitem></varlistentry>
54202 <varlistentry>
54203 <term><emphasis role="bold">void&nbsp;debug_printf(char&nbsp;*,&nbsp;...)</emphasis></term>
54204 <listitem>
54205 <para>
54206 This is Exim&#x2019;s debugging function, with arguments as for <emphasis>(printf()</emphasis>. The
54207 output is written to the standard error stream. If no debugging is selected,
54208 calls to <emphasis>debug_printf()</emphasis> have no effect. Normally, you should make calls
54209 conditional on the <literal>local_scan</literal> debug selector by coding like this:
54210 </para>
54211 <literallayout class="monospaced">
54212 if ((debug_selector &amp; D_local_scan) != 0)
54213   debug_printf("xxx", ...);
54214 </literallayout>
54215 </listitem></varlistentry>
54216 <varlistentry>
54217 <term><emphasis role="bold">uschar&nbsp;*expand_string(uschar&nbsp;*string)</emphasis></term>
54218 <listitem>
54219 <para>
54220 This is an interface to Exim&#x2019;s string expansion code. The return value is the
54221 expanded string, or NULL if there was an expansion failure.
54222 The C variable <option>expand_string_message</option> contains an error message after an
54223 expansion failure. If expansion does not change the string, the return value is
54224 the pointer to the input string. Otherwise, the return value points to a new
54225 block of memory that was obtained by a call to <emphasis>store_get()</emphasis>. See section
54226 <xref linkend="SECTmemhanloc"/> below for a discussion of memory handling.
54227 </para>
54228 </listitem></varlistentry>
54229 <varlistentry>
54230 <term><emphasis role="bold">void&nbsp;header_add(int&nbsp;type,&nbsp;char&nbsp;*format,&nbsp;...)</emphasis></term>
54231 <listitem>
54232 <para>
54233 This function allows you to an add additional header line at the end of the
54234 existing ones. The first argument is the type, and should normally be a space
54235 character. The second argument is a format string and any number of
54236 substitution arguments as for <function>sprintf()</function>. You may include internal newlines
54237 if you want, and you must ensure that the string ends with a newline.
54238 </para>
54239 </listitem></varlistentry>
54240 <varlistentry>
54241 <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>
54242 <listitem>
54243 <para>
54244 This function adds a new header line at a specified point in the header
54245 chain. The header itself is specified as for <emphasis>header_add()</emphasis>.
54246 </para>
54247 <para>
54248 If <option>name</option> is NULL, the new header is added at the end of the chain if
54249 <option>after</option> is true, or at the start if <option>after</option> is false. If <option>name</option> is not
54250 NULL, the header lines are searched for the first non-deleted header that
54251 matches the name. If one is found, the new header is added before it if
54252 <option>after</option> is false. If <option>after</option> is true, the new header is added after the
54253 found header and any adjacent subsequent ones with the same name (even if
54254 marked <quote>deleted</quote>). If no matching non-deleted header is found, the <option>topnot</option>
54255 option controls where the header is added. If it is true, addition is at the
54256 top; otherwise at the bottom. Thus, to add a header after all the <emphasis>Received:</emphasis>
54257 headers, or at the top if there are no <emphasis>Received:</emphasis> headers, you could use
54258 </para>
54259 <literallayout class="monospaced">
54260 header_add_at_position(TRUE, US"Received", TRUE,
54261   ' ', "X-xxx: ...");
54262 </literallayout>
54263 <para>
54264 Normally, there is always at least one non-deleted <emphasis>Received:</emphasis> header, but
54265 there may not be if <option>received_header_text</option> expands to an empty string.
54266 </para>
54267 </listitem></varlistentry>
54268 <varlistentry>
54269 <term><emphasis role="bold">void&nbsp;header_remove(int&nbsp;occurrence,&nbsp;uschar&nbsp;*name)</emphasis></term>
54270 <listitem>
54271 <para>
54272 This function removes header lines. If <option>occurrence</option> is zero or negative, all
54273 occurrences of the header are removed. If occurrence is greater than zero, that
54274 particular instance of the header is removed. If no header(s) can be found that
54275 match the specification, the function does nothing.
54276 </para>
54277 </listitem></varlistentry>
54278 <varlistentry>
54279 <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>
54280 <listitem>
54281 <para>
54282 This function tests whether the given header has the given name. It is not just
54283 a string comparison, because white space is permitted between the name and the
54284 colon. If the <option>notdel</option> argument is true, a false return is forced for all
54285 <quote>deleted</quote> headers; otherwise they are not treated specially. For example:
54286 </para>
54287 <literallayout class="monospaced">
54288 if (header_testname(h, US"X-Spam", 6, TRUE)) ...
54289 </literallayout>
54290 </listitem></varlistentry>
54291 <varlistentry>
54292 <term><emphasis role="bold">uschar&nbsp;*lss_b64encode(uschar&nbsp;*cleartext,&nbsp;int&nbsp;length)</emphasis></term>
54293 <listitem>
54294 <para>
54295 <indexterm role="concept">
54296 <primary>base64 encoding</primary>
54297 <secondary>functions for <function>local_scan()</function> use</secondary>
54298 </indexterm>
54299 This function base64-encodes a string, which is passed by address and length.
54300 The text may contain bytes of any value, including zero. The result is passed
54301 back in dynamic memory that is obtained by calling <emphasis>store_get()</emphasis>. It is
54302 zero-terminated.
54303 </para>
54304 </listitem></varlistentry>
54305 <varlistentry>
54306 <term><emphasis role="bold">int&nbsp;lss_b64decode(uschar&nbsp;*codetext,&nbsp;uschar&nbsp;**cleartext)</emphasis></term>
54307 <listitem>
54308 <para>
54309 This function decodes a base64-encoded string. Its arguments are a
54310 zero-terminated base64-encoded string and the address of a variable that is set
54311 to point to the result, which is in dynamic memory. The length of the decoded
54312 string is the yield of the function. If the input is invalid base64 data, the
54313 yield is -1. A zero byte is added to the end of the output string to make it
54314 easy to interpret as a C string (assuming it contains no zeros of its own). The
54315 added zero byte is not included in the returned count.
54316 </para>
54317 </listitem></varlistentry>
54318 <varlistentry>
54319 <term><emphasis role="bold">int&nbsp;lss_match_domain(uschar&nbsp;*domain,&nbsp;uschar&nbsp;*list)</emphasis></term>
54320 <listitem>
54321 <para>
54322 This function checks for a match in a domain list. Domains are always
54323 matched caselessly. The return value is one of the following:
54324 </para>
54325 <literallayout>
54326 <literal>OK     </literal> match succeeded
54327 <literal>FAIL   </literal> match failed
54328 <literal>DEFER  </literal> match deferred
54329 </literallayout>
54330 <para>
54331 DEFER is usually caused by some kind of lookup defer, such as the
54332 inability to contact a database.
54333 </para>
54334 </listitem></varlistentry>
54335 <varlistentry>
54336 <term><emphasis role="bold">int&nbsp;lss_match_local_part(uschar&nbsp;*localpart,&nbsp;uschar&nbsp;*list,&nbsp;BOOL&nbsp;caseless)</emphasis></term>
54337 <listitem>
54338 <para>
54339 This function checks for a match in a local part list. The third argument
54340 controls case-sensitivity. The return values are as for
54341 <emphasis>lss_match_domain()</emphasis>.
54342 </para>
54343 </listitem></varlistentry>
54344 <varlistentry>
54345 <term><emphasis role="bold">int&nbsp;lss_match_address(uschar&nbsp;*address,&nbsp;uschar&nbsp;*list,&nbsp;BOOL&nbsp;caseless)</emphasis></term>
54346 <listitem>
54347 <para>
54348 This function checks for a match in an address list. The third argument
54349 controls the case-sensitivity of the local part match. The domain is always
54350 matched caselessly. The return values are as for <emphasis>lss_match_domain()</emphasis>.
54351 </para>
54352 </listitem></varlistentry>
54353 <varlistentry>
54354 <term><emphasis role="bold">int&nbsp;lss_match_host(uschar&nbsp;*host_name,&nbsp;uschar&nbsp;*host_address,&nbsp;uschar&nbsp;*list)</emphasis></term>
54355 <listitem>
54356 <para>
54357 This function checks for a match in a host list. The most common usage is
54358 expected to be
54359 </para>
54360 <literallayout class="monospaced">
54361 lss_match_host(sender_host_name, sender_host_address, ...)
54362 </literallayout>
54363 <para>
54364 <indexterm role="variable">
54365 <primary><varname>$sender_host_address</varname></primary>
54366 </indexterm>
54367 An empty address field matches an empty item in the host list. If the host name
54368 is NULL, the name corresponding to <varname>$sender_host_address</varname> is automatically
54369 looked up if a host name is required to match an item in the list. The return
54370 values are as for <emphasis>lss_match_domain()</emphasis>, but in addition, <emphasis>lss_match_host()</emphasis>
54371 returns ERROR in the case when it had to look up a host name, but the lookup
54372 failed.
54373 </para>
54374 </listitem></varlistentry>
54375 <varlistentry>
54376 <term><emphasis role="bold">void&nbsp;log_write(unsigned&nbsp;int&nbsp;selector,&nbsp;int&nbsp;which,&nbsp;char&nbsp;*format,&nbsp;...)</emphasis></term>
54377 <listitem>
54378 <para>
54379 This function writes to Exim&#x2019;s log files. The first argument should be zero (it
54380 is concerned with <option>log_selector</option>). The second argument can be <literal>LOG_MAIN</literal> or
54381 <literal>LOG_REJECT</literal> or <literal>LOG_PANIC</literal> or the inclusive <quote>or</quote> of any combination of
54382 them. It specifies to which log or logs the message is written. The remaining
54383 arguments are a format and relevant insertion arguments. The string should not
54384 contain any newlines, not even at the end.
54385 </para>
54386 </listitem></varlistentry>
54387 <varlistentry>
54388 <term><emphasis role="bold">void&nbsp;receive_add_recipient(uschar&nbsp;*address,&nbsp;int&nbsp;pno)</emphasis></term>
54389 <listitem>
54390 <para>
54391 This function adds an additional recipient to the message. The first argument
54392 is the recipient address. If it is unqualified (has no domain), it is qualified
54393 with the <option>qualify_recipient</option> domain. The second argument must always be -1.
54394 </para>
54395 <para>
54396 This function does not allow you to specify a private <option>errors_to</option> address (as
54397 described with the structure of <option>recipient_item</option> above), because it pre-dates
54398 the addition of that field to the structure. However, it is easy to add such a
54399 value afterwards. For example:
54400 </para>
54401 <literallayout class="monospaced">
54402  receive_add_recipient(US"monitor@mydom.example", -1);
54403  recipients_list[recipients_count-1].errors_to =
54404    US"postmaster@mydom.example";
54405 </literallayout>
54406 </listitem></varlistentry>
54407 <varlistentry>
54408 <term><emphasis role="bold">BOOL&nbsp;receive_remove_recipient(uschar&nbsp;*recipient)</emphasis></term>
54409 <listitem>
54410 <para>
54411 This is a convenience function to remove a named recipient from the list of
54412 recipients. It returns true if a recipient was removed, and false if no
54413 matching recipient could be found. The argument must be a complete email
54414 address.
54415 </para>
54416 </listitem></varlistentry>
54417 </variablelist>
54418 <para>
54419 <indexterm role="concept">
54420 <primary>RFC 2047</primary>
54421 </indexterm>
54422 </para>
54423 <variablelist>
54424 <varlistentry>
54425 <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>
54426 <listitem>
54427 <para>
54428 This function decodes strings that are encoded according to RFC 2047. Typically
54429 these are the contents of header lines. First, each <quote>encoded word</quote> is decoded
54430 from the Q or B encoding into a byte-string. Then, if provided with the name of
54431 a charset encoding, and if the <function>iconv()</function> function is available, an attempt is
54432 made  to translate the result to the named character set. If this fails, the
54433 binary string is returned with an error message.
54434 </para>
54435 <para>
54436 The first argument is the string to be decoded. If <option>lencheck</option> is TRUE, the
54437 maximum MIME word length is enforced. The third argument is the target
54438 encoding, or NULL if no translation is wanted.
54439 </para>
54440 <para>
54441 <indexterm role="concept">
54442 <primary>binary zero</primary>
54443 <secondary>in RFC 2047 decoding</secondary>
54444 </indexterm>
54445 <indexterm role="concept">
54446 <primary>RFC 2047</primary>
54447 <secondary>binary zero in</secondary>
54448 </indexterm>
54449 If a binary zero is encountered in the decoded string, it is replaced by the
54450 contents of the <option>zeroval</option> argument. For use with Exim headers, the value must
54451 not be 0 because header lines are handled as zero-terminated strings.
54452 </para>
54453 <para>
54454 The function returns the result of processing the string, zero-terminated; if
54455 <option>lenptr</option> is not NULL, the length of the result is set in the variable to
54456 which it points. When <option>zeroval</option> is 0, <option>lenptr</option> should not be NULL.
54457 </para>
54458 <para>
54459 If an error is encountered, the function returns NULL and uses the <option>error</option>
54460 argument to return an error message. The variable pointed to by <option>error</option> is
54461 set to NULL if there is no error; it may be set non-NULL even when the function
54462 returns a non-NULL value if decoding was successful, but there was a problem
54463 with translation.
54464 </para>
54465 </listitem></varlistentry>
54466 <varlistentry>
54467 <term><emphasis role="bold">int&nbsp;smtp_fflush(void)</emphasis></term>
54468 <listitem>
54469 <para>
54470 This function is used in conjunction with <emphasis>smtp_printf()</emphasis>, as described
54471 below.
54472 </para>
54473 </listitem></varlistentry>
54474 <varlistentry>
54475 <term><emphasis role="bold">void&nbsp;smtp_printf(char&nbsp;*,&nbsp;...)</emphasis></term>
54476 <listitem>
54477 <para>
54478 The arguments of this function are like <function>printf()</function>; it writes to the SMTP
54479 output stream. You should use this function only when there is an SMTP output
54480 stream, that is, when the incoming message is being received via interactive
54481 SMTP. This is the case when <option>smtp_input</option> is TRUE and <option>smtp_batched_input</option>
54482 is FALSE. If you want to test for an incoming message from another host (as
54483 opposed to a local process that used the <option>-bs</option> command line option), you can
54484 test the value of <option>sender_host_address</option>, which is non-NULL when a remote host
54485 is involved.
54486 </para>
54487 <para>
54488 If an SMTP TLS connection is established, <emphasis>smtp_printf()</emphasis> uses the TLS
54489 output function, so it can be used for all forms of SMTP connection.
54490 </para>
54491 <para>
54492 Strings that are written by <emphasis>smtp_printf()</emphasis> from within <function>local_scan()</function>
54493 must start with an appropriate response code: 550 if you are going to return
54494 LOCAL_SCAN_REJECT, 451 if you are going to return
54495 LOCAL_SCAN_TEMPREJECT, and 250 otherwise. Because you are writing the
54496 initial lines of a multi-line response, the code must be followed by a hyphen
54497 to indicate that the line is not the final response line. You must also ensure
54498 that the lines you write terminate with CRLF. For example:
54499 </para>
54500 <literallayout class="monospaced">
54501 smtp_printf("550-this is some extra info\r\n");
54502 return LOCAL_SCAN_REJECT;
54503 </literallayout>
54504 <para>
54505 Note that you can also create multi-line responses by including newlines in
54506 the data returned via the <option>return_text</option> argument. The added value of using
54507 <emphasis>smtp_printf()</emphasis> is that, for instance, you could introduce delays between
54508 multiple output lines.
54509 </para>
54510 <para>
54511 The <emphasis>smtp_printf()</emphasis> function does not return any error indication, because it
54512 does not automatically flush pending output, and therefore does not test
54513 the state of the stream. (In the main code of Exim, flushing and error
54514 detection is done when Exim is ready for the next SMTP input command.) If
54515 you want to flush the output and check for an error (for example, the
54516 dropping of a TCP/IP connection), you can call <emphasis>smtp_fflush()</emphasis>, which has no
54517 arguments. It flushes the output stream, and returns a non-zero value if there
54518 is an error.
54519 </para>
54520 </listitem></varlistentry>
54521 <varlistentry>
54522 <term><emphasis role="bold">void&nbsp;*store_get(int)</emphasis></term>
54523 <listitem>
54524 <para>
54525 This function accesses Exim&#x2019;s internal store (memory) manager. It gets a new
54526 chunk of memory whose size is given by the argument. Exim bombs out if it ever
54527 runs out of memory. See the next section for a discussion of memory handling.
54528 </para>
54529 </listitem></varlistentry>
54530 <varlistentry>
54531 <term><emphasis role="bold">void&nbsp;*store_get_perm(int)</emphasis></term>
54532 <listitem>
54533 <para>
54534 This function is like <emphasis>store_get()</emphasis>, but it always gets memory from the
54535 permanent pool. See the next section for a discussion of memory handling.
54536 </para>
54537 </listitem></varlistentry>
54538 <varlistentry>
54539 <term><emphasis role="bold">uschar&nbsp;*string_copy(uschar&nbsp;*string)</emphasis></term>
54540 <listitem>
54541 <para>
54542 See below.
54543 </para>
54544 </listitem></varlistentry>
54545 <varlistentry>
54546 <term><emphasis role="bold">uschar&nbsp;*string_copyn(uschar&nbsp;*string,&nbsp;int&nbsp;length)</emphasis></term>
54547 <listitem>
54548 <para>
54549 See below.
54550 </para>
54551 </listitem></varlistentry>
54552 <varlistentry>
54553 <term><emphasis role="bold">uschar&nbsp;*string_sprintf(char&nbsp;*format,&nbsp;...)</emphasis></term>
54554 <listitem>
54555 <para>
54556 These three functions create strings using Exim&#x2019;s dynamic memory facilities.
54557 The first makes a copy of an entire string. The second copies up to a maximum
54558 number of characters, indicated by the second argument. The third uses a format
54559 and insertion arguments to create a new string. In each case, the result is a
54560 pointer to a new string in the current memory pool. See the next section for
54561 more discussion.
54562 </para>
54563 </listitem></varlistentry>
54564 </variablelist>
54565 </section>
54566 <section id="SECTmemhanloc">
54567 <title>More about Exim&#x2019;s memory handling</title>
54568 <para>
54569 <indexterm role="concept">
54570 <primary><function>local_scan()</function> function</primary>
54571 <secondary>memory handling</secondary>
54572 </indexterm>
54573 No function is provided for freeing memory, because that is never needed.
54574 The dynamic memory that Exim uses when receiving a message is automatically
54575 recycled if another message is received by the same process (this applies only
54576 to incoming SMTP connections &ndash; other input methods can supply only one
54577 message at a time). After receiving the last message, a reception process
54578 terminates.
54579 </para>
54580 <para>
54581 Because it is recycled, the normal dynamic memory cannot be used for holding
54582 data that must be preserved over a number of incoming messages on the same SMTP
54583 connection. However, Exim in fact uses two pools of dynamic memory; the second
54584 one is not recycled, and can be used for this purpose.
54585 </para>
54586 <para>
54587 If you want to allocate memory that remains available for subsequent messages
54588 in the same SMTP connection, you should set
54589 </para>
54590 <literallayout class="monospaced">
54591 store_pool = POOL_PERM
54592 </literallayout>
54593 <para>
54594 before calling the function that does the allocation. There is no need to
54595 restore the value if you do not need to; however, if you do want to revert to
54596 the normal pool, you can either restore the previous value of <option>store_pool</option> or
54597 set it explicitly to POOL_MAIN.
54598 </para>
54599 <para>
54600 The pool setting applies to all functions that get dynamic memory, including
54601 <emphasis>expand_string()</emphasis>, <emphasis>store_get()</emphasis>, and the <emphasis>string_xxx()</emphasis> functions.
54602 There is also a convenience function called <emphasis>store_get_perm()</emphasis> that gets a
54603 block of memory from the permanent pool while preserving the value of
54604 <option>store_pool</option>.
54605 <indexterm role="concept" startref="IIDlosca" class="endofrange"/>
54606 </para>
54607 </section>
54608 </chapter>
54609
54610 <chapter id="CHAPsystemfilter">
54611 <title>System-wide message filtering</title>
54612 <para>
54613 <indexterm role="concept" id="IIDsysfil1" class="startofrange">
54614 <primary>filter</primary>
54615 <secondary>system filter</secondary>
54616 </indexterm>
54617 <indexterm role="concept" id="IIDsysfil2" class="startofrange">
54618 <primary>filtering all mail</primary>
54619 </indexterm>
54620 <indexterm role="concept" id="IIDsysfil3" class="startofrange">
54621 <primary>system filter</primary>
54622 </indexterm>
54623 The previous chapters (on ACLs and the local scan function) describe checks
54624 that can be applied to messages before they are accepted by a host. There is
54625 also a mechanism for checking messages once they have been received, but before
54626 they are delivered. This is called the <emphasis>system filter</emphasis>.
54627 </para>
54628 <para>
54629 The system filter operates in a similar manner to users&#x2019; filter files, but it
54630 is run just once per message (however many recipients the message has).
54631 It should not normally be used as a substitute for routing, because <option>deliver</option>
54632 commands in a system router provide new envelope recipient addresses.
54633 The system filter must be an Exim filter. It cannot be a Sieve filter.
54634 </para>
54635 <para>
54636 The system filter is run at the start of a delivery attempt, before any routing
54637 is done. If a message fails to be completely delivered at the first attempt,
54638 the system filter is run again at the start of every retry.
54639 If you want your filter to do something only once per message, you can make use
54640 of the <option>first_delivery</option> condition in an <option>if</option> command in the filter to
54641 prevent it happening on retries.
54642 </para>
54643 <para>
54644 <indexterm role="variable">
54645 <primary><varname>$domain</varname></primary>
54646 </indexterm>
54647 <indexterm role="variable">
54648 <primary><varname>$local_part</varname></primary>
54649 </indexterm>
54650 <emphasis role="bold">Warning</emphasis>: Because the system filter runs just once, variables that are
54651 specific to individual recipient addresses, such as <varname>$local_part</varname> and
54652 <varname>$domain</varname>, are not set, and the <quote>personal</quote> condition is not meaningful. If
54653 you want to run a centrally-specified filter for each recipient address
54654 independently, you can do so by setting up a suitable <command>redirect</command> router, as
54655 described in section <xref linkend="SECTperaddfil"/> below.
54656 </para>
54657 <section id="SECID212">
54658 <title>Specifying a system filter</title>
54659 <para>
54660 <indexterm role="concept">
54661 <primary>uid (user id)</primary>
54662 <secondary>system filter</secondary>
54663 </indexterm>
54664 <indexterm role="concept">
54665 <primary>gid (group id)</primary>
54666 <secondary>system filter</secondary>
54667 </indexterm>
54668 The name of the file that contains the system filter must be specified by
54669 setting <option>system_filter</option>. If you want the filter to run under a uid and gid
54670 other than root, you must also set <option>system_filter_user</option> and
54671 <option>system_filter_group</option> as appropriate. For example:
54672 </para>
54673 <literallayout class="monospaced">
54674 system_filter = /etc/mail/exim.filter
54675 system_filter_user = exim
54676 </literallayout>
54677 <para>
54678 If a system filter generates any deliveries directly to files or pipes (via the
54679 <option>save</option> or <option>pipe</option> commands), transports to handle these deliveries must be
54680 specified by setting <option>system_filter_file_transport</option> and
54681 <option>system_filter_pipe_transport</option>, respectively. Similarly,
54682 <option>system_filter_reply_transport</option> must be set to handle any messages generated
54683 by the <option>reply</option> command.
54684 </para>
54685 </section>
54686 <section id="SECID213">
54687 <title>Testing a system filter</title>
54688 <para>
54689 You can run simple tests of a system filter in the same way as for a user
54690 filter, but you should use <option>-bF</option> rather than <option>-bf</option>, so that features that
54691 are permitted only in system filters are recognized.
54692 </para>
54693 <para>
54694 If you want to test the combined effect of a system filter and a user filter,
54695 you can use both <option>-bF</option> and <option>-bf</option> on the same command line.
54696 </para>
54697 </section>
54698 <section id="SECID214">
54699 <title>Contents of a system filter</title>
54700 <para>
54701 The language used to specify system filters is the same as for users&#x2019; filter
54702 files. It is described in the separate end-user document <emphasis>Exim&#x2019;s interface to
54703 mail filtering</emphasis>. However, there are some additional features that are
54704 available only in system filters; these are described in subsequent sections.
54705 If they are encountered in a user&#x2019;s filter file or when testing with <option>-bf</option>,
54706 they cause errors.
54707 </para>
54708 <para>
54709 <indexterm role="concept">
54710 <primary>frozen messages</primary>
54711 <secondary>manual thaw; testing in filter</secondary>
54712 </indexterm>
54713 There are two special conditions which, though available in users&#x2019; filter
54714 files, are designed for use in system filters. The condition <option>first_delivery</option>
54715 is true only for the first attempt at delivering a message, and
54716 <option>manually_thawed</option> is true only if the message has been frozen, and
54717 subsequently thawed by an admin user. An explicit forced delivery counts as a
54718 manual thaw, but thawing as a result of the <option>auto_thaw</option> setting does not.
54719 </para>
54720 <para>
54721 <emphasis role="bold">Warning</emphasis>: If a system filter uses the <option>first_delivery</option> condition to
54722 specify an <quote>unseen</quote> (non-significant) delivery, and that delivery does not
54723 succeed, it will not be tried again.
54724 If you want Exim to retry an unseen delivery until it succeeds, you should
54725 arrange to set it up every time the filter runs.
54726 </para>
54727 <para>
54728 When a system filter finishes running, the values of the variables <varname>$n0</varname> &ndash;
54729 <varname>$n9</varname> are copied into <varname>$sn0</varname> &ndash; <varname>$sn9</varname> and are thereby made available to
54730 users&#x2019; filter files. Thus a system filter can, for example, set up <quote>scores</quote>
54731 to which users&#x2019; filter files can refer.
54732 </para>
54733 </section>
54734 <section id="SECID215">
54735 <title>Additional variable for system filters</title>
54736 <para>
54737 <indexterm role="variable">
54738 <primary><varname>$recipients</varname></primary>
54739 </indexterm>
54740 The expansion variable <varname>$recipients</varname>, containing a list of all the recipients
54741 of the message (separated by commas and white space), is available in system
54742 filters. It is not available in users&#x2019; filters for privacy reasons.
54743 </para>
54744 </section>
54745 <section id="SECID216">
54746 <title>Defer, freeze, and fail commands for system filters</title>
54747 <para>
54748 <indexterm role="concept">
54749 <primary>freezing messages</primary>
54750 </indexterm>
54751 <indexterm role="concept">
54752 <primary>message</primary>
54753 <secondary>freezing</secondary>
54754 </indexterm>
54755 <indexterm role="concept">
54756 <primary>message</primary>
54757 <secondary>forced failure</secondary>
54758 </indexterm>
54759 <indexterm role="concept">
54760 <primary><option>fail</option></primary>
54761 <secondary>in system filter</secondary>
54762 </indexterm>
54763 <indexterm role="concept">
54764 <primary><option>freeze</option> in system filter</primary>
54765 </indexterm>
54766 <indexterm role="concept">
54767 <primary><option>defer</option> in system filter</primary>
54768 </indexterm>
54769 There are three extra commands (<option>defer</option>, <option>freeze</option> and <option>fail</option>) which are
54770 always available in system filters, but are not normally enabled in users&#x2019;
54771 filters. (See the <option>allow_defer</option>, <option>allow_freeze</option> and <option>allow_fail</option> options
54772 for the <command>redirect</command> router.) These commands can optionally be followed by the
54773 word <option>text</option> and a string containing an error message, for example:
54774 </para>
54775 <literallayout class="monospaced">
54776 fail text "this message looks like spam to me"
54777 </literallayout>
54778 <para>
54779 The keyword <option>text</option> is optional if the next character is a double quote.
54780 </para>
54781 <para>
54782 The <option>defer</option> command defers delivery of the original recipients of the
54783 message. The <option>fail</option> command causes all the original recipients to be failed,
54784 and a bounce message to be created. The <option>freeze</option> command suspends all
54785 delivery attempts for the original recipients. In all cases, any new deliveries
54786 that are specified by the filter are attempted as normal after the filter has
54787 run.
54788 </para>
54789 <para>
54790 The <option>freeze</option> command is ignored if the message has been manually unfrozen and
54791 not manually frozen since. This means that automatic freezing by a system
54792 filter can be used as a way of checking out suspicious messages. If a message
54793 is found to be all right, manually unfreezing it allows it to be delivered.
54794 </para>
54795 <para>
54796 <indexterm role="concept">
54797 <primary>log</primary>
54798 <secondary><option>fail</option> command log line</secondary>
54799 </indexterm>
54800 <indexterm role="concept">
54801 <primary><option>fail</option></primary>
54802 <secondary>log line; reducing</secondary>
54803 </indexterm>
54804 The text given with a fail command is used as part of the bounce message as
54805 well as being written to the log. If the message is quite long, this can fill
54806 up a lot of log space when such failures are common. To reduce the size of the
54807 log message, Exim interprets the text in a special way if it starts with the
54808 two characters <literal>&lt;&lt;</literal> and contains <literal>&gt;&gt;</literal> later. The text between these two
54809 strings is written to the log, and the rest of the text is used in the bounce
54810 message. For example:
54811 </para>
54812 <literallayout class="monospaced">
54813 fail "&lt;&lt;filter test 1&gt;&gt;Your message is rejected \
54814      because it contains attachments that we are \
54815      not prepared to receive."
54816 </literallayout>
54817 <para>
54818 <indexterm role="concept">
54819 <primary>loop</primary>
54820 <secondary>caused by <option>fail</option></secondary>
54821 </indexterm>
54822 Take great care with the <option>fail</option> command when basing the decision to fail on
54823 the contents of the message, because the bounce message will of course include
54824 the contents of the original message and will therefore trigger the <option>fail</option>
54825 command again (causing a mail loop) unless steps are taken to prevent this.
54826 Testing the <option>error_message</option> condition is one way to prevent this. You could
54827 use, for example
54828 </para>
54829 <literallayout class="monospaced">
54830 if $message_body contains "this is spam" and not error_message
54831 then fail text "spam is not wanted here" endif
54832 </literallayout>
54833 <para>
54834 though of course that might let through unwanted bounce messages. The
54835 alternative is clever checking of the body and/or headers to detect bounces
54836 generated by the filter.
54837 </para>
54838 <para>
54839 The interpretation of a system filter file ceases after a
54840 <option>defer</option>,
54841 <option>freeze</option>, or <option>fail</option> command is obeyed. However, any deliveries that were
54842 set up earlier in the filter file are honoured, so you can use a sequence such
54843 as
54844 </para>
54845 <literallayout class="monospaced">
54846 mail ...
54847 freeze
54848 </literallayout>
54849 <para>
54850 to send a specified message when the system filter is freezing (or deferring or
54851 failing) a message. The normal deliveries for the message do not, of course,
54852 take place.
54853 </para>
54854 </section>
54855 <section id="SECTaddremheasys">
54856 <title>Adding and removing headers in a system filter</title>
54857 <para>
54858 <indexterm role="concept">
54859 <primary>header lines</primary>
54860 <secondary>adding; in system filter</secondary>
54861 </indexterm>
54862 <indexterm role="concept">
54863 <primary>header lines</primary>
54864 <secondary>removing; in system filter</secondary>
54865 </indexterm>
54866 <indexterm role="concept">
54867 <primary>filter</primary>
54868 <secondary>header lines; adding/removing</secondary>
54869 </indexterm>
54870 Two filter commands that are available only in system filters are:
54871 </para>
54872 <literallayout class="monospaced">
54873 headers add &lt;string&gt;
54874 headers remove &lt;string&gt;
54875 </literallayout>
54876 <para>
54877 The argument for the <option>headers add</option> is a string that is expanded and then
54878 added to the end of the message&#x2019;s headers. It is the responsibility of the
54879 filter maintainer to make sure it conforms to RFC 2822 syntax. Leading white
54880 space is ignored, and if the string is otherwise empty, or if the expansion is
54881 forced to fail, the command has no effect.
54882 </para>
54883 <para>
54884 You can use <quote>\n</quote> within the string, followed by white space, to specify
54885 continued header lines. More than one header may be added in one command by
54886 including <quote>\n</quote> within the string without any following white space. For
54887 example:
54888 </para>
54889 <literallayout class="monospaced">
54890 headers add "X-header-1: ....\n  \
54891              continuation of X-header-1 ...\n\
54892              X-header-2: ...."
54893 </literallayout>
54894 <para>
54895 Note that the header line continuation white space after the first newline must
54896 be placed before the backslash that continues the input string, because white
54897 space after input continuations is ignored.
54898 </para>
54899 <para>
54900 The argument for <option>headers remove</option> is a colon-separated list of header names.
54901 This command applies only to those headers that are stored with the message;
54902 those that are added at delivery time (such as <emphasis>Envelope-To:</emphasis> and
54903 <emphasis>Return-Path:</emphasis>) cannot be removed by this means. If there is more than one
54904 header with the same name, they are all removed.
54905 </para>
54906 <para>
54907 The <option>headers</option> command in a system filter makes an immediate change to the set
54908 of header lines that was received with the message (with possible additions
54909 from ACL processing). Subsequent commands in the system filter operate on the
54910 modified set, which also forms the basis for subsequent message delivery.
54911 Unless further modified during routing or transporting, this set of headers is
54912 used for all recipients of the message.
54913 </para>
54914 <para>
54915 During routing and transporting, the variables that refer to the contents of
54916 header lines refer only to those lines that are in this set. Thus, header lines
54917 that are added by a system filter are visible to users&#x2019; filter files and to all
54918 routers and transports. This contrasts with the manipulation of header lines by
54919 routers and transports, which is not immediate, but which instead is saved up
54920 until the message is actually being written (see section
54921 <xref linkend="SECTheadersaddrem"/>).
54922 </para>
54923 <para>
54924 If the message is not delivered at the first attempt, header lines that were
54925 added by the system filter are stored with the message, and so are still
54926 present at the next delivery attempt. Header lines that were removed are still
54927 present, but marked <quote>deleted</quote> so that they are not transported with the
54928 message. For this reason, it is usual to make the <option>headers</option> command
54929 conditional on <option>first_delivery</option> so that the set of header lines is not
54930 modified more than once.
54931 </para>
54932 <para>
54933 Because header modification in a system filter acts immediately, you have to
54934 use an indirect approach if you want to modify the contents of a header line.
54935 For example:
54936 </para>
54937 <literallayout class="monospaced">
54938 headers add "Old-Subject: $h_subject:"
54939 headers remove "Subject"
54940 headers add "Subject: new subject (was: $h_old-subject:)"
54941 headers remove "Old-Subject"
54942 </literallayout>
54943 </section>
54944 <section id="SECID217">
54945 <title>Setting an errors address in a system filter</title>
54946 <para>
54947 <indexterm role="concept">
54948 <primary>envelope sender</primary>
54949 </indexterm>
54950 In a system filter, if a <option>deliver</option> command is followed by
54951 </para>
54952 <literallayout class="monospaced">
54953 errors_to &lt;some address&gt;
54954 </literallayout>
54955 <para>
54956 in order to change the envelope sender (and hence the error reporting) for that
54957 delivery, any address may be specified. (In a user filter, only the current
54958 user&#x2019;s address can be set.) For example, if some mail is being monitored, you
54959 might use
54960 </para>
54961 <literallayout class="monospaced">
54962 unseen deliver monitor@spying.example errors_to root@local.example
54963 </literallayout>
54964 <para>
54965 to take a copy which would not be sent back to the normal error reporting
54966 address if its delivery failed.
54967 </para>
54968 </section>
54969 <section id="SECTperaddfil">
54970 <title>Per-address filtering</title>
54971 <para>
54972 <indexterm role="variable">
54973 <primary><varname>$domain</varname></primary>
54974 </indexterm>
54975 <indexterm role="variable">
54976 <primary><varname>$local_part</varname></primary>
54977 </indexterm>
54978 In contrast to the system filter, which is run just once per message for each
54979 delivery attempt, it is also possible to set up a system-wide filtering
54980 operation that runs once for each recipient address. In this case, variables
54981 such as <varname>$local_part</varname> and <varname>$domain</varname> can be used, and indeed, the choice of
54982 filter file could be made dependent on them. This is an example of a router
54983 which implements such a filter:
54984 </para>
54985 <literallayout class="monospaced">
54986 central_filter:
54987   check_local_user
54988   driver = redirect
54989   domains = +local_domains
54990   file = /central/filters/$local_part
54991   no_verify
54992   allow_filter
54993   allow_freeze
54994 </literallayout>
54995 <para>
54996 The filter is run in a separate process under its own uid. Therefore, either
54997 <option>check_local_user</option> must be set (as above), in which case the filter is run as
54998 the local user, or the <option>user</option> option must be used to specify which user to
54999 use. If both are set, <option>user</option> overrides.
55000 </para>
55001 <para>
55002 Care should be taken to ensure that none of the commands in the filter file
55003 specify a significant delivery if the message is to go on to be delivered to
55004 its intended recipient. The router will not then claim to have dealt with the
55005 address, so it will be passed on to subsequent routers to be delivered in the
55006 normal way.
55007 <indexterm role="concept" startref="IIDsysfil1" class="endofrange"/>
55008 <indexterm role="concept" startref="IIDsysfil2" class="endofrange"/>
55009 <indexterm role="concept" startref="IIDsysfil3" class="endofrange"/>
55010 </para>
55011 </section>
55012 </chapter>
55013
55014 <chapter id="CHAPmsgproc">
55015 <title>Message processing</title>
55016 <para>
55017 <indexterm role="concept" id="IIDmesproc" class="startofrange">
55018 <primary>message</primary>
55019 <secondary>general processing</secondary>
55020 </indexterm>
55021 Exim performs various transformations on the sender and recipient addresses of
55022 all messages that it handles, and also on the messages&#x2019; header lines. Some of
55023 these are optional and configurable, while others always take place. All of
55024 this processing, except rewriting as a result of routing, and the addition or
55025 removal of header lines while delivering, happens when a message is received,
55026 before it is placed on Exim&#x2019;s queue.
55027 </para>
55028 <para>
55029 Some of the automatic processing takes place by default only for
55030 <quote>locally-originated</quote> messages. This adjective is used to describe messages
55031 that are not received over TCP/IP, but instead are passed to an Exim process on
55032 its standard input. This includes the interactive <quote>local SMTP</quote> case that is
55033 set up by the <option>-bs</option> command line option.
55034 </para>
55035 <para>
55036 <emphasis role="bold">Note</emphasis>: Messages received over TCP/IP on the loopback interface (127.0.0.1
55037 or ::1) are not considered to be locally-originated. Exim does not treat the
55038 loopback interface specially in any way.
55039 </para>
55040 <para>
55041 If you want the loopback interface to be treated specially, you must ensure
55042 that there are appropriate entries in your ACLs.
55043 </para>
55044 <section id="SECTsubmodnon">
55045 <title>Submission mode for non-local messages</title>
55046 <para>
55047 <indexterm role="concept">
55048 <primary>message</primary>
55049 <secondary>submission</secondary>
55050 </indexterm>
55051 <indexterm role="concept">
55052 <primary>submission mode</primary>
55053 </indexterm>
55054 Processing that happens automatically for locally-originated messages (unless
55055 <option>suppress_local_fixups</option> is set) can also be requested for messages that are
55056 received over TCP/IP. The term <quote>submission mode</quote> is used to describe this
55057 state. Submission mode is set by the modifier
55058 </para>
55059 <literallayout class="monospaced">
55060 control = submission
55061 </literallayout>
55062 <para>
55063 in a MAIL, RCPT, or pre-data ACL for an incoming message (see sections
55064 <xref linkend="SECTACLmodi"/> and <xref linkend="SECTcontrols"/>). This makes Exim treat the message as
55065 a local submission, and is normally used when the source of the message is
55066 known to be an MUA running on a client host (as opposed to an MTA). For
55067 example, to set submission mode for messages originating on the IPv4 loopback
55068 interface, you could include the following in the MAIL ACL:
55069 </para>
55070 <literallayout class="monospaced">
55071 warn  hosts = 127.0.0.1
55072       control = submission
55073 </literallayout>
55074 <para>
55075 <indexterm role="concept">
55076 <primary><option>sender_retain</option> submission option</primary>
55077 </indexterm>
55078 There are some options that can be used when setting submission mode. A slash
55079 is used to separate options. For example:
55080 </para>
55081 <literallayout class="monospaced">
55082 control = submission/sender_retain
55083 </literallayout>
55084 <para>
55085 Specifying <option>sender_retain</option> has the effect of setting <option>local_sender_retain</option>
55086 true and <option>local_from_check</option> false for the current incoming message. The first
55087 of these allows an existing <emphasis>Sender:</emphasis> header in the message to remain, and
55088 the second suppresses the check to ensure that <emphasis>From:</emphasis> matches the
55089 authenticated sender. With this setting, Exim still fixes up messages by adding
55090 <emphasis>Date:</emphasis> and <emphasis>Message-ID:</emphasis> header lines if they are missing, but makes no
55091 attempt to check sender authenticity in header lines.
55092 </para>
55093 <para>
55094 When <option>sender_retain</option> is not set, a submission mode setting may specify a
55095 domain to be used when generating a <emphasis>From:</emphasis> or <emphasis>Sender:</emphasis> header line. For
55096 example:
55097 </para>
55098 <literallayout class="monospaced">
55099 control = submission/domain=some.domain
55100 </literallayout>
55101 <para>
55102 The domain may be empty. How this value is used is described in sections
55103 <xref linkend="SECTthefrohea"/> and <xref linkend="SECTthesenhea"/>. There is also a <option>name</option> option
55104 that allows you to specify the user&#x2019;s full name for inclusion in a created
55105 <emphasis>Sender:</emphasis> or <emphasis>From:</emphasis> header line. For example:
55106 </para>
55107 <literallayout class="monospaced">
55108 accept authenticated = *
55109        control = submission/domain=wonderland.example/\
55110                             name=${lookup {$authenticated_id} \
55111                                    lsearch {/etc/exim/namelist}}
55112 </literallayout>
55113 <para>
55114 Because the name may contain any characters, including slashes, the <option>name</option>
55115 option must be given last. The remainder of the string is used as the name. For
55116 the example above, if <filename>/etc/exim/namelist</filename> contains:
55117 </para>
55118 <literallayout class="monospaced">
55119 bigegg:  Humpty Dumpty
55120 </literallayout>
55121 <para>
55122 then when the sender has authenticated as <emphasis>bigegg</emphasis>, the generated <emphasis>Sender:</emphasis>
55123 line would be:
55124 </para>
55125 <literallayout class="monospaced">
55126 Sender: Humpty Dumpty &lt;bigegg@wonderland.example&gt;
55127 </literallayout>
55128 <para>
55129 <indexterm role="concept">
55130 <primary>return path</primary>
55131 <secondary>in submission mode</secondary>
55132 </indexterm>
55133 By default, submission mode forces the return path to the same address as is
55134 used to create the <emphasis>Sender:</emphasis> header. However, if <option>sender_retain</option> is
55135 specified, the return path is also left unchanged.
55136 </para>
55137 <para>
55138 <emphasis role="bold">Note</emphasis>: The changes caused by submission mode take effect after the predata
55139 ACL. This means that any sender checks performed before the fix-ups use the
55140 untrusted sender address specified by the user, not the trusted sender address
55141 specified by submission mode. Although this might be slightly unexpected, it
55142 does mean that you can configure ACL checks to spot that a user is trying to
55143 spoof another&#x2019;s address.
55144 </para>
55145 </section>
55146 <section id="SECTlineendings">
55147 <title>Line endings</title>
55148 <para>
55149 <indexterm role="concept">
55150 <primary>line endings</primary>
55151 </indexterm>
55152 <indexterm role="concept">
55153 <primary>carriage return</primary>
55154 </indexterm>
55155 <indexterm role="concept">
55156 <primary>linefeed</primary>
55157 </indexterm>
55158 RFC 2821 specifies that CRLF (two characters: carriage-return, followed by
55159 linefeed) is the line ending for messages transmitted over the Internet using
55160 SMTP over TCP/IP. However, within individual operating systems, different
55161 conventions are used. For example, Unix-like systems use just LF, but others
55162 use CRLF or just CR.
55163 </para>
55164 <para>
55165 Exim was designed for Unix-like systems, and internally, it stores messages
55166 using the system&#x2019;s convention of a single LF as a line terminator. When
55167 receiving a message, all line endings are translated to this standard format.
55168 Originally, it was thought that programs that passed messages directly to an
55169 MTA within an operating system would use that system&#x2019;s convention. Experience
55170 has shown that this is not the case; for example, there are Unix applications
55171 that use CRLF in this circumstance. For this reason, and for compatibility with
55172 other MTAs, the way Exim handles line endings for all messages is now as
55173 follows:
55174 </para>
55175 <itemizedlist>
55176 <listitem>
55177 <para>
55178 LF not preceded by CR is treated as a line ending.
55179 </para>
55180 </listitem>
55181 <listitem>
55182 <para>
55183 CR is treated as a line ending; if it is immediately followed by LF, the LF
55184 is ignored.
55185 </para>
55186 </listitem>
55187 <listitem>
55188 <para>
55189 The sequence <quote>CR, dot, CR</quote> does not terminate an incoming SMTP message,
55190 nor a local message in the state where a line containing only a dot is a
55191 terminator.
55192 </para>
55193 </listitem>
55194 <listitem>
55195 <para>
55196 If a bare CR is encountered within a header line, an extra space is added after
55197 the line terminator so as not to end the header line. The reasoning behind this
55198 is that bare CRs in header lines are most likely either to be mistakes, or
55199 people trying to play silly games.
55200 </para>
55201 </listitem>
55202 <listitem>
55203 <para>
55204 If the first header line received in a message ends with CRLF, a subsequent
55205 bare LF in a header line is treated in the same way as a bare CR in a header
55206 line.
55207 </para>
55208 </listitem>
55209 </itemizedlist>
55210 </section>
55211 <section id="SECID218">
55212 <title>Unqualified addresses</title>
55213 <para>
55214 <indexterm role="concept">
55215 <primary>unqualified addresses</primary>
55216 </indexterm>
55217 <indexterm role="concept">
55218 <primary>address</primary>
55219 <secondary>qualification</secondary>
55220 </indexterm>
55221 By default, Exim expects every envelope address it receives from an external
55222 host to be fully qualified. Unqualified addresses cause negative responses to
55223 SMTP commands. However, because SMTP is used as a means of transporting
55224 messages from MUAs running on personal workstations, there is sometimes a
55225 requirement to accept unqualified addresses from specific hosts or IP networks.
55226 </para>
55227 <para>
55228 Exim has two options that separately control which hosts may send unqualified
55229 sender or recipient addresses in SMTP commands, namely
55230 <option>sender_unqualified_hosts</option> and <option>recipient_unqualified_hosts</option>. In both
55231 cases, if an unqualified address is accepted, it is qualified by adding the
55232 value of <option>qualify_domain</option> or <option>qualify_recipient</option>, as appropriate.
55233 </para>
55234 <para>
55235 <indexterm role="option">
55236 <primary><option>qualify_domain</option></primary>
55237 </indexterm>
55238 <indexterm role="option">
55239 <primary><option>qualify_recipient</option></primary>
55240 </indexterm>
55241 Unqualified addresses in header lines are automatically qualified for messages
55242 that are locally originated, unless the <option>-bnq</option> option is given on the command
55243 line. For messages received over SMTP, unqualified addresses in header lines
55244 are qualified only if unqualified addresses are permitted in SMTP commands. In
55245 other words, such qualification is also controlled by
55246 <option>sender_unqualified_hosts</option> and <option>recipient_unqualified_hosts</option>,
55247 </para>
55248 </section>
55249 <section id="SECID219">
55250 <title>The UUCP From line</title>
55251 <para>
55252 <indexterm role="concept">
55253 <primary><quote>From</quote> line</primary>
55254 </indexterm>
55255 <indexterm role="concept">
55256 <primary>UUCP</primary>
55257 <secondary><quote>From</quote> line</secondary>
55258 </indexterm>
55259 <indexterm role="concept">
55260 <primary>sender</primary>
55261 <secondary>address</secondary>
55262 </indexterm>
55263 <indexterm role="option">
55264 <primary><option>uucp_from_pattern</option></primary>
55265 </indexterm>
55266 <indexterm role="option">
55267 <primary><option>uucp_from_sender</option></primary>
55268 </indexterm>
55269 <indexterm role="concept">
55270 <primary>envelope sender</primary>
55271 </indexterm>
55272 <indexterm role="concept">
55273 <primary>Sendmail compatibility</primary>
55274 <secondary><quote>From</quote> line</secondary>
55275 </indexterm>
55276 Messages that have come from UUCP (and some other applications) often begin
55277 with a line containing the envelope sender and a timestamp, following the word
55278 <quote>From</quote>. Examples of two common formats are:
55279 </para>
55280 <literallayout class="monospaced">
55281 From a.oakley@berlin.mus Fri Jan  5 12:35 GMT 1996
55282 From f.butler@berlin.mus Fri, 7 Jan 97 14:00:00 GMT
55283 </literallayout>
55284 <para>
55285 This line precedes the RFC 2822 header lines. For compatibility with Sendmail,
55286 Exim recognizes such lines at the start of messages that are submitted to it
55287 via the command line (that is, on the standard input). It does not recognize
55288 such lines in incoming SMTP messages, unless the sending host matches
55289 <option>ignore_fromline_hosts</option> or the <option>-bs</option> option was used for a local message
55290 and <option>ignore_fromline_local</option> is set. The recognition is controlled by a
55291 regular expression that is defined by the <option>uucp_from_pattern</option> option, whose
55292 default value matches the two common cases shown above and puts the address
55293 that follows <quote>From</quote> into <varname>$1</varname>.
55294 </para>
55295 <para>
55296 <indexterm role="concept">
55297 <primary>numerical variables (<varname>$1</varname> <varname>$2</varname> etc)</primary>
55298 <secondary>in <quote>From </quote> line handling</secondary>
55299 </indexterm>
55300 When the caller of Exim for a non-SMTP message that contains a <quote>From</quote> line is
55301 a trusted user, the message&#x2019;s sender address is constructed by expanding the
55302 contents of <option>uucp_sender_address</option>, whose default value is <quote>$1</quote>. This is
55303 then parsed as an RFC 2822 address. If there is no domain, the local part is
55304 qualified with <option>qualify_domain</option> unless it is the empty string. However, if
55305 the command line <option>-f</option> option is used, it overrides the <quote>From</quote> line.
55306 </para>
55307 <para>
55308 If the caller of Exim is not trusted, the <quote>From</quote> line is recognized, but the
55309 sender address is not changed. This is also the case for incoming SMTP messages
55310 that are permitted to contain <quote>From</quote> lines.
55311 </para>
55312 <para>
55313 Only one <quote>From</quote> line is recognized. If there is more than one, the second is
55314 treated as a data line that starts the body of the message, as it is not valid
55315 as a header line. This also happens if a <quote>From</quote> line is present in an
55316 incoming SMTP message from a source that is not permitted to send them.
55317 </para>
55318 </section>
55319 <section id="SECID220">
55320 <title>Resent- header lines</title>
55321 <para>
55322 <indexterm role="concept">
55323 <primary><option>Resent-</option> header lines</primary>
55324 </indexterm>
55325 RFC 2822 makes provision for sets of header lines starting with the string
55326 <literal>Resent-</literal> to be added to a message when it is resent by the original
55327 recipient to somebody else. These headers are <emphasis>Resent-Date:</emphasis>,
55328 <emphasis>Resent-From:</emphasis>, <emphasis>Resent-Sender:</emphasis>, <emphasis>Resent-To:</emphasis>, <emphasis>Resent-Cc:</emphasis>,
55329 <emphasis>Resent-Bcc:</emphasis> and <emphasis>Resent-Message-ID:</emphasis>. The RFC says:
55330 </para>
55331 <blockquote>
55332 <para>
55333 <emphasis>Resent fields are strictly informational. They MUST NOT be used in the normal
55334 processing of replies or other such automatic actions on messages.</emphasis>
55335 </para>
55336 </blockquote>
55337 <para>
55338 This leaves things a bit vague as far as other processing actions such as
55339 address rewriting are concerned. Exim treats <option>Resent-</option> header lines as
55340 follows:
55341 </para>
55342 <itemizedlist>
55343 <listitem>
55344 <para>
55345 A <emphasis>Resent-From:</emphasis> line that just contains the login id of the submitting user
55346 is automatically rewritten in the same way as <emphasis>From:</emphasis> (see below).
55347 </para>
55348 </listitem>
55349 <listitem>
55350 <para>
55351 If there&#x2019;s a rewriting rule for a particular header line, it is also applied to
55352 <option>Resent-</option> header lines of the same type. For example, a rule that rewrites
55353 <emphasis>From:</emphasis> also rewrites <emphasis>Resent-From:</emphasis>.
55354 </para>
55355 </listitem>
55356 <listitem>
55357 <para>
55358 For local messages, if <emphasis>Sender:</emphasis> is removed on input, <emphasis>Resent-Sender:</emphasis> is
55359 also removed.
55360 </para>
55361 </listitem>
55362 <listitem>
55363 <para>
55364 For a locally-submitted message,
55365 if there are any <option>Resent-</option> header lines but no <emphasis>Resent-Date:</emphasis>,
55366 <emphasis>Resent-From:</emphasis>, or <emphasis>Resent-Message-Id:</emphasis>, they are added as necessary. It is
55367 the contents of <emphasis>Resent-Message-Id:</emphasis> (rather than <emphasis>Message-Id:</emphasis>) which are
55368 included in log lines in this case.
55369 </para>
55370 </listitem>
55371 <listitem>
55372 <para>
55373 The logic for adding <emphasis>Sender:</emphasis> is duplicated for <emphasis>Resent-Sender:</emphasis> when any
55374 <option>Resent-</option> header lines are present.
55375 </para>
55376 </listitem>
55377 </itemizedlist>
55378 </section>
55379 <section id="SECID221">
55380 <title>The Auto-Submitted: header line</title>
55381 <para>
55382 Whenever Exim generates an autoreply, a bounce, or a delay warning message, it
55383 includes the header line:
55384 </para>
55385 <literallayout class="monospaced">
55386 Auto-Submitted: auto-replied
55387 </literallayout>
55388 </section>
55389 <section id="SECID222">
55390 <title>The Bcc: header line</title>
55391 <para>
55392 <indexterm role="concept">
55393 <primary><emphasis>Bcc:</emphasis> header line</primary>
55394 </indexterm>
55395 If Exim is called with the <option>-t</option> option, to take recipient addresses from a
55396 message&#x2019;s header, it removes any <emphasis>Bcc:</emphasis> header line that may exist (after
55397 extracting its addresses). If <option>-t</option> is not present on the command line, any
55398 existing <emphasis>Bcc:</emphasis> is not removed.
55399 </para>
55400 </section>
55401 <section id="SECID223">
55402 <title>The Date: header line</title>
55403 <para>
55404 <indexterm role="concept">
55405 <primary><emphasis>Date:</emphasis> header line</primary>
55406 </indexterm>
55407 If a locally-generated or submission-mode message has no <emphasis>Date:</emphasis> header line,
55408 Exim adds one, using the current date and time, unless the
55409 <option>suppress_local_fixups</option> control has been specified.
55410 </para>
55411 </section>
55412 <section id="SECID224">
55413 <title>The Delivery-date: header line</title>
55414 <para>
55415 <indexterm role="concept">
55416 <primary><emphasis>Delivery-date:</emphasis> header line</primary>
55417 </indexterm>
55418 <indexterm role="option">
55419 <primary><option>delivery_date_remove</option></primary>
55420 </indexterm>
55421 <emphasis>Delivery-date:</emphasis> header lines are not part of the standard RFC 2822 header
55422 set. Exim can be configured to add them to the final delivery of messages. (See
55423 the generic <option>delivery_date_add</option> transport option.) They should not be present
55424 in messages in transit. If the <option>delivery_date_remove</option> configuration option is
55425 set (the default), Exim removes <emphasis>Delivery-date:</emphasis> header lines from incoming
55426 messages.
55427 </para>
55428 </section>
55429 <section id="SECID225">
55430 <title>The Envelope-to: header line</title>
55431 <para>
55432 <indexterm role="concept">
55433 <primary><emphasis>Envelope-to:</emphasis> header line</primary>
55434 </indexterm>
55435 <indexterm role="option">
55436 <primary><option>envelope_to_remove</option></primary>
55437 </indexterm>
55438 <emphasis>Envelope-to:</emphasis> header lines are not part of the standard RFC 2822 header set.
55439 Exim can be configured to add them to the final delivery of messages. (See the
55440 generic <option>envelope_to_add</option> transport option.) They should not be present in
55441 messages in transit. If the <option>envelope_to_remove</option> configuration option is set
55442 (the default), Exim removes <emphasis>Envelope-to:</emphasis> header lines from incoming
55443 messages.
55444 </para>
55445 </section>
55446 <section id="SECTthefrohea">
55447 <title>The From: header line</title>
55448 <para>
55449 <indexterm role="concept">
55450 <primary><emphasis>From:</emphasis> header line</primary>
55451 </indexterm>
55452 <indexterm role="concept">
55453 <primary>Sendmail compatibility</primary>
55454 <secondary><quote>From</quote> line</secondary>
55455 </indexterm>
55456 <indexterm role="concept">
55457 <primary>message</primary>
55458 <secondary>submission</secondary>
55459 </indexterm>
55460 <indexterm role="concept">
55461 <primary>submission mode</primary>
55462 </indexterm>
55463 If a submission-mode message does not contain a <emphasis>From:</emphasis> header line, Exim
55464 adds one if either of the following conditions is true:
55465 </para>
55466 <itemizedlist>
55467 <listitem>
55468 <para>
55469 The envelope sender address is not empty (that is, this is not a bounce
55470 message). The added header line copies the envelope sender address.
55471 </para>
55472 </listitem>
55473 <listitem>
55474 <para>
55475 <indexterm role="variable">
55476 <primary><varname>$authenticated_id</varname></primary>
55477 </indexterm>
55478 The SMTP session is authenticated and <varname>$authenticated_id</varname> is not empty.
55479 </para>
55480 <orderedlist numeration="arabic">
55481 <listitem>
55482 <para>
55483 <indexterm role="variable">
55484 <primary><varname>$qualify_domain</varname></primary>
55485 </indexterm>
55486 If no domain is specified by the submission control, the local part is
55487 <varname>$authenticated_id</varname> and the domain is <varname>$qualify_domain</varname>.
55488 </para>
55489 </listitem>
55490 <listitem>
55491 <para>
55492 If a non-empty domain is specified by the submission control, the local
55493 part is <varname>$authenticated_id</varname>, and the domain is the specified domain.
55494 </para>
55495 </listitem>
55496 <listitem>
55497 <para>
55498 If an empty domain is specified by the submission control,
55499 <varname>$authenticated_id</varname> is assumed to be the complete address.
55500 </para>
55501 </listitem>
55502 </orderedlist>
55503 </listitem>
55504 </itemizedlist>
55505 <para>
55506 A non-empty envelope sender takes precedence.
55507 </para>
55508 <para>
55509 If a locally-generated incoming message does not contain a <emphasis>From:</emphasis> header
55510 line, and the <option>suppress_local_fixups</option> control is not set, Exim adds one
55511 containing the sender&#x2019;s address. The calling user&#x2019;s login name and full name
55512 are used to construct the address, as described in section <xref linkend="SECTconstr"/>.
55513 They are obtained from the password data by calling <function>getpwuid()</function> (but see the
55514 <option>unknown_login</option> configuration option). The address is qualified with
55515 <option>qualify_domain</option>.
55516 </para>
55517 <para>
55518 For compatibility with Sendmail, if an incoming, non-SMTP message has a
55519 <emphasis>From:</emphasis> header line containing just the unqualified login name of the calling
55520 user, this is replaced by an address containing the user&#x2019;s login name and full
55521 name as described in section <xref linkend="SECTconstr"/>.
55522 </para>
55523 </section>
55524 <section id="SECID226">
55525 <title>The Message-ID: header line</title>
55526 <para>
55527 <indexterm role="concept">
55528 <primary><emphasis>Message-ID:</emphasis> header line</primary>
55529 </indexterm>
55530 <indexterm role="concept">
55531 <primary>message</primary>
55532 <secondary>submission</secondary>
55533 </indexterm>
55534 <indexterm role="option">
55535 <primary><option>message_id_header_text</option></primary>
55536 </indexterm>
55537 If a locally-generated or submission-mode incoming message does not contain a
55538 <emphasis>Message-ID:</emphasis> or <emphasis>Resent-Message-ID:</emphasis> header line, and the
55539 <option>suppress_local_fixups</option> control is not set, Exim adds a suitable header line
55540 to the message. If there are any <emphasis>Resent-:</emphasis> headers in the message, it
55541 creates <emphasis>Resent-Message-ID:</emphasis>. The id is constructed from Exim&#x2019;s internal
55542 message id, preceded by the letter E to ensure it starts with a letter, and
55543 followed by @ and the primary host name. Additional information can be included
55544 in this header line by setting the <option>message_id_header_text</option> and/or
55545 <option>message_id_header_domain</option> options.
55546 </para>
55547 </section>
55548 <section id="SECID227">
55549 <title>The Received: header line</title>
55550 <para>
55551 <indexterm role="concept">
55552 <primary><emphasis>Received:</emphasis> header line</primary>
55553 </indexterm>
55554 A <emphasis>Received:</emphasis> header line is added at the start of every message. The
55555 contents are defined by the <option>received_header_text</option> configuration option, and
55556 Exim automatically adds a semicolon and a timestamp to the configured string.
55557 </para>
55558 <para>
55559 The <emphasis>Received:</emphasis> header is generated as soon as the message&#x2019;s header lines
55560 have been received. At this stage, the timestamp in the <emphasis>Received:</emphasis> header
55561 line is the time that the message started to be received. This is the value
55562 that is seen by the DATA ACL and by the <function>local_scan()</function> function.
55563 </para>
55564 <para>
55565 Once a message is accepted, the timestamp in the <emphasis>Received:</emphasis> header line is
55566 changed to the time of acceptance, which is (apart from a small delay while the
55567 -H spool file is written) the earliest time at which delivery could start.
55568 </para>
55569 </section>
55570 <section id="SECID228">
55571 <title>The References: header line</title>
55572 <para>
55573 <indexterm role="concept">
55574 <primary><emphasis>References:</emphasis> header line</primary>
55575 </indexterm>
55576 Messages created by the <command>autoreply</command> transport include a <emphasis>References:</emphasis>
55577 header line. This is constructed according to the rules that are described in
55578 section 3.64 of RFC 2822 (which states that replies should contain such a
55579 header line), and section 3.14 of RFC 3834 (which states that automatic
55580 responses are not different in this respect). However, because some mail
55581 processing software does not cope well with very long header lines, no more
55582 than 12 message IDs are copied from the <emphasis>References:</emphasis> header line in the
55583 incoming message. If there are more than 12, the first one and then the final
55584 11 are copied, before adding the message ID of the incoming message.
55585 </para>
55586 </section>
55587 <section id="SECID229">
55588 <title>The Return-path: header line</title>
55589 <para>
55590 <indexterm role="concept">
55591 <primary><emphasis>Return-path:</emphasis> header line</primary>
55592 </indexterm>
55593 <indexterm role="option">
55594 <primary><option>return_path_remove</option></primary>
55595 </indexterm>
55596 <emphasis>Return-path:</emphasis> header lines are defined as something an MTA may insert when
55597 it does the final delivery of messages. (See the generic <option>return_path_add</option>
55598 transport option.) Therefore, they should not be present in messages in
55599 transit. If the <option>return_path_remove</option> configuration option is set (the
55600 default), Exim removes <emphasis>Return-path:</emphasis> header lines from incoming messages.
55601 </para>
55602 </section>
55603 <section id="SECTthesenhea">
55604 <title>The Sender: header line</title>
55605 <para>
55606 <indexterm role="concept">
55607 <primary><emphasis>Sender:</emphasis> header line</primary>
55608 </indexterm>
55609 <indexterm role="concept">
55610 <primary>message</primary>
55611 <secondary>submission</secondary>
55612 </indexterm>
55613 For a locally-originated message from an untrusted user, Exim may remove an
55614 existing <emphasis>Sender:</emphasis> header line, and it may add a new one. You can modify
55615 these actions by setting the <option>local_sender_retain</option> option true, the
55616 <option>local_from_check</option> option false, or by using the <option>suppress_local_fixups</option>
55617 control setting.
55618 </para>
55619 <para>
55620 When a local message is received from an untrusted user and
55621 <option>local_from_check</option> is true (the default), and the <option>suppress_local_fixups</option>
55622 control has not been set, a check is made to see if the address given in the
55623 <emphasis>From:</emphasis> header line is the correct (local) sender of the message. The address
55624 that is expected has the login name as the local part and the value of
55625 <option>qualify_domain</option> as the domain. Prefixes and suffixes for the local part can
55626 be permitted by setting <option>local_from_prefix</option> and <option>local_from_suffix</option>
55627 appropriately. If <emphasis>From:</emphasis> does not contain the correct sender, a <emphasis>Sender:</emphasis>
55628 line is added to the message.
55629 </para>
55630 <para>
55631 If you set <option>local_from_check</option> false, this checking does not occur. However,
55632 the removal of an existing <emphasis>Sender:</emphasis> line still happens, unless you also set
55633 <option>local_sender_retain</option> to be true. It is not possible to set both of these
55634 options true at the same time.
55635 </para>
55636 <para>
55637 <indexterm role="concept">
55638 <primary>submission mode</primary>
55639 </indexterm>
55640 By default, no processing of <emphasis>Sender:</emphasis> header lines is done for messages
55641 received over TCP/IP or for messages submitted by trusted users. However, when
55642 a message is received over TCP/IP in submission mode, and <option>sender_retain</option> is
55643 not specified on the submission control, the following processing takes place:
55644 </para>
55645 <para>
55646 <indexterm role="variable">
55647 <primary><varname>$authenticated_id</varname></primary>
55648 </indexterm>
55649 First, any existing <emphasis>Sender:</emphasis> lines are removed. Then, if the SMTP session is
55650 authenticated, and <varname>$authenticated_id</varname> is not empty, a sender address is
55651 created as follows:
55652 </para>
55653 <itemizedlist>
55654 <listitem>
55655 <para>
55656 <indexterm role="variable">
55657 <primary><varname>$qualify_domain</varname></primary>
55658 </indexterm>
55659 If no domain is specified by the submission control, the local part is
55660 <varname>$authenticated_id</varname> and the domain is <varname>$qualify_domain</varname>.
55661 </para>
55662 </listitem>
55663 <listitem>
55664 <para>
55665 If a non-empty domain is specified by the submission control, the local part
55666 is <varname>$authenticated_id</varname>, and the domain is the specified domain.
55667 </para>
55668 </listitem>
55669 <listitem>
55670 <para>
55671 If an empty domain is specified by the submission control,
55672 <varname>$authenticated_id</varname> is assumed to be the complete address.
55673 </para>
55674 </listitem>
55675 </itemizedlist>
55676 <para>
55677 This address is compared with the address in the <emphasis>From:</emphasis> header line. If they
55678 are different, a <emphasis>Sender:</emphasis> header line containing the created address is
55679 added. Prefixes and suffixes for the local part in <emphasis>From:</emphasis> can be permitted
55680 by setting <option>local_from_prefix</option> and <option>local_from_suffix</option> appropriately.
55681 </para>
55682 <para>
55683 <indexterm role="concept">
55684 <primary>return path</primary>
55685 <secondary>created from <emphasis>Sender:</emphasis></secondary>
55686 </indexterm>
55687 <emphasis role="bold">Note</emphasis>: Whenever a <emphasis>Sender:</emphasis> header line is created, the return path for
55688 the message (the envelope sender address) is changed to be the same address,
55689 except in the case of submission mode when <option>sender_retain</option> is specified.
55690 </para>
55691 </section>
55692 <section id="SECTheadersaddrem">
55693 <title>Adding and removing header lines in routers and transports</title>
55694 <para>
55695 <indexterm role="concept">
55696 <primary>header lines</primary>
55697 <secondary>adding; in router or transport</secondary>
55698 </indexterm>
55699 <indexterm role="concept">
55700 <primary>header lines</primary>
55701 <secondary>removing; in router or transport</secondary>
55702 </indexterm>
55703 When a message is delivered, the addition and removal of header lines can be
55704 specified in a system filter, or on any of the routers and transports that
55705 process the message. Section <xref linkend="SECTaddremheasys"/> contains details about
55706 modifying headers in a system filter. Header lines can also be added in an ACL
55707 as a message is received (see section <xref linkend="SECTaddheadacl"/>).
55708 </para>
55709 <para>
55710 In contrast to what happens in a system filter, header modifications that are
55711 specified on routers and transports apply only to the particular recipient
55712 addresses that are being processed by those routers and transports. These
55713 changes do not actually take place until a copy of the message is being
55714 transported. Therefore, they do not affect the basic set of header lines, and
55715 they do not affect the values of the variables that refer to header lines.
55716 </para>
55717 <para>
55718 <emphasis role="bold">Note</emphasis>: In particular, this means that any expansions in the configuration of
55719 the transport cannot refer to the modified header lines, because such
55720 expansions all occur before the message is actually transported.
55721 </para>
55722 <para>
55723 For both routers and transports, the result of expanding a <option>headers_add</option>
55724 option must be in the form of one or more RFC 2822 header lines, separated by
55725 newlines (coded as <quote>\n</quote>). For example:
55726 </para>
55727 <literallayout class="monospaced">
55728 headers_add = X-added-header: added by $primary_hostname\n\
55729               X-added-second: another added header line
55730 </literallayout>
55731 <para>
55732 Exim does not check the syntax of these added header lines.
55733 </para>
55734 <para>
55735 The result of expanding <option>headers_remove</option> must consist of a colon-separated
55736 list of header names. This is confusing, because header names themselves are
55737 often terminated by colons. In this case, the colons are the list separators,
55738 not part of the names. For example:
55739 </para>
55740 <literallayout class="monospaced">
55741 headers_remove = return-receipt-to:acknowledge-to
55742 </literallayout>
55743 <para>
55744 When <option>headers_add</option> or <option>headers_remove</option> is specified on a router, its value
55745 is expanded at routing time, and then associated with all addresses that are
55746 accepted by that router, and also with any new addresses that it generates. If
55747 an address passes through several routers as a result of aliasing or
55748 forwarding, the changes are cumulative.
55749 </para>
55750 <para>
55751 <indexterm role="option">
55752 <primary><option>unseen</option></primary>
55753 </indexterm>
55754 However, this does not apply to multiple routers that result from the use of
55755 the <option>unseen</option> option. Any header modifications that were specified by the
55756 <quote>unseen</quote> router or its predecessors apply only to the <quote>unseen</quote> delivery.
55757 </para>
55758 <para>
55759 Addresses that end up with different <option>headers_add</option> or <option>headers_remove</option>
55760 settings cannot be delivered together in a batch, so a transport is always
55761 dealing with a set of addresses that have the same header-processing
55762 requirements.
55763 </para>
55764 <para>
55765 The transport starts by writing the original set of header lines that arrived
55766 with the message, possibly modified by the system filter. As it writes out
55767 these lines, it consults the list of header names that were attached to the
55768 recipient address(es) by <option>headers_remove</option> options in routers, and it also
55769 consults the transport&#x2019;s own <option>headers_remove</option> option. Header lines whose
55770 names are on either of these lists are not written out. If there are multiple
55771 instances of any listed header, they are all skipped.
55772 </para>
55773 <para>
55774 After the remaining original header lines have been written, new header
55775 lines that were specified by routers&#x2019; <option>headers_add</option> options are written, in
55776 the order in which they were attached to the address. These are followed by any
55777 header lines specified by the transport&#x2019;s <option>headers_add</option> option.
55778 </para>
55779 <para>
55780 This way of handling header line modifications in routers and transports has
55781 the following consequences:
55782 </para>
55783 <itemizedlist>
55784 <listitem>
55785 <para>
55786 The original set of header lines, possibly modified by the system filter,
55787 remains <quote>visible</quote>, in the sense that the <varname>$header_</varname><emphasis>xxx</emphasis> variables refer
55788 to it, at all times.
55789 </para>
55790 </listitem>
55791 <listitem>
55792 <para>
55793 Header lines that are added by a router&#x2019;s
55794 <option>headers_add</option> option are not accessible by means of the <varname>$header_</varname><emphasis>xxx</emphasis>
55795 expansion syntax in subsequent routers or the transport.
55796 </para>
55797 </listitem>
55798 <listitem>
55799 <para>
55800 Conversely, header lines that are specified for removal by <option>headers_remove</option>
55801 in a router remain visible to subsequent routers and the transport.
55802 </para>
55803 </listitem>
55804 <listitem>
55805 <para>
55806 Headers added to an address by <option>headers_add</option> in a router cannot be removed by
55807 a later router or by a transport.
55808 </para>
55809 </listitem>
55810 <listitem>
55811 <para>
55812 An added header can refer to the contents of an original header that is to be
55813 removed, even it has the same name as the added header. For example:
55814 </para>
55815 <literallayout class="monospaced">
55816 headers_remove = subject
55817 headers_add = Subject: new subject (was: $h_subject:)
55818 </literallayout>
55819 </listitem>
55820 </itemizedlist>
55821 <para>
55822 <emphasis role="bold">Warning</emphasis>: The <option>headers_add</option> and <option>headers_remove</option> options cannot be used
55823 for a <command>redirect</command> router that has the <option>one_time</option> option set.
55824 </para>
55825 </section>
55826 <section id="SECTconstr">
55827 <title>Constructed addresses</title>
55828 <para>
55829 <indexterm role="concept">
55830 <primary>address</primary>
55831 <secondary>constructed</secondary>
55832 </indexterm>
55833 <indexterm role="concept">
55834 <primary>constructed address</primary>
55835 </indexterm>
55836 When Exim constructs a sender address for a locally-generated message, it uses
55837 the form
55838 </para>
55839 <literallayout>
55840 &lt;<emphasis>user name</emphasis>&gt;&nbsp;&nbsp;&lt;<emphasis>login</emphasis><literal>@</literal><emphasis>qualify_domain</emphasis>&gt;
55841 </literallayout>
55842 <para>
55843 For example:
55844 </para>
55845 <literallayout class="monospaced">
55846 Zaphod Beeblebrox &lt;zaphod@end.univ.example&gt;
55847 </literallayout>
55848 <para>
55849 The user name is obtained from the <option>-F</option> command line option if set, or
55850 otherwise by looking up the calling user by <function>getpwuid()</function> and extracting the
55851 <quote>gecos</quote> field from the password entry. If the <quote>gecos</quote> field contains an
55852 ampersand character, this is replaced by the login name with the first letter
55853 upper cased, as is conventional in a number of operating systems. See the
55854 <option>gecos_name</option> option for a way to tailor the handling of the <quote>gecos</quote> field.
55855 The <option>unknown_username</option> option can be used to specify user names in cases when
55856 there is no password file entry.
55857 </para>
55858 <para>
55859 <indexterm role="concept">
55860 <primary>RFC 2047</primary>
55861 </indexterm>
55862 In all cases, the user name is made to conform to RFC 2822 by quoting all or
55863 parts of it if necessary. In addition, if it contains any non-printing
55864 characters, it is encoded as described in RFC 2047, which defines a way of
55865 including non-ASCII characters in header lines. The value of the
55866 <option>headers_charset</option> option specifies the name of the encoding that is used (the
55867 characters are assumed to be in this encoding). The setting of
55868 <option>print_topbitchars</option> controls whether characters with the top bit set (that
55869 is, with codes greater than 127) count as printing characters or not.
55870 </para>
55871 </section>
55872 <section id="SECID230">
55873 <title>Case of local parts</title>
55874 <para>
55875 <indexterm role="concept">
55876 <primary>case of local parts</primary>
55877 </indexterm>
55878 <indexterm role="concept">
55879 <primary>local part</primary>
55880 <secondary>case of</secondary>
55881 </indexterm>
55882 RFC 2822 states that the case of letters in the local parts of addresses cannot
55883 be assumed to be non-significant. Exim preserves the case of local parts of
55884 addresses, but by default it uses a lower-cased form when it is routing,
55885 because on most Unix systems, usernames are in lower case and case-insensitive
55886 routing is required. However, any particular router can be made to use the
55887 original case for local parts by setting the <option>caseful_local_part</option> generic
55888 router option.
55889 </para>
55890 <para>
55891 <indexterm role="concept">
55892 <primary>mixed-case login names</primary>
55893 </indexterm>
55894 If you must have mixed-case user names on your system, the best way to proceed,
55895 assuming you want case-independent handling of incoming email, is to set up
55896 your first router to convert incoming local parts in your domains to the
55897 correct case by means of a file lookup. For example:
55898 </para>
55899 <literallayout class="monospaced">
55900 correct_case:
55901   driver = redirect
55902   domains = +local_domains
55903   data = ${lookup{$local_part}cdb\
55904               {/etc/usercased.cdb}{$value}fail}\
55905               @$domain
55906 </literallayout>
55907 <para>
55908 For this router, the local part is forced to lower case by the default action
55909 (<option>caseful_local_part</option> is not set). The lower-cased local part is used to look
55910 up a new local part in the correct case. If you then set <option>caseful_local_part</option>
55911 on any subsequent routers which process your domains, they will operate on
55912 local parts with the correct case in a case-sensitive manner.
55913 </para>
55914 </section>
55915 <section id="SECID231">
55916 <title>Dots in local parts</title>
55917 <para>
55918 <indexterm role="concept">
55919 <primary>dot</primary>
55920 <secondary>in local part</secondary>
55921 </indexterm>
55922 <indexterm role="concept">
55923 <primary>local part</primary>
55924 <secondary>dots in</secondary>
55925 </indexterm>
55926 RFC 2822 forbids empty components in local parts. That is, an unquoted local
55927 part may not begin or end with a dot, nor have two consecutive dots in the
55928 middle. However, it seems that many MTAs do not enforce this, so Exim permits
55929 empty components for compatibility.
55930 </para>
55931 </section>
55932 <section id="SECID232">
55933 <title>Rewriting addresses</title>
55934 <para>
55935 <indexterm role="concept">
55936 <primary>rewriting</primary>
55937 <secondary>addresses</secondary>
55938 </indexterm>
55939 Rewriting of sender and recipient addresses, and addresses in headers, can
55940 happen automatically, or as the result of configuration options, as described
55941 in chapter <xref linkend="CHAPrewrite"/>. The headers that may be affected by this are
55942 <emphasis>Bcc:</emphasis>, <emphasis>Cc:</emphasis>, <emphasis>From:</emphasis>, <emphasis>Reply-To:</emphasis>, <emphasis>Sender:</emphasis>, and <emphasis>To:</emphasis>.
55943 </para>
55944 <para>
55945 Automatic rewriting includes qualification, as mentioned above. The other case
55946 in which it can happen is when an incomplete non-local domain is given. The
55947 routing process may cause this to be expanded into the full domain name. For
55948 example, a header such as
55949 </para>
55950 <literallayout class="monospaced">
55951 To: hare@teaparty
55952 </literallayout>
55953 <para>
55954 might get rewritten as
55955 </para>
55956 <literallayout class="monospaced">
55957 To: hare@teaparty.wonderland.fict.example
55958 </literallayout>
55959 <para>
55960 Rewriting as a result of routing is the one kind of message processing that
55961 does not happen at input time, as it cannot be done until the address has
55962 been routed.
55963 </para>
55964 <para>
55965 Strictly, one should not do <emphasis>any</emphasis> deliveries of a message until all its
55966 addresses have been routed, in case any of the headers get changed as a
55967 result of routing. However, doing this in practice would hold up many
55968 deliveries for unreasonable amounts of time, just because one address could not
55969 immediately be routed. Exim therefore does not delay other deliveries when
55970 routing of one or more addresses is deferred.
55971 <indexterm role="concept" startref="IIDmesproc" class="endofrange"/>
55972 </para>
55973 </section>
55974 </chapter>
55975
55976 <chapter id="CHAPSMTP">
55977 <title>SMTP processing</title>
55978 <para>
55979 <indexterm role="concept" id="IIDsmtpproc1" class="startofrange">
55980 <primary>SMTP</primary>
55981 <secondary>processing details</secondary>
55982 </indexterm>
55983 <indexterm role="concept" id="IIDsmtpproc2" class="startofrange">
55984 <primary>LMTP</primary>
55985 <secondary>processing details</secondary>
55986 </indexterm>
55987 Exim supports a number of different ways of using the SMTP protocol, and its
55988 LMTP variant, which is an interactive protocol for transferring messages into a
55989 closed mail store application. This chapter contains details of how SMTP is
55990 processed. For incoming mail, the following are available:
55991 </para>
55992 <itemizedlist>
55993 <listitem>
55994 <para>
55995 SMTP over TCP/IP (Exim daemon or <emphasis>inetd</emphasis>);
55996 </para>
55997 </listitem>
55998 <listitem>
55999 <para>
56000 SMTP over the standard input and output (the <option>-bs</option> option);
56001 </para>
56002 </listitem>
56003 <listitem>
56004 <para>
56005 Batched SMTP on the standard input (the <option>-bS</option> option).
56006 </para>
56007 </listitem>
56008 </itemizedlist>
56009 <para>
56010 For mail delivery, the following are available:
56011 </para>
56012 <itemizedlist>
56013 <listitem>
56014 <para>
56015 SMTP over TCP/IP (the <command>smtp</command> transport);
56016 </para>
56017 </listitem>
56018 <listitem>
56019 <para>
56020 LMTP over TCP/IP (the <command>smtp</command> transport with the <option>protocol</option> option set to
56021 <quote>lmtp</quote>);
56022 </para>
56023 </listitem>
56024 <listitem>
56025 <para>
56026 LMTP over a pipe to a process running in the local host (the <command>lmtp</command>
56027 transport);
56028 </para>
56029 </listitem>
56030 <listitem>
56031 <para>
56032 Batched SMTP to a file or pipe (the <command>appendfile</command> and <command>pipe</command> transports with
56033 the <option>use_bsmtp</option> option set).
56034 </para>
56035 </listitem>
56036 </itemizedlist>
56037 <para>
56038 <emphasis>Batched SMTP</emphasis> is the name for a process in which batches of messages are
56039 stored in or read from files (or pipes), in a format in which SMTP commands are
56040 used to contain the envelope information.
56041 </para>
56042 <section id="SECToutSMTPTCP">
56043 <title>Outgoing SMTP and LMTP over TCP/IP</title>
56044 <para>
56045 <indexterm role="concept">
56046 <primary>SMTP</primary>
56047 <secondary>outgoing over TCP/IP</secondary>
56048 </indexterm>
56049 <indexterm role="concept">
56050 <primary>outgoing SMTP over TCP/IP</primary>
56051 </indexterm>
56052 <indexterm role="concept">
56053 <primary>LMTP</primary>
56054 <secondary>over TCP/IP</secondary>
56055 </indexterm>
56056 <indexterm role="concept">
56057 <primary>outgoing LMTP over TCP/IP</primary>
56058 </indexterm>
56059 <indexterm role="concept">
56060 <primary>EHLO</primary>
56061 </indexterm>
56062 <indexterm role="concept">
56063 <primary>HELO</primary>
56064 </indexterm>
56065 <indexterm role="concept">
56066 <primary>SIZE option on MAIL command</primary>
56067 </indexterm>
56068 Outgoing SMTP and LMTP over TCP/IP is implemented by the <command>smtp</command> transport.
56069 The <option>protocol</option> option selects which protocol is to be used, but the actual
56070 processing is the same in both cases.
56071 </para>
56072 <para>
56073 If, in response to its EHLO command, Exim is told that the SIZE
56074 parameter is supported, it adds SIZE=&lt;<emphasis>n</emphasis>&gt; to each subsequent MAIL
56075 command. The value of &lt;<emphasis>n</emphasis>&gt; is the message size plus the value of the
56076 <option>size_addition</option> option (default 1024) to allow for additions to the message
56077 such as per-transport header lines, or changes made in a
56078 <indexterm role="concept">
56079 <primary>transport</primary>
56080 <secondary>filter</secondary>
56081 </indexterm>
56082 <indexterm role="concept">
56083 <primary>filter</primary>
56084 <secondary>transport filter</secondary>
56085 </indexterm>
56086 transport filter. If <option>size_addition</option> is set negative, the use of SIZE is
56087 suppressed.
56088 </para>
56089 <para>
56090 If the remote server advertises support for PIPELINING, Exim uses the
56091 pipelining extension to SMTP (RFC 2197) to reduce the number of TCP/IP packets
56092 required for the transaction.
56093 </para>
56094 <para>
56095 If the remote server advertises support for the STARTTLS command, and Exim
56096 was built to support TLS encryption, it tries to start a TLS session unless the
56097 server matches <option>hosts_avoid_tls</option>. See chapter <xref linkend="CHAPTLS"/> for more details.
56098 </para>
56099 <para>
56100 If the remote server advertises support for the AUTH command, Exim scans
56101 the authenticators configuration for any suitable client settings, as described
56102 in chapter <xref linkend="CHAPSMTPAUTH"/>.
56103 </para>
56104 <para>
56105 <indexterm role="concept">
56106 <primary>carriage return</primary>
56107 </indexterm>
56108 <indexterm role="concept">
56109 <primary>linefeed</primary>
56110 </indexterm>
56111 Responses from the remote host are supposed to be terminated by CR followed by
56112 LF. However, there are known to be hosts that do not send CR characters, so in
56113 order to be able to interwork with such hosts, Exim treats LF on its own as a
56114 line terminator.
56115 </para>
56116 <para>
56117 If a message contains a number of different addresses, all those with the same
56118 characteristics (for example, the same envelope sender) that resolve to the
56119 same set of hosts, in the same order, are sent in a single SMTP transaction,
56120 even if they are for different domains, unless there are more than the setting
56121 of the <option>max_rcpt</option>s option in the <command>smtp</command> transport allows, in which case
56122 they are split into groups containing no more than <option>max_rcpt</option>s addresses
56123 each. If <option>remote_max_parallel</option> is greater than one, such groups may be sent
56124 in parallel sessions. The order of hosts with identical MX values is not
56125 significant when checking whether addresses can be batched in this way.
56126 </para>
56127 <para>
56128 When the <command>smtp</command> transport suffers a temporary failure that is not
56129 message-related, Exim updates its transport-specific database, which contains
56130 records indexed by host name that remember which messages are waiting for each
56131 particular host. It also updates the retry database with new retry times.
56132 </para>
56133 <para>
56134 <indexterm role="concept">
56135 <primary>hints database</primary>
56136 <secondary>retry keys</secondary>
56137 </indexterm>
56138 Exim&#x2019;s retry hints are based on host name plus IP address, so if one address of
56139 a multi-homed host is broken, it will soon be skipped most of the time.
56140 See the next section for more detail about error handling.
56141 </para>
56142 <para>
56143 <indexterm role="concept">
56144 <primary>SMTP</primary>
56145 <secondary>passed connection</secondary>
56146 </indexterm>
56147 <indexterm role="concept">
56148 <primary>SMTP</primary>
56149 <secondary>batching over TCP/IP</secondary>
56150 </indexterm>
56151 When a message is successfully delivered over a TCP/IP SMTP connection, Exim
56152 looks in the hints database for the transport to see if there are any queued
56153 messages waiting for the host to which it is connected. If it finds one, it
56154 creates a new Exim process using the <option>-MC</option> option (which can only be used by
56155 a process running as root or the Exim user) and passes the TCP/IP socket to it
56156 so that it can deliver another message using the same socket. The new process
56157 does only those deliveries that are routed to the connected host, and may in
56158 turn pass the socket on to a third process, and so on.
56159 </para>
56160 <para>
56161 The <option>connection_max_messages</option> option of the <command>smtp</command> transport can be used to
56162 limit the number of messages sent down a single TCP/IP connection.
56163 </para>
56164 <para>
56165 <indexterm role="concept">
56166 <primary>asterisk</primary>
56167 <secondary>after IP address</secondary>
56168 </indexterm>
56169 The second and subsequent messages delivered down an existing connection are
56170 identified in the main log by the addition of an asterisk after the closing
56171 square bracket of the IP address.
56172 </para>
56173 </section>
56174 <section id="SECToutSMTPerr">
56175 <title>Errors in outgoing SMTP</title>
56176 <para>
56177 <indexterm role="concept">
56178 <primary>error</primary>
56179 <secondary>in outgoing SMTP</secondary>
56180 </indexterm>
56181 <indexterm role="concept">
56182 <primary>SMTP</primary>
56183 <secondary>errors in outgoing</secondary>
56184 </indexterm>
56185 <indexterm role="concept">
56186 <primary>host</primary>
56187 <secondary>error</secondary>
56188 </indexterm>
56189 Three different kinds of error are recognized for outgoing SMTP: host errors,
56190 message errors, and recipient errors.
56191 </para>
56192 <variablelist>
56193 <varlistentry>
56194 <term><emphasis role="bold">Host errors</emphasis></term>
56195 <listitem>
56196 <para>
56197 A host error is not associated with a particular message or with a
56198 particular recipient of a message. The host errors are:
56199 </para>
56200 <itemizedlist>
56201 <listitem>
56202 <para>
56203 Connection refused or timed out,
56204 </para>
56205 </listitem>
56206 <listitem>
56207 <para>
56208 Any error response code on connection,
56209 </para>
56210 </listitem>
56211 <listitem>
56212 <para>
56213 Any error response code to EHLO or HELO,
56214 </para>
56215 </listitem>
56216 <listitem>
56217 <para>
56218 Loss of connection at any time, except after <quote>.</quote>,
56219 </para>
56220 </listitem>
56221 <listitem>
56222 <para>
56223 I/O errors at any time,
56224 </para>
56225 </listitem>
56226 <listitem>
56227 <para>
56228 Timeouts during the session, other than in response to MAIL, RCPT or
56229 the <quote>.</quote> at the end of the data.
56230 </para>
56231 </listitem>
56232 </itemizedlist>
56233 <para>
56234 For a host error, a permanent error response on connection, or in response to
56235 EHLO, causes all addresses routed to the host to be failed. Any other host
56236 error causes all addresses to be deferred, and retry data to be created for the
56237 host. It is not tried again, for any message, until its retry time arrives. If
56238 the current set of addresses are not all delivered in this run (to some
56239 alternative host), the message is added to the list of those waiting for this
56240 host, so if it is still undelivered when a subsequent successful delivery is
56241 made to the host, it will be sent down the same SMTP connection.
56242 </para>
56243 </listitem></varlistentry>
56244 <varlistentry>
56245 <term><emphasis role="bold">Message errors</emphasis></term>
56246 <listitem>
56247 <para>
56248 <indexterm role="concept">
56249 <primary>message</primary>
56250 <secondary>error</secondary>
56251 </indexterm>
56252 A message error is associated with a particular message when sent to a
56253 particular host, but not with a particular recipient of the message. The
56254 message errors are:
56255 </para>
56256 <itemizedlist>
56257 <listitem>
56258 <para>
56259 Any error response code to MAIL, DATA, or the <quote>.</quote> that terminates
56260 the data,
56261 </para>
56262 </listitem>
56263 <listitem>
56264 <para>
56265 Timeout after MAIL,
56266 </para>
56267 </listitem>
56268 <listitem>
56269 <para>
56270 Timeout or loss of connection after the <quote>.</quote> that terminates the data. A
56271 timeout after the DATA command itself is treated as a host error, as is loss of
56272 connection at any other time.
56273 </para>
56274 </listitem>
56275 </itemizedlist>
56276 <para>
56277 For a message error, a permanent error response (5<emphasis>xx</emphasis>) causes all addresses
56278 to be failed, and a delivery error report to be returned to the sender. A
56279 temporary error response (4<emphasis>xx</emphasis>), or one of the timeouts, causes all
56280 addresses to be deferred. Retry data is not created for the host, but instead,
56281 a retry record for the combination of host plus message id is created. The
56282 message is not added to the list of those waiting for this host. This ensures
56283 that the failing message will not be sent to this host again until the retry
56284 time arrives. However, other messages that are routed to the host are not
56285 affected, so if it is some property of the message that is causing the error,
56286 it will not stop the delivery of other mail.
56287 </para>
56288 <para>
56289 If the remote host specified support for the SIZE parameter in its response
56290 to EHLO, Exim adds SIZE=<emphasis>nnn</emphasis> to the MAIL command, so an
56291 over-large message will cause a message error because the error arrives as a
56292 response to MAIL.
56293 </para>
56294 </listitem></varlistentry>
56295 <varlistentry>
56296 <term><emphasis role="bold">Recipient errors</emphasis></term>
56297 <listitem>
56298 <para>
56299 <indexterm role="concept">
56300 <primary>recipient</primary>
56301 <secondary>error</secondary>
56302 </indexterm>
56303 A recipient error is associated with a particular recipient of a message. The
56304 recipient errors are:
56305 </para>
56306 <itemizedlist>
56307 <listitem>
56308 <para>
56309 Any error response to RCPT,
56310 </para>
56311 </listitem>
56312 <listitem>
56313 <para>
56314 Timeout after RCPT.
56315 </para>
56316 </listitem>
56317 </itemizedlist>
56318 <para>
56319 For a recipient error, a permanent error response (5<emphasis>xx</emphasis>) causes the
56320 recipient address to be failed, and a bounce message to be returned to the
56321 sender. A temporary error response (4<emphasis>xx</emphasis>) or a timeout causes the failing
56322 address to be deferred, and routing retry data to be created for it. This is
56323 used to delay processing of the address in subsequent queue runs, until its
56324 routing retry time arrives. This applies to all messages, but because it
56325 operates only in queue runs, one attempt will be made to deliver a new message
56326 to the failing address before the delay starts to operate. This ensures that,
56327 if the failure is really related to the message rather than the recipient
56328 (<quote>message too big for this recipient</quote> is a possible example), other messages
56329 have a chance of getting delivered. If a delivery to the address does succeed,
56330 the retry information gets cleared, so all stuck messages get tried again, and
56331 the retry clock is reset.
56332 </para>
56333 <para>
56334 The message is not added to the list of those waiting for this host. Use of the
56335 host for other messages is unaffected, and except in the case of a timeout,
56336 other recipients are processed independently, and may be successfully delivered
56337 in the current SMTP session. After a timeout it is of course impossible to
56338 proceed with the session, so all addresses get deferred. However, those other
56339 than the one that failed do not suffer any subsequent retry delays. Therefore,
56340 if one recipient is causing trouble, the others have a chance of getting
56341 through when a subsequent delivery attempt occurs before the failing
56342 recipient&#x2019;s retry time.
56343 </para>
56344 </listitem></varlistentry>
56345 </variablelist>
56346 <para>
56347 In all cases, if there are other hosts (or IP addresses) available for the
56348 current set of addresses (for example, from multiple MX records), they are
56349 tried in this run for any undelivered addresses, subject of course to their
56350 own retry data. In other words, recipient error retry data does not take effect
56351 until the next delivery attempt.
56352 </para>
56353 <para>
56354 Some hosts have been observed to give temporary error responses to every
56355 MAIL command at certain times (<quote>insufficient space</quote> has been seen). It
56356 would be nice if such circumstances could be recognized, and defer data for the
56357 host itself created, but this is not possible within the current Exim design.
56358 What actually happens is that retry data for every (host, message) combination
56359 is created.
56360 </para>
56361 <para>
56362 The reason that timeouts after MAIL and RCPT are treated specially is that
56363 these can sometimes arise as a result of the remote host&#x2019;s verification
56364 procedures. Exim makes this assumption, and treats them as if a temporary error
56365 response had been received. A timeout after <quote>.</quote> is treated specially because
56366 it is known that some broken implementations fail to recognize the end of the
56367 message if the last character of the last line is a binary zero. Thus, it is
56368 helpful to treat this case as a message error.
56369 </para>
56370 <para>
56371 Timeouts at other times are treated as host errors, assuming a problem with the
56372 host, or the connection to it. If a timeout after MAIL, RCPT,
56373 or <quote>.</quote> is really a connection problem, the assumption is that at the next try
56374 the timeout is likely to occur at some other point in the dialogue, causing it
56375 then to be treated as a host error.
56376 </para>
56377 <para>
56378 There is experimental evidence that some MTAs drop the connection after the
56379 terminating <quote>.</quote> if they do not like the contents of the message for some
56380 reason, in contravention of the RFC, which indicates that a 5<emphasis>xx</emphasis> response
56381 should be given. That is why Exim treats this case as a message rather than a
56382 host error, in order not to delay other messages to the same host.
56383 </para>
56384 </section>
56385 <section id="SECID233">
56386 <title>Incoming SMTP messages over TCP/IP</title>
56387 <para>
56388 <indexterm role="concept">
56389 <primary>SMTP</primary>
56390 <secondary>incoming over TCP/IP</secondary>
56391 </indexterm>
56392 <indexterm role="concept">
56393 <primary>incoming SMTP over TCP/IP</primary>
56394 </indexterm>
56395 <indexterm role="concept">
56396 <primary>inetd</primary>
56397 </indexterm>
56398 <indexterm role="concept">
56399 <primary>daemon</primary>
56400 </indexterm>
56401 Incoming SMTP messages can be accepted in one of two ways: by running a
56402 listening daemon, or by using <emphasis>inetd</emphasis>. In the latter case, the entry in
56403 <filename>/etc/inetd.conf</filename> should be like this:
56404 </para>
56405 <literallayout class="monospaced">
56406 smtp stream tcp nowait exim /opt/exim/bin/exim in.exim -bs
56407 </literallayout>
56408 <para>
56409 Exim distinguishes between this case and the case of a locally running user
56410 agent using the <option>-bs</option> option by checking whether or not the standard input is
56411 a socket. When it is, either the port must be privileged (less than 1024), or
56412 the caller must be root or the Exim user. If any other user passes a socket
56413 with an unprivileged port number, Exim prints a message on the standard error
56414 stream and exits with an error code.
56415 </para>
56416 <para>
56417 By default, Exim does not make a log entry when a remote host connects or
56418 disconnects (either via the daemon or <emphasis>inetd</emphasis>), unless the disconnection is
56419 unexpected. It can be made to write such log entries by setting the
56420 <option>smtp_connection</option> log selector.
56421 </para>
56422 <para>
56423 <indexterm role="concept">
56424 <primary>carriage return</primary>
56425 </indexterm>
56426 <indexterm role="concept">
56427 <primary>linefeed</primary>
56428 </indexterm>
56429 Commands from the remote host are supposed to be terminated by CR followed by
56430 LF. However, there are known to be hosts that do not send CR characters. In
56431 order to be able to interwork with such hosts, Exim treats LF on its own as a
56432 line terminator.
56433 Furthermore, because common code is used for receiving messages from all
56434 sources, a CR on its own is also interpreted as a line terminator. However, the
56435 sequence <quote>CR, dot, CR</quote> does not terminate incoming SMTP data.
56436 </para>
56437 <para>
56438 <indexterm role="concept">
56439 <primary>EHLO</primary>
56440 <secondary>invalid data</secondary>
56441 </indexterm>
56442 <indexterm role="concept">
56443 <primary>HELO</primary>
56444 <secondary>invalid data</secondary>
56445 </indexterm>
56446 One area that sometimes gives rise to problems concerns the EHLO or
56447 HELO commands. Some clients send syntactically invalid versions of these
56448 commands, which Exim rejects by default. (This is nothing to do with verifying
56449 the data that is sent, so <option>helo_verify_hosts</option> is not relevant.) You can tell
56450 Exim not to apply a syntax check by setting <option>helo_accept_junk_hosts</option> to
56451 match the broken hosts that send invalid commands.
56452 </para>
56453 <para>
56454 <indexterm role="concept">
56455 <primary>SIZE option on MAIL command</primary>
56456 </indexterm>
56457 <indexterm role="concept">
56458 <primary>MAIL</primary>
56459 <secondary>SIZE option</secondary>
56460 </indexterm>
56461 The amount of disk space available is checked whenever SIZE is received on
56462 a MAIL command, independently of whether <option>message_size_limit</option> or
56463 <option>check_spool_space</option> is configured, unless <option>smtp_check_spool_space</option> is set
56464 false. A temporary error is given if there is not enough space. If
56465 <option>check_spool_space</option> is set, the check is for that amount of space plus the
56466 value given with SIZE, that is, it checks that the addition of the incoming
56467 message will not reduce the space below the threshold.
56468 </para>
56469 <para>
56470 When a message is successfully received, Exim includes the local message id in
56471 its response to the final <quote>.</quote> that terminates the data. If the remote host
56472 logs this text it can help with tracing what has happened to a message.
56473 </para>
56474 <para>
56475 The Exim daemon can limit the number of simultaneous incoming connections it is
56476 prepared to handle (see the <option>smtp_accept_max</option> option). It can also limit the
56477 number of simultaneous incoming connections from a single remote host (see the
56478 <option>smtp_accept_max_per_host</option> option). Additional connection attempts are
56479 rejected using the SMTP temporary error code 421.
56480 </para>
56481 <para>
56482 The Exim daemon does not rely on the SIGCHLD signal to detect when a
56483 subprocess has finished, as this can get lost at busy times. Instead, it looks
56484 for completed subprocesses every time it wakes up. Provided there are other
56485 things happening (new incoming calls, starts of queue runs), completed
56486 processes will be noticed and tidied away. On very quiet systems you may
56487 sometimes see a <quote>defunct</quote> Exim process hanging about. This is not a problem;
56488 it will be noticed when the daemon next wakes up.
56489 </para>
56490 <para>
56491 When running as a daemon, Exim can reserve some SMTP slots for specific hosts,
56492 and can also be set up to reject SMTP calls from non-reserved hosts at times of
56493 high system load &ndash; for details see the <option>smtp_accept_reserve</option>,
56494 <option>smtp_load_reserve</option>, and <option>smtp_reserve_hosts</option> options. The load check
56495 applies in both the daemon and <emphasis>inetd</emphasis> cases.
56496 </para>
56497 <para>
56498 Exim normally starts a delivery process for each message received, though this
56499 can be varied by means of the <option>-odq</option> command line option and the
56500 <option>queue_only</option>, <option>queue_only_file</option>, and <option>queue_only_load</option> options. The
56501 number of simultaneously running delivery processes started in this way from
56502 SMTP input can be limited by the <option>smtp_accept_queue</option> and
56503 <option>smtp_accept_queue_per_connection</option> options. When either limit is reached,
56504 subsequently received messages are just put on the input queue without starting
56505 a delivery process.
56506 </para>
56507 <para>
56508 The controls that involve counts of incoming SMTP calls (<option>smtp_accept_max</option>,
56509 <option>smtp_accept_queue</option>, <option>smtp_accept_reserve</option>) are not available when Exim is
56510 started up from the <emphasis>inetd</emphasis> daemon, because in that case each connection is
56511 handled by an entirely independent Exim process. Control by load average is,
56512 however, available with <emphasis>inetd</emphasis>.
56513 </para>
56514 <para>
56515 Exim can be configured to verify addresses in incoming SMTP commands as they
56516 are received. See chapter <xref linkend="CHAPACL"/> for details. It can also be configured
56517 to rewrite addresses at this time &ndash; before any syntax checking is done. See
56518 section <xref linkend="SECTrewriteS"/>.
56519 </para>
56520 <para>
56521 Exim can also be configured to limit the rate at which a client host submits
56522 MAIL and RCPT commands in a single SMTP session. See the
56523 <option>smtp_ratelimit_hosts</option> option.
56524 </para>
56525 </section>
56526 <section id="SECID234">
56527 <title>Unrecognized SMTP commands</title>
56528 <para>
56529 <indexterm role="concept">
56530 <primary>SMTP</primary>
56531 <secondary>unrecognized commands</secondary>
56532 </indexterm>
56533 If Exim receives more than <option>smtp_max_unknown_commands</option> unrecognized SMTP
56534 commands during a single SMTP connection, it drops the connection after sending
56535 the error response to the last command. The default value for
56536 <option>smtp_max_unknown_commands</option> is 3. This is a defence against some kinds of
56537 abuse that subvert web servers into making connections to SMTP ports; in these
56538 circumstances, a number of non-SMTP lines are sent first.
56539 </para>
56540 </section>
56541 <section id="SECID235">
56542 <title>Syntax and protocol errors in SMTP commands</title>
56543 <para>
56544 <indexterm role="concept">
56545 <primary>SMTP</primary>
56546 <secondary>syntax errors</secondary>
56547 </indexterm>
56548 <indexterm role="concept">
56549 <primary>SMTP</primary>
56550 <secondary>protocol errors</secondary>
56551 </indexterm>
56552 A syntax error is detected if an SMTP command is recognized, but there is
56553 something syntactically wrong with its data, for example, a malformed email
56554 address in a RCPT command. Protocol errors include invalid command
56555 sequencing such as RCPT before MAIL. If Exim receives more than
56556 <option>smtp_max_synprot_errors</option> such commands during a single SMTP connection, it
56557 drops the connection after sending the error response to the last command. The
56558 default value for <option>smtp_max_synprot_errors</option> is 3. This is a defence against
56559 broken clients that loop sending bad commands (yes, it has been seen).
56560 </para>
56561 </section>
56562 <section id="SECID236">
56563 <title>Use of non-mail SMTP commands</title>
56564 <para>
56565 <indexterm role="concept">
56566 <primary>SMTP</primary>
56567 <secondary>non-mail commands</secondary>
56568 </indexterm>
56569 The <quote>non-mail</quote> SMTP commands are those other than MAIL, RCPT, and
56570 DATA. Exim counts such commands, and drops the connection if there are too
56571 many of them in a single SMTP session. This action catches some
56572 denial-of-service attempts and things like repeated failing AUTHs, or a mad
56573 client looping sending EHLO. The global option <option>smtp_accept_max_nonmail</option>
56574 defines what <quote>too many</quote> means. Its default value is 10.
56575 </para>
56576 <para>
56577 When a new message is expected, one occurrence of RSET is not counted. This
56578 allows a client to send one RSET between messages (this is not necessary,
56579 but some clients do it). Exim also allows one uncounted occurrence of HELO
56580 or EHLO, and one occurrence of STARTTLS between messages. After
56581 starting up a TLS session, another EHLO is expected, and so it too is not
56582 counted.
56583 </para>
56584 <para>
56585 The first occurrence of AUTH in a connection, or immediately following
56586 STARTTLS is also not counted. Otherwise, all commands other than MAIL,
56587 RCPT, DATA, and QUIT are counted.
56588 </para>
56589 <para>
56590 You can control which hosts are subject to the limit set by
56591 <option>smtp_accept_max_nonmail</option> by setting
56592 <option>smtp_accept_max_nonmail_hosts</option>. The default value is <literal>*</literal>, which makes
56593 the limit apply to all hosts. This option means that you can exclude any
56594 specific badly-behaved hosts that you have to live with.
56595 </para>
56596 </section>
56597 <section id="SECID237">
56598 <title>The VRFY and EXPN commands</title>
56599 <para>
56600 When Exim receives a VRFY or EXPN command on a TCP/IP connection, it
56601 runs the ACL specified by <option>acl_smtp_vrfy</option> or <option>acl_smtp_expn</option> (as
56602 appropriate) in order to decide whether the command should be accepted or not.
56603 If no ACL is defined, the command is rejected.
56604 </para>
56605 <para>
56606 <indexterm role="concept">
56607 <primary>VRFY</primary>
56608 <secondary>processing</secondary>
56609 </indexterm>
56610 When VRFY is accepted, it runs exactly the same code as when Exim is
56611 called with the <option>-bv</option> option.
56612 </para>
56613 <para>
56614 <indexterm role="concept">
56615 <primary>EXPN</primary>
56616 <secondary>processing</secondary>
56617 </indexterm>
56618 When EXPN is accepted, a single-level expansion of the address is done.
56619 EXPN is treated as an <quote>address test</quote> (similar to the <option>-bt</option> option) rather
56620 than a verification (the <option>-bv</option> option). If an unqualified local part is given
56621 as the argument to EXPN, it is qualified with <option>qualify_domain</option>. Rejections
56622 of VRFY and EXPN commands are logged on the main and reject logs, and
56623 VRFY verification failures are logged on the main log for consistency with
56624 RCPT failures.
56625 </para>
56626 </section>
56627 <section id="SECTETRN">
56628 <title>The ETRN command</title>
56629 <para>
56630 <indexterm role="concept">
56631 <primary>ETRN</primary>
56632 <secondary>processing</secondary>
56633 </indexterm>
56634 RFC 1985 describes an SMTP command called ETRN that is designed to
56635 overcome the security problems of the TURN command (which has fallen into
56636 disuse). When Exim receives an ETRN command on a TCP/IP connection, it runs
56637 the ACL specified by <option>acl_smtp_etrn</option> in order to decide whether the command
56638 should be accepted or not. If no ACL is defined, the command is rejected.
56639 </para>
56640 <para>
56641 The ETRN command is concerned with <quote>releasing</quote> messages that are awaiting
56642 delivery to certain hosts. As Exim does not organize its message queue by host,
56643 the only form of ETRN that is supported by default is the one where the
56644 text starts with the <quote>#</quote> prefix, in which case the remainder of the text is
56645 specific to the SMTP server. A valid ETRN command causes a run of Exim with
56646 the <option>-R</option> option to happen, with the remainder of the ETRN text as its
56647 argument. For example,
56648 </para>
56649 <literallayout class="monospaced">
56650 ETRN #brigadoon
56651 </literallayout>
56652 <para>
56653 runs the command
56654 </para>
56655 <literallayout class="monospaced">
56656 exim -R brigadoon
56657 </literallayout>
56658 <para>
56659 which causes a delivery attempt on all messages with undelivered addresses
56660 containing the text <quote>brigadoon</quote>. When <option>smtp_etrn_serialize</option> is set (the
56661 default), Exim prevents the simultaneous execution of more than one queue run
56662 for the same argument string as a result of an ETRN command. This stops
56663 a misbehaving client from starting more than one queue runner at once.
56664 </para>
56665 <para>
56666 <indexterm role="concept">
56667 <primary>hints database</primary>
56668 <secondary>ETRN serialization</secondary>
56669 </indexterm>
56670 Exim implements the serialization by means of a hints database in which a
56671 record is written whenever a process is started by ETRN, and deleted when
56672 the process completes. However, Exim does not keep the SMTP session waiting for
56673 the ETRN process to complete. Once ETRN is accepted, the client is sent
56674 a <quote>success</quote> return code. Obviously there is scope for hints records to get
56675 left lying around if there is a system or program crash. To guard against this,
56676 Exim ignores any records that are more than six hours old.
56677 </para>
56678 <para>
56679 <indexterm role="option">
56680 <primary><option>smtp_etrn_command</option></primary>
56681 </indexterm>
56682 For more control over what ETRN does, the <option>smtp_etrn_command</option> option can
56683 used. This specifies a command that is run whenever ETRN is received,
56684 whatever the form of its argument. For
56685 example:
56686 </para>
56687 <literallayout class="monospaced">
56688 smtp_etrn_command = /etc/etrn_command $domain \
56689                     $sender_host_address
56690 </literallayout>
56691 <para>
56692 <indexterm role="variable">
56693 <primary><varname>$domain</varname></primary>
56694 </indexterm>
56695 The string is split up into arguments which are independently expanded. The
56696 expansion variable <varname>$domain</varname> is set to the argument of the ETRN command,
56697 and no syntax checking is done on the contents of this argument. Exim does not
56698 wait for the command to complete, so its status code is not checked. Exim runs
56699 under its own uid and gid when receiving incoming SMTP, so it is not possible
56700 for it to change them before running the command.
56701 </para>
56702 </section>
56703 <section id="SECID238">
56704 <title>Incoming local SMTP</title>
56705 <para>
56706 <indexterm role="concept">
56707 <primary>SMTP</primary>
56708 <secondary>local incoming</secondary>
56709 </indexterm>
56710 Some user agents use SMTP to pass messages to their local MTA using the
56711 standard input and output, as opposed to passing the envelope on the command
56712 line and writing the message to the standard input. This is supported by the
56713 <option>-bs</option> option. This form of SMTP is handled in the same way as incoming
56714 messages over TCP/IP (including the use of ACLs), except that the envelope
56715 sender given in a MAIL command is ignored unless the caller is trusted. In
56716 an ACL you can detect this form of SMTP input by testing for an empty host
56717 identification. It is common to have this as the first line in the ACL that
56718 runs for RCPT commands:
56719 </para>
56720 <literallayout class="monospaced">
56721 accept hosts = :
56722 </literallayout>
56723 <para>
56724 This accepts SMTP messages from local processes without doing any other tests.
56725 </para>
56726 </section>
56727 <section id="SECTbatchSMTP">
56728 <title>Outgoing batched SMTP</title>
56729 <para>
56730 <indexterm role="concept">
56731 <primary>SMTP</primary>
56732 <secondary>batched outgoing</secondary>
56733 </indexterm>
56734 <indexterm role="concept">
56735 <primary>batched SMTP output</primary>
56736 </indexterm>
56737 Both the <command>appendfile</command> and <command>pipe</command> transports can be used for handling
56738 batched SMTP. Each has an option called <option>use_bsmtp</option> which causes messages to
56739 be output in BSMTP format. No SMTP responses are possible for this form of
56740 delivery. All it is doing is using SMTP commands as a way of transmitting the
56741 envelope along with the message.
56742 </para>
56743 <para>
56744 The message is written to the file or pipe preceded by the SMTP commands
56745 MAIL and RCPT, and followed by a line containing a single dot. Lines in
56746 the message that start with a dot have an extra dot added. The SMTP command
56747 HELO is not normally used. If it is required, the <option>message_prefix</option> option
56748 can be used to specify it.
56749 </para>
56750 <para>
56751 Because <command>appendfile</command> and <command>pipe</command> are both local transports, they accept only
56752 one recipient address at a time by default. However, you can arrange for them
56753 to handle several addresses at once by setting the <option>batch_max</option> option. When
56754 this is done for BSMTP, messages may contain multiple RCPT commands. See
56755 chapter <xref linkend="CHAPbatching"/> for more details.
56756 </para>
56757 <para>
56758 <indexterm role="variable">
56759 <primary><varname>$host</varname></primary>
56760 </indexterm>
56761 When one or more addresses are routed to a BSMTP transport by a router that
56762 sets up a host list, the name of the first host on the list is available to the
56763 transport in the variable <varname>$host</varname>. Here is an example of such a transport and
56764 router:
56765 </para>
56766 <literallayout class="monospaced">
56767 begin routers
56768 route_append:
56769   driver = manualroute
56770   transport = smtp_appendfile
56771   route_list = domain.example  batch.host.example
56772
56773 begin transports
56774 smtp_appendfile:
56775   driver = appendfile
56776   directory = /var/bsmtp/$host
56777   batch_max = 1000
56778   use_bsmtp
56779   user = exim
56780 </literallayout>
56781 <para>
56782 This causes messages addressed to <emphasis>domain.example</emphasis> to be written in BSMTP
56783 format to <filename>/var/bsmtp/batch.host.example</filename>, with only a single copy of each
56784 message (unless there are more than 1000 recipients).
56785 </para>
56786 </section>
56787 <section id="SECTincomingbatchedSMTP">
56788 <title>Incoming batched SMTP</title>
56789 <para>
56790 <indexterm role="concept">
56791 <primary>SMTP</primary>
56792 <secondary>batched incoming</secondary>
56793 </indexterm>
56794 <indexterm role="concept">
56795 <primary>batched SMTP input</primary>
56796 </indexterm>
56797 The <option>-bS</option> command line option causes Exim to accept one or more messages by
56798 reading SMTP on the standard input, but to generate no responses. If the caller
56799 is trusted, the senders in the MAIL commands are believed; otherwise the
56800 sender is always the caller of Exim. Unqualified senders and receivers are not
56801 rejected (there seems little point) but instead just get qualified. HELO
56802 and EHLO act as RSET; VRFY, EXPN, ETRN and  HELP, act
56803 as NOOP; QUIT quits.
56804 </para>
56805 <para revisionflag="changed">
56806 Minimal policy checking is done for BSMTP input. Only the non-SMTP
56807 ACL is run in the same way as for non-SMTP local input.
56808 </para>
56809 <para>
56810 If an error is detected while reading a message, including a missing <quote>.</quote> at
56811 the end, Exim gives up immediately. It writes details of the error to the
56812 standard output in a stylized way that the calling program should be able to
56813 make some use of automatically, for example:
56814 </para>
56815 <literallayout class="monospaced">
56816 554 Unexpected end of file
56817 Transaction started in line 10
56818 Error detected in line 14
56819 </literallayout>
56820 <para>
56821 It writes a more verbose version, for human consumption, to the standard error
56822 file, for example:
56823 </para>
56824 <literallayout class="monospaced">
56825 An error was detected while processing a file of BSMTP input.
56826 The error message was:
56827
56828 501 '&gt;' missing at end of address
56829
56830 The SMTP transaction started in line 10.
56831 The error was detected in line 12.
56832 The SMTP command at fault was:
56833
56834 rcpt to:&lt;malformed@in.com.plete
56835
56836 1 previous message was successfully processed.
56837 The rest of the batch was abandoned.
56838 </literallayout>
56839 <para>
56840 The return code from Exim is zero only if there were no errors. It is 1 if some
56841 messages were accepted before an error was detected, and 2 if no messages were
56842 accepted.
56843 <indexterm role="concept" startref="IIDsmtpproc1" class="endofrange"/>
56844 <indexterm role="concept" startref="IIDsmtpproc2" class="endofrange"/>
56845 </para>
56846 </section>
56847 </chapter>
56848
56849 <chapter id="CHAPemsgcust">
56850 <title>Customizing bounce and warning messages</title>
56851 <titleabbrev>Customizing messages</titleabbrev>
56852 <para>
56853 When a message fails to be delivered, or remains on the queue for more than a
56854 configured amount of time, Exim sends a message to the original sender, or
56855 to an alternative configured address. The text of these messages is built into
56856 the code of Exim, but it is possible to change it, either by adding a single
56857 string, or by replacing each of the paragraphs by text supplied in a file.
56858 </para>
56859 <para>
56860 The <emphasis>From:</emphasis> and <emphasis>To:</emphasis> header lines are automatically generated; you can
56861 cause a <emphasis>Reply-To:</emphasis> line to be added by setting the <option>errors_reply_to</option>
56862 option. Exim also adds the line
56863 </para>
56864 <literallayout class="monospaced">
56865 Auto-Submitted: auto-generated
56866 </literallayout>
56867 <para>
56868 to all warning and bounce messages,
56869 </para>
56870 <section id="SECID239">
56871 <title>Customizing bounce messages</title>
56872 <para>
56873 <indexterm role="concept">
56874 <primary>customizing</primary>
56875 <secondary>bounce message</secondary>
56876 </indexterm>
56877 <indexterm role="concept">
56878 <primary>bounce message</primary>
56879 <secondary>customizing</secondary>
56880 </indexterm>
56881 If <option>bounce_message_text</option> is set, its contents are included in the default
56882 message immediately after <quote>This message was created automatically by mail
56883 delivery software.</quote> The string is not expanded. It is not used if
56884 <option>bounce_message_file</option> is set.
56885 </para>
56886 <para>
56887 When <option>bounce_message_file</option> is set, it must point to a template file for
56888 constructing error messages. The file consists of a series of text items,
56889 separated by lines consisting of exactly four asterisks. If the file cannot be
56890 opened, default text is used and a message is written to the main and panic
56891 logs. If any text item in the file is empty, default text is used for that
56892 item.
56893 </para>
56894 <para>
56895 <indexterm role="variable">
56896 <primary><varname>$bounce_recipient</varname></primary>
56897 </indexterm>
56898 <indexterm role="variable">
56899 <primary><varname>$bounce_return_size_limit</varname></primary>
56900 </indexterm>
56901 Each item of text that is read from the file is expanded, and there are two
56902 expansion variables which can be of use here: <varname>$bounce_recipient</varname> is set to
56903 the recipient of an error message while it is being created, and
56904 <varname>$bounce_return_size_limit</varname> contains the value of the <option>return_size_limit</option>
56905 option, rounded to a whole number.
56906 </para>
56907 <para>
56908 The items must appear in the file in the following order:
56909 </para>
56910 <itemizedlist>
56911 <listitem>
56912 <para>
56913 The first item is included in the headers, and should include at least a
56914 <emphasis>Subject:</emphasis> header. Exim does not check the syntax of these headers.
56915 </para>
56916 </listitem>
56917 <listitem>
56918 <para>
56919 The second item forms the start of the error message. After it, Exim lists the
56920 failing addresses with their error messages.
56921 </para>
56922 </listitem>
56923 <listitem>
56924 <para>
56925 The third item is used to introduce any text from pipe transports that is to be
56926 returned to the sender. It is omitted if there is no such text.
56927 </para>
56928 </listitem>
56929 <listitem>
56930 <para>
56931 The fourth item is used to introduce the copy of the message that is returned
56932 as part of the error report.
56933 </para>
56934 </listitem>
56935 <listitem>
56936 <para>
56937 The fifth item is added after the fourth one if the returned message is
56938 truncated because it is bigger than <option>return_size_limit</option>.
56939 </para>
56940 </listitem>
56941 <listitem>
56942 <para>
56943 The sixth item is added after the copy of the original message.
56944 </para>
56945 </listitem>
56946 </itemizedlist>
56947 <para>
56948 The default state (<option>bounce_message_file</option> unset) is equivalent to the
56949 following file, in which the sixth item is empty. The <emphasis>Subject:</emphasis> and some
56950 other lines have been split in order to fit them on the page:
56951 </para>
56952 <literallayout class="monospaced">
56953 Subject: Mail delivery failed
56954   ${if eq{$sender_address}{$bounce_recipient}
56955   {: returning message to sender}}
56956 ****
56957 This message was created automatically by mail delivery software.
56958
56959 A message ${if eq{$sender_address}{$bounce_recipient}
56960   {that you sent }{sent by
56961
56962 &lt;$sender_address&gt;
56963
56964 }}could not be delivered to all of its recipients.
56965 This is a permanent error. The following address(es) failed:
56966 ****
56967 The following text was generated during the delivery attempt(s):
56968 ****
56969 ------ This is a copy of the message, including all the headers.
56970   ------
56971 ****
56972 ------ The body of the message is $message_size characters long;
56973   only the first
56974 ------ $bounce_return_size_limit or so are included here.
56975 ****
56976 </literallayout>
56977 </section>
56978 <section id="SECTcustwarn">
56979 <title>Customizing warning messages</title>
56980 <para>
56981 <indexterm role="concept">
56982 <primary>customizing</primary>
56983 <secondary>warning message</secondary>
56984 </indexterm>
56985 <indexterm role="concept">
56986 <primary>warning of delay</primary>
56987 <secondary>customizing the message</secondary>
56988 </indexterm>
56989 The option <option>warn_message_file</option> can be pointed at a template file for use when
56990 warnings about message delays are created. In this case there are only three
56991 text sections:
56992 </para>
56993 <itemizedlist>
56994 <listitem>
56995 <para>
56996 The first item is included in the headers, and should include at least a
56997 <emphasis>Subject:</emphasis> header. Exim does not check the syntax of these headers.
56998 </para>
56999 </listitem>
57000 <listitem>
57001 <para>
57002 The second item forms the start of the warning message. After it, Exim lists
57003 the delayed addresses.
57004 </para>
57005 </listitem>
57006 <listitem>
57007 <para>
57008 The third item then ends the message.
57009 </para>
57010 </listitem>
57011 </itemizedlist>
57012 <para>
57013 The default state is equivalent to the following file, except that some lines
57014 have been split here, in order to fit them on the page:
57015 </para>
57016 <literallayout class="monospaced">
57017 Subject: Warning: message $message_exim_id delayed
57018   $warn_message_delay
57019 ****
57020 This message was created automatically by mail delivery software.
57021
57022 A message ${if eq{$sender_address}{$warn_message_recipients}
57023 {that you sent }{sent by
57024
57025 &lt;$sender_address&gt;
57026
57027 }}has not been delivered to all of its recipients after
57028 more than $warn_message_delay on the queue on $primary_hostname.
57029
57030 The message identifier is:     $message_exim_id
57031 The subject of the message is: $h_subject
57032 The date of the message is:    $h_date
57033
57034 The following address(es) have not yet been delivered:
57035 ****
57036 No action is required on your part. Delivery attempts will
57037 continue for some time, and this warning may be repeated at
57038 intervals if the message remains undelivered. Eventually the
57039 mail delivery software will give up, and when that happens,
57040 the message will be returned to you.
57041 </literallayout>
57042 <para>
57043 <indexterm role="variable">
57044 <primary><varname>$warn_message_delay</varname></primary>
57045 </indexterm>
57046 <indexterm role="variable">
57047 <primary><varname>$warn_message_recipients</varname></primary>
57048 </indexterm>
57049 However, in the default state the subject and date lines are omitted if no
57050 appropriate headers exist. During the expansion of this file,
57051 <varname>$warn_message_delay</varname> is set to the delay time in one of the forms <quote>&lt;<emphasis>n</emphasis>&gt;
57052 minutes</quote> or <quote>&lt;<emphasis>n</emphasis>&gt; hours</quote>, and <varname>$warn_message_recipients</varname> contains a list
57053 of recipients for the warning message. There may be more than one if there are
57054 multiple addresses with different <option>errors_to</option> settings on the routers that
57055 handled them.
57056 </para>
57057 </section>
57058 </chapter>
57059
57060 <chapter id="CHAPcomconreq">
57061 <title>Some common configuration settings</title>
57062 <para>
57063 This chapter discusses some configuration settings that seem to be fairly
57064 common. More examples and discussion can be found in the Exim book.
57065 </para>
57066 <section id="SECID240">
57067 <title>Sending mail to a smart host</title>
57068 <para>
57069 <indexterm role="concept">
57070 <primary>smart host</primary>
57071 <secondary>example router</secondary>
57072 </indexterm>
57073 If you want to send all mail for non-local domains to a <quote>smart host</quote>, you
57074 should replace the default <command>dnslookup</command> router with a router which does the
57075 routing explicitly:
57076 </para>
57077 <literallayout class="monospaced">
57078 send_to_smart_host:
57079   driver = manualroute
57080   route_list = !+local_domains smart.host.name
57081   transport = remote_smtp
57082 </literallayout>
57083 <para>
57084 You can use the smart host&#x2019;s IP address instead of the name if you wish.
57085 If you are using Exim only to submit messages to a smart host, and not for
57086 receiving incoming messages, you can arrange for it to do the submission
57087 synchronously by setting the <option>mua_wrapper</option> option (see chapter
57088 <xref linkend="CHAPnonqueueing"/>).
57089 </para>
57090 </section>
57091 <section id="SECTmailinglists">
57092 <title>Using Exim to handle mailing lists</title>
57093 <para>
57094 <indexterm role="concept">
57095 <primary>mailing lists</primary>
57096 </indexterm>
57097 Exim can be used to run simple mailing lists, but for large and/or complicated
57098 requirements, the use of additional specialized mailing list software such as
57099 Majordomo or Mailman is recommended.
57100 </para>
57101 <para>
57102 The <command>redirect</command> router can be used to handle mailing lists where each list
57103 is maintained in a separate file, which can therefore be managed by an
57104 independent manager. The <option>domains</option> router option can be used to run these
57105 lists in a separate domain from normal mail. For example:
57106 </para>
57107 <literallayout class="monospaced">
57108 lists:
57109   driver = redirect
57110   domains = lists.example
57111   file = /usr/lists/$local_part
57112   forbid_pipe
57113   forbid_file
57114   errors_to = $local_part-request@lists.example
57115   no_more
57116 </literallayout>
57117 <para>
57118 This router is skipped for domains other than <emphasis>lists.example</emphasis>. For addresses
57119 in that domain, it looks for a file that matches the local part. If there is no
57120 such file, the router declines, but because <option>no_more</option> is set, no subsequent
57121 routers are tried, and so the whole delivery fails.
57122 </para>
57123 <para>
57124 The <option>forbid_pipe</option> and <option>forbid_file</option> options prevent a local part from being
57125 expanded into a file name or a pipe delivery, which is usually inappropriate in
57126 a mailing list.
57127 </para>
57128 <para>
57129 <indexterm role="option">
57130 <primary><option>errors_to</option></primary>
57131 </indexterm>
57132 The <option>errors_to</option> option specifies that any delivery errors caused by addresses
57133 taken from a mailing list are to be sent to the given address rather than the
57134 original sender of the message. However, before acting on this, Exim verifies
57135 the error address, and ignores it if verification fails.
57136 </para>
57137 <para>
57138 For example, using the configuration above, mail sent to
57139 <emphasis>dicts@lists.example</emphasis> is passed on to those addresses contained in
57140 <filename>/usr/lists/dicts</filename>, with error reports directed to
57141 <emphasis>dicts-request@lists.example</emphasis>, provided that this address can be verified.
57142 There could be a file called <filename>/usr/lists/dicts-request</filename> containing
57143 the address(es) of this particular list&#x2019;s manager(s), but other approaches,
57144 such as setting up an earlier router (possibly using the <option>local_part_prefix</option>
57145 or <option>local_part_suffix</option> options) to handle addresses of the form
57146 <option>owner-</option><emphasis>xxx</emphasis> or <option>xxx-</option><emphasis>request</emphasis>, are also possible.
57147 </para>
57148 </section>
57149 <section id="SECID241">
57150 <title>Syntax errors in mailing lists</title>
57151 <para>
57152 <indexterm role="concept">
57153 <primary>mailing lists</primary>
57154 <secondary>syntax errors in</secondary>
57155 </indexterm>
57156 If an entry in redirection data contains a syntax error, Exim normally defers
57157 delivery of the original address. That means that a syntax error in a mailing
57158 list holds up all deliveries to the list. This may not be appropriate when a
57159 list is being maintained automatically from data supplied by users, and the
57160 addresses are not rigorously checked.
57161 </para>
57162 <para>
57163 If the <option>skip_syntax_errors</option> option is set, the <command>redirect</command> router just skips
57164 entries that fail to parse, noting the incident in the log. If in addition
57165 <option>syntax_errors_to</option> is set to a verifiable address, a message is sent to it
57166 whenever a broken address is skipped. It is usually appropriate to set
57167 <option>syntax_errors_to</option> to the same address as <option>errors_to</option>.
57168 </para>
57169 </section>
57170 <section id="SECID242">
57171 <title>Re-expansion of mailing lists</title>
57172 <para>
57173 <indexterm role="concept">
57174 <primary>mailing lists</primary>
57175 <secondary>re-expansion of</secondary>
57176 </indexterm>
57177 Exim remembers every individual address to which a message has been delivered,
57178 in order to avoid duplication, but it normally stores only the original
57179 recipient addresses with a message. If all the deliveries to a mailing list
57180 cannot be done at the first attempt, the mailing list is re-expanded when the
57181 delivery is next tried. This means that alterations to the list are taken into
57182 account at each delivery attempt, so addresses that have been added to
57183 the list since the message arrived will therefore receive a copy of the
57184 message, even though it pre-dates their subscription.
57185 </para>
57186 <para>
57187 If this behaviour is felt to be undesirable, the <option>one_time</option> option can be set
57188 on the <command>redirect</command> router. If this is done, any addresses generated by the
57189 router that fail to deliver at the first attempt are added to the message as
57190 <quote>top level</quote> addresses, and the parent address that generated them is marked
57191 <quote>delivered</quote>. Thus, expansion of the mailing list does not happen again at the
57192 subsequent delivery attempts. The disadvantage of this is that if any of the
57193 failing addresses are incorrect, correcting them in the file has no effect on
57194 pre-existing messages.
57195 </para>
57196 <para>
57197 The original top-level address is remembered with each of the generated
57198 addresses, and is output in any log messages. However, any intermediate parent
57199 addresses are not recorded. This makes a difference to the log only if the
57200 <option>all_parents</option> selector is set, but for mailing lists there is normally only
57201 one level of expansion anyway.
57202 </para>
57203 </section>
57204 <section id="SECID243">
57205 <title>Closed mailing lists</title>
57206 <para>
57207 <indexterm role="concept">
57208 <primary>mailing lists</primary>
57209 <secondary>closed</secondary>
57210 </indexterm>
57211 The examples so far have assumed open mailing lists, to which anybody may
57212 send mail. It is also possible to set up closed lists, where mail is accepted
57213 from specified senders only. This is done by making use of the generic
57214 <option>senders</option> option to restrict the router that handles the list.
57215 </para>
57216 <para>
57217 The following example uses the same file as a list of recipients and as a list
57218 of permitted senders. It requires three routers:
57219 </para>
57220 <literallayout class="monospaced">
57221 lists_request:
57222   driver = redirect
57223   domains = lists.example
57224   local_part_suffix = -request
57225   file = /usr/lists/$local_part$local_part_suffix
57226   no_more
57227
57228 lists_post:
57229   driver = redirect
57230   domains = lists.example
57231   senders = ${if exists {/usr/lists/$local_part}\
57232              {lsearch;/usr/lists/$local_part}{*}}
57233   file = /usr/lists/$local_part
57234   forbid_pipe
57235   forbid_file
57236   errors_to = $local_part-request@lists.example
57237   no_more
57238
57239 lists_closed:
57240   driver = redirect
57241   domains = lists.example
57242   allow_fail
57243   data = :fail: $local_part@lists.example is a closed mailing list
57244 </literallayout>
57245 <para>
57246 All three routers have the same <option>domains</option> setting, so for any other domains,
57247 they are all skipped. The first router runs only if the local part ends in
57248 <option>-request</option>. It handles messages to the list manager(s) by means of an open
57249 mailing list.
57250 </para>
57251 <para>
57252 The second router runs only if the <option>senders</option> precondition is satisfied. It
57253 checks for the existence of a list that corresponds to the local part, and then
57254 checks that the sender is on the list by means of a linear search. It is
57255 necessary to check for the existence of the file before trying to search it,
57256 because otherwise Exim thinks there is a configuration error. If the file does
57257 not exist, the expansion of <option>senders</option> is *, which matches all senders. This
57258 means that the router runs, but because there is no list, declines, and
57259 <option>no_more</option> ensures that no further routers are run. The address fails with an
57260 <quote>unrouteable address</quote> error.
57261 </para>
57262 <para>
57263 The third router runs only if the second router is skipped, which happens when
57264 a mailing list exists, but the sender is not on it. This router forcibly fails
57265 the address, giving a suitable error message.
57266 </para>
57267 </section>
57268 <section id="SECTverp">
57269 <title>Variable Envelope Return Paths (VERP)</title>
57270 <para>
57271 <indexterm role="concept">
57272 <primary>VERP</primary>
57273 </indexterm>
57274 <indexterm role="concept">
57275 <primary>Variable Envelope Return Paths</primary>
57276 </indexterm>
57277 <indexterm role="concept">
57278 <primary>envelope sender</primary>
57279 </indexterm>
57280 Variable Envelope Return Paths &ndash; see <emphasis role="bold"><ulink url="http://cr.yp.to/proto/verp.txt">http://cr.yp.to/proto/verp.txt</ulink></emphasis> &ndash;
57281 are a way of helping mailing list administrators discover which subscription
57282 address is the cause of a particular delivery failure. The idea is to encode
57283 the original recipient address in the outgoing envelope sender address, so that
57284 if the message is forwarded by another host and then subsequently bounces, the
57285 original recipient can be extracted from the recipient address of the bounce.
57286 </para>
57287 <para>
57288 <indexterm role="option">
57289 <primary><option>errors_to</option></primary>
57290 </indexterm>
57291 <indexterm role="option">
57292 <primary><option>return_path</option></primary>
57293 </indexterm>
57294 Envelope sender addresses can be modified by Exim using two different
57295 facilities: the <option>errors_to</option> option on a router (as shown in previous mailing
57296 list examples), or the <option>return_path</option> option on a transport. The second of
57297 these is effective only if the message is successfully delivered to another
57298 host; it is not used for errors detected on the local host (see the description
57299 of <option>return_path</option> in chapter <xref linkend="CHAPtransportgeneric"/>). Here is an example
57300 of the use of <option>return_path</option> to implement VERP on an <command>smtp</command> transport:
57301 </para>
57302 <literallayout class="monospaced">
57303 verp_smtp:
57304   driver = smtp
57305   max_rcpt = 1
57306   return_path = \
57307     ${if match {$return_path}{^(.+?)-request@your.dom.example\$}\
57308       {$1-request+$local_part=$domain@your.dom.example}fail}
57309 </literallayout>
57310 <para>
57311 This has the effect of rewriting the return path (envelope sender) on outgoing
57312 SMTP messages, if the local part of the original return path ends in
57313 <quote>-request</quote>, and the domain is <emphasis>your.dom.example</emphasis>. The rewriting inserts the
57314 local part and domain of the recipient into the return path. Suppose, for
57315 example, that a message whose return path has been set to
57316 <emphasis>somelist-request@your.dom.example</emphasis> is sent to
57317 <emphasis>subscriber@other.dom.example</emphasis>. In the transport, the return path is
57318 rewritten as
57319 </para>
57320 <literallayout class="monospaced">
57321 somelist-request+subscriber=other.dom.example@your.dom.example
57322 </literallayout>
57323 <para>
57324 <indexterm role="variable">
57325 <primary><varname>$local_part</varname></primary>
57326 </indexterm>
57327 For this to work, you must tell Exim to send multiple copies of messages that
57328 have more than one recipient, so that each copy has just one recipient. This is
57329 achieved by setting <option>max_rcpt</option> to 1. Without this, a single copy of a message
57330 might be sent to several different recipients in the same domain, in which case
57331 <varname>$local_part</varname> is not available in the transport, because it is not unique.
57332 </para>
57333 <para>
57334 Unless your host is doing nothing but mailing list deliveries, you should
57335 probably use a separate transport for the VERP deliveries, so as not to use
57336 extra resources in making one-per-recipient copies for other deliveries. This
57337 can easily be done by expanding the <option>transport</option> option in the router:
57338 </para>
57339 <literallayout class="monospaced">
57340 dnslookup:
57341   driver = dnslookup
57342   domains = ! +local_domains
57343   transport = \
57344     ${if match {$return_path}{^(.+?)-request@your.dom.example\$}\
57345       {verp_smtp}{remote_smtp}}
57346   no_more
57347 </literallayout>
57348 <para>
57349 If you want to change the return path using <option>errors_to</option> in a router instead
57350 of using <option>return_path</option> in the transport, you need to set <option>errors_to</option> on all
57351 routers that handle mailing list addresses. This will ensure that all delivery
57352 errors, including those detected on the local host, are sent to the VERP
57353 address.
57354 </para>
57355 <para>
57356 On a host that does no local deliveries and has no manual routing, only the
57357 <command>dnslookup</command> router needs to be changed. A special transport is not needed for
57358 SMTP deliveries. Every mailing list recipient has its own return path value,
57359 and so Exim must hand them to the transport one at a time. Here is an example
57360 of a <command>dnslookup</command> router that implements VERP:
57361 </para>
57362 <literallayout class="monospaced">
57363 verp_dnslookup:
57364   driver = dnslookup
57365   domains = ! +local_domains
57366   transport = remote_smtp
57367   errors_to = \
57368     ${if match {$return_path}{^(.+?)-request@your.dom.example\$}}
57369      {$1-request+$local_part=$domain@your.dom.example}fail}
57370   no_more
57371 </literallayout>
57372 <para>
57373 Before you start sending out messages with VERPed return paths, you must also
57374 configure Exim to accept the bounce messages that come back to those paths.
57375 Typically this is done by setting a <option>local_part_suffix</option> option for a
57376 router, and using this to route the messages to wherever you want to handle
57377 them.
57378 </para>
57379 <para>
57380 The overhead incurred in using VERP depends very much on the size of the
57381 message, the number of recipient addresses that resolve to the same remote
57382 host, and the speed of the connection over which the message is being sent. If
57383 a lot of addresses resolve to the same host and the connection is slow, sending
57384 a separate copy of the message for each address may take substantially longer
57385 than sending a single copy with many recipients (for which VERP cannot be
57386 used).
57387 </para>
57388 </section>
57389 <section id="SECTvirtualdomains">
57390 <title>Virtual domains</title>
57391 <para>
57392 <indexterm role="concept">
57393 <primary>virtual domains</primary>
57394 </indexterm>
57395 <indexterm role="concept">
57396 <primary>domain</primary>
57397 <secondary>virtual</secondary>
57398 </indexterm>
57399 The phrase <emphasis>virtual domain</emphasis> is unfortunately used with two rather different
57400 meanings:
57401 </para>
57402 <itemizedlist>
57403 <listitem>
57404 <para>
57405 A domain for which there are no real mailboxes; all valid local parts are
57406 aliases for other email addresses. Common examples are organizational
57407 top-level domains and <quote>vanity</quote> domains.
57408 </para>
57409 </listitem>
57410 <listitem>
57411 <para>
57412 One of a number of independent domains that are all handled by the same host,
57413 with mailboxes on that host, but where the mailbox owners do not necessarily
57414 have login accounts on that host.
57415 </para>
57416 </listitem>
57417 </itemizedlist>
57418 <para>
57419 The first usage is probably more common, and does seem more <quote>virtual</quote> than
57420 the second. This kind of domain can be handled in Exim with a straightforward
57421 aliasing router. One approach is to create a separate alias file for each
57422 virtual domain. Exim can test for the existence of the alias file to determine
57423 whether the domain exists. The <command>dsearch</command> lookup type is useful here, leading
57424 to a router of this form:
57425 </para>
57426 <literallayout class="monospaced">
57427 virtual:
57428   driver = redirect
57429   domains = dsearch;/etc/mail/virtual
57430   data = ${lookup{$local_part}lsearch{/etc/mail/virtual/$domain}}
57431   no_more
57432 </literallayout>
57433 <para>
57434 The <option>domains</option> option specifies that the router is to be skipped, unless there
57435 is a file in the <filename>/etc/mail/virtual</filename> directory whose name is the same as the
57436 domain that is being processed. When the router runs, it looks up the local
57437 part in the file to find a new address (or list of addresses). The <option>no_more</option>
57438 setting ensures that if the lookup fails (leading to <option>data</option> being an empty
57439 string), Exim gives up on the address without trying any subsequent routers.
57440 </para>
57441 <para>
57442 This one router can handle all the virtual domains because the alias file names
57443 follow a fixed pattern. Permissions can be arranged so that appropriate people
57444 can edit the different alias files. A successful aliasing operation results in
57445 a new envelope recipient address, which is then routed from scratch.
57446 </para>
57447 <para>
57448 The other kind of <quote>virtual</quote> domain can also be handled in a straightforward
57449 way. One approach is to create a file for each domain containing a list of
57450 valid local parts, and use it in a router like this:
57451 </para>
57452 <literallayout class="monospaced">
57453 my_domains:
57454   driver = accept
57455   domains = dsearch;/etc/mail/domains
57456   local_parts = lsearch;/etc/mail/domains/$domain
57457   transport = my_mailboxes
57458 </literallayout>
57459 <para>
57460 The address is accepted if there is a file for the domain, and the local part
57461 can be found in the file. The <option>domains</option> option is used to check for the
57462 file&#x2019;s existence because <option>domains</option> is tested before the <option>local_parts</option>
57463 option (see section <xref linkend="SECTrouprecon"/>). You cannot use <option>require_files</option>,
57464 because that option is tested after <option>local_parts</option>. The transport is as
57465 follows:
57466 </para>
57467 <literallayout class="monospaced">
57468 my_mailboxes:
57469   driver = appendfile
57470   file = /var/mail/$domain/$local_part
57471   user = mail
57472 </literallayout>
57473 <para>
57474 This uses a directory of mailboxes for each domain. The <option>user</option> setting is
57475 required, to specify which uid is to be used for writing to the mailboxes.
57476 </para>
57477 <para>
57478 The configuration shown here is just one example of how you might support this
57479 requirement. There are many other ways this kind of configuration can be set
57480 up, for example, by using a database instead of separate files to hold all the
57481 information about the domains.
57482 </para>
57483 </section>
57484 <section id="SECTmulbox">
57485 <title>Multiple user mailboxes</title>
57486 <para>
57487 <indexterm role="concept">
57488 <primary>multiple mailboxes</primary>
57489 </indexterm>
57490 <indexterm role="concept">
57491 <primary>mailbox</primary>
57492 <secondary>multiple</secondary>
57493 </indexterm>
57494 <indexterm role="concept">
57495 <primary>local part</primary>
57496 <secondary>prefix</secondary>
57497 </indexterm>
57498 <indexterm role="concept">
57499 <primary>local part</primary>
57500 <secondary>suffix</secondary>
57501 </indexterm>
57502 Heavy email users often want to operate with multiple mailboxes, into which
57503 incoming mail is automatically sorted. A popular way of handling this is to
57504 allow users to use multiple sender addresses, so that replies can easily be
57505 identified. Users are permitted to add prefixes or suffixes to their local
57506 parts for this purpose. The wildcard facility of the generic router options
57507 <option>local_part_prefix</option> and <option>local_part_suffix</option> can be used for this. For
57508 example, consider this router:
57509 </para>
57510 <literallayout class="monospaced">
57511 userforward:
57512   driver = redirect
57513   check_local_user
57514   file = $home/.forward
57515   local_part_suffix = -*
57516   local_part_suffix_optional
57517   allow_filter
57518 </literallayout>
57519 <para>
57520 <indexterm role="variable">
57521 <primary><varname>$local_part_suffix</varname></primary>
57522 </indexterm>
57523 It runs a user&#x2019;s <filename>.forward</filename> file for all local parts of the form
57524 <emphasis>username-*</emphasis>. Within the filter file the user can distinguish different
57525 cases by testing the variable <varname>$local_part_suffix</varname>. For example:
57526 </para>
57527 <literallayout class="monospaced">
57528 if $local_part_suffix contains -special then
57529 save /home/$local_part/Mail/special
57530 endif
57531 </literallayout>
57532 <para>
57533 If the filter file does not exist, or does not deal with such addresses, they
57534 fall through to subsequent routers, and, assuming no subsequent use of the
57535 <option>local_part_suffix</option> option is made, they presumably fail. Thus, users have
57536 control over which suffixes are valid.
57537 </para>
57538 <para>
57539 Alternatively, a suffix can be used to trigger the use of a different
57540 <filename>.forward</filename> file &ndash; which is the way a similar facility is implemented in
57541 another MTA:
57542 </para>
57543 <literallayout class="monospaced">
57544 userforward:
57545   driver = redirect
57546   check_local_user
57547   file = $home/.forward$local_part_suffix
57548   local_part_suffix = -*
57549   local_part_suffix_optional
57550   allow_filter
57551 </literallayout>
57552 <para>
57553 If there is no suffix, <filename>.forward</filename> is used; if the suffix is <emphasis>-special</emphasis>, for
57554 example, <filename>.forward-special</filename> is used. Once again, if the appropriate file
57555 does not exist, or does not deal with the address, it is passed on to
57556 subsequent routers, which could, if required, look for an unqualified
57557 <filename>.forward</filename> file to use as a default.
57558 </para>
57559 </section>
57560 <section id="SECID244">
57561 <title>Simplified vacation processing</title>
57562 <para>
57563 <indexterm role="concept">
57564 <primary>vacation processing</primary>
57565 </indexterm>
57566 The traditional way of running the <emphasis>vacation</emphasis> program is for a user to set up
57567 a pipe command in a <filename>.forward</filename> file
57568 (see section <xref linkend="SECTspecitredli"/> for syntax details).
57569 This is prone to error by inexperienced users. There are two features of Exim
57570 that can be used to make this process simpler for users:
57571 </para>
57572 <itemizedlist>
57573 <listitem>
57574 <para>
57575 A local part prefix such as <quote>vacation-</quote> can be specified on a router which
57576 can cause the message to be delivered directly to the <emphasis>vacation</emphasis> program, or
57577 alternatively can use Exim&#x2019;s <command>autoreply</command> transport. The contents of a user&#x2019;s
57578 <filename>.forward</filename> file are then much simpler. For example:
57579 </para>
57580 <literallayout class="monospaced">
57581 spqr, vacation-spqr
57582 </literallayout>
57583 </listitem>
57584 <listitem>
57585 <para>
57586 The <option>require_files</option> generic router option can be used to trigger a
57587 vacation delivery by checking for the existence of a certain file in the
57588 user&#x2019;s home directory. The <option>unseen</option> generic option should also be used, to
57589 ensure that the original delivery also proceeds. In this case, all the user has
57590 to do is to create a file called, say, <filename>.vacation</filename>, containing a vacation
57591 message.
57592 </para>
57593 </listitem>
57594 </itemizedlist>
57595 <para>
57596 Another advantage of both these methods is that they both work even when the
57597 use of arbitrary pipes by users is locked out.
57598 </para>
57599 </section>
57600 <section id="SECID245">
57601 <title>Taking copies of mail</title>
57602 <para>
57603 <indexterm role="concept">
57604 <primary>message</primary>
57605 <secondary>copying every</secondary>
57606 </indexterm>
57607 Some installations have policies that require archive copies of all messages to
57608 be made. A single copy of each message can easily be taken by an appropriate
57609 command in a system filter, which could, for example, use a different file for
57610 each day&#x2019;s messages.
57611 </para>
57612 <para>
57613 There is also a shadow transport mechanism that can be used to take copies of
57614 messages that are successfully delivered by local transports, one copy per
57615 delivery. This could be used, <emphasis>inter alia</emphasis>, to implement automatic
57616 notification of delivery by sites that insist on doing such things.
57617 </para>
57618 </section>
57619 <section id="SECID246">
57620 <title>Intermittently connected hosts</title>
57621 <para>
57622 <indexterm role="concept">
57623 <primary>intermittently connected hosts</primary>
57624 </indexterm>
57625 It has become quite common (because it is cheaper) for hosts to connect to the
57626 Internet periodically rather than remain connected all the time. The normal
57627 arrangement is that mail for such hosts accumulates on a system that is
57628 permanently connected.
57629 </para>
57630 <para>
57631 Exim was designed for use on permanently connected hosts, and so it is not
57632 particularly well-suited to use in an intermittently connected environment.
57633 Nevertheless there are some features that can be used.
57634 </para>
57635 </section>
57636 <section id="SECID247">
57637 <title>Exim on the upstream server host</title>
57638 <para>
57639 It is tempting to arrange for incoming mail for the intermittently connected
57640 host to remain on Exim&#x2019;s queue until the client connects. However, this
57641 approach does not scale very well. Two different kinds of waiting message are
57642 being mixed up in the same queue &ndash; those that cannot be delivered because of
57643 some temporary problem, and those that are waiting for their destination host
57644 to connect. This makes it hard to manage the queue, as well as wasting
57645 resources, because each queue runner scans the entire queue.
57646 </para>
57647 <para>
57648 A better approach is to separate off those messages that are waiting for an
57649 intermittently connected host. This can be done by delivering these messages
57650 into local files in batch SMTP, <quote>mailstore</quote>, or other envelope-preserving
57651 format, from where they are transmitted by other software when their
57652 destination connects. This makes it easy to collect all the mail for one host
57653 in a single directory, and to apply local timeout rules on a per-message basis
57654 if required.
57655 </para>
57656 <para>
57657 On a very small scale, leaving the mail on Exim&#x2019;s queue can be made to work. If
57658 you are doing this, you should configure Exim with a long retry period for the
57659 intermittent host. For example:
57660 </para>
57661 <literallayout class="monospaced">
57662 cheshire.wonderland.fict.example    *   F,5d,24h
57663 </literallayout>
57664 <para>
57665 This stops a lot of failed delivery attempts from occurring, but Exim remembers
57666 which messages it has queued up for that host. Once the intermittent host comes
57667 online, forcing delivery of one message (either by using the <option>-M</option> or <option>-R</option>
57668 options, or by using the ETRN SMTP command (see section <xref linkend="SECTETRN"/>)
57669 causes all the queued up messages to be delivered, often down a single SMTP
57670 connection. While the host remains connected, any new messages get delivered
57671 immediately.
57672 </para>
57673 <para>
57674 If the connecting hosts do not have fixed IP addresses, that is, if a host is
57675 issued with a different IP address each time it connects, Exim&#x2019;s retry
57676 mechanisms on the holding host get confused, because the IP address is normally
57677 used as part of the key string for holding retry information. This can be
57678 avoided by unsetting <option>retry_include_ip_address</option> on the <command>smtp</command> transport.
57679 Since this has disadvantages for permanently connected hosts, it is best to
57680 arrange a separate transport for the intermittently connected ones.
57681 </para>
57682 </section>
57683 <section id="SECID248">
57684 <title>Exim on the intermittently connected client host</title>
57685 <para>
57686 The value of <option>smtp_accept_queue_per_connection</option> should probably be
57687 increased, or even set to zero (that is, disabled) on the intermittently
57688 connected host, so that all incoming messages down a single connection get
57689 delivered immediately.
57690 </para>
57691 <para>
57692 <indexterm role="concept">
57693 <primary>SMTP</primary>
57694 <secondary>passed connection</secondary>
57695 </indexterm>
57696 <indexterm role="concept">
57697 <primary>SMTP</primary>
57698 <secondary>multiple deliveries</secondary>
57699 </indexterm>
57700 <indexterm role="concept">
57701 <primary>multiple SMTP deliveries</primary>
57702 </indexterm>
57703 Mail waiting to be sent from an intermittently connected host will probably
57704 not have been routed, because without a connection DNS lookups are not
57705 possible. This means that if a normal queue run is done at connection time,
57706 each message is likely to be sent in a separate SMTP session. This can be
57707 avoided by starting the queue run with a command line option beginning with
57708 <option>-qq</option> instead of <option>-q</option>. In this case, the queue is scanned twice. In the
57709 first pass, routing is done but no deliveries take place. The second pass is a
57710 normal queue run; since all the messages have been previously routed, those
57711 destined for the same host are likely to get sent as multiple deliveries in a
57712 single SMTP connection.
57713 </para>
57714 </section>
57715 </chapter>
57716
57717 <chapter id="CHAPnonqueueing">
57718 <title>Using Exim as a non-queueing client</title>
57719 <titleabbrev>Exim as a non-queueing client</titleabbrev>
57720 <para>
57721 <indexterm role="concept">
57722 <primary>client, non-queueing</primary>
57723 </indexterm>
57724 <indexterm role="concept">
57725 <primary>smart host</primary>
57726 <secondary>suppressing queueing</secondary>
57727 </indexterm>
57728 On a personal computer, it is a common requirement for all
57729 email to be sent to a <quote>smart host</quote>. There are plenty of MUAs that can be
57730 configured to operate that way, for all the popular operating systems.
57731 However, there are some MUAs for Unix-like systems that cannot be so
57732 configured: they submit messages using the command line interface of
57733 <filename>/usr/sbin/sendmail</filename>. Furthermore, utility programs such as <emphasis>cron</emphasis> submit
57734 messages this way.
57735 </para>
57736 <para>
57737 If the personal computer runs continuously, there is no problem, because it can
57738 run a conventional MTA that handles delivery to the smart host, and deal with
57739 any delays via its queueing mechanism. However, if the computer does not run
57740 continuously or runs different operating systems at different times, queueing
57741 email is not desirable.
57742 </para>
57743 <para>
57744 There is therefore a requirement for something that can provide the
57745 <filename>/usr/sbin/sendmail</filename> interface but deliver messages to a smart host without
57746 any queueing or retrying facilities. Furthermore, the delivery to the smart
57747 host should be synchronous, so that if it fails, the sending MUA is immediately
57748 informed. In other words, we want something that extends an MUA that submits
57749 to a local MTA via the command line so that it behaves like one that submits
57750 to a remote smart host using TCP/SMTP.
57751 </para>
57752 <para>
57753 There are a number of applications (for example, there is one called <emphasis>ssmtp</emphasis>)
57754 that do this job. However, people have found them to be lacking in various
57755 ways. For instance, you might want to allow aliasing and forwarding to be done
57756 before sending a message to the smart host.
57757 </para>
57758 <para>
57759 Exim already had the necessary infrastructure for doing this job. Just a few
57760 tweaks were needed to make it behave as required, though it is somewhat of an
57761 overkill to use a fully-featured MTA for this purpose.
57762 </para>
57763 <para>
57764 <indexterm role="option">
57765 <primary><option>mua_wrapper</option></primary>
57766 </indexterm>
57767 There is a Boolean global option called <option>mua_wrapper</option>, defaulting false.
57768 Setting <option>mua_wrapper</option> true causes Exim to run in a special mode where it
57769 assumes that it is being used to <quote>wrap</quote> a command-line MUA in the manner
57770 just described. As well as setting <option>mua_wrapper</option>, you also need to provide a
57771 compatible router and transport configuration. Typically there will be just one
57772 router and one transport, sending everything to a smart host.
57773 </para>
57774 <para>
57775 When run in MUA wrapping mode, the behaviour of Exim changes in the
57776 following ways:
57777 </para>
57778 <itemizedlist>
57779 <listitem>
57780 <para>
57781 A daemon cannot be run, nor will Exim accept incoming messages from <emphasis>inetd</emphasis>.
57782 In other words, the only way to submit messages is via the command line.
57783 </para>
57784 </listitem>
57785 <listitem>
57786 <para>
57787 Each message is synchronously delivered as soon as it is received (<option>-odi</option> is
57788 assumed). All queueing options (<option>queue_only</option>, <option>queue_smtp_domains</option>,
57789 <option>control</option> in an ACL, etc.) are quietly ignored. The Exim reception process
57790 does not finish until the delivery attempt is complete. If the delivery is
57791 successful, a zero return code is given.
57792 </para>
57793 </listitem>
57794 <listitem>
57795 <para>
57796 Address redirection is permitted, but the final routing for all addresses must
57797 be to the same remote transport, and to the same list of hosts. Furthermore,
57798 the return address (envelope sender) must be the same for all recipients, as
57799 must any added or deleted header lines. In other words, it must be possible to
57800 deliver the message in a single SMTP transaction, however many recipients there
57801 are.
57802 </para>
57803 </listitem>
57804 <listitem>
57805 <para>
57806 If these conditions are not met, or if routing any address results in a
57807 failure or defer status, or if Exim is unable to deliver all the recipients
57808 successfully to one of the smart hosts, delivery of the entire message fails.
57809 </para>
57810 </listitem>
57811 <listitem>
57812 <para>
57813 Because no queueing is allowed, all failures are treated as permanent; there
57814 is no distinction between 4<emphasis>xx</emphasis> and 5<emphasis>xx</emphasis> SMTP response codes from the
57815 smart host. Furthermore, because only a single yes/no response can be given to
57816 the caller, it is not possible to deliver to some recipients and not others. If
57817 there is an error (temporary or permanent) for any recipient, all are failed.
57818 </para>
57819 </listitem>
57820 <listitem>
57821 <para>
57822 If more than one smart host is listed, Exim will try another host after a
57823 connection failure or a timeout, in the normal way. However, if this kind of
57824 failure happens for all the hosts, the delivery fails.
57825 </para>
57826 </listitem>
57827 <listitem>
57828 <para>
57829 When delivery fails, an error message is written to the standard error stream
57830 (as well as to Exim&#x2019;s log), and Exim exits to the caller with a return code
57831 value 1. The message is expunged from Exim&#x2019;s spool files. No bounce messages
57832 are ever generated.
57833 </para>
57834 </listitem>
57835 <listitem>
57836 <para>
57837 No retry data is maintained, and any retry rules are ignored.
57838 </para>
57839 </listitem>
57840 <listitem>
57841 <para>
57842 A number of Exim options are overridden: <option>deliver_drop_privilege</option> is forced
57843 true, <option>max_rcpt</option> in the <command>smtp</command> transport is forced to <quote>unlimited</quote>,
57844 <option>remote_max_parallel</option> is forced to one, and fallback hosts are ignored.
57845 </para>
57846 </listitem>
57847 </itemizedlist>
57848 <para>
57849 The overall effect is that Exim makes a single synchronous attempt to deliver
57850 the message, failing if there is any kind of problem. Because no local
57851 deliveries are done and no daemon can be run, Exim does not need root
57852 privilege. It should be possible to run it setuid to <emphasis>exim</emphasis> instead of setuid
57853 to <emphasis>root</emphasis>. See section <xref linkend="SECTrunexiwitpri"/> for a general discussion about
57854 the advantages and disadvantages of running without root privilege.
57855 </para>
57856 </chapter>
57857
57858 <chapter id="CHAPlog">
57859 <title>Log files</title>
57860 <para>
57861 <indexterm role="concept" id="IIDloggen" class="startofrange">
57862 <primary>log</primary>
57863 <secondary>general description</secondary>
57864 </indexterm>
57865 <indexterm role="concept">
57866 <primary>log</primary>
57867 <secondary>types of</secondary>
57868 </indexterm>
57869 Exim writes three different logs, referred to as the main log, the reject log,
57870 and the panic log:
57871 </para>
57872 <itemizedlist>
57873 <listitem>
57874 <para>
57875 <indexterm role="concept">
57876 <primary>main log</primary>
57877 </indexterm>
57878 The main log records the arrival of each message and each delivery in a single
57879 line in each case. The format is as compact as possible, in an attempt to keep
57880 down the size of log files. Two-character flag sequences make it easy to pick
57881 out these lines. A number of other events are recorded in the main log. Some of
57882 them are optional, in which case the <option>log_selector</option> option controls whether
57883 they are included or not. A Perl script called <emphasis>eximstats</emphasis>, which does simple
57884 analysis of main log files, is provided in the Exim distribution (see section
57885 <xref linkend="SECTmailstat"/>).
57886 </para>
57887 </listitem>
57888 <listitem>
57889 <para>
57890 <indexterm role="concept">
57891 <primary>reject log</primary>
57892 </indexterm>
57893 The reject log records information from messages that are rejected as a result
57894 of a configuration option (that is, for policy reasons).
57895 The first line of each rejection is a copy of the line that is also written to
57896 the main log. Then, if the message&#x2019;s header has been read at the time the log
57897 is written, its contents are written to this log. Only the original header
57898 lines are available; header lines added by ACLs are not logged. You can use the
57899 reject log to check that your policy controls are working correctly; on a busy
57900 host this may be easier than scanning the main log for rejection messages. You
57901 can suppress the writing of the reject log by setting <option>write_rejectlog</option>
57902 false.
57903 </para>
57904 </listitem>
57905 <listitem>
57906 <para>
57907 <indexterm role="concept">
57908 <primary>panic log</primary>
57909 </indexterm>
57910 <indexterm role="concept">
57911 <primary>system log</primary>
57912 </indexterm>
57913 When certain serious errors occur, Exim writes entries to its panic log. If the
57914 error is sufficiently disastrous, Exim bombs out afterwards. Panic log entries
57915 are usually written to the main log as well, but can get lost amid the mass of
57916 other entries. The panic log should be empty under normal circumstances. It is
57917 therefore a good idea to check it (or to have a <emphasis>cron</emphasis> script check it)
57918 regularly, in order to become aware of any problems. When Exim cannot open its
57919 panic log, it tries as a last resort to write to the system log (syslog). This
57920 is opened with LOG_PID+LOG_CONS and the facility code of LOG_MAIL. The
57921 message itself is written at priority LOG_CRIT.
57922 </para>
57923 </listitem>
57924 </itemizedlist>
57925 <para>
57926 Every log line starts with a timestamp, in the format shown in the following
57927 example. Note that many of the examples shown in this chapter are line-wrapped.
57928 In the log file, this would be all on one line:
57929 </para>
57930 <literallayout class="monospaced">
57931 2001-09-16 16:09:47 SMTP connection from [127.0.0.1] closed
57932   by QUIT
57933 </literallayout>
57934 <para>
57935 By default, the timestamps are in the local timezone. There are two
57936 ways of changing this:
57937 </para>
57938 <itemizedlist>
57939 <listitem>
57940 <para>
57941 You can set the <option>timezone</option> option to a different time zone; in particular, if
57942 you set
57943 </para>
57944 <literallayout class="monospaced">
57945 timezone = UTC
57946 </literallayout>
57947 <para>
57948 the timestamps will be in UTC (aka GMT).
57949 </para>
57950 </listitem>
57951 <listitem>
57952 <para>
57953 If you set <option>log_timezone</option> true, the time zone is added to the timestamp, for
57954 example:
57955 </para>
57956 <literallayout class="monospaced">
57957 2003-04-25 11:17:07 +0100 Start queue run: pid=12762
57958 </literallayout>
57959 </listitem>
57960 </itemizedlist>
57961 <para>
57962 <indexterm role="concept">
57963 <primary>log</primary>
57964 <secondary>process ids in</secondary>
57965 </indexterm>
57966 <indexterm role="concept">
57967 <primary>pid (process id)</primary>
57968 <secondary>in log lines</secondary>
57969 </indexterm>
57970 Exim does not include its process id in log lines by default, but you can
57971 request that it does so by specifying the <literal>pid</literal> log selector (see section
57972 <xref linkend="SECTlogselector"/>). When this is set, the process id is output, in square
57973 brackets, immediately after the time and date.
57974 </para>
57975 <section id="SECTwhelogwri">
57976 <title>Where the logs are written</title>
57977 <para>
57978 <indexterm role="concept">
57979 <primary>log</primary>
57980 <secondary>destination</secondary>
57981 </indexterm>
57982 <indexterm role="concept">
57983 <primary>log</primary>
57984 <secondary>to file</secondary>
57985 </indexterm>
57986 <indexterm role="concept">
57987 <primary>log</primary>
57988 <secondary>to syslog</secondary>
57989 </indexterm>
57990 <indexterm role="concept">
57991 <primary>syslog</primary>
57992 </indexterm>
57993 The logs may be written to local files, or to syslog, or both. However, it
57994 should be noted that many syslog implementations use UDP as a transport, and
57995 are therefore unreliable in the sense that messages are not guaranteed to
57996 arrive at the loghost, nor is the ordering of messages necessarily maintained.
57997 It has also been reported that on large log files (tens of megabytes) you may
57998 need to tweak syslog to prevent it syncing the file with each write &ndash; on
57999 Linux this has been seen to make syslog take 90% plus of CPU time.
58000 </para>
58001 <para>
58002 The destination for Exim&#x2019;s logs is configured by setting LOG_FILE_PATH in
58003 <filename>Local/Makefile</filename> or by setting <option>log_file_path</option> in the run time
58004 configuration. This latter string is expanded, so it can contain, for example,
58005 references to the host name:
58006 </para>
58007 <literallayout class="monospaced">
58008 log_file_path = /var/log/$primary_hostname/exim_%slog
58009 </literallayout>
58010 <para>
58011 It is generally advisable, however, to set the string in <filename>Local/Makefile</filename>
58012 rather than at run time, because then the setting is available right from the
58013 start of Exim&#x2019;s execution. Otherwise, if there&#x2019;s something it wants to log
58014 before it has read the configuration file (for example, an error in the
58015 configuration file) it will not use the path you want, and may not be able to
58016 log at all.
58017 </para>
58018 <para>
58019 The value of LOG_FILE_PATH or <option>log_file_path</option> is a colon-separated
58020 list, currently limited to at most two items. This is one option where the
58021 facility for changing a list separator may not be used. The list must always be
58022 colon-separated. If an item in the list is <quote>syslog</quote> then syslog is used;
58023 otherwise the item must either be an absolute path, containing <literal>%s</literal> at the
58024 point where <quote>main</quote>, <quote>reject</quote>, or <quote>panic</quote> is to be inserted, or be empty,
58025 implying the use of a default path.
58026 </para>
58027 <para>
58028 When Exim encounters an empty item in the list, it searches the list defined by
58029 LOG_FILE_PATH, and uses the first item it finds that is neither empty nor
58030 <quote>syslog</quote>. This means that an empty item in <option>log_file_path</option> can be used to
58031 mean <quote>use the path specified at build time</quote>. It no such item exists, log
58032 files are written in the <filename>log</filename> subdirectory of the spool directory. This is
58033 equivalent to the setting:
58034 </para>
58035 <literallayout class="monospaced">
58036 log_file_path = $spool_directory/log/%slog
58037 </literallayout>
58038 <para>
58039 If you do not specify anything at build time or run time, that is where the
58040 logs are written.
58041 </para>
58042 <para>
58043 A log file path may also contain <literal>%D</literal> if datestamped log file names are in
58044 use &ndash; see section <xref linkend="SECTdatlogfil"/> below.
58045 </para>
58046 <para>
58047 Here are some examples of possible settings:
58048 </para>
58049 <literallayout>
58050 <literal>LOG_FILE_PATH=syslog                    </literal> syslog only
58051 <literal>LOG_FILE_PATH=:syslog                   </literal> syslog and default path
58052 <literal>LOG_FILE_PATH=syslog : /usr/log/exim_%s </literal> syslog and specified path
58053 <literal>LOG_FILE_PATH=/usr/log/exim_%s          </literal> specified path only
58054 </literallayout>
58055 <para>
58056 If there are more than two paths in the list, the first is used and a panic
58057 error is logged.
58058 </para>
58059 </section>
58060 <section id="SECID285">
58061 <title>Logging to local files that are periodically <quote>cycled</quote></title>
58062 <para>
58063 <indexterm role="concept">
58064 <primary>log</primary>
58065 <secondary>cycling local files</secondary>
58066 </indexterm>
58067 <indexterm role="concept">
58068 <primary>cycling logs</primary>
58069 </indexterm>
58070 <indexterm role="concept">
58071 <primary><emphasis>exicyclog</emphasis></primary>
58072 </indexterm>
58073 <indexterm role="concept">
58074 <primary>log</primary>
58075 <secondary>local files; writing to</secondary>
58076 </indexterm>
58077 Some operating systems provide centralized and standardized methods for cycling
58078 log files. For those that do not, a utility script called <emphasis>exicyclog</emphasis> is
58079 provided (see section <xref linkend="SECTcyclogfil"/>). This renames and compresses the
58080 main and reject logs each time it is called. The maximum number of old logs to
58081 keep can be set. It is suggested this script is run as a daily <emphasis>cron</emphasis> job.
58082 </para>
58083 <para>
58084 An Exim delivery process opens the main log when it first needs to write to it,
58085 and it keeps the file open in case subsequent entries are required &ndash; for
58086 example, if a number of different deliveries are being done for the same
58087 message. However, remote SMTP deliveries can take a long time, and this means
58088 that the file may be kept open long after it is renamed if <emphasis>exicyclog</emphasis> or
58089 something similar is being used to rename log files on a regular basis. To
58090 ensure that a switch of log files is noticed as soon as possible, Exim calls
58091 <function>stat()</function> on the main log&#x2019;s name before reusing an open file, and if the file
58092 does not exist, or its inode has changed, the old file is closed and Exim
58093 tries to open the main log from scratch. Thus, an old log file may remain open
58094 for quite some time, but no Exim processes should write to it once it has been
58095 renamed.
58096 </para>
58097 </section>
58098 <section id="SECTdatlogfil">
58099 <title>Datestamped log files</title>
58100 <para>
58101 <indexterm role="concept">
58102 <primary>log</primary>
58103 <secondary>datestamped files</secondary>
58104 </indexterm>
58105 Instead of cycling the main and reject log files by renaming them
58106 periodically, some sites like to use files whose names contain a datestamp,
58107 for example, <filename>mainlog-20031225</filename>. The datestamp is in the form <filename>yyyymmdd</filename>.
58108 Exim has support for this way of working. It is enabled by setting the
58109 <option>log_file_path</option> option to a path that includes <literal>%D</literal> at the point where the
58110 datestamp is required. For example:
58111 </para>
58112 <literallayout class="monospaced">
58113 log_file_path = /var/spool/exim/log/%slog-%D
58114 log_file_path = /var/log/exim-%s-%D.log
58115 log_file_path = /var/spool/exim/log/%D-%slog
58116 </literallayout>
58117 <para>
58118 As before, <literal>%s</literal> is replaced by <quote>main</quote> or <quote>reject</quote>; the following are
58119 examples of names generated by the above examples:
58120 </para>
58121 <literallayout class="monospaced">
58122 /var/spool/exim/log/mainlog-20021225
58123 /var/log/exim-reject-20021225.log
58124 /var/spool/exim/log/20021225-mainlog
58125 </literallayout>
58126 <para>
58127 When this form of log file is specified, Exim automatically switches to new
58128 files at midnight. It does not make any attempt to compress old logs; you
58129 will need to write your own script if you require this. You should not
58130 run <emphasis>exicyclog</emphasis> with this form of logging.
58131 </para>
58132 <para>
58133 The location of the panic log is also determined by <option>log_file_path</option>, but it
58134 is not datestamped, because rotation of the panic log does not make sense.
58135 When generating the name of the panic log, <literal>%D</literal> is removed from the string.
58136 In addition, if it immediately follows a slash, a following non-alphanumeric
58137 character is removed; otherwise a preceding non-alphanumeric character is
58138 removed. Thus, the three examples above would give these panic log names:
58139 </para>
58140 <literallayout class="monospaced">
58141 /var/spool/exim/log/paniclog
58142 /var/log/exim-panic.log
58143 /var/spool/exim/log/paniclog
58144 </literallayout>
58145 </section>
58146 <section id="SECID249">
58147 <title>Logging to syslog</title>
58148 <para>
58149 <indexterm role="concept">
58150 <primary>log</primary>
58151 <secondary>syslog; writing to</secondary>
58152 </indexterm>
58153 The use of syslog does not change what Exim logs or the format of its messages,
58154 except in one respect. If <option>syslog_timestamp</option> is set false, the timestamps on
58155 Exim&#x2019;s log lines are omitted when these lines are sent to syslog. Apart from
58156 that, the same strings are written to syslog as to log files. The syslog
58157 <quote>facility</quote> is set to LOG_MAIL, and the program name to <quote>exim</quote>
58158 by default, but you can change these by setting the <option>syslog_facility</option> and
58159 <option>syslog_processname</option> options, respectively. If Exim was compiled with
58160 SYSLOG_LOG_PID set in <filename>Local/Makefile</filename> (this is the default in
58161 <filename>src/EDITME</filename>), then, on systems that permit it (all except ULTRIX), the
58162 LOG_PID flag is set so that the <function>syslog()</function> call adds the pid as well as
58163 the time and host name to each line.
58164 The three log streams are mapped onto syslog priorities as follows:
58165 </para>
58166 <itemizedlist>
58167 <listitem>
58168 <para>
58169 <emphasis>mainlog</emphasis> is mapped to LOG_INFO
58170 </para>
58171 </listitem>
58172 <listitem>
58173 <para>
58174 <emphasis>rejectlog</emphasis> is mapped to LOG_NOTICE
58175 </para>
58176 </listitem>
58177 <listitem>
58178 <para>
58179 <emphasis>paniclog</emphasis> is mapped to LOG_ALERT
58180 </para>
58181 </listitem>
58182 </itemizedlist>
58183 <para>
58184 Many log lines are written to both <emphasis>mainlog</emphasis> and <emphasis>rejectlog</emphasis>, and some are
58185 written to both <emphasis>mainlog</emphasis> and <emphasis>paniclog</emphasis>, so there will be duplicates if
58186 these are routed by syslog to the same place. You can suppress this duplication
58187 by setting <option>syslog_duplication</option> false.
58188 </para>
58189 <para>
58190 Exim&#x2019;s log lines can sometimes be very long, and some of its <emphasis>rejectlog</emphasis>
58191 entries contain multiple lines when headers are included. To cope with both
58192 these cases, entries written to syslog are split into separate <function>syslog()</function>
58193 calls at each internal newline, and also after a maximum of
58194 870 data characters. (This allows for a total syslog line length of 1024, when
58195 additions such as timestamps are added.) If you are running a syslog
58196 replacement that can handle lines longer than the 1024 characters allowed by
58197 RFC 3164, you should set
58198 </para>
58199 <literallayout class="monospaced">
58200 SYSLOG_LONG_LINES=yes
58201 </literallayout>
58202 <para>
58203 in <filename>Local/Makefile</filename> before building Exim. That stops Exim from splitting long
58204 lines, but it still splits at internal newlines in <emphasis>reject</emphasis> log entries.
58205 </para>
58206 <para>
58207 To make it easy to re-assemble split lines later, each component of a split
58208 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;]
58209 where &lt;<emphasis>n</emphasis>&gt; is the component number and &lt;<emphasis>m</emphasis>&gt; is the total number of
58210 components in the entry. The / delimiter is used when the line was split
58211 because it was too long; if it was split because of an internal newline, the \
58212 delimiter is used. For example, supposing the length limit to be 50 instead of
58213 870, the following would be the result of a typical rejection message to
58214 <emphasis>mainlog</emphasis> (LOG_INFO), each line in addition being preceded by the time, host
58215 name, and pid as added by syslog:
58216 </para>
58217 <literallayout class="monospaced">
58218 [1/5] 2002-09-16 16:09:43 16RdAL-0006pc-00 rejected from
58219 [2/5]  [127.0.0.1] (ph10): syntax error in 'From' header
58220 [3/5]  when scanning for sender: missing or malformed lo
58221 [4/5] cal part in "&lt;&gt;" (envelope sender is &lt;ph10@cam.exa
58222 [5/5] mple&gt;)
58223 </literallayout>
58224 <para>
58225 The same error might cause the following lines to be written to <quote>rejectlog</quote>
58226 (LOG_NOTICE):
58227 </para>
58228 <literallayout class="monospaced">
58229 [1/18] 2002-09-16 16:09:43 16RdAL-0006pc-00 rejected fro
58230 [2/18] m [127.0.0.1] (ph10): syntax error in 'From' head
58231 [3/18] er when scanning for sender: missing or malformed
58232 [4/18]  local part in "&lt;&gt;" (envelope sender is &lt;ph10@cam
58233 [5\18] .example&gt;)
58234 [6\18] Recipients: ph10@some.domain.cam.example
58235 [7\18] P Received: from [127.0.0.1] (ident=ph10)
58236 [8\18]        by xxxxx.cam.example with smtp (Exim 4.00)
58237 [9\18]        id 16RdAL-0006pc-00
58238 [10/18]        for ph10@cam.example; Mon, 16 Sep 2002 16:
58239 [11\18] 09:43 +0100
58240 [12\18] F From: &lt;&gt;
58241 [13\18]   Subject: this is a test header
58242 [18\18]   X-something: this is another header
58243 [15/18] I Message-Id: &lt;E16RdAL-0006pc-00@xxxxx.cam.examp
58244 [16\18] le&gt;
58245 [17\18] B Bcc:
58246 [18/18]   Date: Mon, 16 Sep 2002 16:09:43 +0100
58247 </literallayout>
58248 <para>
58249 Log lines that are neither too long nor contain newlines are written to syslog
58250 without modification.
58251 </para>
58252 <para>
58253 If only syslog is being used, the Exim monitor is unable to provide a log tail
58254 display, unless syslog is routing <emphasis>mainlog</emphasis> to a file on the local host and
58255 the environment variable EXIMON_LOG_FILE_PATH is set to tell the monitor
58256 where it is.
58257 </para>
58258 </section>
58259 <section id="SECID250">
58260 <title>Log line flags</title>
58261 <para>
58262 One line is written to the main log for each message received, and for each
58263 successful, unsuccessful, and delayed delivery. These lines can readily be
58264 picked out by the distinctive two-character flags that immediately follow the
58265 timestamp. The flags are:
58266 </para>
58267 <literallayout>
58268 <literal>&lt;=</literal>     message arrival
58269 <literal>=&gt;</literal>     normal message delivery
58270 <literal>-&gt;</literal>     additional address in same delivery
58271 <literal>*&gt;</literal>     delivery suppressed by <option>-N</option>
58272 <literal>**</literal>     delivery failed; address bounced
58273 <literal>==</literal>     delivery deferred; temporary problem
58274 </literallayout>
58275 </section>
58276 <section id="SECID251">
58277 <title>Logging message reception</title>
58278 <para>
58279 <indexterm role="concept">
58280 <primary>log</primary>
58281 <secondary>reception line</secondary>
58282 </indexterm>
58283 The format of the single-line entry in the main log that is written for every
58284 message received is shown in the basic example below, which is split over
58285 several lines in order to fit it on the page:
58286 </para>
58287 <literallayout class="monospaced">
58288 2002-10-31 08:57:53 16ZCW1-0005MB-00 &lt;= kryten@dwarf.fict.example
58289   H=mailer.fict.example [192.168.123.123] U=exim
58290   P=smtp S=5678 id=&lt;incoming message id&gt;
58291 </literallayout>
58292 <para>
58293 The address immediately following <quote>&lt;=</quote> is the envelope sender address. A
58294 bounce message is shown with the sender address <quote>&lt;&gt;</quote>, and if it is locally
58295 generated, this is followed by an item of the form
58296 </para>
58297 <literallayout class="monospaced">
58298 R=&lt;message id&gt;
58299 </literallayout>
58300 <para>
58301 which is a reference to the message that caused the bounce to be sent.
58302 </para>
58303 <para>
58304 <indexterm role="concept">
58305 <primary>HELO</primary>
58306 </indexterm>
58307 <indexterm role="concept">
58308 <primary>EHLO</primary>
58309 </indexterm>
58310 For messages from other hosts, the H and U fields identify the remote host and
58311 record the RFC 1413 identity of the user that sent the message, if one was
58312 received. The number given in square brackets is the IP address of the sending
58313 host. If there is a single, unparenthesized  host name in the H field, as
58314 above, it has been verified to correspond to the IP address (see the
58315 <option>host_lookup</option> option). If the name is in parentheses, it was the name quoted
58316 by the remote host in the SMTP HELO or EHLO command, and has not been
58317 verified. If verification yields a different name to that given for HELO or
58318 EHLO, the verified name appears first, followed by the HELO or EHLO
58319 name in parentheses.
58320 </para>
58321 <para>
58322 Misconfigured hosts (and mail forgers) sometimes put an IP address, with or
58323 without brackets, in the HELO or EHLO command, leading to entries in
58324 the log containing text like these examples:
58325 </para>
58326 <literallayout class="monospaced">
58327 H=(10.21.32.43) [192.168.8.34]
58328 H=([10.21.32.43]) [192.168.8.34]
58329 </literallayout>
58330 <para>
58331 This can be confusing. Only the final address in square brackets can be relied
58332 on.
58333 </para>
58334 <para>
58335 For locally generated messages (that is, messages not received over TCP/IP),
58336 the H field is omitted, and the U field contains the login name of the caller
58337 of Exim.
58338 </para>
58339 <para>
58340 <indexterm role="concept">
58341 <primary>authentication</primary>
58342 <secondary>logging</secondary>
58343 </indexterm>
58344 <indexterm role="concept">
58345 <primary>AUTH</primary>
58346 <secondary>logging</secondary>
58347 </indexterm>
58348 For all messages, the P field specifies the protocol used to receive the
58349 message. This is the value that is stored in <varname>$received_protocol</varname>. In the case
58350 of incoming SMTP messages, the value indicates whether or not any SMTP
58351 extensions (ESMTP), encryption, or authentication were used. If the SMTP
58352 session was encrypted, there is an additional X field that records the cipher
58353 suite that was used.
58354 </para>
58355 <para>
58356 The protocol is set to <quote>esmtpsa</quote> or <quote>esmtpa</quote> for messages received from
58357 hosts that have authenticated themselves using the SMTP AUTH command. The first
58358 value is used when the SMTP connection was encrypted (<quote>secure</quote>). In this case
58359 there is an additional item A= followed by the name of the authenticator that
58360 was used. If an authenticated identification was set up by the authenticator&#x2019;s
58361 <option>server_set_id</option> option, this is logged too, separated by a colon from the
58362 authenticator name.
58363 </para>
58364 <para>
58365 <indexterm role="concept">
58366 <primary>size</primary>
58367 <secondary>of message</secondary>
58368 </indexterm>
58369 The id field records the existing message id, if present. The size of the
58370 received message is given by the S field. When the message is delivered,
58371 headers may be removed or added, so that the size of delivered copies of the
58372 message may not correspond with this value (and indeed may be different to each
58373 other).
58374 </para>
58375 <para>
58376 The <option>log_selector</option> option can be used to request the logging of additional
58377 data when a message is received. See section <xref linkend="SECTlogselector"/> below.
58378 </para>
58379 </section>
58380 <section id="SECID252">
58381 <title>Logging deliveries</title>
58382 <para>
58383 <indexterm role="concept">
58384 <primary>log</primary>
58385 <secondary>delivery line</secondary>
58386 </indexterm>
58387 The format of the single-line entry in the main log that is written for every
58388 delivery is shown in one of the examples below, for local and remote
58389 deliveries, respectively. Each example has been split into two lines in order
58390 to fit it on the page:
58391 </para>
58392 <literallayout class="monospaced">
58393 2002-10-31 08:59:13 16ZCW1-0005MB-00 =&gt; marv
58394   &lt;marv@hitch.fict.example&gt; R=localuser T=local_delivery
58395 2002-10-31 09:00:10 16ZCW1-0005MB-00 =&gt;
58396   monk@holistic.fict.example R=dnslookup T=remote_smtp
58397   H=holistic.fict.example [192.168.234.234]
58398 </literallayout>
58399 <para>
58400 For ordinary local deliveries, the original address is given in angle brackets
58401 after the final delivery address, which might be a pipe or a file. If
58402 intermediate address(es) exist between the original and the final address, the
58403 last of these is given in parentheses after the final address. The R and T
58404 fields record the router and transport that were used to process the address.
58405 </para>
58406 <para>
58407 If a shadow transport was run after a successful local delivery, the log line
58408 for the successful delivery has an item added on the end, of the form
58409 </para>
58410 <literallayout>
58411 <literal>ST=&lt;</literal><emphasis>shadow transport name</emphasis><literal>&gt;</literal>
58412 </literallayout>
58413 <para>
58414 If the shadow transport did not succeed, the error message is put in
58415 parentheses afterwards.
58416 </para>
58417 <para>
58418 <indexterm role="concept">
58419 <primary>asterisk</primary>
58420 <secondary>after IP address</secondary>
58421 </indexterm>
58422 When more than one address is included in a single delivery (for example, two
58423 SMTP RCPT commands in one transaction) the second and subsequent addresses are
58424 flagged with <literal>-&gt;</literal> instead of <literal>=&gt;</literal>. When two or more messages are delivered
58425 down a single SMTP connection, an asterisk follows the IP address in the log
58426 lines for the second and subsequent messages.
58427 </para>
58428 <para>
58429 The generation of a reply message by a filter file gets logged as a
58430 <quote>delivery</quote> to the addressee, preceded by <quote>&gt;</quote>.
58431 </para>
58432 <para>
58433 The <option>log_selector</option> option can be used to request the logging of additional
58434 data when a message is delivered. See section <xref linkend="SECTlogselector"/> below.
58435 </para>
58436 </section>
58437 <section id="SECID253">
58438 <title>Discarded deliveries</title>
58439 <para>
58440 <indexterm role="concept">
58441 <primary>discarded messages</primary>
58442 </indexterm>
58443 <indexterm role="concept">
58444 <primary>message</primary>
58445 <secondary>discarded</secondary>
58446 </indexterm>
58447 <indexterm role="concept">
58448 <primary>delivery</primary>
58449 <secondary>discarded; logging</secondary>
58450 </indexterm>
58451 When a message is discarded as a result of the command <quote>seen finish</quote> being
58452 obeyed in a filter file which generates no deliveries, a log entry of the form
58453 </para>
58454 <literallayout class="monospaced">
58455 2002-12-10 00:50:49 16auJc-0001UB-00 =&gt; discarded
58456   &lt;low.club@bridge.example&gt; R=userforward
58457 </literallayout>
58458 <para>
58459 is written, to record why no deliveries are logged. When a message is discarded
58460 because it is aliased to <quote>:blackhole:</quote> the log line is like this:
58461 </para>
58462 <literallayout class="monospaced">
58463 1999-03-02 09:44:33 10HmaX-0005vi-00 =&gt; :blackhole:
58464   &lt;hole@nowhere.example&gt; R=blackhole_router
58465 </literallayout>
58466 </section>
58467 <section id="SECID254">
58468 <title>Deferred deliveries</title>
58469 <para>
58470 When a delivery is deferred, a line of the following form is logged:
58471 </para>
58472 <literallayout class="monospaced">
58473 2002-12-19 16:20:23 16aiQz-0002Q5-00 == marvin@endrest.example
58474   R=dnslookup T=smtp defer (146): Connection refused
58475 </literallayout>
58476 <para>
58477 In the case of remote deliveries, the error is the one that was given for the
58478 last IP address that was tried. Details of individual SMTP failures are also
58479 written to the log, so the above line would be preceded by something like
58480 </para>
58481 <literallayout class="monospaced">
58482 2002-12-19 16:20:23 16aiQz-0002Q5-00 Failed to connect to
58483   mail1.endrest.example [192.168.239.239]: Connection refused
58484 </literallayout>
58485 <para>
58486 When a deferred address is skipped because its retry time has not been reached,
58487 a message is written to the log, but this can be suppressed by setting an
58488 appropriate value in <option>log_selector</option>.
58489 </para>
58490 </section>
58491 <section id="SECID255">
58492 <title>Delivery failures</title>
58493 <para>
58494 <indexterm role="concept">
58495 <primary>delivery</primary>
58496 <secondary>failure; logging</secondary>
58497 </indexterm>
58498 If a delivery fails because an address cannot be routed, a line of the
58499 following form is logged:
58500 </para>
58501 <literallayout class="monospaced">
58502 1995-12-19 16:20:23 0tRiQz-0002Q5-00 ** jim@trek99.example
58503   &lt;jim@trek99.example&gt;: unknown mail domain
58504 </literallayout>
58505 <para>
58506 If a delivery fails at transport time, the router and transport are shown, and
58507 the response from the remote host is included, as in this example:
58508 </para>
58509 <literallayout class="monospaced">
58510 2002-07-11 07:14:17 17SXDU-000189-00 ** ace400@pb.example
58511   R=dnslookup T=remote_smtp: SMTP error from remote mailer
58512   after pipelined RCPT TO:&lt;ace400@pb.example&gt;: host
58513   pbmail3.py.example [192.168.63.111]: 553 5.3.0
58514   &lt;ace400@pb.example&gt;...Addressee unknown
58515 </literallayout>
58516 <para>
58517 The word <quote>pipelined</quote> indicates that the SMTP PIPELINING extension was being
58518 used. See <option>hosts_avoid_esmtp</option> in the <command>smtp</command> transport for a way of
58519 disabling PIPELINING. The log lines for all forms of delivery failure are
58520 flagged with <literal>**</literal>.
58521 </para>
58522 </section>
58523 <section id="SECID256">
58524 <title>Fake deliveries</title>
58525 <para>
58526 <indexterm role="concept">
58527 <primary>delivery</primary>
58528 <secondary>fake; logging</secondary>
58529 </indexterm>
58530 If a delivery does not actually take place because the <option>-N</option> option has been
58531 used to suppress it, a normal delivery line is written to the log, except that
58532 <quote>=&gt;</quote> is replaced by <quote>*&gt;</quote>.
58533 </para>
58534 </section>
58535 <section id="SECID257">
58536 <title>Completion</title>
58537 <para>
58538 A line of the form
58539 </para>
58540 <literallayout class="monospaced">
58541 2002-10-31 09:00:11 16ZCW1-0005MB-00 Completed
58542 </literallayout>
58543 <para>
58544 is written to the main log when a message is about to be removed from the spool
58545 at the end of its processing.
58546 </para>
58547 </section>
58548 <section id="SECID258">
58549 <title>Summary of Fields in Log Lines</title>
58550 <para>
58551 <indexterm role="concept">
58552 <primary>log</primary>
58553 <secondary>summary of fields</secondary>
58554 </indexterm>
58555 A summary of the field identifiers that are used in log lines is shown in
58556 the following table:
58557 </para>
58558 <literallayout>
58559 <literal>A   </literal>        authenticator name (and optional id)
58560 <literal>C   </literal>        SMTP confirmation on delivery
58561 <literal>    </literal>        command list for <quote>no mail in SMTP session</quote>
58562 <literal>CV  </literal>        certificate verification status
58563 <literal>D   </literal>        duration of <quote>no mail in SMTP session</quote>
58564 <literal>DN  </literal>        distinguished name from peer certificate
58565 <literal>DT  </literal>        on <literal>=&gt;</literal> lines: time taken for a delivery
58566 <literal>F   </literal>        sender address (on delivery lines)
58567 <literal>H   </literal>        host name and IP address
58568 <literal>I   </literal>        local interface used
58569 <literal>id  </literal>        message id for incoming message
58570 <literal>P   </literal>        on <literal>&lt;=</literal> lines: protocol used
58571 <literal>    </literal>        on <literal>=&gt;</literal> and <literal>**</literal> lines: return path
58572 <literal>QT  </literal>        on <literal>=&gt;</literal> lines: time spent on queue so far
58573 <literal>    </literal>        on <quote>Completed</quote> lines: time spent on queue
58574 <literal>R   </literal>        on <literal>&lt;=</literal> lines: reference for local bounce
58575 <literal>    </literal>        on <literal>=&gt;</literal>  <literal>**</literal> and <literal>==</literal> lines: router name
58576 <literal>S   </literal>        size of message
58577 <literal>ST  </literal>        shadow transport name
58578 <literal>T   </literal>        on <literal>&lt;=</literal> lines: message subject (topic)
58579 <literal>    </literal>        on <literal>=&gt;</literal> <literal>**</literal> and <literal>==</literal> lines: transport name
58580 <literal>U   </literal>        local user or RFC 1413 identity
58581 <literal>X   </literal>        TLS cipher suite
58582 </literallayout>
58583 </section>
58584 <section id="SECID259">
58585 <title>Other log entries</title>
58586 <para>
58587 Various other types of log entry are written from time to time. Most should be
58588 self-explanatory. Among the more common are:
58589 </para>
58590 <itemizedlist>
58591 <listitem>
58592 <para>
58593 <indexterm role="concept">
58594 <primary>retry</primary>
58595 <secondary>time not reached</secondary>
58596 </indexterm>
58597 <emphasis>retry time not reached</emphasis>&nbsp;&nbsp;An address previously suffered a temporary error
58598 during routing or local delivery, and the time to retry has not yet arrived.
58599 This message is not written to an individual message log file unless it happens
58600 during the first delivery attempt.
58601 </para>
58602 </listitem>
58603 <listitem>
58604 <para>
58605 <emphasis>retry time not reached for any host</emphasis>&nbsp;&nbsp;An address previously suffered
58606 temporary errors during remote delivery, and the retry time has not yet arrived
58607 for any of the hosts to which it is routed.
58608 </para>
58609 </listitem>
58610 <listitem>
58611 <para>
58612 <indexterm role="concept">
58613 <primary>spool directory</primary>
58614 <secondary>file locked</secondary>
58615 </indexterm>
58616 <emphasis>spool file locked</emphasis>&nbsp;&nbsp;An attempt to deliver a message cannot proceed because
58617 some other Exim process is already working on the message. This can be quite
58618 common if queue running processes are started at frequent intervals. The
58619 <emphasis>exiwhat</emphasis> utility script can be used to find out what Exim processes are
58620 doing.
58621 </para>
58622 </listitem>
58623 <listitem>
58624 <para>
58625 <indexterm role="concept">
58626 <primary>error</primary>
58627 <secondary>ignored</secondary>
58628 </indexterm>
58629 <emphasis>error ignored</emphasis>&nbsp;&nbsp;There are several circumstances that give rise to this
58630 message:
58631 </para>
58632 <orderedlist numeration="arabic">
58633 <listitem>
58634 <para>
58635 Exim failed to deliver a bounce message whose age was greater than
58636 <option>ignore_bounce_errors_after</option>. The bounce was discarded.
58637 </para>
58638 </listitem>
58639 <listitem>
58640 <para>
58641 A filter file set up a delivery using the <quote>noerror</quote> option, and the delivery
58642 failed. The delivery was discarded.
58643 </para>
58644 </listitem>
58645 <listitem>
58646 <para>
58647 A delivery set up by a router configured with
58648 </para>
58649 <literallayout class="monospaced">
58650     errors_to = &lt;&gt;
58651 </literallayout>
58652 <para>
58653 failed. The delivery was discarded.
58654 </para>
58655 </listitem>
58656 </orderedlist>
58657 </listitem>
58658 </itemizedlist>
58659 </section>
58660 <section id="SECTlogselector">
58661 <title>Reducing or increasing what is logged</title>
58662 <para>
58663 <indexterm role="concept">
58664 <primary>log</primary>
58665 <secondary>selectors</secondary>
58666 </indexterm>
58667 By setting the <option>log_selector</option> global option, you can disable some of Exim&#x2019;s
58668 default logging, or you can request additional logging. The value of
58669 <option>log_selector</option> is made up of names preceded by plus or minus characters. For
58670 example:
58671 </para>
58672 <literallayout class="monospaced">
58673 log_selector = +arguments -retry_defer
58674 </literallayout>
58675 <para>
58676 The list of optional log items is in the following table, with the default
58677 selection marked by asterisks:
58678 </para>
58679 <literallayout>
58680 <literal>*acl_warn_skipped           </literal>  skipped <option>warn</option> statement in ACL
58681 <literal> address_rewrite            </literal>  address rewriting
58682 <literal> all_parents                </literal>  all parents in =&gt; lines
58683 <literal> arguments                  </literal>  command line arguments
58684 <literal>*connection_reject          </literal>  connection rejections
58685 <literal>*delay_delivery             </literal>  immediate delivery delayed
58686 <literal> deliver_time               </literal>  time taken to perform delivery
58687 <literal> delivery_size              </literal>  add <literal>S=</literal><emphasis>nnn</emphasis> to =&gt; lines
58688 <literal>*dnslist_defer              </literal>  defers of DNS list (aka RBL) lookups
58689 <literal>*etrn                       </literal>  ETRN commands
58690 <literal>*host_lookup_failed         </literal>  as it says
58691 <literal> ident_timeout              </literal>  timeout for ident connection
58692 <literal> incoming_interface         </literal>  incoming interface on &lt;= lines
58693 <literal> incoming_port              </literal>  incoming port on &lt;= lines
58694 <literal>*lost_incoming_connection   </literal>  as it says (includes timeouts)
58695 <literal> outgoing_port              </literal>  add remote port to =&gt; lines
58696 <literal>*queue_run                  </literal>  start and end queue runs
58697 <literal> queue_time                 </literal>  time on queue for one recipient
58698 <literal> queue_time_overall         </literal>  time on queue for whole message
58699 <literal> pid                        </literal>  Exim process id
58700 <literal> received_recipients        </literal>  recipients on &lt;= lines
58701 <literal> received_sender            </literal>  sender on &lt;= lines
58702 <literal>*rejected_header            </literal>  header contents on reject log
58703 <literal>*retry_defer                </literal>  <quote>retry time not reached</quote>
58704 <literal> return_path_on_delivery    </literal>  put return path on =&gt; and ** lines
58705 <literal> sender_on_delivery         </literal>  add sender to =&gt; lines
58706 <literal>*sender_verify_fail         </literal>  sender verification failures
58707 <literal>*size_reject                </literal>  rejection because too big
58708 <literal>*skip_delivery              </literal>  delivery skipped in a queue run
58709 <literal> smtp_confirmation          </literal>  SMTP confirmation on =&gt; lines
58710 <literal> smtp_connection            </literal>  SMTP connections
58711 <literal> smtp_incomplete_transaction</literal>  incomplete SMTP transactions
58712 <literal> smtp_no_mail               </literal>  session with no MAIL commands
58713 <literal> smtp_protocol_error        </literal>  SMTP protocol errors
58714 <literal> smtp_syntax_error          </literal>  SMTP syntax errors
58715 <literal> subject                    </literal>  contents of <emphasis>Subject:</emphasis> on &lt;= lines
58716 <literal> tls_certificate_verified   </literal>  certificate verification status
58717 <literal>*tls_cipher                 </literal>  TLS cipher suite on &lt;= and =&gt; lines
58718 <literal> tls_peerdn                 </literal>  TLS peer DN on &lt;= and =&gt; lines
58719 <literal> unknown_in_list            </literal>  DNS lookup failed in list match
58720
58721 <literal> all                        </literal>  all of the above
58722 </literallayout>
58723 <para>
58724 More details on each of these items follows:
58725 </para>
58726 <itemizedlist>
58727 <listitem>
58728 <para>
58729 <indexterm role="concept">
58730 <primary><option>warn</option> ACL verb</primary>
58731 <secondary>log when skipping</secondary>
58732 </indexterm>
58733 <option>acl_warn_skipped</option>: When an ACL <option>warn</option> statement is skipped because one of
58734 its conditions cannot be evaluated, a log line to this effect is written if
58735 this log selector is set.
58736 </para>
58737 </listitem>
58738 <listitem>
58739 <para>
58740 <indexterm role="concept">
58741 <primary>log</primary>
58742 <secondary>rewriting</secondary>
58743 </indexterm>
58744 <indexterm role="concept">
58745 <primary>rewriting</primary>
58746 <secondary>logging</secondary>
58747 </indexterm>
58748 <option>address_rewrite</option>: This applies both to global rewrites and per-transport
58749 rewrites, but not to rewrites in filters run as an unprivileged user (because
58750 such users cannot access the log).
58751 </para>
58752 </listitem>
58753 <listitem>
58754 <para>
58755 <indexterm role="concept">
58756 <primary>log</primary>
58757 <secondary>full parentage</secondary>
58758 </indexterm>
58759 <option>all_parents</option>: Normally only the original and final addresses are logged on
58760 delivery lines; with this selector, intermediate parents are given in
58761 parentheses between them.
58762 </para>
58763 </listitem>
58764 <listitem>
58765 <para>
58766 <indexterm role="concept">
58767 <primary>log</primary>
58768 <secondary>Exim arguments</secondary>
58769 </indexterm>
58770 <indexterm role="concept">
58771 <primary>Exim arguments, logging</primary>
58772 </indexterm>
58773 <option>arguments</option>: This causes Exim to write the arguments with which it was called
58774 to the main log, preceded by the current working directory. This is a debugging
58775 feature, added to make it easier to find out how certain MUAs call
58776 <filename>/usr/sbin/sendmail</filename>. The logging does not happen if Exim has given up root
58777 privilege because it was called with the <option>-C</option> or <option>-D</option> options. Arguments
58778 that are empty or that contain white space are quoted. Non-printing characters
58779 are shown as escape sequences. This facility cannot log unrecognized arguments,
58780 because the arguments are checked before the configuration file is read. The
58781 only way to log such cases is to interpose a script such as <filename>util/logargs.sh</filename>
58782 between the caller and Exim.
58783 </para>
58784 </listitem>
58785 <listitem>
58786 <para>
58787 <indexterm role="concept">
58788 <primary>log</primary>
58789 <secondary>connection rejections</secondary>
58790 </indexterm>
58791 <option>connection_reject</option>: A log entry is written whenever an incoming SMTP
58792 connection is rejected, for whatever reason.
58793 </para>
58794 </listitem>
58795 <listitem>
58796 <para>
58797 <indexterm role="concept">
58798 <primary>log</primary>
58799 <secondary>delayed delivery</secondary>
58800 </indexterm>
58801 <indexterm role="concept">
58802 <primary>delayed delivery, logging</primary>
58803 </indexterm>
58804 <option>delay_delivery</option>: A log entry is written whenever a delivery process is not
58805 started for an incoming message because the load is too high or too many
58806 messages were received on one connection. Logging does not occur if no delivery
58807 process is started because <option>queue_only</option> is set or <option>-odq</option> was used.
58808 </para>
58809 </listitem>
58810 <listitem>
58811 <para>
58812 <indexterm role="concept">
58813 <primary>log</primary>
58814 <secondary>delivery duration</secondary>
58815 </indexterm>
58816 <option>deliver_time</option>: For each delivery, the amount of real time it has taken to
58817 perform the actual delivery is logged as DT=&lt;<emphasis>time</emphasis>&gt;, for example, <literal>DT=1s</literal>.
58818 </para>
58819 </listitem>
58820 <listitem>
58821 <para>
58822 <indexterm role="concept">
58823 <primary>log</primary>
58824 <secondary>message size on delivery</secondary>
58825 </indexterm>
58826 <indexterm role="concept">
58827 <primary>size</primary>
58828 <secondary>of message</secondary>
58829 </indexterm>
58830 <option>delivery_size</option>: For each delivery, the size of message delivered is added to
58831 the <quote>=&gt;</quote> line, tagged with S=.
58832 </para>
58833 </listitem>
58834 <listitem>
58835 <para>
58836 <indexterm role="concept">
58837 <primary>log</primary>
58838 <secondary>dnslist defer</secondary>
58839 </indexterm>
58840 <indexterm role="concept">
58841 <primary>DNS list</primary>
58842 <secondary>logging defer</secondary>
58843 </indexterm>
58844 <indexterm role="concept">
58845 <primary>black list (DNS)</primary>
58846 </indexterm>
58847 <option>dnslist_defer</option>: A log entry is written if an attempt to look up a host in a
58848 DNS black list suffers a temporary error.
58849 </para>
58850 </listitem>
58851 <listitem>
58852 <para>
58853 <indexterm role="concept">
58854 <primary>log</primary>
58855 <secondary>ETRN commands</secondary>
58856 </indexterm>
58857 <indexterm role="concept">
58858 <primary>ETRN</primary>
58859 <secondary>logging</secondary>
58860 </indexterm>
58861 <option>etrn</option>: Every valid ETRN command that is received is logged, before the ACL
58862 is run to determine whether or not it is actually accepted. An invalid ETRN
58863 command, or one received within a message transaction is not logged by this
58864 selector (see <option>smtp_syntax_error</option> and <option>smtp_protocol_error</option>).
58865 </para>
58866 </listitem>
58867 <listitem>
58868 <para>
58869 <indexterm role="concept">
58870 <primary>log</primary>
58871 <secondary>host lookup failure</secondary>
58872 </indexterm>
58873 <option>host_lookup_failed</option>: When a lookup of a host&#x2019;s IP addresses fails to find
58874 any addresses, or when a lookup of an IP address fails to find a host name, a
58875 log line is written. This logging does not apply to direct DNS lookups when
58876 routing email addresses, but it does apply to <quote>byname</quote> lookups.
58877 </para>
58878 </listitem>
58879 <listitem>
58880 <para>
58881 <indexterm role="concept">
58882 <primary>log</primary>
58883 <secondary>ident timeout</secondary>
58884 </indexterm>
58885 <indexterm role="concept">
58886 <primary>RFC 1413</primary>
58887 <secondary>logging timeout</secondary>
58888 </indexterm>
58889 <option>ident_timeout</option>: A log line is written whenever an attempt to connect to a
58890 client&#x2019;s ident port times out.
58891 </para>
58892 </listitem>
58893 <listitem>
58894 <para>
58895 <indexterm role="concept">
58896 <primary>log</primary>
58897 <secondary>incoming interface</secondary>
58898 </indexterm>
58899 <indexterm role="concept">
58900 <primary>interface</primary>
58901 <secondary>logging</secondary>
58902 </indexterm>
58903 <option>incoming_interface</option>: The interface on which a message was received is added
58904 to the <quote>&lt;=</quote> line as an IP address in square brackets, tagged by I= and
58905 followed by a colon and the port number. The local interface and port are also
58906 added to other SMTP log lines, for example <quote>SMTP connection from</quote>, and to
58907 rejection lines.
58908 </para>
58909 </listitem>
58910 <listitem>
58911 <para>
58912 <indexterm role="concept">
58913 <primary>log</primary>
58914 <secondary>incoming remote port</secondary>
58915 </indexterm>
58916 <indexterm role="concept">
58917 <primary>port</primary>
58918 <secondary>logging remote</secondary>
58919 </indexterm>
58920 <indexterm role="concept">
58921 <primary>TCP/IP</primary>
58922 <secondary>logging incoming remote port</secondary>
58923 </indexterm>
58924 <indexterm role="variable">
58925 <primary><varname>$sender_fullhost</varname></primary>
58926 </indexterm>
58927 <indexterm role="variable">
58928 <primary><varname>$sender_rcvhost</varname></primary>
58929 </indexterm>
58930 <option>incoming_port</option>: The remote port number from which a message was received is
58931 added to log entries and <emphasis>Received:</emphasis> header lines, following the IP address
58932 in square brackets, and separated from it by a colon. This is implemented by
58933 changing the value that is put in the <varname>$sender_fullhost</varname> and
58934 <varname>$sender_rcvhost</varname> variables. Recording the remote port number has become more
58935 important with the widening use of NAT (see RFC 2505).
58936 </para>
58937 </listitem>
58938 <listitem>
58939 <para>
58940 <indexterm role="concept">
58941 <primary>log</primary>
58942 <secondary>dropped connection</secondary>
58943 </indexterm>
58944 <option>lost_incoming_connection</option>: A log line is written when an incoming SMTP
58945 connection is unexpectedly dropped.
58946 </para>
58947 </listitem>
58948 <listitem>
58949 <para>
58950 <indexterm role="concept">
58951 <primary>log</primary>
58952 <secondary>outgoing remote port</secondary>
58953 </indexterm>
58954 <indexterm role="concept">
58955 <primary>port</primary>
58956 <secondary>logging outgoint remote</secondary>
58957 </indexterm>
58958 <indexterm role="concept">
58959 <primary>TCP/IP</primary>
58960 <secondary>logging ougtoing remote port</secondary>
58961 </indexterm>
58962 <option>outgoing_port</option>: The remote port number is added to delivery log lines (those
58963 containing =&gt; tags) following the IP address. This option is not included in
58964 the default setting, because for most ordinary configurations, the remote port
58965 number is always 25 (the SMTP port).
58966 </para>
58967 </listitem>
58968 <listitem>
58969 <para>
58970 <indexterm role="concept">
58971 <primary>log</primary>
58972 <secondary>process ids in</secondary>
58973 </indexterm>
58974 <indexterm role="concept">
58975 <primary>pid (process id)</primary>
58976 <secondary>in log lines</secondary>
58977 </indexterm>
58978 <option>pid</option>: The current process id is added to every log line, in square brackets,
58979 immediately after the time and date.
58980 </para>
58981 </listitem>
58982 <listitem>
58983 <para>
58984 <indexterm role="concept">
58985 <primary>log</primary>
58986 <secondary>queue run</secondary>
58987 </indexterm>
58988 <indexterm role="concept">
58989 <primary>queue runner</primary>
58990 <secondary>logging</secondary>
58991 </indexterm>
58992 <option>queue_run</option>: The start and end of every queue run are logged.
58993 </para>
58994 </listitem>
58995 <listitem>
58996 <para>
58997 <indexterm role="concept">
58998 <primary>log</primary>
58999 <secondary>queue time</secondary>
59000 </indexterm>
59001 <option>queue_time</option>: The amount of time the message has been in the queue on the
59002 local host is logged as QT=&lt;<emphasis>time</emphasis>&gt; on delivery (<literal>=&gt;</literal>) lines, for example,
59003 <literal>QT=3m45s</literal>. The clock starts when Exim starts to receive the message, so it
59004 includes reception time as well as the delivery time for the current address.
59005 This means that it may be longer than the difference between the arrival and
59006 delivery log line times, because the arrival log line is not written until the
59007 message has been successfully received.
59008 </para>
59009 </listitem>
59010 <listitem>
59011 <para>
59012 <option>queue_time_overall</option>: The amount of time the message has been in the queue on
59013 the local host is logged as QT=&lt;<emphasis>time</emphasis>&gt; on <quote>Completed</quote> lines, for
59014 example, <literal>QT=3m45s</literal>. The clock starts when Exim starts to receive the
59015 message, so it includes reception time as well as the total delivery time.
59016 </para>
59017 </listitem>
59018 <listitem>
59019 <para>
59020 <indexterm role="concept">
59021 <primary>log</primary>
59022 <secondary>recipients</secondary>
59023 </indexterm>
59024 <option>received_recipients</option>: The recipients of a message are listed in the main log
59025 as soon as the message is received. The list appears at the end of the log line
59026 that is written when a message is received, preceded by the word <quote>for</quote>. The
59027 addresses are listed after they have been qualified, but before any rewriting
59028 has taken place.
59029 Recipients that were discarded by an ACL for MAIL or RCPT do not appear
59030 in the list.
59031 </para>
59032 </listitem>
59033 <listitem>
59034 <para>
59035 <indexterm role="concept">
59036 <primary>log</primary>
59037 <secondary>sender reception</secondary>
59038 </indexterm>
59039 <option>received_sender</option>: The unrewritten original sender of a message is added to
59040 the end of the log line that records the message&#x2019;s arrival, after the word
59041 <quote>from</quote> (before the recipients if <option>received_recipients</option> is also set).
59042 </para>
59043 </listitem>
59044 <listitem>
59045 <para>
59046 <indexterm role="concept">
59047 <primary>log</primary>
59048 <secondary>header lines for rejection</secondary>
59049 </indexterm>
59050 <option>rejected_header</option>: If a message&#x2019;s header has been received at the time a
59051 rejection is written to the reject log, the complete header is added to the
59052 log. Header logging can be turned off individually for messages that are
59053 rejected by the <function>local_scan()</function> function (see section <xref linkend="SECTapiforloc"/>).
59054 </para>
59055 </listitem>
59056 <listitem>
59057 <para>
59058 <indexterm role="concept">
59059 <primary>log</primary>
59060 <secondary>retry defer</secondary>
59061 </indexterm>
59062 <option>retry_defer</option>: A log line is written if a delivery is deferred because a
59063 retry time has not yet been reached. However, this <quote>retry time not reached</quote>
59064 message is always omitted from individual message logs after the first delivery
59065 attempt.
59066 </para>
59067 </listitem>
59068 <listitem>
59069 <para>
59070 <indexterm role="concept">
59071 <primary>log</primary>
59072 <secondary>return path</secondary>
59073 </indexterm>
59074 <option>return_path_on_delivery</option>: The return path that is being transmitted with
59075 the message is included in delivery and bounce lines, using the tag P=.
59076 This is omitted if no delivery actually happens, for example, if routing fails,
59077 or if delivery is to <filename>/dev/null</filename> or to <literal>:blackhole:</literal>.
59078 </para>
59079 </listitem>
59080 <listitem>
59081 <para>
59082 <indexterm role="concept">
59083 <primary>log</primary>
59084 <secondary>sender on delivery</secondary>
59085 </indexterm>
59086 <option>sender_on_delivery</option>: The message&#x2019;s sender address is added to every delivery
59087 and bounce line, tagged by F= (for <quote>from</quote>).
59088 This is the original sender that was received with the message; it is not
59089 necessarily the same as the outgoing return path.
59090 </para>
59091 </listitem>
59092 <listitem>
59093 <para>
59094 <indexterm role="concept">
59095 <primary>log</primary>
59096 <secondary>sender verify failure</secondary>
59097 </indexterm>
59098 <option>sender_verify_fail</option>: If this selector is unset, the separate log line that
59099 gives details of a sender verification failure is not written. Log lines for
59100 the rejection of SMTP commands contain just <quote>sender verify failed</quote>, so some
59101 detail is lost.
59102 </para>
59103 </listitem>
59104 <listitem>
59105 <para>
59106 <indexterm role="concept">
59107 <primary>log</primary>
59108 <secondary>size rejection</secondary>
59109 </indexterm>
59110 <option>size_reject</option>: A log line is written whenever a message is rejected because
59111 it is too big.
59112 </para>
59113 </listitem>
59114 <listitem>
59115 <para>
59116 <indexterm role="concept">
59117 <primary>log</primary>
59118 <secondary>frozen messages; skipped</secondary>
59119 </indexterm>
59120 <indexterm role="concept">
59121 <primary>frozen messages</primary>
59122 <secondary>logging skipping</secondary>
59123 </indexterm>
59124 <option>skip_delivery</option>: A log line is written whenever a message is skipped during a
59125 queue run because it is frozen or because another process is already delivering
59126 it.
59127 <indexterm role="concept">
59128 <primary><quote>spool file is locked</quote></primary>
59129 </indexterm>
59130 The message that is written is <quote>spool file is locked</quote>.
59131 </para>
59132 </listitem>
59133 <listitem>
59134 <para>
59135 <indexterm role="concept">
59136 <primary>log</primary>
59137 <secondary>smtp confirmation</secondary>
59138 </indexterm>
59139 <indexterm role="concept">
59140 <primary>SMTP</primary>
59141 <secondary>logging confirmation</secondary>
59142 </indexterm>
59143 <option>smtp_confirmation</option>: The response to the final <quote>.</quote> in the SMTP dialogue for
59144 outgoing messages is added to delivery log lines in the form <literal>C=</literal>&lt;<emphasis>text</emphasis>&gt;.
59145 A number of MTAs (including Exim) return an identifying string in this
59146 response.
59147 </para>
59148 </listitem>
59149 <listitem>
59150 <para>
59151 <indexterm role="concept">
59152 <primary>log</primary>
59153 <secondary>SMTP connections</secondary>
59154 </indexterm>
59155 <indexterm role="concept">
59156 <primary>SMTP</primary>
59157 <secondary>logging connections</secondary>
59158 </indexterm>
59159 <option>smtp_connection</option>: A log line is written whenever an SMTP connection is
59160 established or closed, unless the connection is from a host that matches
59161 <option>hosts_connection_nolog</option>. (In contrast, <option>lost_incoming_connection</option> applies
59162 only when the closure is unexpected.) This applies to connections from local
59163 processes that use <option>-bs</option> as well as to TCP/IP connections. If a connection is
59164 dropped in the middle of a message, a log line is always written, whether or
59165 not this selector is set, but otherwise nothing is written at the start and end
59166 of connections unless this selector is enabled.
59167 </para>
59168 <para>
59169 For TCP/IP connections to an Exim daemon, the current number of connections is
59170 included in the log message for each new connection, but note that the count is
59171 reset if the daemon is restarted.
59172 Also, because connections are closed (and the closure is logged) in
59173 subprocesses, the count may not include connections that have been closed but
59174 whose termination the daemon has not yet noticed. Thus, while it is possible to
59175 match up the opening and closing of connections in the log, the value of the
59176 logged counts may not be entirely accurate.
59177 </para>
59178 </listitem>
59179 <listitem>
59180 <para>
59181 <indexterm role="concept">
59182 <primary>log</primary>
59183 <secondary>SMTP transaction; incomplete</secondary>
59184 </indexterm>
59185 <indexterm role="concept">
59186 <primary>SMTP</primary>
59187 <secondary>logging incomplete transactions</secondary>
59188 </indexterm>
59189 <option>smtp_incomplete_transaction</option>: When a mail transaction is aborted by
59190 RSET, QUIT, loss of connection, or otherwise, the incident is logged,
59191 and the message sender plus any accepted recipients are included in the log
59192 line. This can provide evidence of dictionary attacks.
59193 </para>
59194 </listitem>
59195 <listitem>
59196 <para>
59197 <indexterm role="concept">
59198 <primary>log</primary>
59199 <secondary>non-MAIL SMTP sessions</secondary>
59200 </indexterm>
59201 <indexterm role="concept">
59202 <primary>MAIL</primary>
59203 <secondary>logging session without</secondary>
59204 </indexterm>
59205 <option>smtp_no_mail</option>: A line is written to the main log whenever an accepted SMTP
59206 connection terminates without having issued a MAIL command. This includes both
59207 the case when the connection is dropped, and the case when QUIT is used. It
59208 does not include cases where the connection is rejected right at the start (by
59209 an ACL, or because there are too many connections, or whatever). These cases
59210 already have their own log lines.
59211 </para>
59212 <para>
59213 The log line that is written contains the identity of the client in the usual
59214 way, followed by D= and a time, which records the duration of the connection.
59215 If the connection was authenticated, this fact is logged exactly as it is for
59216 an incoming message, with an A= item. If the connection was encrypted, CV=,
59217 DN=, and X= items may appear as they do for an incoming message, controlled by
59218 the same logging options.
59219 </para>
59220 <para>
59221 Finally, if any SMTP commands were issued during the connection, a C= item
59222 is added to the line, listing the commands that were used. For example,
59223 </para>
59224 <literallayout class="monospaced">
59225 C=EHLO,QUIT
59226 </literallayout>
59227 <para>
59228 shows that the client issued QUIT straight after EHLO. If there were fewer
59229 than 20 commands, they are all listed. If there were more than 20 commands,
59230 the last 20 are listed, preceded by <quote>...</quote>. However, with the default
59231 setting of 10 for <option>smtp_accep_max_nonmail</option>, the connection will in any case
59232 have been aborted before 20 non-mail commands are processed.
59233 </para>
59234 </listitem>
59235 <listitem>
59236 <para>
59237 <indexterm role="concept">
59238 <primary>log</primary>
59239 <secondary>SMTP protocol error</secondary>
59240 </indexterm>
59241 <indexterm role="concept">
59242 <primary>SMTP</primary>
59243 <secondary>logging protocol error</secondary>
59244 </indexterm>
59245 <option>smtp_protocol_error</option>: A log line is written for every SMTP protocol error
59246 encountered. Exim does not have perfect detection of all protocol errors
59247 because of transmission delays and the use of pipelining. If PIPELINING has
59248 been advertised to a client, an Exim server assumes that the client will use
59249 it, and therefore it does not count <quote>expected</quote> errors (for example, RCPT
59250 received after rejecting MAIL) as protocol errors.
59251 </para>
59252 </listitem>
59253 <listitem>
59254 <para>
59255 <indexterm role="concept">
59256 <primary>SMTP</primary>
59257 <secondary>logging syntax errors</secondary>
59258 </indexterm>
59259 <indexterm role="concept">
59260 <primary>SMTP</primary>
59261 <secondary>syntax errors; logging</secondary>
59262 </indexterm>
59263 <indexterm role="concept">
59264 <primary>SMTP</primary>
59265 <secondary>unknown command; logging</secondary>
59266 </indexterm>
59267 <indexterm role="concept">
59268 <primary>log</primary>
59269 <secondary>unknown SMTP command</secondary>
59270 </indexterm>
59271 <indexterm role="concept">
59272 <primary>log</primary>
59273 <secondary>SMTP syntax error</secondary>
59274 </indexterm>
59275 <option>smtp_syntax_error</option>: A log line is written for every SMTP syntax error
59276 encountered. An unrecognized command is treated as a syntax error. For an
59277 external connection, the host identity is given; for an internal connection
59278 using <option>-bs</option> the sender identification (normally the calling user) is given.
59279 </para>
59280 </listitem>
59281 <listitem>
59282 <para>
59283 <indexterm role="concept">
59284 <primary>log</primary>
59285 <secondary>subject</secondary>
59286 </indexterm>
59287 <indexterm role="concept">
59288 <primary>subject, logging</primary>
59289 </indexterm>
59290 <option>subject</option>: The subject of the message is added to the arrival log line,
59291 preceded by <quote>T=</quote> (T for <quote>topic</quote>, since S is already used for <quote>size</quote>).
59292 Any MIME <quote>words</quote> in the subject are decoded. The <option>print_topbitchars</option> option
59293 specifies whether characters with values greater than 127 should be logged
59294 unchanged, or whether they should be rendered as escape sequences.
59295 </para>
59296 </listitem>
59297 <listitem>
59298 <para>
59299 <indexterm role="concept">
59300 <primary>log</primary>
59301 <secondary>certificate verification</secondary>
59302 </indexterm>
59303 <option>tls_certificate_verified</option>: An extra item is added to &lt;= and =&gt; log lines
59304 when TLS is in use. The item is <literal>CV=yes</literal> if the peer&#x2019;s certificate was
59305 verified, and <literal>CV=no</literal> if not.
59306 </para>
59307 </listitem>
59308 <listitem>
59309 <para>
59310 <indexterm role="concept">
59311 <primary>log</primary>
59312 <secondary>TLS cipher</secondary>
59313 </indexterm>
59314 <indexterm role="concept">
59315 <primary>TLS</primary>
59316 <secondary>logging cipher</secondary>
59317 </indexterm>
59318 <option>tls_cipher</option>: When a message is sent or received over an encrypted
59319 connection, the cipher suite used is added to the log line, preceded by X=.
59320 </para>
59321 </listitem>
59322 <listitem>
59323 <para>
59324 <indexterm role="concept">
59325 <primary>log</primary>
59326 <secondary>TLS peer DN</secondary>
59327 </indexterm>
59328 <indexterm role="concept">
59329 <primary>TLS</primary>
59330 <secondary>logging peer DN</secondary>
59331 </indexterm>
59332 <option>tls_peerdn</option>: When a message is sent or received over an encrypted
59333 connection, and a certificate is supplied by the remote host, the peer DN is
59334 added to the log line, preceded by DN=.
59335 </para>
59336 </listitem>
59337 <listitem>
59338 <para>
59339 <indexterm role="concept">
59340 <primary>log</primary>
59341 <secondary>DNS failure in list</secondary>
59342 </indexterm>
59343 <option>unknown_in_list</option>: This setting causes a log entry to be written when the
59344 result of a list match is failure because a DNS lookup failed.
59345 </para>
59346 </listitem>
59347 </itemizedlist>
59348 </section>
59349 <section id="SECID260">
59350 <title>Message log</title>
59351 <para>
59352 <indexterm role="concept">
59353 <primary>message</primary>
59354 <secondary>log file for</secondary>
59355 </indexterm>
59356 <indexterm role="concept">
59357 <primary>log</primary>
59358 <secondary>message log; description of</secondary>
59359 </indexterm>
59360 <indexterm role="concept">
59361 <primary><filename>msglog</filename> directory</primary>
59362 </indexterm>
59363 <indexterm role="option">
59364 <primary><option>preserve_message_logs</option></primary>
59365 </indexterm>
59366 In addition to the general log files, Exim writes a log file for each message
59367 that it handles. The names of these per-message logs are the message ids, and
59368 they are kept in the <filename>msglog</filename> sub-directory of the spool directory. Each
59369 message log contains copies of the log lines that apply to the message. This
59370 makes it easier to inspect the status of an individual message without having
59371 to search the main log. A message log is deleted when processing of the message
59372 is complete, unless <option>preserve_message_logs</option> is set, but this should be used
59373 only with great care because they can fill up your disk very quickly.
59374 </para>
59375 <para>
59376 On a heavily loaded system, it may be desirable to disable the use of
59377 per-message logs, in order to reduce disk I/O. This can be done by setting the
59378 <option>message_logs</option> option false.
59379 <indexterm role="concept" startref="IIDloggen" class="endofrange"/>
59380 </para>
59381 </section>
59382 </chapter>
59383
59384 <chapter id="CHAPutils">
59385 <title>Exim utilities</title>
59386 <para>
59387 <indexterm role="concept" id="IIDutils" class="startofrange">
59388 <primary>utilities</primary>
59389 </indexterm>
59390 A number of utility scripts and programs are supplied with Exim and are
59391 described in this chapter. There is also the Exim Monitor, which is covered in
59392 the next chapter. The utilities described here are:
59393 </para>
59394 <informaltable frame="none">
59395 <tgroup cols="3" colsep="0" rowsep="0">
59396 <colspec colwidth="7*" align="left"/>
59397 <colspec colwidth="15*" align="left"/>
59398 <colspec colwidth="40*" align="left"/>
59399 <tbody>
59400 <row>
59401 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECTfinoutwha"/></entry>
59402 <entry><emphasis>exiwhat</emphasis></entry>
59403 <entry>list what Exim processes are doing</entry>
59404 </row>
59405 <row>
59406 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECTgreptheque"/></entry>
59407 <entry><emphasis>exiqgrep</emphasis></entry>
59408 <entry>grep the queue</entry>
59409 </row>
59410 <row>
59411 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECTsumtheque"/></entry>
59412 <entry><emphasis>exiqsumm</emphasis></entry>
59413 <entry>summarize the queue</entry>
59414 </row>
59415 <row>
59416 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECTextspeinf"/></entry>
59417 <entry><emphasis>exigrep</emphasis></entry>
59418 <entry>search the main log</entry>
59419 </row>
59420 <row>
59421 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECTexipick"/></entry>
59422 <entry><emphasis>exipick</emphasis></entry>
59423 <entry>select messages on various criteria</entry>
59424 </row>
59425 <row>
59426 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECTcyclogfil"/></entry>
59427 <entry><emphasis>exicyclog</emphasis></entry>
59428 <entry>cycle (rotate) log files</entry>
59429 </row>
59430 <row>
59431 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECTmailstat"/></entry>
59432 <entry><emphasis>eximstats</emphasis></entry>
59433 <entry>extract statistics from the log</entry>
59434 </row>
59435 <row>
59436 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECTcheckaccess"/></entry>
59437 <entry><emphasis>exim_checkaccess</emphasis></entry>
59438 <entry>check address acceptance from given IP</entry>
59439 </row>
59440 <row>
59441 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECTdbmbuild"/></entry>
59442 <entry><emphasis>exim_dbmbuild</emphasis></entry>
59443 <entry>build a DBM file</entry>
59444 </row>
59445 <row>
59446 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECTfinindret"/></entry>
59447 <entry><emphasis>exinext</emphasis></entry>
59448 <entry>extract retry information</entry>
59449 </row>
59450 <row>
59451 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECThindatmai"/></entry>
59452 <entry><emphasis>exim_dumpdb</emphasis></entry>
59453 <entry>dump a hints database</entry>
59454 </row>
59455 <row>
59456 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECThindatmai"/></entry>
59457 <entry><emphasis>exim_tidydb</emphasis></entry>
59458 <entry>clean up a hints database</entry>
59459 </row>
59460 <row>
59461 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECThindatmai"/></entry>
59462 <entry><emphasis>exim_fixdb</emphasis></entry>
59463 <entry>patch a hints database</entry>
59464 </row>
59465 <row>
59466 <entry>&nbsp;&nbsp;&nbsp;&nbsp;<xref linkend="SECTmailboxmaint"/></entry>
59467 <entry><emphasis>exim_lock</emphasis></entry>
59468 <entry>lock a mailbox file</entry>
59469 </row>
59470 </tbody>
59471 </tgroup>
59472 </informaltable>
59473 <para>
59474 Another utility that might be of use to sites with many MTAs is Tom Kistner&#x2019;s
59475 <emphasis>exilog</emphasis>. It provides log visualizations across multiple Exim servers. See
59476 <emphasis role="bold"><ulink url="http://duncanthrax.net/exilog/">http://duncanthrax.net/exilog/</ulink></emphasis> for details.
59477 </para>
59478 <section id="SECTfinoutwha">
59479 <title>Finding out what Exim processes are doing (exiwhat)</title>
59480 <para>
59481 <indexterm role="concept">
59482 <primary><emphasis>exiwhat</emphasis></primary>
59483 </indexterm>
59484 <indexterm role="concept">
59485 <primary>process, querying</primary>
59486 </indexterm>
59487 <indexterm role="concept">
59488 <primary>SIGUSR1</primary>
59489 </indexterm>
59490 On operating systems that can restart a system call after receiving a signal
59491 (most modern OS), an Exim process responds to the SIGUSR1 signal by writing
59492 a line describing what it is doing to the file <filename>exim-process.info</filename> in the
59493 Exim spool directory. The <emphasis>exiwhat</emphasis> script sends the signal to all Exim
59494 processes it can find, having first emptied the file. It then waits for one
59495 second to allow the Exim processes to react before displaying the results. In
59496 order to run <emphasis>exiwhat</emphasis> successfully you have to have sufficient privilege to
59497 send the signal to the Exim processes, so it is normally run as root.
59498 </para>
59499 <para>
59500 <emphasis role="bold">Warning</emphasis>: This is not an efficient process. It is intended for occasional
59501 use by system administrators. It is not sensible, for example, to set up a
59502 script that sends SIGUSR1 signals to Exim processes at short intervals.
59503 </para>
59504 <para>
59505 Unfortunately, the <emphasis>ps</emphasis> command that <emphasis>exiwhat</emphasis> uses to find Exim processes
59506 varies in different operating systems. Not only are different options used,
59507 but the format of the output is different. For this reason, there are some
59508 system configuration options that configure exactly how <emphasis>exiwhat</emphasis> works. If
59509 it doesn&#x2019;t seem to be working for you, check the following compile-time
59510 options:
59511 </para>
59512 <literallayout>
59513 <literal>EXIWHAT_PS_CMD    </literal> the command for running <emphasis>ps</emphasis>
59514 <literal>EXIWHAT_PS_ARG    </literal> the argument for <emphasis>ps</emphasis>
59515 <literal>EXIWHAT_EGREP_ARG </literal> the argument for <emphasis>egrep</emphasis> to select from <emphasis>ps</emphasis> output
59516 <literal>EXIWHAT_KILL_ARG  </literal> the argument for the <emphasis>kill</emphasis> command
59517 </literallayout>
59518 <para>
59519 An example of typical output from <emphasis>exiwhat</emphasis> is
59520 </para>
59521 <literallayout class="monospaced">
59522 164 daemon: -q1h, listening on port 25
59523 10483 running queue: waiting for 0tAycK-0002ij-00 (10492)
59524 10492 delivering 0tAycK-0002ij-00 to mail.ref.example
59525   [10.19.42.42] (editor@ref.example)
59526 10592 handling incoming call from [192.168.243.242]
59527 10628 accepting a local non-SMTP message
59528 </literallayout>
59529 <para>
59530 The first number in the output line is the process number. The third line has
59531 been split here, in order to fit it on the page.
59532 </para>
59533 </section>
59534 <section id="SECTgreptheque">
59535 <title>Selective queue listing (exiqgrep)</title>
59536 <para>
59537 <indexterm role="concept">
59538 <primary><emphasis>exiqgrep</emphasis></primary>
59539 </indexterm>
59540 <indexterm role="concept">
59541 <primary>queue</primary>
59542 <secondary>grepping</secondary>
59543 </indexterm>
59544 This utility is a Perl script contributed by Matt Hubbard. It runs
59545 </para>
59546 <literallayout class="monospaced">
59547 exim -bpu
59548 </literallayout>
59549 <para>
59550 to obtain a queue listing with undelivered recipients only, and then greps the
59551 output to select messages that match given criteria. The following selection
59552 options are available:
59553 </para>
59554 <variablelist>
59555 <varlistentry>
59556 <term><emphasis role="bold">-f</emphasis>&nbsp;&lt;<emphasis>regex</emphasis>&gt;</term>
59557 <listitem>
59558 <para>
59559 Match the sender address. The field that is tested is enclosed in angle
59560 brackets, so you can test for bounce messages with
59561 </para>
59562 <literallayout class="monospaced">
59563 exiqgrep -f '^&lt;&gt;$'
59564 </literallayout>
59565 </listitem></varlistentry>
59566 <varlistentry>
59567 <term><emphasis role="bold">-r</emphasis>&nbsp;&lt;<emphasis>regex</emphasis>&gt;</term>
59568 <listitem>
59569 <para>
59570 Match a recipient address. The field that is tested is not enclosed in angle
59571 brackets.
59572 </para>
59573 </listitem></varlistentry>
59574 <varlistentry>
59575 <term><emphasis role="bold">-s</emphasis>&nbsp;&lt;<emphasis>regex</emphasis>&gt;</term>
59576 <listitem>
59577 <para>
59578 Match against the size field.
59579 </para>
59580 </listitem></varlistentry>
59581 <varlistentry>
59582 <term><emphasis role="bold">-y</emphasis>&nbsp;&lt;<emphasis>seconds</emphasis>&gt;</term>
59583 <listitem>
59584 <para>
59585 Match messages that are younger than the given time.
59586 </para>
59587 </listitem></varlistentry>
59588 <varlistentry>
59589 <term><emphasis role="bold">-o</emphasis>&nbsp;&lt;<emphasis>seconds</emphasis>&gt;</term>
59590 <listitem>
59591 <para>
59592 Match messages that are older than the given time.
59593 </para>
59594 </listitem></varlistentry>
59595 <varlistentry>
59596 <term><emphasis role="bold">-z</emphasis></term>
59597 <listitem>
59598 <para>
59599 Match only frozen messages.
59600 </para>
59601 </listitem></varlistentry>
59602 <varlistentry>
59603 <term><emphasis role="bold">-x</emphasis></term>
59604 <listitem>
59605 <para>
59606 Match only non-frozen messages.
59607 </para>
59608 </listitem></varlistentry>
59609 </variablelist>
59610 <para>
59611 The following options control the format of the output:
59612 </para>
59613 <variablelist>
59614 <varlistentry>
59615 <term><emphasis role="bold">-c</emphasis></term>
59616 <listitem>
59617 <para>
59618 Display only the count of matching messages.
59619 </para>
59620 </listitem></varlistentry>
59621 <varlistentry>
59622 <term><emphasis role="bold">-l</emphasis></term>
59623 <listitem>
59624 <para>
59625 Long format &ndash; display the full message information as output by Exim. This is
59626 the default.
59627 </para>
59628 </listitem></varlistentry>
59629 <varlistentry>
59630 <term><emphasis role="bold">-i</emphasis></term>
59631 <listitem>
59632 <para>
59633 Display message ids only.
59634 </para>
59635 </listitem></varlistentry>
59636 <varlistentry>
59637 <term><emphasis role="bold">-b</emphasis></term>
59638 <listitem>
59639 <para>
59640 Brief format &ndash; one line per message.
59641 </para>
59642 </listitem></varlistentry>
59643 <varlistentry>
59644 <term><emphasis role="bold">-R</emphasis></term>
59645 <listitem>
59646 <para>
59647 Display messages in reverse order.
59648 </para>
59649 </listitem></varlistentry>
59650 </variablelist>
59651 <para>
59652 There is one more option, <option>-h</option>, which outputs a list of options.
59653 </para>
59654 </section>
59655 <section id="SECTsumtheque">
59656 <title>Summarizing the queue (exiqsumm)</title>
59657 <para>
59658 <indexterm role="concept">
59659 <primary><emphasis>exiqsumm</emphasis></primary>
59660 </indexterm>
59661 <indexterm role="concept">
59662 <primary>queue</primary>
59663 <secondary>summary</secondary>
59664 </indexterm>
59665 The <emphasis>exiqsumm</emphasis> utility is a Perl script which reads the output of <literal>exim
59666 -bp</literal> and produces a summary of the messages on the queue. Thus, you use it by
59667 running a command such as
59668 </para>
59669 <literallayout class="monospaced">
59670 exim -bp | exiqsumm
59671 </literallayout>
59672 <para>
59673 The output consists of one line for each domain that has messages waiting for
59674 it, as in the following example:
59675 </para>
59676 <literallayout class="monospaced">
59677 3   2322   74m   66m  msn.com.example
59678 </literallayout>
59679 <para>
59680 Each line lists the number of pending deliveries for a domain, their total
59681 volume, and the length of time that the oldest and the newest messages have
59682 been waiting. Note that the number of pending deliveries is greater than the
59683 number of messages when messages have more than one recipient.
59684 </para>
59685 <para>
59686 A summary line is output at the end. By default the output is sorted on the
59687 domain name, but <emphasis>exiqsumm</emphasis> has the options <option>-a</option> and <option>-c</option>, which cause
59688 the output to be sorted by oldest message and by count of messages,
59689 respectively. There are also three options that split the messages for each
59690 domain into two or more subcounts: <option>-b</option> separates bounce messages, <option>-f</option>
59691 separates frozen messages, and <option>-s</option> separates messages according to their
59692 sender.
59693 </para>
59694 <para>
59695 The output of <emphasis>exim -bp</emphasis> contains the original addresses in the message, so
59696 this also applies to the output from <emphasis>exiqsumm</emphasis>. No domains from addresses
59697 generated by aliasing or forwarding are included (unless the <option>one_time</option>
59698 option of the <command>redirect</command> router has been used to convert them into <quote>top
59699 level</quote> addresses).
59700 </para>
59701 </section>
59702 <section id="SECTextspeinf">
59703 <title>Extracting specific information from the log (exigrep)</title>
59704 <para>
59705 <indexterm role="concept">
59706 <primary><emphasis>exigrep</emphasis></primary>
59707 </indexterm>
59708 <indexterm role="concept">
59709 <primary>log</primary>
59710 <secondary>extracts; grepping for</secondary>
59711 </indexterm>
59712 The <emphasis>exigrep</emphasis> utility is a Perl script that searches one or more main log
59713 files for entries that match a given pattern. When it finds a match, it
59714 extracts all the log entries for the relevant message, not just those that
59715 match the pattern. Thus, <emphasis>exigrep</emphasis> can extract complete log entries for a
59716 given message, or all mail for a given user, or for a given host, for example.
59717 The input files can be in Exim log format or syslog format.
59718 If a matching log line is not associated with a specific message, it is
59719 included in <emphasis>exigrep</emphasis>&#x2019;s output without any additional lines. The usage is:
59720 </para>
59721 <literallayout>
59722 <literal>exigrep [-t&lt;</literal><emphasis>n</emphasis><literal>&gt;] [-I] [-l] [-v] &lt;</literal><emphasis>pattern</emphasis><literal>&gt; [&lt;</literal><emphasis>log file</emphasis><literal>&gt;] ...</literal>
59723 </literallayout>
59724 <para>
59725 If no log file names are given on the command line, the standard input is read.
59726 </para>
59727 <para>
59728 The <option>-t</option> argument specifies a number of seconds. It adds an additional
59729 condition for message selection. Messages that are complete are shown only if
59730 they spent more than &lt;<emphasis>n</emphasis>&gt; seconds on the queue.
59731 </para>
59732 <para>
59733 By default, <emphasis>exigrep</emphasis> does case-insensitive matching. The <option>-I</option> option
59734 makes it case-sensitive. This may give a performance improvement when searching
59735 large log files. Without <option>-I</option>, the Perl pattern matches use Perl&#x2019;s <literal>/i</literal>
59736 option; with <option>-I</option> they do not. In both cases it is possible to change the
59737 case sensitivity within the pattern by using <literal>(?i)</literal> or <literal>(?-i)</literal>.
59738 </para>
59739 <para>
59740 The <option>-l</option> option means <quote>literal</quote>, that is, treat all characters in the
59741 pattern as standing for themselves. Otherwise the pattern must be a Perl
59742 regular expression.
59743 </para>
59744 <para>
59745 The <option>-v</option> option inverts the matching condition. That is, a line is selected
59746 if it does <emphasis>not</emphasis> match the pattern.
59747 </para>
59748 <para>
59749 If the location of a <emphasis>zcat</emphasis> command is known from the definition of
59750 ZCAT_COMMAND in <filename>Local/Makefile</filename>, <emphasis>exigrep</emphasis> automatically passes any file
59751 whose name ends in COMPRESS_SUFFIX through <emphasis>zcat</emphasis> as it searches it.
59752 </para>
59753 </section>
59754 <section id="SECTexipick">
59755 <title>Selecting messages by various criteria (exipick)</title>
59756 <para>
59757 <indexterm role="concept">
59758 <primary><emphasis>exipick</emphasis></primary>
59759 </indexterm>
59760 John Jetmore&#x2019;s <emphasis>exipick</emphasis> utility is included in the Exim distribution. It
59761 lists messages from the queue according to a variety of criteria. For details
59762 of <emphasis>exipick</emphasis>&#x2019;s facilities, visit the web page at
59763 <emphasis role="bold"><ulink url="http://www.exim.org/eximwiki/ToolExipickManPage">http://www.exim.org/eximwiki/ToolExipickManPage</ulink></emphasis> or run <emphasis>exipick</emphasis> with
59764 the <option>--help</option> option.
59765 </para>
59766 </section>
59767 <section id="SECTcyclogfil">
59768 <title>Cycling log files (exicyclog)</title>
59769 <para>
59770 <indexterm role="concept">
59771 <primary>log</primary>
59772 <secondary>cycling local files</secondary>
59773 </indexterm>
59774 <indexterm role="concept">
59775 <primary>cycling logs</primary>
59776 </indexterm>
59777 <indexterm role="concept">
59778 <primary><emphasis>exicyclog</emphasis></primary>
59779 </indexterm>
59780 The <emphasis>exicyclog</emphasis> script can be used to cycle (rotate) <emphasis>mainlog</emphasis> and
59781 <emphasis>rejectlog</emphasis> files. This is not necessary if only syslog is being used, or if
59782 you are using log files with datestamps in their names (see section
59783 <xref linkend="SECTdatlogfil"/>). Some operating systems have their own standard mechanisms
59784 for log cycling, and these can be used instead of <emphasis>exicyclog</emphasis> if preferred.
59785 There are two command line options for <emphasis>exicyclog</emphasis>:
59786 </para>
59787 <itemizedlist>
59788 <listitem>
59789 <para>
59790 <option>-k</option> &lt;<emphasis>count</emphasis>&gt; specifies the number of log files to keep, overriding the
59791 default that is set when Exim is built. The default default is 10.
59792 </para>
59793 </listitem>
59794 <listitem>
59795 <para>
59796 <option>-l</option> &lt;<emphasis>path</emphasis>&gt; specifies the log file path, in the same format as Exim&#x2019;s
59797 <option>log_file_path</option> option (for example, <literal>/var/log/exim_%slog</literal>), again
59798 overriding the script&#x2019;s default, which is to find the setting from Exim&#x2019;s
59799 configuration.
59800 </para>
59801 </listitem>
59802 </itemizedlist>
59803 <para>
59804 Each time <emphasis>exicyclog</emphasis> is run the file names get <quote>shuffled down</quote> by one. If
59805 the main log file name is <filename>mainlog</filename> (the default) then when <emphasis>exicyclog</emphasis> is
59806 run <filename>mainlog</filename> becomes <filename>mainlog.01</filename>, the previous <filename>mainlog.01</filename> becomes
59807 <filename>mainlog.02</filename> and so on, up to the limit that is set in the script or by the
59808 <option>-k</option> option. Log files whose numbers exceed the limit are discarded. Reject
59809 logs are handled similarly.
59810 </para>
59811 <para>
59812 If the limit is greater than 99, the script uses 3-digit numbers such as
59813 <filename>mainlog.001</filename>, <filename>mainlog.002</filename>, etc. If you change from a number less than 99
59814 to one that is greater, or <emphasis>vice versa</emphasis>, you will have to fix the names of
59815 any existing log files.
59816 </para>
59817 <para>
59818 If no <filename>mainlog</filename> file exists, the script does nothing. Files that <quote>drop off</quote>
59819 the end are deleted. All files with numbers greater than 01 are compressed,
59820 using a compression command which is configured by the COMPRESS_COMMAND
59821 setting in <filename>Local/Makefile</filename>. It is usual to run <emphasis>exicyclog</emphasis> daily from a
59822 root <option>crontab</option> entry of the form
59823 </para>
59824 <literallayout class="monospaced">
59825 1 0 * * * su exim -c /usr/exim/bin/exicyclog
59826 </literallayout>
59827 <para>
59828 assuming you have used the name <quote>exim</quote> for the Exim user. You can run
59829 <emphasis>exicyclog</emphasis> as root if you wish, but there is no need.
59830 </para>
59831 </section>
59832 <section id="SECTmailstat">
59833 <title>Mail statistics (eximstats)</title>
59834 <para>
59835 <indexterm role="concept">
59836 <primary>statistics</primary>
59837 </indexterm>
59838 <indexterm role="concept">
59839 <primary><emphasis>eximstats</emphasis></primary>
59840 </indexterm>
59841 A Perl script called <emphasis>eximstats</emphasis> is provided for extracting statistical
59842 information from log files. The output is either plain text, or HTML.
59843 Exim log files are also supported by the <emphasis>Lire</emphasis> system produced by the
59844 LogReport Foundation <emphasis role="bold"><ulink url="http://www.logreport.org">http://www.logreport.org</ulink></emphasis>.
59845 </para>
59846 <para>
59847 The <emphasis>eximstats</emphasis> script has been hacked about quite a bit over time. The
59848 latest version is the result of some extensive revision by Steve Campbell. A
59849 lot of information is given by default, but there are options for suppressing
59850 various parts of it. Following any options, the arguments to the script are a
59851 list of files, which should be main log files. For example:
59852 </para>
59853 <literallayout class="monospaced">
59854 eximstats -nr /var/spool/exim/log/mainlog.01
59855 </literallayout>
59856 <para>
59857 By default, <emphasis>eximstats</emphasis> extracts information about the number and volume of
59858 messages received from or delivered to various hosts. The information is sorted
59859 both by message count and by volume, and the top fifty hosts in each category
59860 are listed on the standard output. Similar information, based on email
59861 addresses or domains instead of hosts can be requested by means of various
59862 options. For messages delivered and received locally, similar statistics are
59863 also produced per user.
59864 </para>
59865 <para>
59866 The output also includes total counts and statistics about delivery errors, and
59867 histograms showing the number of messages received and deliveries made in each
59868 hour of the day. A delivery with more than one address in its envelope (for
59869 example, an SMTP transaction with more than one RCPT command) is counted
59870 as a single delivery by <emphasis>eximstats</emphasis>.
59871 </para>
59872 <para>
59873 Though normally more deliveries than receipts are reported (as messages may
59874 have multiple recipients), it is possible for <emphasis>eximstats</emphasis> to report more
59875 messages received than delivered, even though the queue is empty at the start
59876 and end of the period in question. If an incoming message contains no valid
59877 recipients, no deliveries are recorded for it. A bounce message is handled as
59878 an entirely separate message.
59879 </para>
59880 <para>
59881 <emphasis>eximstats</emphasis> always outputs a grand total summary giving the volume and number
59882 of messages received and deliveries made, and the number of hosts involved in
59883 each case. It also outputs the number of messages that were delayed (that is,
59884 not completely delivered at the first attempt), and the number that had at
59885 least one address that failed.
59886 </para>
59887 <para>
59888 The remainder of the output is in sections that can be independently disabled
59889 or modified by various options. It consists of a summary of deliveries by
59890 transport, histograms of messages received and delivered per time interval
59891 (default per hour), information about the time messages spent on the queue,
59892 a list of relayed messages, lists of the top fifty sending hosts, local
59893 senders, destination hosts, and destination local users by count and by volume,
59894 and a list of delivery errors that occurred.
59895 </para>
59896 <para>
59897 The relay information lists messages that were actually relayed, that is, they
59898 came from a remote host and were directly delivered to some other remote host,
59899 without being processed (for example, for aliasing or forwarding) locally.
59900 </para>
59901 <para>
59902 There are quite a few options for <emphasis>eximstats</emphasis> to control exactly what it
59903 outputs. These are documented in the Perl script itself, and can be extracted
59904 by running the command <command>perldoc</command> on the script. For example:
59905 </para>
59906 <literallayout class="monospaced">
59907 perldoc /usr/exim/bin/eximstats
59908 </literallayout>
59909 </section>
59910 <section id="SECTcheckaccess">
59911 <title>Checking access policy (exim_checkaccess)</title>
59912 <para>
59913 <indexterm role="concept">
59914 <primary><emphasis>exim_checkaccess</emphasis></primary>
59915 </indexterm>
59916 <indexterm role="concept">
59917 <primary>policy control</primary>
59918 <secondary>checking access</secondary>
59919 </indexterm>
59920 <indexterm role="concept">
59921 <primary>checking access</primary>
59922 </indexterm>
59923 The <option>-bh</option> command line argument allows you to run a fake SMTP session with
59924 debugging output, in order to check what Exim is doing when it is applying
59925 policy controls to incoming SMTP mail. However, not everybody is sufficiently
59926 familiar with the SMTP protocol to be able to make full use of <option>-bh</option>, and
59927 sometimes you just want to answer the question <quote>Does this address have
59928 access?</quote> without bothering with any further details.
59929 </para>
59930 <para>
59931 The <emphasis>exim_checkaccess</emphasis> utility is a <quote>packaged</quote> version of <option>-bh</option>. It takes
59932 two arguments, an IP address and an email address:
59933 </para>
59934 <literallayout class="monospaced">
59935 exim_checkaccess 10.9.8.7 A.User@a.domain.example
59936 </literallayout>
59937 <para>
59938 The utility runs a call to Exim with the <option>-bh</option> option, to test whether the
59939 given email address would be accepted in a RCPT command in a TCP/IP
59940 connection from the host with the given IP address. The output of the utility
59941 is either the word <quote>accepted</quote>, or the SMTP error response, for example:
59942 </para>
59943 <literallayout class="monospaced">
59944 Rejected:
59945 550 Relay not permitted
59946 </literallayout>
59947 <para>
59948 When running this test, the utility uses <literal>&lt;&gt;</literal> as the envelope sender address
59949 for the MAIL command, but you can change this by providing additional
59950 options. These are passed directly to the Exim command. For example, to specify
59951 that the test is to be run with the sender address <emphasis>himself@there.example</emphasis>
59952 you can use:
59953 </para>
59954 <literallayout class="monospaced">
59955 exim_checkaccess 10.9.8.7 A.User@a.domain.example \
59956                  -f himself@there.example
59957 </literallayout>
59958 <para>
59959 Note that these additional Exim command line items must be given after the two
59960 mandatory arguments.
59961 </para>
59962 <para>
59963 Because the <option>exim_checkaccess</option> uses <option>-bh</option>, it does not perform callouts
59964 while running its checks. You can run checks that include callouts by using
59965 <option>-bhc</option>, but this is not yet available in a <quote>packaged</quote> form.
59966 </para>
59967 </section>
59968 <section id="SECTdbmbuild">
59969 <title>Making DBM files (exim_dbmbuild)</title>
59970 <para>
59971 <indexterm role="concept">
59972 <primary>DBM</primary>
59973 <secondary>building dbm files</secondary>
59974 </indexterm>
59975 <indexterm role="concept">
59976 <primary>building DBM files</primary>
59977 </indexterm>
59978 <indexterm role="concept">
59979 <primary><emphasis>exim_dbmbuild</emphasis></primary>
59980 </indexterm>
59981 <indexterm role="concept">
59982 <primary>lower casing</primary>
59983 </indexterm>
59984 <indexterm role="concept">
59985 <primary>binary zero</primary>
59986 <secondary>in lookup key</secondary>
59987 </indexterm>
59988 The <emphasis>exim_dbmbuild</emphasis> program reads an input file containing keys and data in
59989 the format used by the <command>lsearch</command> lookup (see section
59990 <xref linkend="SECTsinglekeylookups"/>). It writes a DBM file using the lower-cased alias
59991 names as keys and the remainder of the information as data. The lower-casing
59992 can be prevented by calling the program with the <option>-nolc</option> option.
59993 </para>
59994 <para>
59995 A terminating zero is included as part of the key string. This is expected by
59996 the <command>dbm</command> lookup type. However, if the option <option>-nozero</option> is given,
59997 <emphasis>exim_dbmbuild</emphasis> creates files without terminating zeroes in either the key
59998 strings or the data strings. The <command>dbmnz</command> lookup type can be used with such
59999 files.
60000 </para>
60001 <para>
60002 The program requires two arguments: the name of the input file (which can be a
60003 single hyphen to indicate the standard input), and the name of the output file.
60004 It creates the output under a temporary name, and then renames it if all went
60005 well.
60006 </para>
60007 <para>
60008 <indexterm role="concept">
60009 <primary>USE_DB</primary>
60010 </indexterm>
60011 If the native DB interface is in use (USE_DB is set in a compile-time
60012 configuration file &ndash; this is common in free versions of Unix) the two file
60013 names must be different, because in this mode the Berkeley DB functions create
60014 a single output file using exactly the name given. For example,
60015 </para>
60016 <literallayout class="monospaced">
60017 exim_dbmbuild /etc/aliases /etc/aliases.db
60018 </literallayout>
60019 <para>
60020 reads the system alias file and creates a DBM version of it in
60021 <filename>/etc/aliases.db</filename>.
60022 </para>
60023 <para>
60024 In systems that use the <emphasis>ndbm</emphasis> routines (mostly proprietary versions of
60025 Unix), two files are used, with the suffixes <filename>.dir</filename> and <filename>.pag</filename>. In this
60026 environment, the suffixes are added to the second argument of
60027 <emphasis>exim_dbmbuild</emphasis>, so it can be the same as the first. This is also the case
60028 when the Berkeley functions are used in compatibility mode (though this is not
60029 recommended), because in that case it adds a <filename>.db</filename> suffix to the file name.
60030 </para>
60031 <para>
60032 If a duplicate key is encountered, the program outputs a warning, and when it
60033 finishes, its return code is 1 rather than zero, unless the <option>-noduperr</option>
60034 option is used. By default, only the first of a set of duplicates is used &ndash;
60035 this makes it compatible with <command>lsearch</command> lookups. There is an option
60036 <option>-lastdup</option> which causes it to use the data for the last duplicate instead.
60037 There is also an option <option>-nowarn</option>, which stops it listing duplicate keys to
60038 <option>stderr</option>. For other errors, where it doesn&#x2019;t actually make a new file, the
60039 return code is 2.
60040 </para>
60041 </section>
60042 <section id="SECTfinindret">
60043 <title>Finding individual retry times (exinext)</title>
60044 <para>
60045 <indexterm role="concept">
60046 <primary>retry</primary>
60047 <secondary>times</secondary>
60048 </indexterm>
60049 <indexterm role="concept">
60050 <primary><emphasis>exinext</emphasis></primary>
60051 </indexterm>
60052 A utility called <emphasis>exinext</emphasis> (mostly a Perl script) provides the ability to
60053 fish specific information out of the retry database. Given a mail domain (or a
60054 complete address), it looks up the hosts for that domain, and outputs any retry
60055 information for the hosts or for the domain. At present, the retry information
60056 is obtained by running <emphasis>exim_dumpdb</emphasis> (see below) and post-processing the
60057 output. For example:
60058 </para>
60059 <literallayout class="monospaced">
60060 $ exinext piglet@milne.fict.example
60061 kanga.milne.example:192.168.8.1 error 146: Connection refused
60062   first failed: 21-Feb-1996 14:57:34
60063   last tried:   21-Feb-1996 14:57:34
60064   next try at:  21-Feb-1996 15:02:34
60065 roo.milne.example:192.168.8.3 error 146: Connection refused
60066   first failed: 20-Jan-1996 13:12:08
60067   last tried:   21-Feb-1996 11:42:03
60068   next try at:  21-Feb-1996 19:42:03
60069   past final cutoff time
60070 </literallayout>
60071 <para>
60072 You can also give <emphasis>exinext</emphasis> a local part, without a domain, and it
60073 will give any retry information for that local part in your default domain.
60074 A message id can be used to obtain retry information pertaining to a specific
60075 message. This exists only when an attempt to deliver a message to a remote host
60076 suffers a message-specific error (see section <xref linkend="SECToutSMTPerr"/>).
60077 <emphasis>exinext</emphasis> is not particularly efficient, but then it is not expected to be
60078 run very often.
60079 </para>
60080 <para>
60081 The <emphasis>exinext</emphasis> utility calls Exim to find out information such as the location
60082 of the spool directory. The utility has <option>-C</option> and <option>-D</option> options, which are
60083 passed on to the <emphasis>exim</emphasis> commands. The first specifies an alternate Exim
60084 configuration file, and the second sets macros for use within the configuration
60085 file. These features are mainly to help in testing, but might also be useful in
60086 environments where more than one configuration file is in use.
60087 </para>
60088 </section>
60089 <section id="SECThindatmai">
60090 <title>Hints database maintenance</title>
60091 <para>
60092 <indexterm role="concept">
60093 <primary>hints database</primary>
60094 <secondary>maintenance</secondary>
60095 </indexterm>
60096 <indexterm role="concept">
60097 <primary>maintaining Exim&#x2019;s hints database</primary>
60098 </indexterm>
60099 Three utility programs are provided for maintaining the DBM files that Exim
60100 uses to contain its delivery hint information. Each program requires two
60101 arguments. The first specifies the name of Exim&#x2019;s spool directory, and the
60102 second is the name of the database it is to operate on. These are as follows:
60103 </para>
60104 <itemizedlist>
60105 <listitem>
60106 <para>
60107 <emphasis>retry</emphasis>: the database of retry information
60108 </para>
60109 </listitem>
60110 <listitem>
60111 <para>
60112 <emphasis>wait-</emphasis>&lt;<emphasis>transport name</emphasis>&gt;: databases of information about messages waiting
60113 for remote hosts
60114 </para>
60115 </listitem>
60116 <listitem>
60117 <para>
60118 <emphasis>callout</emphasis>: the callout cache
60119 </para>
60120 </listitem>
60121 <listitem>
60122 <para>
60123 <emphasis>ratelimit</emphasis>: the data for implementing the ratelimit ACL condition
60124 </para>
60125 </listitem>
60126 <listitem>
60127 <para>
60128 <emphasis>misc</emphasis>: other hints data
60129 </para>
60130 </listitem>
60131 </itemizedlist>
60132 <para>
60133 The <emphasis>misc</emphasis> database is used for
60134 </para>
60135 <itemizedlist>
60136 <listitem>
60137 <para>
60138 Serializing ETRN runs (when <option>smtp_etrn_serialize</option> is set)
60139 </para>
60140 </listitem>
60141 <listitem>
60142 <para>
60143 Serializing delivery to a specific host (when <option>serialize_hosts</option> is set in an
60144 <command>smtp</command> transport)
60145 </para>
60146 </listitem>
60147 </itemizedlist>
60148 </section>
60149 <section id="SECID261">
60150 <title>exim_dumpdb</title>
60151 <para>
60152 <indexterm role="concept">
60153 <primary><emphasis>exim_dumpdb</emphasis></primary>
60154 </indexterm>
60155 The entire contents of a database are written to the standard output by the
60156 <emphasis>exim_dumpdb</emphasis> program, which has no options or arguments other than the
60157 spool and database names. For example, to dump the retry database:
60158 </para>
60159 <literallayout class="monospaced">
60160 exim_dumpdb /var/spool/exim retry
60161 </literallayout>
60162 <para>
60163 Two lines of output are produced for each entry:
60164 </para>
60165 <literallayout class="monospaced">
60166 T:mail.ref.example:192.168.242.242 146 77 Connection refused
60167 31-Oct-1995 12:00:12 02-Nov-1995 12:21:39 02-Nov-1995 20:21:39 *
60168 </literallayout>
60169 <para>
60170 The first item on the first line is the key of the record. It starts with one
60171 of the letters R, or T, depending on whether it refers to a routing or
60172 transport retry. For a local delivery, the next part is the local address; for
60173 a remote delivery it is the name of the remote host, followed by its failing IP
60174 address (unless <option>retry_include_ip_address</option> is set false on the <command>smtp</command>
60175 transport). If the remote port is not the standard one (port 25), it is added
60176 to the IP address. Then there follows an error code, an additional error code,
60177 and a textual description of the error.
60178 </para>
60179 <para>
60180 The three times on the second line are the time of first failure, the time of
60181 the last delivery attempt, and the computed time for the next attempt. The line
60182 ends with an asterisk if the cutoff time for the last retry rule has been
60183 exceeded.
60184 </para>
60185 <para>
60186 Each output line from <emphasis>exim_dumpdb</emphasis> for the <emphasis>wait-xxx</emphasis> databases
60187 consists of a host name followed by a list of ids for messages that are or were
60188 waiting to be delivered to that host. If there are a very large number for any
60189 one host, continuation records, with a sequence number added to the host name,
60190 may be seen. The data in these records is often out of date, because a message
60191 may be routed to several alternative hosts, and Exim makes no effort to keep
60192 cross-references.
60193 </para>
60194 </section>
60195 <section id="SECID262">
60196 <title>exim_tidydb</title>
60197 <para>
60198 <indexterm role="concept">
60199 <primary><emphasis>exim_tidydb</emphasis></primary>
60200 </indexterm>
60201 The <emphasis>exim_tidydb</emphasis> utility program is used to tidy up the contents of a hints
60202 database. If run with no options, it removes all records that are more than 30
60203 days old. The age is calculated from the date and time that the record was last
60204 updated. Note that, in the case of the retry database, it is <emphasis>not</emphasis> the time
60205 since the first delivery failure. Information about a host that has been down
60206 for more than 30 days will remain in the database, provided that the record is
60207 updated sufficiently often.
60208 </para>
60209 <para>
60210 The cutoff date can be altered by means of the <option>-t</option> option, which must be
60211 followed by a time. For example, to remove all records older than a week from
60212 the retry database:
60213 </para>
60214 <literallayout class="monospaced">
60215 exim_tidydb -t 7d /var/spool/exim retry
60216 </literallayout>
60217 <para>
60218 Both the <emphasis>wait-xxx</emphasis> and <emphasis>retry</emphasis> databases contain items that involve
60219 message ids. In the former these appear as data in records keyed by host &ndash;
60220 they were messages that were waiting for that host &ndash; and in the latter they
60221 are the keys for retry information for messages that have suffered certain
60222 types of error. When <emphasis>exim_tidydb</emphasis> is run, a check is made to ensure that
60223 message ids in database records are those of messages that are still on the
60224 queue. Message ids for messages that no longer exist are removed from
60225 <emphasis>wait-xxx</emphasis> records, and if this leaves any records empty, they are deleted.
60226 For the <emphasis>retry</emphasis> database, records whose keys are non-existent message ids are
60227 removed. The <emphasis>exim_tidydb</emphasis> utility outputs comments on the standard output
60228 whenever it removes information from the database.
60229 </para>
60230 <para>
60231 Certain records are automatically removed by Exim when they are no longer
60232 needed, but others are not. For example, if all the MX hosts for a domain are
60233 down, a retry record is created for each one. If the primary MX host comes back
60234 first, its record is removed when Exim successfully delivers to it, but the
60235 records for the others remain because Exim has not tried to use those hosts.
60236 </para>
60237 <para>
60238 It is important, therefore, to run <emphasis>exim_tidydb</emphasis> periodically on all the
60239 hints databases. You should do this at a quiet time of day, because it requires
60240 a database to be locked (and therefore inaccessible to Exim) while it does its
60241 work. Removing records from a DBM file does not normally make the file smaller,
60242 but all the common DBM libraries are able to re-use the space that is released.
60243 After an initial phase of increasing in size, the databases normally reach a
60244 point at which they no longer get any bigger, as long as they are regularly
60245 tidied.
60246 </para>
60247 <para>
60248 <emphasis role="bold">Warning</emphasis>: If you never run <emphasis>exim_tidydb</emphasis>, the space used by the hints
60249 databases is likely to keep on increasing.
60250 </para>
60251 </section>
60252 <section id="SECID263">
60253 <title>exim_fixdb</title>
60254 <para>
60255 <indexterm role="concept">
60256 <primary><emphasis>exim_fixdb</emphasis></primary>
60257 </indexterm>
60258 The <emphasis>exim_fixdb</emphasis> program is a utility for interactively modifying databases.
60259 Its main use is for testing Exim, but it might also be occasionally useful for
60260 getting round problems in a live system. It has no options, and its interface
60261 is somewhat crude. On entry, it prompts for input with a right angle-bracket. A
60262 key of a database record can then be entered, and the data for that record is
60263 displayed.
60264 </para>
60265 <para>
60266 If <quote>d</quote> is typed at the next prompt, the entire record is deleted. For all
60267 except the <emphasis>retry</emphasis> database, that is the only operation that can be carried
60268 out. For the <emphasis>retry</emphasis> database, each field is output preceded by a number, and
60269 data for individual fields can be changed by typing the field number followed
60270 by new data, for example:
60271 </para>
60272 <literallayout class="monospaced">
60273 &gt; 4 951102:1000
60274 </literallayout>
60275 <para>
60276 resets the time of the next delivery attempt. Time values are given as a
60277 sequence of digit pairs for year, month, day, hour, and minute. Colons can be
60278 used as optional separators.
60279 </para>
60280 </section>
60281 <section id="SECTmailboxmaint">
60282 <title>Mailbox maintenance (exim_lock)</title>
60283 <para>
60284 <indexterm role="concept">
60285 <primary>mailbox</primary>
60286 <secondary>maintenance</secondary>
60287 </indexterm>
60288 <indexterm role="concept">
60289 <primary><emphasis>exim_lock</emphasis></primary>
60290 </indexterm>
60291 <indexterm role="concept">
60292 <primary>locking mailboxes</primary>
60293 </indexterm>
60294 The <emphasis>exim_lock</emphasis> utility locks a mailbox file using the same algorithm as
60295 Exim. For a discussion of locking issues, see section <xref linkend="SECTopappend"/>.
60296 <emphasis>Exim_lock</emphasis> can be used to prevent any modification of a mailbox by Exim or
60297 a user agent while investigating a problem. The utility requires the name of
60298 the file as its first argument. If the locking is successful, the second
60299 argument is run as a command (using C&#x2019;s <function>system()</function> function); if there is no
60300 second argument, the value of the SHELL environment variable is used; if this
60301 is unset or empty, <filename>/bin/sh</filename> is run. When the command finishes, the mailbox
60302 is unlocked and the utility ends. The following options are available:
60303 </para>
60304 <variablelist>
60305 <varlistentry>
60306 <term><option>-fcntl</option></term>
60307 <listitem>
60308 <para>
60309 Use <function>fcntl()</function> locking on the open mailbox.
60310 </para>
60311 </listitem></varlistentry>
60312 <varlistentry>
60313 <term><option>-flock</option></term>
60314 <listitem>
60315 <para>
60316 Use <function>flock()</function> locking on the open mailbox, provided the operating system
60317 supports it.
60318 </para>
60319 </listitem></varlistentry>
60320 <varlistentry>
60321 <term><option>-interval</option></term>
60322 <listitem>
60323 <para>
60324 This must be followed by a number, which is a number of seconds; it sets the
60325 interval to sleep between retries (default 3).
60326 </para>
60327 </listitem></varlistentry>
60328 <varlistentry>
60329 <term><option>-lockfile</option></term>
60330 <listitem>
60331 <para>
60332 Create a lock file before opening the mailbox.
60333 </para>
60334 </listitem></varlistentry>
60335 <varlistentry>
60336 <term><option>-mbx</option></term>
60337 <listitem>
60338 <para>
60339 Lock the mailbox using MBX rules.
60340 </para>
60341 </listitem></varlistentry>
60342 <varlistentry>
60343 <term><option>-q</option></term>
60344 <listitem>
60345 <para>
60346 Suppress verification output.
60347 </para>
60348 </listitem></varlistentry>
60349 <varlistentry>
60350 <term><option>-retries</option></term>
60351 <listitem>
60352 <para>
60353 This must be followed by a number; it sets the number of times to try to get
60354 the lock (default 10).
60355 </para>
60356 </listitem></varlistentry>
60357 <varlistentry>
60358 <term><option>-restore_time</option></term>
60359 <listitem>
60360 <para>
60361 This option causes <option>exim_lock</option> to restore the modified and read times to the
60362 locked file before exiting. This allows you to access a locked mailbox (for
60363 example, to take a backup copy) without disturbing the times that the user
60364 subsequently sees.
60365 </para>
60366 </listitem></varlistentry>
60367 <varlistentry>
60368 <term><option>-timeout</option></term>
60369 <listitem>
60370 <para>
60371 This must be followed by a number, which is a number of seconds; it sets a
60372 timeout to be used with a blocking <function>fcntl()</function> lock. If it is not set (the
60373 default), a non-blocking call is used.
60374 </para>
60375 </listitem></varlistentry>
60376 <varlistentry>
60377 <term><option>-v</option></term>
60378 <listitem>
60379 <para>
60380 Generate verbose output.
60381 </para>
60382 </listitem></varlistentry>
60383 </variablelist>
60384 <para>
60385 If none of <option>-fcntl</option>, <option>-flock</option>, <option>-lockfile</option> or <option>-mbx</option> are given, the
60386 default is to create a lock file and also to use <function>fcntl()</function> locking on the
60387 mailbox, which is the same as Exim&#x2019;s default. The use of <option>-flock</option> or
60388 <option>-fcntl</option> requires that the file be writeable; the use of <option>-lockfile</option>
60389 requires that the directory containing the file be writeable. Locking by lock
60390 file does not last for ever; Exim assumes that a lock file is expired if it is
60391 more than 30 minutes old.
60392 </para>
60393 <para>
60394 The <option>-mbx</option> option can be used with either or both of <option>-fcntl</option> or
60395 <option>-flock</option>. It assumes <option>-fcntl</option> by default. MBX locking causes a shared lock
60396 to be taken out on the open mailbox, and an exclusive lock on the file
60397 <filename>/tmp/.n.m</filename> where <emphasis>n</emphasis> and <emphasis>m</emphasis> are the device number and inode
60398 number of the mailbox file. When the locking is released, if an exclusive lock
60399 can be obtained for the mailbox, the file in <filename>/tmp</filename> is deleted.
60400 </para>
60401 <para>
60402 The default output contains verification of the locking that takes place. The
60403 <option>-v</option> option causes some additional information to be given. The <option>-q</option> option
60404 suppresses all output except error messages.
60405 </para>
60406 <para>
60407 A command such as
60408 </para>
60409 <literallayout class="monospaced">
60410 exim_lock /var/spool/mail/spqr
60411 </literallayout>
60412 <para>
60413 runs an interactive shell while the file is locked, whereas
60414 </para>
60415 <literallayout>
60416 <literal>exim_lock -q /var/spool/mail/spqr &lt;&lt;End</literal>
60417 &lt;<emphasis>some commands</emphasis>&gt;
60418 <literal>End</literal>
60419 </literallayout>
60420 <para>
60421 runs a specific non-interactive sequence of commands while the file is locked,
60422 suppressing all verification output. A single command can be run by a command
60423 such as
60424 </para>
60425 <literallayout class="monospaced">
60426 exim_lock -q /var/spool/mail/spqr \
60427   "cp /var/spool/mail/spqr /some/where"
60428 </literallayout>
60429 <para>
60430 Note that if a command is supplied, it must be entirely contained within the
60431 second argument &ndash; hence the quotes.
60432 <indexterm role="concept" startref="IIDutils" class="endofrange"/>
60433 </para>
60434 </section>
60435 </chapter>
60436
60437 <chapter id="CHAPeximon">
60438 <title>The Exim monitor</title>
60439 <para>
60440 <indexterm role="concept" id="IIDeximon" class="startofrange">
60441 <primary>Exim monitor</primary>
60442 <secondary>description</secondary>
60443 </indexterm>
60444 <indexterm role="concept">
60445 <primary>X-windows</primary>
60446 </indexterm>
60447 <indexterm role="concept">
60448 <primary><emphasis>eximon</emphasis></primary>
60449 </indexterm>
60450 <indexterm role="concept">
60451 <primary>Local/eximon.conf</primary>
60452 </indexterm>
60453 <indexterm role="concept">
60454 <primary><filename>exim_monitor/EDITME</filename></primary>
60455 </indexterm>
60456 The Exim monitor is an application which displays in an X window information
60457 about the state of Exim&#x2019;s queue and what Exim is doing. An admin user can
60458 perform certain operations on messages from this GUI interface; however all
60459 such facilities are also available from the command line, and indeed, the
60460 monitor itself makes use of the command line to perform any actions requested.
60461 </para>
60462 <section id="SECID264">
60463 <title>Running the monitor</title>
60464 <para>
60465 The monitor is started by running the script called <emphasis>eximon</emphasis>. This is a shell
60466 script that sets up a number of environment variables, and then runs the
60467 binary called <filename>eximon.bin</filename>. The default appearance of the monitor window can
60468 be changed by editing the <filename>Local/eximon.conf</filename> file created by editing
60469 <filename>exim_monitor/EDITME</filename>. Comments in that file describe what the various
60470 parameters are for.
60471 </para>
60472 <para>
60473 The parameters that get built into the <emphasis>eximon</emphasis> script can be overridden for
60474 a particular invocation by setting up environment variables of the same names,
60475 preceded by <literal>EXIMON_</literal>. For example, a shell command such as
60476 </para>
60477 <literallayout class="monospaced">
60478 EXIMON_LOG_DEPTH=400 eximon
60479 </literallayout>
60480 <para>
60481 (in a Bourne-compatible shell) runs <emphasis>eximon</emphasis> with an overriding setting of
60482 the LOG_DEPTH parameter. If EXIMON_LOG_FILE_PATH is set in the environment, it
60483 overrides the Exim log file configuration. This makes it possible to have
60484 <emphasis>eximon</emphasis> tailing log data that is written to syslog, provided that MAIL.INFO
60485 syslog messages are routed to a file on the local host.
60486 </para>
60487 <para>
60488 X resources can be used to change the appearance of the window in the normal
60489 way. For example, a resource setting of the form
60490 </para>
60491 <literallayout class="monospaced">
60492 Eximon*background: gray94
60493 </literallayout>
60494 <para>
60495 changes the colour of the background to light grey rather than white. The
60496 stripcharts are drawn with both the data lines and the reference lines in
60497 black. This means that the reference lines are not visible when on top of the
60498 data. However, their colour can be changed by setting a resource called
60499 <quote>highlight</quote> (an odd name, but that&#x2019;s what the Athena stripchart widget uses).
60500 For example, if your X server is running Unix, you could set up lighter
60501 reference lines in the stripcharts by obeying
60502 </para>
60503 <literallayout class="monospaced">
60504 xrdb -merge &lt;&lt;End
60505 Eximon*highlight: gray
60506 End
60507 </literallayout>
60508 <para>
60509 <indexterm role="concept">
60510 <primary>admin user</primary>
60511 </indexterm>
60512 In order to see the contents of messages on the queue, and to operate on them,
60513 <emphasis>eximon</emphasis> must either be run as root or by an admin user.
60514 </para>
60515 <para>
60516 The monitor&#x2019;s window is divided into three parts. The first contains one or
60517 more stripcharts and two action buttons, the second contains a <quote>tail</quote> of the
60518 main log file, and the third is a display of the queue of messages awaiting
60519 delivery, with two more action buttons. The following sections describe these
60520 different parts of the display.
60521 </para>
60522 </section>
60523 <section id="SECID265">
60524 <title>The stripcharts</title>
60525 <para>
60526 <indexterm role="concept">
60527 <primary>stripchart</primary>
60528 </indexterm>
60529 The first stripchart is always a count of messages on the queue. Its name can
60530 be configured by setting QUEUE_STRIPCHART_NAME in the
60531 <filename>Local/eximon.conf</filename> file. The remaining stripcharts are defined in the
60532 configuration script by regular expression matches on log file entries, making
60533 it possible to display, for example, counts of messages delivered to certain
60534 hosts or using certain transports. The supplied defaults display counts of
60535 received and delivered messages, and of local and SMTP deliveries. The default
60536 period between stripchart updates is one minute; this can be adjusted by a
60537 parameter in the <filename>Local/eximon.conf</filename> file.
60538 </para>
60539 <para>
60540 The stripchart displays rescale themselves automatically as the value they are
60541 displaying changes. There are always 10 horizontal lines in each chart; the
60542 title string indicates the value of each division when it is greater than one.
60543 For example, <quote>x2</quote> means that each division represents a value of 2.
60544 </para>
60545 <para>
60546 It is also possible to have a stripchart which shows the percentage fullness of
60547 a particular disk partition, which is useful when local deliveries are confined
60548 to a single partition.
60549 </para>
60550 <para>
60551 <indexterm role="concept">
60552 <primary><option>statvfs</option> function</primary>
60553 </indexterm>
60554 This relies on the availability of the <function>statvfs()</function> function or equivalent in
60555 the operating system. Most, but not all versions of Unix that support Exim have
60556 this. For this particular stripchart, the top of the chart always represents
60557 100%, and the scale is given as <quote>x10%</quote>. This chart is configured by setting
60558 SIZE_STRIPCHART and (optionally) SIZE_STRIPCHART_NAME in the
60559 <filename>Local/eximon.conf</filename> file.
60560 </para>
60561 </section>
60562 <section id="SECID266">
60563 <title>Main action buttons</title>
60564 <para>
60565 <indexterm role="concept">
60566 <primary>size</primary>
60567 <secondary>of monitor window</secondary>
60568 </indexterm>
60569 <indexterm role="concept">
60570 <primary>Exim monitor</primary>
60571 <secondary>window size</secondary>
60572 </indexterm>
60573 <indexterm role="concept">
60574 <primary>window size</primary>
60575 </indexterm>
60576 Below the stripcharts there is an action button for quitting the monitor. Next
60577 to this is another button marked <quote>Size</quote>. They are placed here so that
60578 shrinking the window to its default minimum size leaves just the queue count
60579 stripchart and these two buttons visible. Pressing the <quote>Size</quote> button causes
60580 the window to expand to its maximum size, unless it is already at the maximum,
60581 in which case it is reduced to its minimum.
60582 </para>
60583 <para>
60584 When expanding to the maximum, if the window cannot be fully seen where it
60585 currently is, it is moved back to where it was the last time it was at full
60586 size. When it is expanding from its minimum size, the old position is
60587 remembered, and next time it is reduced to the minimum it is moved back there.
60588 </para>
60589 <para>
60590 The idea is that you can keep a reduced window just showing one or two
60591 stripcharts at a convenient place on your screen, easily expand it to show
60592 the full window when required, and just as easily put it back to what it was.
60593 The idea is copied from what the <emphasis>twm</emphasis> window manager does for its
60594 <emphasis>f.fullzoom</emphasis> action. The minimum size of the window can be changed by setting
60595 the MIN_HEIGHT and MIN_WIDTH values in <filename>Local/eximon.conf</filename>.
60596 </para>
60597 <para>
60598 Normally, the monitor starts up with the window at its full size, but it can be
60599 built so that it starts up with the window at its smallest size, by setting
60600 START_SMALL=yes in <filename>Local/eximon.conf</filename>.
60601 </para>
60602 </section>
60603 <section id="SECID267">
60604 <title>The log display</title>
60605 <para>
60606 <indexterm role="concept">
60607 <primary>log</primary>
60608 <secondary>tail of; in monitor</secondary>
60609 </indexterm>
60610 The second section of the window is an area in which a display of the tail of
60611 the main log is maintained.
60612 To save space on the screen, the timestamp on each log line is shortened by
60613 removing the date and, if <option>log_timezone</option> is set, the timezone.
60614 The log tail is not available when the only destination for logging data is
60615 syslog, unless the syslog lines are routed to a local file whose name is passed
60616 to <emphasis>eximon</emphasis> via the EXIMON_LOG_FILE_PATH environment variable.
60617 </para>
60618 <para>
60619 The log sub-window has a scroll bar at its lefthand side which can be used to
60620 move back to look at earlier text, and the up and down arrow keys also have a
60621 scrolling effect. The amount of log that is kept depends on the setting of
60622 LOG_BUFFER in <filename>Local/eximon.conf</filename>, which specifies the amount of memory
60623 to use. When this is full, the earlier 50% of data is discarded &ndash; this is
60624 much more efficient than throwing it away line by line. The sub-window also has
60625 a horizontal scroll bar for accessing the ends of long log lines. This is the
60626 only means of horizontal scrolling; the right and left arrow keys are not
60627 available. Text can be cut from this part of the window using the mouse in the
60628 normal way. The size of this subwindow is controlled by parameters in the
60629 configuration file <filename>Local/eximon.conf</filename>.
60630 </para>
60631 <para>
60632 Searches of the text in the log window can be carried out by means of the ^R
60633 and ^S keystrokes, which default to a reverse and a forward search,
60634 respectively. The search covers only the text that is displayed in the window.
60635 It cannot go further back up the log.
60636 </para>
60637 <para>
60638 The point from which the search starts is indicated by a caret marker. This is
60639 normally at the end of the text in the window, but can be positioned explicitly
60640 by pointing and clicking with the left mouse button, and is moved automatically
60641 by a successful search. If new text arrives in the window when it is scrolled
60642 back, the caret remains where it is, but if the window is not scrolled back,
60643 the caret is moved to the end of the new text.
60644 </para>
60645 <para>
60646 Pressing ^R or ^S pops up a window into which the search text can be typed.
60647 There are buttons for selecting forward or reverse searching, for carrying out
60648 the search, and for cancelling. If the <quote>Search</quote> button is pressed, the search
60649 happens and the window remains so that further searches can be done. If the
60650 <quote>Return</quote> key is pressed, a single search is done and the window is closed. If
60651 ^C is typed the search is cancelled.
60652 </para>
60653 <para>
60654 The searching facility is implemented using the facilities of the Athena text
60655 widget. By default this pops up a window containing both <quote>search</quote> and
60656 <quote>replace</quote> options. In order to suppress the unwanted <quote>replace</quote> portion for
60657 eximon, a modified version of the <option>TextPop</option> widget is distributed with Exim.
60658 However, the linkers in BSDI and HP-UX seem unable to handle an externally
60659 provided version of <option>TextPop</option> when the remaining parts of the text widget
60660 come from the standard libraries. The compile-time option EXIMON_TEXTPOP can be
60661 unset to cut out the modified <option>TextPop</option>, making it possible to build Eximon
60662 on these systems, at the expense of having unwanted items in the search popup
60663 window.
60664 </para>
60665 </section>
60666 <section id="SECID268">
60667 <title>The queue display</title>
60668 <para>
60669 <indexterm role="concept">
60670 <primary>queue</primary>
60671 <secondary>display in monitor</secondary>
60672 </indexterm>
60673 The bottom section of the monitor window contains a list of all messages that
60674 are on the queue, which includes those currently being received or delivered,
60675 as well as those awaiting delivery. The size of this subwindow is controlled by
60676 parameters in the configuration file <filename>Local/eximon.conf</filename>, and the frequency
60677 at which it is updated is controlled by another parameter in the same file &ndash;
60678 the default is 5 minutes, since queue scans can be quite expensive. However,
60679 there is an <quote>Update</quote> action button just above the display which can be used
60680 to force an update of the queue display at any time.
60681 </para>
60682 <para>
60683 When a host is down for some time, a lot of pending mail can build up for it,
60684 and this can make it hard to deal with other messages on the queue. To help
60685 with this situation there is a button next to <quote>Update</quote> called <quote>Hide</quote>. If
60686 pressed, a dialogue box called <quote>Hide addresses ending with</quote> is put up. If you
60687 type anything in here and press <quote>Return</quote>, the text is added to a chain of
60688 such texts, and if every undelivered address in a message matches at least one
60689 of the texts, the message is not displayed.
60690 </para>
60691 <para>
60692 If there is an address that does not match any of the texts, all the addresses
60693 are displayed as normal. The matching happens on the ends of addresses so, for
60694 example, <emphasis>cam.ac.uk</emphasis> specifies all addresses in Cambridge, while
60695 <emphasis>xxx@foo.com.example</emphasis> specifies just one specific address. When any hiding
60696 has been set up, a button called <quote>Unhide</quote> is displayed. If pressed, it
60697 cancels all hiding. Also, to ensure that hidden messages do not get forgotten,
60698 a hide request is automatically cancelled after one hour.
60699 </para>
60700 <para>
60701 While the dialogue box is displayed, you can&#x2019;t press any buttons or do anything
60702 else to the monitor window. For this reason, if you want to cut text from the
60703 queue display to use in the dialogue box, you have to do the cutting before
60704 pressing the <quote>Hide</quote> button.
60705 </para>
60706 <para>
60707 The queue display contains, for each unhidden queued message, the length of
60708 time it has been on the queue, the size of the message, the message id, the
60709 message sender, and the first undelivered recipient, all on one line. If it is
60710 a bounce message, the sender is shown as <quote>&lt;&gt;</quote>. If there is more than one
60711 recipient to which the message has not yet been delivered, subsequent ones are
60712 listed on additional lines, up to a maximum configured number, following which
60713 an ellipsis is displayed. Recipients that have already received the message are
60714 not shown.
60715 </para>
60716 <para>
60717 <indexterm role="concept">
60718 <primary>frozen messages</primary>
60719 <secondary>display</secondary>
60720 </indexterm>
60721 If a message is frozen, an asterisk is displayed at the left-hand side.
60722 </para>
60723 <para>
60724 The queue display has a vertical scroll bar, and can also be scrolled by means
60725 of the arrow keys. Text can be cut from it using the mouse in the normal way.
60726 The text searching facilities, as described above for the log window, are also
60727 available, but the caret is always moved to the end of the text when the queue
60728 display is updated.
60729 </para>
60730 </section>
60731 <section id="SECID269">
60732 <title>The queue menu</title>
60733 <para>
60734 <indexterm role="concept">
60735 <primary>queue</primary>
60736 <secondary>menu in monitor</secondary>
60737 </indexterm>
60738 If the <option>shift</option> key is held down and the left button is clicked when the mouse
60739 pointer is over the text for any message, an action menu pops up, and the first
60740 line of the queue display for the message is highlighted. This does not affect
60741 any selected text.
60742 </para>
60743 <para>
60744 If you want to use some other event for popping up the menu, you can set the
60745 MENU_EVENT parameter in <filename>Local/eximon.conf</filename> to change the default, or
60746 set EXIMON_MENU_EVENT in the environment before starting the monitor. The
60747 value set in this parameter is a standard X event description. For example, to
60748 run eximon using <option>ctrl</option> rather than <option>shift</option> you could use
60749 </para>
60750 <literallayout class="monospaced">
60751 EXIMON_MENU_EVENT='Ctrl&lt;Btn1Down&gt;' eximon
60752 </literallayout>
60753 <para>
60754 The title of the menu is the message id, and it contains entries which act as
60755 follows:
60756 </para>
60757 <itemizedlist>
60758 <listitem>
60759 <para>
60760 <emphasis>message log</emphasis>: The contents of the message log for the message are displayed
60761 in a new text window.
60762 </para>
60763 </listitem>
60764 <listitem>
60765 <para>
60766 <emphasis>headers</emphasis>: Information from the spool file that contains the envelope
60767 information and headers is displayed in a new text window. See chapter
60768 <xref linkend="CHAPspool"/> for a description of the format of spool files.
60769 </para>
60770 </listitem>
60771 <listitem>
60772 <para>
60773 <emphasis>body</emphasis>: The contents of the spool file containing the body of the message are
60774 displayed in a new text window. There is a default limit of 20,000 bytes to the
60775 amount of data displayed. This can be changed by setting the BODY_MAX
60776 option at compile time, or the EXIMON_BODY_MAX option at run time.
60777 </para>
60778 </listitem>
60779 <listitem>
60780 <para>
60781 <emphasis>deliver message</emphasis>: A call to Exim is made using the <option>-M</option> option to request
60782 delivery of the message. This causes an automatic thaw if the message is
60783 frozen. The <option>-v</option> option is also set, and the output from Exim is displayed in
60784 a new text window. The delivery is run in a separate process, to avoid holding
60785 up the monitor while the delivery proceeds.
60786 </para>
60787 </listitem>
60788 <listitem>
60789 <para>
60790 <emphasis>freeze message</emphasis>: A call to Exim is made using the <option>-Mf</option> option to request
60791 that the message be frozen.
60792 </para>
60793 </listitem>
60794 <listitem>
60795 <para>
60796 <indexterm role="concept">
60797 <primary>thawing messages</primary>
60798 </indexterm>
60799 <indexterm role="concept">
60800 <primary>unfreezing messages</primary>
60801 </indexterm>
60802 <indexterm role="concept">
60803 <primary>frozen messages</primary>
60804 <secondary>thawing</secondary>
60805 </indexterm>
60806 <emphasis>thaw message</emphasis>: A call to Exim is made using the <option>-Mt</option> option to request
60807 that the message be thawed.
60808 </para>
60809 </listitem>
60810 <listitem>
60811 <para>
60812 <indexterm role="concept">
60813 <primary>delivery</primary>
60814 <secondary>forcing failure</secondary>
60815 </indexterm>
60816 <emphasis>give up on msg</emphasis>: A call to Exim is made using the <option>-Mg</option> option to request
60817 that Exim gives up trying to deliver the message. A bounce message is generated
60818 for any remaining undelivered addresses.
60819 </para>
60820 </listitem>
60821 <listitem>
60822 <para>
60823 <emphasis>remove message</emphasis>: A call to Exim is made using the <option>-Mrm</option> option to request
60824 that the message be deleted from the system without generating a bounce
60825 message.
60826 </para>
60827 </listitem>
60828 <listitem>
60829 <para>
60830 <emphasis>add recipient</emphasis>: A dialog box is displayed into which a recipient address can
60831 be typed. If the address is not qualified and the QUALIFY_DOMAIN parameter
60832 is set in <filename>Local/eximon.conf</filename>, the address is qualified with that domain.
60833 Otherwise it must be entered as a fully qualified address. Pressing RETURN
60834 causes a call to Exim to be made using the <option>-Mar</option> option to request that an
60835 additional recipient be added to the message, unless the entry box is empty, in
60836 which case no action is taken.
60837 </para>
60838 </listitem>
60839 <listitem>
60840 <para>
60841 <emphasis>mark delivered</emphasis>: A dialog box is displayed into which a recipient address
60842 can be typed. If the address is not qualified and the QUALIFY_DOMAIN parameter
60843 is set in <filename>Local/eximon.conf</filename>, the address is qualified with that domain.
60844 Otherwise it must be entered as a fully qualified address. Pressing RETURN
60845 causes a call to Exim to be made using the <option>-Mmd</option> option to mark the given
60846 recipient address as already delivered, unless the entry box is empty, in which
60847 case no action is taken.
60848 </para>
60849 </listitem>
60850 <listitem>
60851 <para>
60852 <emphasis>mark all delivered</emphasis>: A call to Exim is made using the <option>-Mmad</option> option to
60853 mark all recipient addresses as already delivered.
60854 </para>
60855 </listitem>
60856 <listitem>
60857 <para>
60858 <emphasis>edit sender</emphasis>: A dialog box is displayed initialized with the current
60859 sender&#x2019;s address. Pressing RETURN causes a call to Exim to be made using the
60860 <option>-Mes</option> option to replace the sender address, unless the entry box is empty,
60861 in which case no action is taken. If you want to set an empty sender (as in
60862 bounce messages), you must specify it as <quote>&lt;&gt;</quote>. Otherwise, if the address is
60863 not qualified and the QUALIFY_DOMAIN parameter is set in <filename>Local/eximon.conf</filename>,
60864 the address is qualified with that domain.
60865 </para>
60866 </listitem>
60867 </itemizedlist>
60868 <para>
60869 When a delivery is forced, a window showing the <option>-v</option> output is displayed. In
60870 other cases when a call to Exim is made, if there is any output from Exim (in
60871 particular, if the command fails) a window containing the command and the
60872 output is displayed. Otherwise, the results of the action are normally apparent
60873 from the log and queue displays. However, if you set ACTION_OUTPUT=yes in
60874 <filename>Local/eximon.conf</filename>, a window showing the Exim command is always opened, even
60875 if no output is generated.
60876 </para>
60877 <para>
60878 The queue display is automatically updated for actions such as freezing and
60879 thawing, unless ACTION_QUEUE_UPDATE=no has been set in
60880 <filename>Local/eximon.conf</filename>. In this case the <quote>Update</quote> button has to be used to
60881 force an update of the display after one of these actions.
60882 </para>
60883 <para>
60884 In any text window that is displayed as result of a menu action, the normal
60885 cut-and-paste facility is available, and searching can be carried out using ^R
60886 and ^S, as described above for the log tail window.
60887 <indexterm role="concept" startref="IIDeximon" class="endofrange"/>
60888 </para>
60889 </section>
60890 </chapter>
60891
60892 <chapter id="CHAPsecurity">
60893 <title>Security considerations</title>
60894 <para>
60895 <indexterm role="concept" id="IIDsecurcon" class="startofrange">
60896 <primary>security</primary>
60897 <secondary>discussion of</secondary>
60898 </indexterm>
60899 This chapter discusses a number of issues concerned with security, some of
60900 which are also covered in other parts of this manual.
60901 </para>
60902 <para>
60903 For reasons that this author does not understand, some people have promoted
60904 Exim as a <quote>particularly secure</quote> mailer. Perhaps it is because of the
60905 existence of this chapter in the documentation. However, the intent of the
60906 chapter is simply to describe the way Exim works in relation to certain
60907 security concerns, not to make any specific claims about the effectiveness of
60908 its security as compared with other MTAs.
60909 </para>
60910 <para>
60911 What follows is a description of the way Exim is supposed to be. Best efforts
60912 have been made to try to ensure that the code agrees with the theory, but an
60913 absence of bugs can never be guaranteed. Any that are reported will get fixed
60914 as soon as possible.
60915 </para>
60916 <section id="SECID286">
60917 <title>Building a more <quote>hardened</quote> Exim</title>
60918 <para>
60919 <indexterm role="concept">
60920 <primary>security</primary>
60921 <secondary>build-time features</secondary>
60922 </indexterm>
60923 There are a number of build-time options that can be set in <filename>Local/Makefile</filename>
60924 to create Exim binaries that are <quote>harder</quote> to attack, in particular by a rogue
60925 Exim administrator who does not have the root password, or by someone who has
60926 penetrated the Exim (but not the root) account. These options are as follows:
60927 </para>
60928 <itemizedlist>
60929 <listitem>
60930 <para>
60931 ALT_CONFIG_PREFIX can be set to a string that is required to match the
60932 start of any file names used with the <option>-C</option> option. When it is set, these file
60933 names are also not allowed to contain the sequence <quote>/../</quote>. (However, if the
60934 value of the <option>-C</option> option is identical to the value of CONFIGURE_FILE in
60935 <filename>Local/Makefile</filename>, Exim ignores <option>-C</option> and proceeds as usual.) There is no
60936 default setting for <option>ALT_CONFIG_PREFIX</option>.
60937 </para>
60938 <para revisionflag="changed">
60939 If the permitted configuration files are confined to a directory to
60940 which only root has access, this guards against someone who has broken
60941 into the Exim account from running a privileged Exim with an arbitrary
60942 configuration file, and using it to break into other accounts.
60943 </para>
60944 </listitem>
60945 <listitem>
60946 <para revisionflag="changed">
60947 If a non-trusted configuration file (i.e. not the default configuration file
60948 or one which is trusted by virtue of being listed in the TRUSTED_CONFIG_LIST
60949 file) is specified with <option>-C</option>, or if macros are given with <option>-D</option> (but see
60950 the next item), then root privilege is retained only if the caller of Exim is
60951 root. This locks out the possibility of testing a configuration using <option>-C</option>
60952 right through message reception and delivery, even if the caller is root. The
60953 reception works, but by that time, Exim is running as the Exim user, so when
60954 it re-execs to regain privilege for the delivery, the use of <option>-C</option> causes
60955 privilege to be lost. However, root can test reception and delivery using two
60956 separate commands.
60957 </para>
60958 </listitem>
60959 <listitem>
60960 <para revisionflag="changed">
60961 The WHITELIST_D_MACROS build option declares some macros to be safe to override
60962 with <option>-D</option> if the real uid is one of root, the Exim run-time user or the
60963 CONFIGURE_OWNER, if defined.  The potential impact of this option is limited by
60964 requiring the run-time value supplied to <option>-D</option> to match a regex that errs on
60965 the restrictive side.  Requiring build-time selection of safe macros is onerous
60966 but this option is intended solely as a transition mechanism to permit
60967 previously-working configurations to continue to work after release 4.73.
60968 </para>
60969 </listitem>
60970 <listitem>
60971 <para revisionflag="changed">
60972 If DISABLE_D_OPTION is defined, the use of the <option>-D</option> command line option
60973 is disabled.
60974 </para>
60975 </listitem>
60976 <listitem>
60977 <para revisionflag="changed">
60978 FIXED_NEVER_USERS can be set to a colon-separated list of users that are
60979 never to be used for any deliveries. This is like the <option>never_users</option> runtime
60980 option, but it cannot be overridden; the runtime option adds additional users
60981 to the list. The default setting is <quote>root</quote>; this prevents a non-root user who
60982 is permitted to modify the runtime file from using Exim as a way to get root.
60983 </para>
60984 </listitem>
60985 </itemizedlist>
60986 </section>
60987 <section id="SECID270">
60988 <title>Root privilege</title>
60989 <para>
60990 <indexterm role="concept">
60991 <primary>setuid</primary>
60992 </indexterm>
60993 <indexterm role="concept">
60994 <primary>root privilege</primary>
60995 </indexterm>
60996 The Exim binary is normally setuid to root, which means that it gains root
60997 privilege (runs as root) when it starts execution. In some special cases (for
60998 example, when the daemon is not in use and there are no local deliveries), it
60999 may be possible to run Exim setuid to some user other than root. This is
61000 discussed in the next section. However, in most installations, root privilege
61001 is required for two things:
61002 </para>
61003 <itemizedlist>
61004 <listitem>
61005 <para>
61006 To set up a socket connected to the standard SMTP port (25) when initialising
61007 the listening daemon. If Exim is run from <emphasis>inetd</emphasis>, this privileged action is
61008 not required.
61009 </para>
61010 </listitem>
61011 <listitem>
61012 <para>
61013 To be able to change uid and gid in order to read users&#x2019; <filename>.forward</filename> files and
61014 perform local deliveries as the receiving user or as specified in the
61015 configuration.
61016 </para>
61017 </listitem>
61018 </itemizedlist>
61019 <para>
61020 It is not necessary to be root to do any of the other things Exim does, such as
61021 receiving messages and delivering them externally over SMTP, and it is
61022 obviously more secure if Exim does not run as root except when necessary.
61023 For this reason, a user and group for Exim to use must be defined in
61024 <filename>Local/Makefile</filename>. These are known as <quote>the Exim user</quote> and <quote>the Exim
61025 group</quote>. Their values can be changed by the run time configuration, though this
61026 is not recommended. Often a user called <emphasis>exim</emphasis> is used, but some sites use
61027 <emphasis>mail</emphasis> or another user name altogether.
61028 </para>
61029 <para>
61030 Exim uses <function>setuid()</function> whenever it gives up root privilege. This is a permanent
61031 abdication; the process cannot regain root afterwards. Prior to release 4.00,
61032 <function>seteuid()</function> was used in some circumstances, but this is no longer the case.
61033 </para>
61034 <para>
61035 After a new Exim process has interpreted its command line options, it changes
61036 uid and gid in the following cases:
61037 </para>
61038 <itemizedlist revisionflag="changed">
61039 <listitem>
61040 <para revisionflag="changed">
61041 <indexterm role="option">
61042 <primary><option>-C</option></primary>
61043 </indexterm>
61044 <indexterm role="option">
61045 <primary><option>-D</option></primary>
61046 </indexterm>
61047 If the <option>-C</option> option is used to specify an alternate configuration file, or if
61048 the <option>-D</option> option is used to define macro values for the configuration, and the
61049 calling process is not running as root, the uid and gid are changed to those of
61050 the calling process.
61051 However, if DISABLE_D_OPTION is defined in <filename>Local/Makefile</filename>, the <option>-D</option>
61052 option may not be used at all.
61053 If WHITELIST_D_MACROS is defined in <filename>Local/Makefile</filename>, then some macro values
61054 can be supplied if the calling process is running as root, the Exim run-time
61055 user or CONFIGURE_OWNER, if defined.
61056 </para>
61057 </listitem>
61058 <listitem>
61059 <para revisionflag="changed">
61060 <indexterm role="option">
61061 <primary><option>-be</option></primary>
61062 </indexterm>
61063 <indexterm role="option">
61064 <primary><option>-bf</option></primary>
61065 </indexterm>
61066 <indexterm role="option">
61067 <primary><option>-bF</option></primary>
61068 </indexterm>
61069 If the expansion test option (<option>-be</option>) or one of the filter testing options
61070 (<option>-bf</option> or <option>-bF</option>) are used, the uid and gid are changed to those of the
61071 calling process.
61072 </para>
61073 </listitem>
61074 <listitem>
61075 <para revisionflag="changed">
61076 If the process is not a daemon process or a queue runner process or a delivery
61077 process or a process for testing address routing (started with <option>-bt</option>), the
61078 uid and gid are changed to the Exim user and group. This means that Exim always
61079 runs under its own uid and gid when receiving messages. This also applies when
61080 testing address verification
61081 <indexterm role="option">
61082 <primary><option>-bv</option></primary>
61083 </indexterm>
61084 <indexterm role="option">
61085 <primary><option>-bh</option></primary>
61086 </indexterm>
61087 (the <option>-bv</option> option) and testing incoming message policy controls (the <option>-bh</option>
61088 option).
61089 </para>
61090 </listitem>
61091 <listitem>
61092 <para revisionflag="changed">
61093 For a daemon, queue runner, delivery, or address testing process, the uid
61094 remains as root at this stage, but the gid is changed to the Exim group.
61095 </para>
61096 </listitem>
61097 </itemizedlist>
61098 <para>
61099 The processes that initially retain root privilege behave as follows:
61100 </para>
61101 <itemizedlist>
61102 <listitem>
61103 <para>
61104 A daemon process changes the gid to the Exim group and the uid to the Exim
61105 user after setting up one or more listening sockets. The <function>initgroups()</function>
61106 function is called, so that if the Exim user is in any additional groups, they
61107 will be used during message reception.
61108 </para>
61109 </listitem>
61110 <listitem>
61111 <para>
61112 A queue runner process retains root privilege throughout its execution. Its
61113 job is to fork a controlled sequence of delivery processes.
61114 </para>
61115 </listitem>
61116 <listitem>
61117 <para>
61118 A delivery process retains root privilege throughout most of its execution,
61119 but any actual deliveries (that is, the transports themselves) are run in
61120 subprocesses which always change to a non-root uid and gid. For local
61121 deliveries this is typically the uid and gid of the owner of the mailbox; for
61122 remote deliveries, the Exim uid and gid are used. Once all the delivery
61123 subprocesses have been run, a delivery process changes to the Exim uid and gid
61124 while doing post-delivery tidying up such as updating the retry database and
61125 generating bounce and warning messages.
61126 </para>
61127 <para>
61128 While the recipient addresses in a message are being routed, the delivery
61129 process runs as root. However, if a user&#x2019;s filter file has to be processed,
61130 this is done in a subprocess that runs under the individual user&#x2019;s uid and
61131 gid. A system filter is run as root unless <option>system_filter_user</option> is set.
61132 </para>
61133 </listitem>
61134 <listitem>
61135 <para>
61136 A process that is testing addresses (the <option>-bt</option> option) runs as root so that
61137 the routing is done in the same environment as a message delivery.
61138 </para>
61139 </listitem>
61140 </itemizedlist>
61141 </section>
61142 <section id="SECTrunexiwitpri">
61143 <title>Running Exim without privilege</title>
61144 <para>
61145 <indexterm role="concept">
61146 <primary>privilege, running without</primary>
61147 </indexterm>
61148 <indexterm role="concept">
61149 <primary>unprivileged running</primary>
61150 </indexterm>
61151 <indexterm role="concept">
61152 <primary>root privilege</primary>
61153 <secondary>running without</secondary>
61154 </indexterm>
61155 Some installations like to run Exim in an unprivileged state for more of its
61156 operation, for added security. Support for this mode of operation is provided
61157 by the global option <option>deliver_drop_privilege</option>. When this is set, the uid and
61158 gid are changed to the Exim user and group at the start of a delivery process
61159 (and also queue runner and address testing processes). This means that address
61160 routing is no longer run as root, and the deliveries themselves cannot change
61161 to any other uid.
61162 </para>
61163 <para>
61164 <indexterm role="concept">
61165 <primary>SIGHUP</primary>
61166 </indexterm>
61167 <indexterm role="concept">
61168 <primary>daemon</primary>
61169 <secondary>restarting</secondary>
61170 </indexterm>
61171 Leaving the binary setuid to root, but setting <option>deliver_drop_privilege</option> means
61172 that the daemon can still be started in the usual way, and it can respond
61173 correctly to SIGHUP because the re-invocation regains root privilege.
61174 </para>
61175 <para>
61176 An alternative approach is to make Exim setuid to the Exim user and also setgid
61177 to the Exim group. If you do this, the daemon must be started from a root
61178 process. (Calling Exim from a root process makes it behave in the way it does
61179 when it is setuid root.) However, the daemon cannot restart itself after a
61180 SIGHUP signal because it cannot regain privilege.
61181 </para>
61182 <para>
61183 It is still useful to set <option>deliver_drop_privilege</option> in this case, because it
61184 stops Exim from trying to re-invoke itself to do a delivery after a message has
61185 been received. Such a re-invocation is a waste of resources because it has no
61186 effect.
61187 </para>
61188 <para>
61189 If restarting the daemon is not an issue (for example, if <option>mua_wrapper</option> is
61190 set, or <emphasis>inetd</emphasis> is being used instead of a daemon), having the binary setuid
61191 to the Exim user seems a clean approach, but there is one complication:
61192 </para>
61193 <para>
61194 In this style of operation, Exim is running with the real uid and gid set to
61195 those of the calling process, and the effective uid/gid set to Exim&#x2019;s values.
61196 Ideally, any association with the calling process&#x2019; uid/gid should be dropped,
61197 that is, the real uid/gid should be reset to the effective values so as to
61198 discard any privileges that the caller may have. While some operating systems
61199 have a function that permits this action for a non-root effective uid, quite a
61200 number of them do not. Because of this lack of standardization, Exim does not
61201 address this problem at this time.
61202 </para>
61203 <para>
61204 For this reason, the recommended approach for <quote>mostly unprivileged</quote> running
61205 is to keep the Exim binary setuid to root, and to set
61206 <option>deliver_drop_privilege</option>. This also has the advantage of allowing a daemon to
61207 be used in the most straightforward way.
61208 </para>
61209 <para>
61210 If you configure Exim not to run delivery processes as root, there are a
61211 number of restrictions on what you can do:
61212 </para>
61213 <itemizedlist>
61214 <listitem>
61215 <para>
61216 You can deliver only as the Exim user/group. You should  explicitly use the
61217 <option>user</option> and <option>group</option> options to override routers or local transports that
61218 normally deliver as the recipient. This makes sure that configurations that
61219 work in this mode function the same way in normal mode. Any implicit or
61220 explicit specification of another user causes an error.
61221 </para>
61222 </listitem>
61223 <listitem>
61224 <para>
61225 Use of <filename>.forward</filename> files is severely restricted, such that it is usually
61226 not worthwhile to include them in the configuration.
61227 </para>
61228 </listitem>
61229 <listitem>
61230 <para>
61231 Users who wish to use <filename>.forward</filename> would have to make their home directory and
61232 the file itself accessible to the Exim user. Pipe and append-to-file entries,
61233 and their equivalents in Exim filters, cannot be used. While they could be
61234 enabled in the Exim user&#x2019;s name, that would be insecure and not very useful.
61235 </para>
61236 </listitem>
61237 <listitem>
61238 <para>
61239 Unless the local user mailboxes are all owned by the Exim user (possible in
61240 some POP3 or IMAP-only environments):
61241 </para>
61242 <orderedlist numeration="arabic">
61243 <listitem>
61244 <para>
61245 They must be owned by the Exim group and be writeable by that group. This
61246 implies you must set <option>mode</option> in the appendfile configuration, as well as the
61247 mode of the mailbox files themselves.
61248 </para>
61249 </listitem>
61250 <listitem>
61251 <para>
61252 You must set <option>no_check_owner</option>, since most or all of the files will not be
61253 owned by the Exim user.
61254 </para>
61255 </listitem>
61256 <listitem>
61257 <para>
61258 You must set <option>file_must_exist</option>, because Exim cannot set the owner correctly
61259 on a newly created mailbox when unprivileged. This also implies that new
61260 mailboxes need to be created manually.
61261 </para>
61262 </listitem>
61263 </orderedlist>
61264 </listitem>
61265 </itemizedlist>
61266 <para>
61267 These restrictions severely restrict what can be done in local deliveries.
61268 However, there are no restrictions on remote deliveries. If you are running a
61269 gateway host that does no local deliveries, setting <option>deliver_drop_privilege</option>
61270 gives more security at essentially no cost.
61271 </para>
61272 <para>
61273 If you are using the <option>mua_wrapper</option> facility (see chapter
61274 <xref linkend="CHAPnonqueueing"/>), <option>deliver_drop_privilege</option> is forced to be true.
61275 </para>
61276 </section>
61277 <section id="SECID271">
61278 <title>Delivering to local files</title>
61279 <para>
61280 Full details of the checks applied by <command>appendfile</command> before it writes to a file
61281 are given in chapter <xref linkend="CHAPappendfile"/>.
61282 </para>
61283 </section>
61284 <section id="SECID272">
61285 <title>IPv4 source routing</title>
61286 <para>
61287 <indexterm role="concept">
61288 <primary>source routing</primary>
61289 <secondary>in IP packets</secondary>
61290 </indexterm>
61291 <indexterm role="concept">
61292 <primary>IP source routing</primary>
61293 </indexterm>
61294 Many operating systems suppress IP source-routed packets in the kernel, but
61295 some cannot be made to do this, so Exim does its own check. It logs incoming
61296 IPv4 source-routed TCP calls, and then drops them. Things are all different in
61297 IPv6. No special checking is currently done.
61298 </para>
61299 </section>
61300 <section id="SECID273">
61301 <title>The VRFY, EXPN, and ETRN commands in SMTP</title>
61302 <para>
61303 Support for these SMTP commands is disabled by default. If required, they can
61304 be enabled by defining suitable ACLs.
61305 </para>
61306 </section>
61307 <section id="SECID274">
61308 <title>Privileged users</title>
61309 <para>
61310 <indexterm role="concept">
61311 <primary>trusted users</primary>
61312 </indexterm>
61313 <indexterm role="concept">
61314 <primary>admin user</primary>
61315 </indexterm>
61316 <indexterm role="concept">
61317 <primary>privileged user</primary>
61318 </indexterm>
61319 <indexterm role="concept">
61320 <primary>user</primary>
61321 <secondary>trusted</secondary>
61322 </indexterm>
61323 <indexterm role="concept">
61324 <primary>user</primary>
61325 <secondary>admin</secondary>
61326 </indexterm>
61327 Exim recognizes two sets of users with special privileges. Trusted users are
61328 able to submit new messages to Exim locally, but supply their own sender
61329 addresses and information about a sending host. For other users submitting
61330 local messages, Exim sets up the sender address from the uid, and doesn&#x2019;t
61331 permit a remote host to be specified.
61332 </para>
61333 <para>
61334 <indexterm role="option">
61335 <primary><option>-f</option></primary>
61336 </indexterm>
61337 However, an untrusted user is permitted to use the <option>-f</option> command line option
61338 in the special form <option>-f &lt;&gt;</option> to indicate that a delivery failure for the
61339 message should not cause an error report. This affects the message&#x2019;s envelope,
61340 but it does not affect the <emphasis>Sender:</emphasis> header. Untrusted users may also be
61341 permitted to use specific forms of address with the <option>-f</option> option by setting
61342 the <option>untrusted_set_sender</option> option.
61343 </para>
61344 <para>
61345 Trusted users are used to run processes that receive mail messages from some
61346 other mail domain and pass them on to Exim for delivery either locally, or over
61347 the Internet. Exim trusts a caller that is running as root, as the Exim user,
61348 as any user listed in the <option>trusted_users</option> configuration option, or under any
61349 group listed in the <option>trusted_groups</option> option.
61350 </para>
61351 <para>
61352 Admin users are permitted to do things to the messages on Exim&#x2019;s queue. They
61353 can freeze or thaw messages, cause them to be returned to their senders, remove
61354 them entirely, or modify them in various ways. In addition, admin users can run
61355 the Exim monitor and see all the information it is capable of providing, which
61356 includes the contents of files on the spool.
61357 </para>
61358 <para>
61359 <indexterm role="option">
61360 <primary><option>-M</option></primary>
61361 </indexterm>
61362 <indexterm role="option">
61363 <primary><option>-q</option></primary>
61364 </indexterm>
61365 By default, the use of the <option>-M</option> and <option>-q</option> options to cause Exim to attempt
61366 delivery of messages on its queue is restricted to admin users. This
61367 restriction can be relaxed by setting the <option>no_prod_requires_admin</option> option.
61368 Similarly, the use of <option>-bp</option> (and its variants) to list the contents of the
61369 queue is also restricted to admin users. This restriction can be relaxed by
61370 setting <option>no_queue_list_requires_admin</option>.
61371 </para>
61372 <para>
61373 Exim recognizes an admin user if the calling process is running as root or as
61374 the Exim user or if any of the groups associated with the calling process is
61375 the Exim group. It is not necessary actually to be running under the Exim
61376 group. However, if admin users who are not root or the Exim user are to access
61377 the contents of files on the spool via the Exim monitor (which runs
61378 unprivileged), Exim must be built to allow group read access to its spool
61379 files.
61380 </para>
61381 </section>
61382 <section id="SECID275">
61383 <title>Spool files</title>
61384 <para>
61385 <indexterm role="concept">
61386 <primary>spool directory</primary>
61387 <secondary>files</secondary>
61388 </indexterm>
61389 Exim&#x2019;s spool directory and everything it contains is owned by the Exim user and
61390 set to the Exim group. The mode for spool files is defined in the
61391 <filename>Local/Makefile</filename> configuration file, and defaults to 0640. This means that
61392 any user who is a member of the Exim group can access these files.
61393 </para>
61394 </section>
61395 <section id="SECID276">
61396 <title>Use of argv[0]</title>
61397 <para>
61398 Exim examines the last component of <option>argv[0]</option>, and if it matches one of a set
61399 of specific strings, Exim assumes certain options. For example, calling Exim
61400 with the last component of <option>argv[0]</option> set to <quote>rsmtp</quote> is exactly equivalent
61401 to calling it with the option <option>-bS</option>. There are no security implications in
61402 this.
61403 </para>
61404 </section>
61405 <section id="SECID277">
61406 <title>Use of %f formatting</title>
61407 <para>
61408 The only use made of <quote>%f</quote> by Exim is in formatting load average values. These
61409 are actually stored in integer variables as 1000 times the load average.
61410 Consequently, their range is limited and so therefore is the length of the
61411 converted output.
61412 </para>
61413 </section>
61414 <section id="SECID278">
61415 <title>Embedded Exim path</title>
61416 <para>
61417 Exim uses its own path name, which is embedded in the code, only when it needs
61418 to re-exec in order to regain root privilege. Therefore, it is not root when it
61419 does so. If some bug allowed the path to get overwritten, it would lead to an
61420 arbitrary program&#x2019;s being run as exim, not as root.
61421 </para>
61422 </section>
61423 <section id="SECTdynmoddir" revisionflag="changed">
61424 <title>Dynamic module directory</title>
61425 <para revisionflag="changed">
61426 Any dynamically loadable modules must be installed into the directory
61427 defined in <literal>LOOKUP_MODULE_DIR</literal> in <filename>Local/Makefile</filename> for Exim to permit
61428 loading it.
61429 </para>
61430 </section>
61431 <section id="SECID279">
61432 <title>Use of sprintf()</title>
61433 <para>
61434 <indexterm role="concept">
61435 <primary><function>sprintf()</function></primary>
61436 </indexterm>
61437 A large number of occurrences of <quote>sprintf</quote> in the code are actually calls to
61438 <emphasis>string_sprintf()</emphasis>, a function that returns the result in malloc&#x2019;d store.
61439 The intermediate formatting is done into a large fixed buffer by a function
61440 that runs through the format string itself, and checks the length of each
61441 conversion before performing it, thus preventing buffer overruns.
61442 </para>
61443 <para>
61444 The remaining uses of <function>sprintf()</function> happen in controlled circumstances where
61445 the output buffer is known to be sufficiently long to contain the converted
61446 string.
61447 </para>
61448 </section>
61449 <section id="SECID280">
61450 <title>Use of debug_printf() and log_write()</title>
61451 <para>
61452 Arbitrary strings are passed to both these functions, but they do their
61453 formatting by calling the function <emphasis>string_vformat()</emphasis>, which runs through
61454 the format string itself, and checks the length of each conversion.
61455 </para>
61456 </section>
61457 <section id="SECID281">
61458 <title>Use of strcat() and strcpy()</title>
61459 <para>
61460 These are used only in cases where the output buffer is known to be large
61461 enough to hold the result.
61462 <indexterm role="concept" startref="IIDsecurcon" class="endofrange"/>
61463 </para>
61464 </section>
61465 </chapter>
61466
61467 <chapter id="CHAPspool">
61468 <title>Format of spool files</title>
61469 <para>
61470 <indexterm role="concept" id="IIDforspo1" class="startofrange">
61471 <primary>format</primary>
61472 <secondary>spool files</secondary>
61473 </indexterm>
61474 <indexterm role="concept" id="IIDforspo2" class="startofrange">
61475 <primary>spool directory</primary>
61476 <secondary>format of files</secondary>
61477 </indexterm>
61478 <indexterm role="concept" id="IIDforspo3" class="startofrange">
61479 <primary>spool files</primary>
61480 <secondary>format of</secondary>
61481 </indexterm>
61482 <indexterm role="concept">
61483 <primary>spool files</primary>
61484 <secondary>editing</secondary>
61485 </indexterm>
61486 A message on Exim&#x2019;s queue consists of two files, whose names are the message id
61487 followed by -D and -H, respectively. The data portion of the message is kept in
61488 the -D file on its own. The message&#x2019;s envelope, status, and headers are all
61489 kept in the -H file, whose format is described in this chapter. Each of these
61490 two files contains the final component of its own name as its first line. This
61491 is insurance against disk crashes where the directory is lost but the files
61492 themselves are recoverable.
61493 </para>
61494 <para>
61495 Some people are tempted into editing -D files in order to modify messages. You
61496 need to be extremely careful if you do this; it is not recommended and you are
61497 on your own if you do it. Here are some of the pitfalls:
61498 </para>
61499 <itemizedlist>
61500 <listitem>
61501 <para>
61502 You must ensure that Exim does not try to deliver the message while you are
61503 fiddling with it. The safest way is to take out a write lock on the -D file,
61504 which is what Exim itself does, using <function>fcntl()</function>. If you update the file in
61505 place, the lock will be retained. If you write a new file and rename it, the
61506 lock will be lost at the instant of rename.
61507 </para>
61508 </listitem>
61509 <listitem>
61510 <para>
61511 <indexterm role="variable">
61512 <primary><varname>$body_linecount</varname></primary>
61513 </indexterm>
61514 If you change the number of lines in the file, the value of
61515 <varname>$body_linecount</varname>, which is stored in the -H file, will be incorrect. At
61516 present, this value is not used by Exim, but there is no guarantee that this
61517 will always be the case.
61518 </para>
61519 </listitem>
61520 <listitem>
61521 <para>
61522 If the message is in MIME format, you must take care not to break it.
61523 </para>
61524 </listitem>
61525 <listitem>
61526 <para>
61527 If the message is cryptographically signed, any change will invalidate the
61528 signature.
61529 </para>
61530 </listitem>
61531 </itemizedlist>
61532 <para>
61533 All in all, modifying -D files is fraught with danger.
61534 </para>
61535 <para>
61536 Files whose names end with -J may also be seen in the <filename>input</filename> directory (or
61537 its subdirectories when <option>split_spool_directory</option> is set). These are journal
61538 files, used to record addresses to which the message has been delivered during
61539 the course of a delivery attempt. If there are still undelivered recipients at
61540 the end, the -H file is updated, and the -J file is deleted. If, however, there
61541 is some kind of crash (for example, a power outage) before this happens, the -J
61542 file remains in existence. When Exim next processes the message, it notices the
61543 -J file and uses it to update the -H file before starting the next delivery
61544 attempt.
61545 </para>
61546 <section id="SECID282">
61547 <title>Format of the -H file</title>
61548 <para>
61549 <indexterm role="concept">
61550 <primary>uid (user id)</primary>
61551 <secondary>in spool file</secondary>
61552 </indexterm>
61553 <indexterm role="concept">
61554 <primary>gid (group id)</primary>
61555 <secondary>in spool file</secondary>
61556 </indexterm>
61557 The second line of the -H file contains the login name for the uid of the
61558 process that called Exim to read the message, followed by the numerical uid and
61559 gid. For a locally generated message, this is normally the user who sent the
61560 message. For a message received over TCP/IP via the daemon, it is
61561 normally the Exim user.
61562 </para>
61563 <para>
61564 The third line of the file contains the address of the message&#x2019;s sender as
61565 transmitted in the envelope, contained in angle brackets. The sender address is
61566 empty for bounce messages. For incoming SMTP mail, the sender address is given
61567 in the MAIL command. For locally generated mail, the sender address is
61568 created by Exim from the login name of the current user and the configured
61569 <option>qualify_domain</option>. However, this can be overridden by the <option>-f</option> option or a
61570 leading <quote>From&nbsp;</quote> line if the caller is trusted, or if the supplied address is
61571 <quote>&lt;&gt;</quote> or an address that matches <option>untrusted_set_senders</option>.
61572 </para>
61573 <para>
61574 The fourth line contains two numbers. The first is the time that the message
61575 was received, in the conventional Unix form &ndash; the number of seconds since the
61576 start of the epoch. The second number is a count of the number of messages
61577 warning of delayed delivery that have been sent to the sender.
61578 </para>
61579 <para>
61580 There follow a number of lines starting with a hyphen. These can appear in any
61581 order, and are omitted when not relevant:
61582 </para>
61583 <variablelist>
61584 <varlistentry>
61585 <term><option>-acl</option>&nbsp;&lt;<emphasis>number</emphasis>&gt;&nbsp;&lt;<emphasis>length</emphasis>&gt;</term>
61586 <listitem>
61587 <para>
61588 This item is obsolete, and is not generated from Exim release 4.61 onwards;
61589 <option>-aclc</option> and <option>-aclm</option> are used instead. However, <option>-acl</option> is still
61590 recognized, to provide backward compatibility. In the old format, a line of
61591 this form is present for every ACL variable that is not empty. The number
61592 identifies the variable; the <option>acl_c</option><emphasis role="bold">x</emphasis> variables are numbered 0&ndash;9 and
61593 the <option>acl_m</option><emphasis role="bold">x</emphasis> variables are numbered 10&ndash;19. The length is the length of
61594 the data string for the variable. The string itself starts at the beginning of
61595 the next line, and is followed by a newline character. It may contain internal
61596 newlines.
61597 </para>
61598 </listitem></varlistentry>
61599 <varlistentry>
61600 <term><option>-aclc</option>&nbsp;&lt;<emphasis>rest-of-name</emphasis>&gt;&nbsp;&lt;<emphasis>length</emphasis>&gt;</term>
61601 <listitem>
61602 <para>
61603 A line of this form is present for every ACL connection variable that is
61604 defined. Note that there is a space between <option>-aclc</option> and the rest of the name.
61605 The length is the length of the data string for the variable. The string itself
61606 starts at the beginning of the next line, and is followed by a newline
61607 character. It may contain internal newlines.
61608 </para>
61609 </listitem></varlistentry>
61610 <varlistentry>
61611 <term><option>-aclm</option>&nbsp;&lt;<emphasis>rest-of-name</emphasis>&gt;&nbsp;&lt;<emphasis>length</emphasis>&gt;</term>
61612 <listitem>
61613 <para>
61614 A line of this form is present for every ACL message variable that is defined.
61615 Note that there is a space between <option>-aclm</option> and the rest of the name. The
61616 length is the length of the data string for the variable. The string itself
61617 starts at the beginning of the next line, and is followed by a newline
61618 character. It may contain internal newlines.
61619 </para>
61620 </listitem></varlistentry>
61621 <varlistentry>
61622 <term><option>-active_hostname</option>&nbsp;&lt;<emphasis>hostname</emphasis>&gt;</term>
61623 <listitem>
61624 <para>
61625 This is present if, when the message was received over SMTP, the value of
61626 <varname>$smtp_active_hostname</varname> was different to the value of <varname>$primary_hostname</varname>.
61627 </para>
61628 </listitem></varlistentry>
61629 <varlistentry>
61630 <term><option>-allow_unqualified_recipient</option></term>
61631 <listitem>
61632 <para>
61633 This is present if unqualified recipient addresses are permitted in header
61634 lines (to stop such addresses from being qualified if rewriting occurs at
61635 transport time). Local messages that were input using <option>-bnq</option> and remote
61636 messages from hosts that match <option>recipient_unqualified_hosts</option> set this flag.
61637 </para>
61638 </listitem></varlistentry>
61639 <varlistentry>
61640 <term><option>-allow_unqualified_sender</option></term>
61641 <listitem>
61642 <para>
61643 This is present if unqualified sender addresses are permitted in header lines
61644 (to stop such addresses from being qualified if rewriting occurs at transport
61645 time). Local messages that were input using <option>-bnq</option> and remote messages from
61646 hosts that match <option>sender_unqualified_hosts</option> set this flag.
61647 </para>
61648 </listitem></varlistentry>
61649 <varlistentry>
61650 <term><option>-auth_id</option>&nbsp;&lt;<emphasis>text</emphasis>&gt;</term>
61651 <listitem>
61652 <para>
61653 The id information for a message received on an authenticated SMTP connection
61654 &ndash; the value of the <varname>$authenticated_id</varname> variable.
61655 </para>
61656 </listitem></varlistentry>
61657 <varlistentry>
61658 <term><option>-auth_sender</option>&nbsp;&lt;<emphasis>address</emphasis>&gt;</term>
61659 <listitem>
61660 <para>
61661 The address of an authenticated sender &ndash; the value of the
61662 <varname>$authenticated_sender</varname> variable.
61663 </para>
61664 </listitem></varlistentry>
61665 <varlistentry>
61666 <term><option>-body_linecount</option>&nbsp;&lt;<emphasis>number</emphasis>&gt;</term>
61667 <listitem>
61668 <para>
61669 This records the number of lines in the body of the message, and is always
61670 present.
61671 </para>
61672 </listitem></varlistentry>
61673 <varlistentry>
61674 <term><option>-body_zerocount</option>&nbsp;&lt;<emphasis>number</emphasis>&gt;</term>
61675 <listitem>
61676 <para>
61677 This records the number of binary zero bytes in the body of the message, and is
61678 present if the number is greater than zero.
61679 </para>
61680 </listitem></varlistentry>
61681 <varlistentry>
61682 <term><option>-deliver_firsttime</option></term>
61683 <listitem>
61684 <para>
61685 This is written when a new message is first added to the spool. When the spool
61686 file is updated after a deferral, it is omitted.
61687 </para>
61688 </listitem></varlistentry>
61689 <varlistentry>
61690 <term><option>-frozen</option>&nbsp;&lt;<emphasis>time</emphasis>&gt;</term>
61691 <listitem>
61692 <para>
61693 <indexterm role="concept">
61694 <primary>frozen messages</primary>
61695 <secondary>spool data</secondary>
61696 </indexterm>
61697 The message is frozen, and the freezing happened at &lt;<emphasis>time</emphasis>&gt;.
61698 </para>
61699 </listitem></varlistentry>
61700 <varlistentry>
61701 <term><option>-helo_name</option>&nbsp;&lt;<emphasis>text</emphasis>&gt;</term>
61702 <listitem>
61703 <para>
61704 This records the host name as specified by a remote host in a HELO or EHLO
61705 command.
61706 </para>
61707 </listitem></varlistentry>
61708 <varlistentry>
61709 <term><option>-host_address</option>&nbsp;&lt;<emphasis>address</emphasis>&gt;.&lt;<emphasis>port</emphasis>&gt;</term>
61710 <listitem>
61711 <para>
61712 This records the IP address of the host from which the message was received and
61713 the remote port number that was used. It is omitted for locally generated
61714 messages.
61715 </para>
61716 </listitem></varlistentry>
61717 <varlistentry>
61718 <term><option>-host_auth</option>&nbsp;&lt;<emphasis>text</emphasis>&gt;</term>
61719 <listitem>
61720 <para>
61721 If the message was received on an authenticated SMTP connection, this records
61722 the name of the authenticator &ndash; the value of the
61723 <varname>$sender_host_authenticated</varname> variable.
61724 </para>
61725 </listitem></varlistentry>
61726 <varlistentry>
61727 <term><option>-host_lookup_failed</option></term>
61728 <listitem>
61729 <para>
61730 This is present if an attempt to look up the sending host&#x2019;s name from its IP
61731 address failed. It corresponds to the <varname>$host_lookup_failed</varname> variable.
61732 </para>
61733 </listitem></varlistentry>
61734 <varlistentry>
61735 <term><option>-host_name</option>&nbsp;&lt;<emphasis>text</emphasis>&gt;</term>
61736 <listitem>
61737 <para>
61738 <indexterm role="concept">
61739 <primary>reverse DNS lookup</primary>
61740 </indexterm>
61741 <indexterm role="concept">
61742 <primary>DNS</primary>
61743 <secondary>reverse lookup</secondary>
61744 </indexterm>
61745 This records the name of the remote host from which the message was received,
61746 if the host name was looked up from the IP address when the message was being
61747 received. It is not present if no reverse lookup was done.
61748 </para>
61749 </listitem></varlistentry>
61750 <varlistentry>
61751 <term><option>-ident</option>&nbsp;&lt;<emphasis>text</emphasis>&gt;</term>
61752 <listitem>
61753 <para>
61754 For locally submitted messages, this records the login of the originating user,
61755 unless it was a trusted user and the <option>-oMt</option> option was used to specify an
61756 ident value. For messages received over TCP/IP, this records the ident string
61757 supplied by the remote host, if any.
61758 </para>
61759 </listitem></varlistentry>
61760 <varlistentry>
61761 <term><option>-interface_address</option>&nbsp;&lt;<emphasis>address</emphasis>&gt;.&lt;<emphasis>port</emphasis>&gt;</term>
61762 <listitem>
61763 <para>
61764 This records the IP address of the local interface and the port number through
61765 which a message was received from a remote host. It is omitted for locally
61766 generated messages.
61767 </para>
61768 </listitem></varlistentry>
61769 <varlistentry>
61770 <term><option>-local</option></term>
61771 <listitem>
61772 <para>
61773 The message is from a local sender.
61774 </para>
61775 </listitem></varlistentry>
61776 <varlistentry>
61777 <term><option>-localerror</option></term>
61778 <listitem>
61779 <para>
61780 The message is a locally-generated bounce message.
61781 </para>
61782 </listitem></varlistentry>
61783 <varlistentry>
61784 <term><option>-local_scan</option>&nbsp;&lt;<emphasis>string</emphasis>&gt;</term>
61785 <listitem>
61786 <para>
61787 This records the data string that was returned by the <function>local_scan()</function> function
61788 when the message was received &ndash; the value of the <varname>$local_scan_data</varname>
61789 variable. It is omitted if no data was returned.
61790 </para>
61791 </listitem></varlistentry>
61792 <varlistentry>
61793 <term><option>-manual_thaw</option></term>
61794 <listitem>
61795 <para>
61796 The message was frozen but has been thawed manually, that is, by an explicit
61797 Exim command rather than via the auto-thaw process.
61798 </para>
61799 </listitem></varlistentry>
61800 <varlistentry>
61801 <term><option>-N</option></term>
61802 <listitem>
61803 <para>
61804 A testing delivery process was started using the <option>-N</option> option to suppress any
61805 actual deliveries, but delivery was deferred. At any further delivery attempts,
61806 <option>-N</option> is assumed.
61807 </para>
61808 </listitem></varlistentry>
61809 <varlistentry>
61810 <term><option>-received_protocol</option></term>
61811 <listitem>
61812 <para>
61813 This records the value of the <varname>$received_protocol</varname> variable, which contains
61814 the name of the protocol by which the message was received.
61815 </para>
61816 </listitem></varlistentry>
61817 <varlistentry>
61818 <term><option>-sender_set_untrusted</option></term>
61819 <listitem>
61820 <para>
61821 The envelope sender of this message was set by an untrusted local caller (used
61822 to ensure that the caller is displayed in queue listings).
61823 </para>
61824 </listitem></varlistentry>
61825 <varlistentry>
61826 <term><option>-spam_score_int</option>&nbsp;&lt;<emphasis>number</emphasis>&gt;</term>
61827 <listitem>
61828 <para>
61829 If a message was scanned by SpamAssassin, this is present. It records the value
61830 of <varname>$spam_score_int</varname>.
61831 </para>
61832 </listitem></varlistentry>
61833 <varlistentry>
61834 <term><option>-tls_certificate_verified</option></term>
61835 <listitem>
61836 <para>
61837 A TLS certificate was received from the client that sent this message, and the
61838 certificate was verified by the server.
61839 </para>
61840 </listitem></varlistentry>
61841 <varlistentry>
61842 <term><option>-tls_cipher</option>&nbsp;&lt;<emphasis>cipher name</emphasis>&gt;</term>
61843 <listitem>
61844 <para>
61845 When the message was received over an encrypted connection, this records the
61846 name of the cipher suite that was used.
61847 </para>
61848 </listitem></varlistentry>
61849 <varlistentry>
61850 <term><option>-tls_peerdn</option>&nbsp;&lt;<emphasis>peer DN</emphasis>&gt;</term>
61851 <listitem>
61852 <para>
61853 When the message was received over an encrypted connection, and a certificate
61854 was received from the client, this records the Distinguished Name from that
61855 certificate.
61856 </para>
61857 </listitem></varlistentry>
61858 </variablelist>
61859 <para>
61860 Following the options there is a list of those addresses to which the message
61861 is not to be delivered. This set of addresses is initialized from the command
61862 line when the <option>-t</option> option is used and <option>extract_addresses_remove_arguments</option>
61863 is set; otherwise it starts out empty. Whenever a successful delivery is made,
61864 the address is added to this set. The addresses are kept internally as a
61865 balanced binary tree, and it is a representation of that tree which is written
61866 to the spool file. If an address is expanded via an alias or forward file, the
61867 original address is added to the tree when deliveries to all its child
61868 addresses are complete.
61869 </para>
61870 <para>
61871 If the tree is empty, there is a single line in the spool file containing just
61872 the text <quote>XX</quote>. Otherwise, each line consists of two letters, which are either
61873 Y or N, followed by an address. The address is the value for the node of the
61874 tree, and the letters indicate whether the node has a left branch and/or a
61875 right branch attached to it, respectively. If branches exist, they immediately
61876 follow. Here is an example of a three-node tree:
61877 </para>
61878 <literallayout class="monospaced">
61879 YY darcy@austen.fict.example
61880 NN alice@wonderland.fict.example
61881 NN editor@thesaurus.ref.example
61882 </literallayout>
61883 <para>
61884 After the non-recipients tree, there is a list of the message&#x2019;s recipients.
61885 This is a simple list, preceded by a count. It includes all the original
61886 recipients of the message, including those to whom the message has already been
61887 delivered. In the simplest case, the list contains one address per line. For
61888 example:
61889 </para>
61890 <literallayout class="monospaced">
61891 4
61892 editor@thesaurus.ref.example
61893 darcy@austen.fict.example
61894 rdo@foundation
61895 alice@wonderland.fict.example
61896 </literallayout>
61897 <para>
61898 However, when a child address has been added to the top-level addresses as a
61899 result of the use of the <option>one_time</option> option on a <command>redirect</command> router, each
61900 line is of the following form:
61901 </para>
61902 <literallayout>
61903 &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;
61904 </literallayout>
61905 <para>
61906 The 01 flag bit indicates the presence of the three other fields that follow
61907 the top-level address. Other bits may be used in future to support additional
61908 fields. The &lt;<emphasis>parent number</emphasis>&gt; is the offset in the recipients list of the
61909 original parent of the <quote>one time</quote> address. The first two fields are the
61910 envelope sender that is associated with this address and its length. If the
61911 length is zero, there is no special envelope sender (there are then two space
61912 characters in the line). A non-empty field can arise from a <command>redirect</command> router
61913 that has an <option>errors_to</option> setting.
61914 </para>
61915 <para>
61916 A blank line separates the envelope and status information from the headers
61917 which follow. A header may occupy several lines of the file, and to save effort
61918 when reading it in, each header is preceded by a number and an identifying
61919 character. The number is the number of characters in the header, including any
61920 embedded newlines and the terminating newline. The character is one of the
61921 following:
61922 </para>
61923 <informaltable frame="none">
61924 <tgroup cols="2" colsep="0" rowsep="0">
61925 <colspec colwidth="50pt" align="left"/>
61926 <colspec colwidth="254pt" align="left"/>
61927 <tbody>
61928 <row>
61929 <entry>&lt;<emphasis>blank</emphasis>&gt;</entry>
61930 <entry>header in which Exim has no special interest</entry>
61931 </row>
61932 <row>
61933 <entry><literal>B</literal></entry>
61934 <entry><emphasis>Bcc:</emphasis> header</entry>
61935 </row>
61936 <row>
61937 <entry><literal>C</literal></entry>
61938 <entry><emphasis>Cc:</emphasis> header</entry>
61939 </row>
61940 <row>
61941 <entry><literal>F</literal></entry>
61942 <entry><emphasis>From:</emphasis> header</entry>
61943 </row>
61944 <row>
61945 <entry><literal>I</literal></entry>
61946 <entry><emphasis>Message-id:</emphasis> header</entry>
61947 </row>
61948 <row>
61949 <entry><literal>P</literal></entry>
61950 <entry><emphasis>Received:</emphasis> header &ndash; P for <quote>postmark</quote></entry>
61951 </row>
61952 <row>
61953 <entry><literal>R</literal></entry>
61954 <entry><emphasis>Reply-To:</emphasis> header</entry>
61955 </row>
61956 <row>
61957 <entry><literal>S</literal></entry>
61958 <entry><emphasis>Sender:</emphasis> header</entry>
61959 </row>
61960 <row>
61961 <entry><literal>T</literal></entry>
61962 <entry><emphasis>To:</emphasis> header</entry>
61963 </row>
61964 <row>
61965 <entry><literal>*</literal></entry>
61966 <entry>replaced or deleted header</entry>
61967 </row>
61968 </tbody>
61969 </tgroup>
61970 </informaltable>
61971 <para>
61972 Deleted or replaced (rewritten) headers remain in the spool file for debugging
61973 purposes. They are not transmitted when the message is delivered. Here is a
61974 typical set of headers:
61975 </para>
61976 <literallayout class="monospaced">
61977 111P Received: by hobbit.fict.example with local (Exim 4.00)
61978 id 14y9EI-00026G-00; Fri, 11 May 2001 10:28:59 +0100
61979 049  Message-Id: &lt;E14y9EI-00026G-00@hobbit.fict.example&gt;
61980 038* X-rewrote-sender: bb@hobbit.fict.example
61981 042* From: Bilbo Baggins &lt;bb@hobbit.fict.example&gt;
61982 049F From: Bilbo Baggins &lt;B.Baggins@hobbit.fict.example&gt;
61983 099* To: alice@wonderland.fict.example, rdo@foundation,
61984 darcy@austen.fict.example, editor@thesaurus.ref.example
61985 104T To: alice@wonderland.fict.example, rdo@foundation.example,
61986 darcy@austen.fict.example, editor@thesaurus.ref.example
61987 038  Date: Fri, 11 May 2001 10:28:59 +0100
61988 </literallayout>
61989 <para>
61990 The asterisked headers indicate that the envelope sender, <emphasis>From:</emphasis> header, and
61991 <emphasis>To:</emphasis> header have been rewritten, the last one because routing expanded the
61992 unqualified domain <emphasis>foundation</emphasis>.
61993 <indexterm role="concept" startref="IIDforspo1" class="endofrange"/>
61994 <indexterm role="concept" startref="IIDforspo2" class="endofrange"/>
61995 <indexterm role="concept" startref="IIDforspo3" class="endofrange"/>
61996 </para>
61997 </section>
61998 </chapter>
61999
62000 <chapter id="CHID12">
62001 <title>Support for DKIM (DomainKeys Identified Mail) - RFC4871</title>
62002 <titleabbrev>DKIM Support</titleabbrev>
62003 <para>
62004 <indexterm role="concept">
62005 <primary>DKIM</primary>
62006 </indexterm>
62007 </para>
62008 <para>
62009 Since version 4.70, DKIM support is compiled into Exim by default. It can be
62010 disabled by setting DISABLE_DKIM=yes in Local/Makefile.
62011 </para>
62012 <para revisionflag="changed">
62013 Exim&#x2019;s DKIM implementation allows to
62014 </para>
62015 <orderedlist numeration="arabic" revisionflag="changed">
62016 <listitem>
62017 <para revisionflag="changed">
62018 Sign outgoing messages: This function is implemented in the SMTP transport.
62019 It can co-exist with all other Exim features, including transport filters.
62020 </para>
62021 </listitem>
62022 <listitem>
62023 <para revisionflag="changed">
62024 Verify signatures in incoming messages: This is implemented by an additional
62025 ACL (acl_smtp_dkim), which can be called several times per message, with
62026 different signature contexts.
62027 </para>
62028 </listitem>
62029 </orderedlist>
62030 <para>
62031 In typical Exim style, the verification implementation does not include any
62032 default "policy". Instead it enables you to build your own policy using
62033 Exim&#x2019;s standard controls.
62034 </para>
62035 <para>
62036 Please note that verification of DKIM signatures in incoming mail is turned
62037 on by default for logging purposes. For each signature in incoming email,
62038 exim will log a line displaying the most important signature details, and the
62039 signature status. Here is an example:
62040 </para>
62041 <literallayout class="monospaced">
62042 2009-09-09 10:22:28 1MlIRf-0003LU-U3 DKIM: d=facebookmail.com s=q1-2009b c=relaxed/relaxed a=rsa-sha1 i=@facebookmail.com t=1252484542 [verification succeeded]
62043 </literallayout>
62044 <para>
62045 You might want to turn off DKIM verification processing entirely for internal
62046 or relay mail sources. To do that, set the <option>dkim_disable_verify</option> ACL
62047 control modifier. This should typically be done in the RCPT ACL, at points
62048 where you accept mail from relay sources (internal hosts or authenticated
62049 senders).
62050 </para>
62051 <section id="SECID513">
62052 <title>Signing outgoing messages</title>
62053 <para>
62054 <indexterm role="concept">
62055 <primary>DKIM</primary>
62056 <secondary>signing</secondary>
62057 </indexterm>
62058 </para>
62059 <para>
62060 Signing is implemented by setting private options on the SMTP transport.
62061 These options take (expandable) strings as arguments.
62062 </para>
62063 <para revisionflag="changed">
62064 <indexterm role="option">
62065 <primary><option>dkim_domain</option></primary>
62066 </indexterm>
62067 </para>
62068 <informaltable frame="all" revisionflag="changed">
62069 <tgroup cols="4" colsep="0" rowsep="0">
62070 <colspec colwidth="8*" align="left"/>
62071 <colspec colwidth="6*" align="center"/>
62072 <colspec colwidth="6*" align="center"/>
62073 <colspec colwidth="6*" align="right"/>
62074 <tbody>
62075 <row>
62076 <entry><option>dkim_domain</option></entry>
62077 <entry>Use: <emphasis>smtp</emphasis></entry>
62078 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
62079 <entry>Default: <emphasis>unset</emphasis></entry>
62080 </row>
62081 </tbody>
62082 </tgroup>
62083 </informaltable>
62084 <para revisionflag="changed">
62085 MANDATORY:
62086 The domain you want to sign with. The result of this expanded
62087 option is put into the <option>$dkim_domain</option> expansion variable.
62088 </para>
62089 <para revisionflag="changed">
62090 <indexterm role="option">
62091 <primary><option>dkim_selector</option></primary>
62092 </indexterm>
62093 </para>
62094 <informaltable frame="all" revisionflag="changed">
62095 <tgroup cols="4" colsep="0" rowsep="0">
62096 <colspec colwidth="8*" align="left"/>
62097 <colspec colwidth="6*" align="center"/>
62098 <colspec colwidth="6*" align="center"/>
62099 <colspec colwidth="6*" align="right"/>
62100 <tbody>
62101 <row>
62102 <entry><option>dkim_selector</option></entry>
62103 <entry>Use: <emphasis>smtp</emphasis></entry>
62104 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
62105 <entry>Default: <emphasis>unset</emphasis></entry>
62106 </row>
62107 </tbody>
62108 </tgroup>
62109 </informaltable>
62110 <para revisionflag="changed">
62111 MANDATORY:
62112 This sets the key selector string. You can use the <option>$dkim_domain</option> expansion
62113 variable to look up a matching selector. The result is put in the expansion
62114 variable <option>$dkim_selector</option> which should be used in the <option>dkim_private_key</option>
62115 option along with <option>$dkim_domain</option>.
62116 </para>
62117 <para revisionflag="changed">
62118 <indexterm role="option">
62119 <primary><option>dkim_private_key</option></primary>
62120 </indexterm>
62121 </para>
62122 <informaltable frame="all" revisionflag="changed">
62123 <tgroup cols="4" colsep="0" rowsep="0">
62124 <colspec colwidth="8*" align="left"/>
62125 <colspec colwidth="6*" align="center"/>
62126 <colspec colwidth="6*" align="center"/>
62127 <colspec colwidth="6*" align="right"/>
62128 <tbody>
62129 <row>
62130 <entry><option>dkim_private_key</option></entry>
62131 <entry>Use: <emphasis>smtp</emphasis></entry>
62132 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
62133 <entry>Default: <emphasis>unset</emphasis></entry>
62134 </row>
62135 </tbody>
62136 </tgroup>
62137 </informaltable>
62138 <para revisionflag="changed">
62139 MANDATORY:
62140 This sets the private key to use. You can use the <option>$dkim_domain</option> and
62141 <option>$dkim_selector</option> expansion variables to determine the private key to use.
62142 The result can either
62143 </para>
62144 <itemizedlist revisionflag="changed">
62145 <listitem>
62146 <para revisionflag="changed">
62147 be a valid RSA private key in ASCII armor, including line breaks.
62148 </para>
62149 </listitem>
62150 <listitem>
62151 <para revisionflag="changed">
62152 start with a slash, in which case it is treated as a file that contains
62153 the private key.
62154 </para>
62155 </listitem>
62156 <listitem>
62157 <para revisionflag="changed">
62158 be "0", "false" or the empty string, in which case the message will not
62159 be signed. This case will not result in an error, even if <option>dkim_strict</option>
62160 is set.
62161 </para>
62162 </listitem>
62163 </itemizedlist>
62164 <para revisionflag="changed">
62165 <indexterm role="option">
62166 <primary><option>dkim_canon</option></primary>
62167 </indexterm>
62168 </para>
62169 <informaltable frame="all" revisionflag="changed">
62170 <tgroup cols="4" colsep="0" rowsep="0">
62171 <colspec colwidth="8*" align="left"/>
62172 <colspec colwidth="6*" align="center"/>
62173 <colspec colwidth="6*" align="center"/>
62174 <colspec colwidth="6*" align="right"/>
62175 <tbody>
62176 <row>
62177 <entry><option>dkim_canon</option></entry>
62178 <entry>Use: <emphasis>smtp</emphasis></entry>
62179 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
62180 <entry>Default: <emphasis>unset</emphasis></entry>
62181 </row>
62182 </tbody>
62183 </tgroup>
62184 </informaltable>
62185 <para revisionflag="changed">
62186 OPTIONAL:
62187 This option sets the canonicalization method used when signing a message.
62188 The DKIM RFC currently supports two methods: "simple" and "relaxed".
62189 The option defaults to "relaxed" when unset. Note: the current implementation
62190 only supports using the same canonicalization method for both headers and body.
62191 </para>
62192 <para revisionflag="changed">
62193 <indexterm role="option">
62194 <primary><option>dkim_strict</option></primary>
62195 </indexterm>
62196 </para>
62197 <informaltable frame="all" revisionflag="changed">
62198 <tgroup cols="4" colsep="0" rowsep="0">
62199 <colspec colwidth="8*" align="left"/>
62200 <colspec colwidth="6*" align="center"/>
62201 <colspec colwidth="6*" align="center"/>
62202 <colspec colwidth="6*" align="right"/>
62203 <tbody>
62204 <row>
62205 <entry><option>dkim_strict</option></entry>
62206 <entry>Use: <emphasis>smtp</emphasis></entry>
62207 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
62208 <entry>Default: <emphasis>unset</emphasis></entry>
62209 </row>
62210 </tbody>
62211 </tgroup>
62212 </informaltable>
62213 <para revisionflag="changed">
62214 OPTIONAL:
62215 This  option  defines  how  Exim  behaves  when  signing a message that
62216 should be signed fails for some reason.  When the expansion evaluates to
62217 either "1" or "true", Exim will defer. Otherwise Exim will send the message
62218 unsigned. You can use the <option>$dkim_domain</option> and <option>$dkim_selector</option> expansion
62219 variables here.
62220 </para>
62221 <para revisionflag="changed">
62222 <indexterm role="option">
62223 <primary><option>dkim_sign_headers</option></primary>
62224 </indexterm>
62225 </para>
62226 <informaltable frame="all" revisionflag="changed">
62227 <tgroup cols="4" colsep="0" rowsep="0">
62228 <colspec colwidth="8*" align="left"/>
62229 <colspec colwidth="6*" align="center"/>
62230 <colspec colwidth="6*" align="center"/>
62231 <colspec colwidth="6*" align="right"/>
62232 <tbody>
62233 <row>
62234 <entry><option>dkim_sign_headers</option></entry>
62235 <entry>Use: <emphasis>smtp</emphasis></entry>
62236 <entry>Type: <emphasis>string</emphasis>&dagger;<emphasis></emphasis></entry>
62237 <entry>Default: <emphasis>unset</emphasis></entry>
62238 </row>
62239 </tbody>
62240 </tgroup>
62241 </informaltable>
62242 <para revisionflag="changed">
62243 OPTIONAL:
62244 When set, this option must expand to (or be specified as) a colon-separated
62245 list of header names. Headers with these names will be included in the message
62246 signature. When unspecified, the header names recommended in RFC4871 will be
62247 used.
62248 </para>
62249 </section>
62250 <section id="SECID514">
62251 <title>Verifying DKIM signatures in incoming mail</title>
62252 <para>
62253 <indexterm role="concept">
62254 <primary>DKIM</primary>
62255 <secondary>verification</secondary>
62256 </indexterm>
62257 </para>
62258 <para>
62259 Verification of DKIM signatures in incoming email is implemented via the
62260 <option>acl_smtp_dkim</option> ACL. By default, this ACL is called once for each
62261 syntactically(!) correct signature in the incoming message.
62262 </para>
62263 <para>
62264 To evaluate the signature in the ACL a large number of expansion variables
62265 containing the signature status and its details are set up during the
62266 runtime of the ACL.
62267 </para>
62268 <para>
62269 Calling the ACL only for existing signatures is not sufficient to build
62270 more advanced policies. For that reason, the global option
62271 <option>dkim_verify_signers</option>, and a global expansion variable
62272 <option>$dkim_signers</option> exist.
62273 </para>
62274 <para revisionflag="changed">
62275 The global option <option>dkim_verify_signers</option> can be set to a colon-separated
62276 list of DKIM domains or identities for which the ACL <option>acl_smtp_dkim</option> is
62277 called. It is expanded when the message has been received. At this point,
62278 the expansion variable <option>$dkim_signers</option> already contains a colon-separated
62279 list of signer domains and identities for the message. When
62280 <option>dkim_verify_signers</option> is not specified in the main configuration,
62281 it defaults as:
62282 </para>
62283 <literallayout class="monospaced" revisionflag="changed">
62284 dkim_verify_signers = $dkim_signers
62285 </literallayout>
62286 <para revisionflag="changed">
62287 This leads to the default behaviour of calling <option>acl_smtp_dkim</option> for each
62288 DKIM signature in the message. Current DKIM verifiers may want to explicitly
62289 call the ACL for known domains or identities. This would be achieved as follows:
62290 </para>
62291 <literallayout class="monospaced" revisionflag="changed">
62292 dkim_verify_signers = paypal.com:ebay.com:$dkim_signers
62293 </literallayout>
62294 <para revisionflag="changed">
62295 This would result in <option>acl_smtp_dkim</option> always being called for "paypal.com"
62296 and "ebay.com", plus all domains and identities that have signatures in the message.
62297 You can also be more creative in constructing your policy. For example:
62298 </para>
62299 <literallayout class="monospaced" revisionflag="changed">
62300 dkim_verify_signers = $sender_address_domain:$dkim_signers
62301 </literallayout>
62302 <para>
62303 If a domain or identity is listed several times in the (expanded) value of
62304 <option>dkim_verify_signers</option>, the ACL is only called once for that domain or identity.
62305 </para>
62306 <para>
62307 Inside the <option>acl_smtp_dkim</option>, the following expansion variables are
62308 available (from most to least important):
62309 </para>
62310 <variablelist revisionflag="changed">
62311 <varlistentry revisionflag="changed">
62312 <term><option>$dkim_cur_signer</option></term>
62313 <listitem>
62314 <para revisionflag="changed">
62315 The signer that is being evaluated in this ACL run. This can be a domain or
62316 an identity. This is one of the list items from the expanded main option
62317 <option>dkim_verify_signers</option> (see above).
62318 </para>
62319 </listitem></varlistentry>
62320 <varlistentry revisionflag="changed">
62321 <term><option>$dkim_verify_status</option></term>
62322 <listitem>
62323 <para revisionflag="changed">
62324 A string describing the general status of the signature. One of
62325 </para>
62326 <itemizedlist revisionflag="changed">
62327 <listitem>
62328 <para revisionflag="changed">
62329 <option>none</option>: There is no signature in the message for the current domain or
62330 identity (as reflected by <option>$dkim_cur_signer</option>).
62331 </para>
62332 </listitem>
62333 <listitem>
62334 <para revisionflag="changed">
62335 <option>invalid</option>: The signature could not be verified due to a processing error.
62336 More detail is available in <option>$dkim_verify_reason</option>.
62337 </para>
62338 </listitem>
62339 <listitem>
62340 <para revisionflag="changed">
62341 <option>fail</option>: Verification of the signature failed.  More detail is
62342 available in <option>$dkim_verify_reason</option>.
62343 </para>
62344 </listitem>
62345 <listitem>
62346 <para revisionflag="changed">
62347 <option>pass</option>: The signature passed verification. It is valid.
62348 </para>
62349 </listitem>
62350 </itemizedlist>
62351 </listitem></varlistentry>
62352 <varlistentry revisionflag="changed">
62353 <term><option>$dkim_verify_reason</option></term>
62354 <listitem>
62355 <para revisionflag="changed">
62356 A string giving a litte bit more detail when <option>$dkim_verify_status</option> is either
62357 "fail" or "invalid". One of
62358 </para>
62359 <itemizedlist revisionflag="changed">
62360 <listitem>
62361 <para revisionflag="changed">
62362 <option>pubkey_unavailable</option> (when <option>$dkim_verify_status</option>="invalid"): The public
62363 key for the domain could not be retrieved. This may be a temporary problem.
62364 </para>
62365 </listitem>
62366 <listitem>
62367 <para revisionflag="changed">
62368 <option>pubkey_syntax</option> (when <option>$dkim_verify_status</option>="invalid"): The public key
62369 record for the domain is syntactically invalid.
62370 </para>
62371 </listitem>
62372 <listitem>
62373 <para revisionflag="changed">
62374 <option>bodyhash_mismatch</option> (when <option>$dkim_verify_status</option>="fail"): The calculated
62375 body hash does not match the one specified in the signature header. This
62376 means that the message body was modified in transit.
62377 </para>
62378 </listitem>
62379 <listitem>
62380 <para revisionflag="changed">
62381 <option>signature_incorrect</option> (when <option>$dkim_verify_status</option>="fail"): The signature
62382 could not be verified. This may mean that headers were modified,
62383 re-written or otherwise changed in a way which is incompatible with
62384 DKIM verification. It may of course also mean that the signature is forged.
62385 </para>
62386 </listitem>
62387 </itemizedlist>
62388 </listitem></varlistentry>
62389 <varlistentry revisionflag="changed">
62390 <term><option>$dkim_domain</option></term>
62391 <listitem>
62392 <para revisionflag="changed">
62393 The signing domain. IMPORTANT: This variable is only populated if there is
62394 an actual signature in the message for the current domain or identity (as
62395 reflected by <option>$dkim_cur_signer</option>).
62396 </para>
62397 </listitem></varlistentry>
62398 <varlistentry revisionflag="changed">
62399 <term><option>$dkim_identity</option></term>
62400 <listitem>
62401 <para revisionflag="changed">
62402 The signing identity, if present. IMPORTANT: This variable is only populated
62403 if there is an actual signature in the message for the current domain or
62404 identity (as reflected by <option>$dkim_cur_signer</option>).
62405 </para>
62406 </listitem></varlistentry>
62407 <varlistentry revisionflag="changed">
62408 <term><option>$dkim_selector</option></term>
62409 <listitem>
62410 <para revisionflag="changed">
62411 The key record selector string.
62412 </para>
62413 </listitem></varlistentry>
62414 <varlistentry revisionflag="changed">
62415 <term><option>$dkim_algo</option></term>
62416 <listitem>
62417 <para revisionflag="changed">
62418 The algorithm used. One of &#x2019;rsa-sha1&#x2019; or &#x2019;rsa-sha256&#x2019;.
62419 </para>
62420 </listitem></varlistentry>
62421 <varlistentry revisionflag="changed">
62422 <term><option>$dkim_canon_body</option></term>
62423 <listitem>
62424 <para revisionflag="changed">
62425 The body canonicalization method. One of &#x2019;relaxed&#x2019; or &#x2019;simple&#x2019;.
62426 </para>
62427 </listitem></varlistentry>
62428 <varlistentry revisionflag="changed">
62429 <term><option>dkim_canon_headers</option></term>
62430 <listitem>
62431 <para revisionflag="changed">
62432 The header canonicalization method. One of &#x2019;relaxed&#x2019; or &#x2019;simple&#x2019;.
62433 </para>
62434 </listitem></varlistentry>
62435 <varlistentry revisionflag="changed">
62436 <term><option>$dkim_copiedheaders</option></term>
62437 <listitem>
62438 <para revisionflag="changed">
62439 A transcript of headers and their values which are included in the signature
62440 (copied from the &#x2019;z=&#x2019; tag of the signature).
62441 </para>
62442 </listitem></varlistentry>
62443 <varlistentry revisionflag="changed">
62444 <term><option>$dkim_bodylength</option></term>
62445 <listitem>
62446 <para revisionflag="changed">
62447 The number of signed body bytes. If zero ("0"), the body is unsigned. If no
62448 limit was set by the signer, "9999999999999" is returned. This makes sure
62449 that this variable always expands to an integer value.
62450 </para>
62451 </listitem></varlistentry>
62452 <varlistentry revisionflag="changed">
62453 <term><option>$dkim_created</option></term>
62454 <listitem>
62455 <para revisionflag="changed">
62456 UNIX timestamp reflecting the date and time when the signature was created.
62457 When this was not specified by the signer, "0" is returned.
62458 </para>
62459 </listitem></varlistentry>
62460 <varlistentry revisionflag="changed">
62461 <term><option>$dkim_expires</option></term>
62462 <listitem>
62463 <para revisionflag="changed">
62464 UNIX timestamp reflecting the date and time when the signer wants the
62465 signature to be treated as "expired". When this was not specified by the
62466 signer, "9999999999999" is returned. This makes it possible to do useful
62467 integer size comparisons against this value.
62468 </para>
62469 </listitem></varlistentry>
62470 <varlistentry revisionflag="changed">
62471 <term><option>$dkim_headernames</option></term>
62472 <listitem>
62473 <para revisionflag="changed">
62474 A colon-separated list of names of headers included in the signature.
62475 </para>
62476 </listitem></varlistentry>
62477 <varlistentry revisionflag="changed">
62478 <term><option>$dkim_key_testing</option></term>
62479 <listitem>
62480 <para revisionflag="changed">
62481 "1" if the key record has the "testing" flag set, "0" if not.
62482 </para>
62483 </listitem></varlistentry>
62484 <varlistentry revisionflag="changed">
62485 <term><option>$dkim_key_nosubdomaining</option></term>
62486 <listitem>
62487 <para revisionflag="changed">
62488 "1" if the key record forbids subdomaining, "0" otherwise.
62489 </para>
62490 </listitem></varlistentry>
62491 <varlistentry revisionflag="changed">
62492 <term><option>$dkim_key_srvtype</option></term>
62493 <listitem>
62494 <para revisionflag="changed">
62495 Service type (tag s=) from the key record. Defaults to "*" if not specified
62496 in the key record.
62497 </para>
62498 </listitem></varlistentry>
62499 <varlistentry revisionflag="changed">
62500 <term><option>$dkim_key_granularity</option></term>
62501 <listitem>
62502 <para revisionflag="changed">
62503 Key granularity (tag g=) from the key record. Defaults to "*" if not specified
62504 in the key record.
62505 </para>
62506 </listitem></varlistentry>
62507 <varlistentry revisionflag="changed">
62508 <term><option>$dkim_key_notes</option></term>
62509 <listitem>
62510 <para revisionflag="changed">
62511 Notes from the key record (tag n=).
62512 </para>
62513 </listitem></varlistentry>
62514 </variablelist>
62515 <para>
62516 In addition, two ACL conditions are provided:
62517 </para>
62518 <variablelist revisionflag="changed">
62519 <varlistentry revisionflag="changed">
62520 <term><option>dkim_signers</option></term>
62521 <listitem>
62522 <para revisionflag="changed">
62523 ACL condition that checks a colon-separated list of domains or identities
62524 for a match against the domain or identity that the ACL is currently verifying
62525 (reflected by <option>$dkim_cur_signer</option>). This is typically used to restrict an ACL
62526 verb to a group of domains or identities. For example:
62527 </para>
62528 <literallayout class="monospaced">
62529 # Warn when message apparently from GMail has no signature at all
62530 warn log_message = GMail sender without DKIM signature
62531      sender_domains = gmail.com
62532      dkim_signers = gmail.com
62533      dkim_status = none
62534 </literallayout>
62535 </listitem></varlistentry>
62536 <varlistentry>
62537 <term><option>dkim_status</option></term>
62538 <listitem>
62539 <para>
62540 ACL condition that checks a colon-separated list of possible DKIM verification
62541 results agains the actual result of verification. This is typically used
62542 to restrict an ACL verb to a list of verification outcomes, like:
62543 </para>
62544 <literallayout class="monospaced">
62545 deny message = Message from Paypal with invalid or missing signature
62546      sender_domains = paypal.com:paypal.de
62547      dkim_signers = paypal.com:paypal.de
62548      dkim_status = none:invalid:fail
62549 </literallayout>
62550 <para>
62551 The possible status keywords are: &#x2019;none&#x2019;,&#x2019;invalid&#x2019;,&#x2019;fail&#x2019; and &#x2019;pass&#x2019;. Please
62552 see the documentation of the <option>$dkim_verify_status</option> expansion variable above
62553 for more information of what they mean.
62554 </para>
62555 </listitem></varlistentry>
62556 </variablelist>
62557 </section>
62558 </chapter>
62559
62560 <chapter id="CHID13">
62561 <title>Adding new drivers or lookup types</title>
62562 <titleabbrev>Adding drivers or lookups</titleabbrev>
62563 <para>
62564 <indexterm role="concept">
62565 <primary>adding drivers</primary>
62566 </indexterm>
62567 <indexterm role="concept">
62568 <primary>new drivers, adding</primary>
62569 </indexterm>
62570 <indexterm role="concept">
62571 <primary>drivers</primary>
62572 <secondary>adding new</secondary>
62573 </indexterm>
62574 The following actions have to be taken in order to add a new router, transport,
62575 authenticator, or lookup type to Exim:
62576 </para>
62577 <orderedlist numeration="arabic">
62578 <listitem>
62579 <para>
62580 Choose a name for the driver or lookup type that does not conflict with any
62581 existing name; I will use <quote>newdriver</quote> in what follows.
62582 </para>
62583 </listitem>
62584 <listitem>
62585 <para>
62586 Add to <filename>src/EDITME</filename> the line:
62587 </para>
62588 <literallayout>
62589 &lt;<emphasis>type</emphasis>&gt;<literal>_NEWDRIVER=yes</literal>
62590 </literallayout>
62591 <para>
62592 where &lt;<emphasis>type</emphasis>&gt; is ROUTER, TRANSPORT, AUTH, or LOOKUP. If the
62593 code is not to be included in the binary by default, comment this line out. You
62594 should also add any relevant comments about the driver or lookup type.
62595 </para>
62596 </listitem>
62597 <listitem>
62598 <para>
62599 Add to <filename>src/config.h.defaults</filename> the line:
62600 </para>
62601 <literallayout class="monospaced">
62602 #define &lt;type&gt;_NEWDRIVER
62603 </literallayout>
62604 </listitem>
62605 <listitem>
62606 <para>
62607 Edit <filename>src/drtables.c</filename>, adding conditional code to pull in the private header
62608 and create a table entry as is done for all the other drivers and lookup types.
62609 </para>
62610 </listitem>
62611 <listitem>
62612 <para>
62613 Edit <filename>Makefile</filename> in the appropriate sub-directory (<filename>src/routers</filename>,
62614 <filename>src/transports</filename>, <filename>src/auths</filename>, or <filename>src/lookups</filename>); add a line for the new
62615 driver or lookup type and add it to the definition of OBJ.
62616 </para>
62617 </listitem>
62618 <listitem>
62619 <para>
62620 Create <filename>newdriver.h</filename> and <filename>newdriver.c</filename> in the appropriate sub-directory of
62621 <filename>src</filename>.
62622 </para>
62623 </listitem>
62624 <listitem>
62625 <para>
62626 Edit <filename>scripts/MakeLinks</filename> and add commands to link the <filename>.h</filename> and <filename>.c</filename> files
62627 as for other drivers and lookups.
62628 </para>
62629 </listitem>
62630 </orderedlist>
62631 <para>
62632 Then all you need to do is write the code! A good way to start is to make a
62633 proforma by copying an existing module of the same type, globally changing all
62634 occurrences of the name, and cutting out most of the code. Note that any
62635 options you create must be listed in alphabetical order, because the tables are
62636 searched using a binary chop procedure.
62637 </para>
62638 <para>
62639 There is a <filename>README</filename> file in each of the sub-directories of <filename>src</filename> describing
62640 the interface that is expected.
62641 </para>
62642 <?sdop
62643   format="newpage"
62644   foot_right_recto="&chaptertitle;"
62645   foot_right_verso="&chaptertitle;"
62646 ?>
62647 </chapter>
62648
62649 <index role="option">
62650 <title>Options index</title>
62651 </index>
62652
62653 <index role="variable">
62654 <title>Variables index</title>
62655 </index>
62656
62657 <index role="concept">
62658 <title>Concept index</title>
62659 </index>
62660
62661 </book>