8d61543cdff8be0b6ff22e397af0aab0bac1b730
[exim.git] / doc / doc-docbook / spec.xfpt
1 . /////////////////////////////////////////////////////////////////////////////
2 . This is the primary source of the Exim Manual. It is an xfpt document that is
3 . converted into DocBook XML for subsequent conversion into printable and online
4 . formats. The markup used herein is "standard" xfpt markup, with some extras.
5 . The markup is summarized in a file called Markup.txt.
6 .
7 . WARNING: When you use the .new macro, make sure it appears *before* any
8 . adjacent index items; otherwise you get an empty "paragraph" which causes
9 . unwanted vertical space.
10 . /////////////////////////////////////////////////////////////////////////////
11
12 .include stdflags
13 .include stdmacs
14
15 . /////////////////////////////////////////////////////////////////////////////
16 . This outputs the standard DocBook boilerplate.
17 . /////////////////////////////////////////////////////////////////////////////
18
19 .docbook
20
21 . /////////////////////////////////////////////////////////////////////////////
22 . These lines are processing instructions for the Simple DocBook Processor that
23 . Philip Hazel has developed as a less cumbersome way of making PostScript and
24 . PDFs than using xmlto and fop. They will be ignored by all other XML
25 . processors.
26 . /////////////////////////////////////////////////////////////////////////////
27
28 .literal xml
29 <?sdop
30   foot_right_recto="&chaptertitle; (&chapternumber;)"
31   foot_right_verso="&chaptertitle; (&chapternumber;)"
32   toc_chapter_blanks="yes,yes"
33   table_warn_overflow="overprint"
34 ?>
35 .literal off
36
37 . /////////////////////////////////////////////////////////////////////////////
38 . This generates the outermost <book> element that wraps the entire document.
39 . /////////////////////////////////////////////////////////////////////////////
40
41 .book
42
43 . /////////////////////////////////////////////////////////////////////////////
44 . These definitions set some parameters and save some typing.
45 . Update the Copyright year (only) when changing content.
46 . /////////////////////////////////////////////////////////////////////////////
47
48 .set previousversion "4.98"
49 .include ./local_params
50
51 .set ACL "access control lists (ACLs)"
52 .set I   "&nbsp;&nbsp;&nbsp;&nbsp;"
53
54 .set drivernamemax "64"
55
56 .macro copyyear
57 2024
58 .endmacro
59
60 . /////////////////////////////////////////////////////////////////////////////
61 . Additional xfpt markup used by this document, over and above the default
62 . provided in the xfpt library.
63 . /////////////////////////////////////////////////////////////////////////////
64
65 . --- Override the &$ flag to automatically insert a $ with the variable name.
66
67 .flag &$  $&   "<varname>$"  "</varname>"
68
69 . --- Short flags for daggers in option headings. They will always be inside
70 . --- an italic string, but we want the daggers to be in Roman.
71
72 .flag &!!      "</emphasis>&dagger;<emphasis>"
73 .flag &!?      "</emphasis>&Dagger;<emphasis>"
74
75 . --- A macro for an Exim option definition heading, generating a one-line
76 . --- table with four columns. For cases when the option name is given with
77 . --- a space, so that it can be split, a fifth argument is used for the
78 . --- index entry.
79 . --- Also one for multiple option def headings be grouped in a single
80 . --- table (but without the split capability).
81
82 .macro otable
83 .itable all 0 0 4 8* left 6* center 6* center 6* right
84 .endmacro
85
86 .macro orow
87 .row "&%$1%&" "Use: &'$2'&" "Type: &'$3'&" "Default: &'$4'&"
88 .endmacro
89
90 .macro option
91 .arg 5
92 .oindex "&%$5%&"
93 .endarg
94 .arg -5
95 .oindex "&%$1%&"
96 .endarg
97 .otable
98 .orow "$1" "$2" "$3" "$4"
99 .endtable
100 .endmacro
101
102 .macro options
103 .eacharg
104 .oindex "&%$+1%&"
105 .endeach 4
106 .otable
107 .eacharg
108 .orow "$+1" "$+2" "$+3" "$+4"
109 .endeach 4
110 .endtable
111 .endmacro
112
113 . --- A macro for the common 2-column tables. The width of the first column
114 . --- is suitable for the many tables at the start of the main options chapter;
115 . --- a small number of other 2-column tables override it.
116
117 .macro table2 196pt 254pt
118 .itable none 0 0 2 $1 left $2 left
119 .endmacro
120
121
122 . --- A macro for a plain variable, including the .vitem and .vindex
123 .macro var
124 .vitem $1
125 .vindex $1
126 .endmacro
127
128 . --- A macro for a "tainted" marker, done as a one-element table
129 .macro tmark
130 .itable none 0 0 1 10pt left
131 .row &'Tainted'&
132 .endtable
133 .endmacro
134
135 . --- A macro for a tainted variable, adding a taint-marker
136 .macro tvar
137 .var $1
138 .tmark
139 .endmacro
140
141 . --- A macro for a cmdline option, including a .oindex
142 . --- 1st arg is the option name, undecorated (we do that here).
143 . --- 2nd arg, optional, text (decorated as needed) to be appended to the name
144 .macro cmdopt
145 .vitem  &%$1%&$=2+&~$2+
146 .oindex &%$1%&
147 .endmacro
148
149 . --- A macro that generates .row, but puts &I; at the start of the first
150 . --- argument, thus indenting it. Assume a minimum of two arguments, and
151 . --- allow up to four arguments, which is as many as we'll ever need.
152
153 .macro irow
154 .arg 4
155 .row "&I;$1" "$2" "$3" "$4"
156 .endarg
157 .arg -4
158 .arg 3
159 .row "&I;$1" "$2" "$3"
160 .endarg
161 .arg -3
162 .row "&I;$1" "$2"
163 .endarg
164 .endarg
165 .endmacro
166
167 . --- Macros for option, variable, and concept index entries. For a "range"
168 . --- style of entry, use .scindex for the start and .ecindex for the end. The
169 . --- first argument of .scindex and the only argument of .ecindex must be the
170 . --- ID that ties them together.
171 . --- The index entry points to the most-recent chapter head, section or subsection
172 . --- head, or list-item.
173
174 .macro cindex
175 &<indexterm role="concept">&
176 &<primary>&$1&</primary>&
177 .arg 2
178 &<secondary>&$2&</secondary>&
179 .endarg
180 &</indexterm>&
181 .endmacro
182
183 .macro scindex
184 &<indexterm role="concept" id="$1" class="startofrange">&
185 &<primary>&$2&</primary>&
186 .arg 3
187 &<secondary>&$3&</secondary>&
188 .endarg
189 &</indexterm>&
190 .endmacro
191
192 .macro ecindex
193 &<indexterm role="concept" startref="$1" class="endofrange"/>&
194 .endmacro
195
196 .macro oindex
197 &<indexterm role="option">&
198 &<primary>&$1&</primary>&
199 .arg 2
200 &<secondary>&$2&</secondary>&
201 .endarg
202 &</indexterm>&
203 .endmacro
204
205 . --- The index entry points to the most-recent chapter head, section or subsection
206 . --- head, or varlist item.
207
208 .macro vindex
209 &<indexterm role="variable">&
210 &<primary>&$1&</primary>&
211 .arg 2
212 &<secondary>&$2&</secondary>&
213 .endarg
214 &</indexterm>&
215 .endmacro
216
217 .macro index
218 .echo "** Don't use .index; use .cindex or .oindex or .vindex"
219 .endmacro
220
221
222 . use this for a concept-index entry for a header line
223 .macro chindex
224 .cindex "&'$1'& header line"
225 .cindex "header lines" $1
226 .endmacro
227 . ////////////////////////////////////////////////////////////////////////////
228
229
230 . ////////////////////////////////////////////////////////////////////////////
231 . The <bookinfo> element is removed from the XML before processing for ASCII
232 . output formats.
233 . ////////////////////////////////////////////////////////////////////////////
234
235 .literal xml
236 <bookinfo>
237 <title>Specification of the Exim Mail Transfer Agent</title>
238 <titleabbrev>The Exim MTA</titleabbrev>
239 <date>
240 .fulldate
241 </date>
242 <author><firstname>Exim</firstname><surname>Maintainers</surname></author>
243 <authorinitials>EM</authorinitials>
244 <revhistory><revision>
245 .versiondatexml
246   <authorinitials>EM</authorinitials>
247 </revision></revhistory>
248 <copyright><year>
249 .copyyear
250            </year><holder>The Exim Maintainers</holder></copyright>
251 </bookinfo>
252 .literal off
253
254
255 . /////////////////////////////////////////////////////////////////////////////
256 . These implement index entries of the form "x, see y" and "x, see also y".
257 . However, the DocBook DTD doesn't allow <indexterm> entries
258 . at the top level, so we have to put the .chapter directive first.
259 . /////////////////////////////////////////////////////////////////////////////
260
261 .chapter "Introduction" "CHID1"
262
263 .macro seeother
264 .literal xml
265 <indexterm role="$2">
266   <primary>$3</primary>
267 .arg 5
268   <secondary>$5</secondary>
269 .endarg
270   <$1><emphasis>$4</emphasis></$1>
271 </indexterm>
272 .literal off
273 .endmacro
274
275 . NB: for the 4-arg variant the ordering is awkward
276 .macro see
277 .seeother see "$1" "$2" "$3" "$4"
278 .endmacro
279 .macro seealso
280 .seeother seealso "$1" "$2" "$3" "$4"
281 .endmacro
282
283 .see     variable "<emphasis>$1</emphasis>, <emphasis>$2</emphasis>, etc." "numerical variables"
284 .see     concept address        rewriting                       rewriting
285 .see     concept "Bounce Address Tag Validation"        BATV
286 .see     concept "Client SMTP Authorization"            CSA
287 .see     concept "CR character" "carriage return"
288 .see     concept CRL            "certificate revocation list"
289 .seealso concept de-tainting    "tainted data"
290 .see     concept delivery       "bounce message"                "failure report"
291 .see     concept dialup         "intermittently connected hosts"
292 .see     concept exiscan        "content scanning"
293 .see     concept fallover       fallback
294 .see     concept filter         "Sieve filter"                  Sieve
295 .see     concept headers        "header lines"
296 .see     concept ident          "RFC 1413"
297 .see     concept "LF character" "linefeed"
298 .seealso concept maximum        limit
299 .see     concept monitor        "Exim monitor"
300 .see     concept "no_<emphasis>xxx</emphasis>"          "entry for xxx"
301 .see     concept NUL            "binary zero"
302 .see     concept "passwd file"  "/etc/passwd"
303 .see     concept "process id"   pid
304 .see     concept RBL            "DNS list"
305 .see     concept redirection    "address redirection"
306 .see     concept "return path"  "envelope sender"
307 .see     concept scanning       "content scanning"
308 .see     concept SSL            TLS
309 .see     concept string         expansion expansion
310 .see     concept "top bit"      "8-bit characters"
311 .see     concept variables      "expansion, variables"
312 .see     concept "zero, binary" "binary zero"
313
314
315 . /////////////////////////////////////////////////////////////////////////////
316 . This is the real start of the first chapter. See the comment above as to why
317 . we can't have the .chapter line here.
318 . chapter "Introduction"
319 . /////////////////////////////////////////////////////////////////////////////
320
321 Exim is a mail transfer agent (MTA) for hosts that are running Unix or
322 Unix-like operating systems. It was designed on the assumption that it would be
323 run on hosts that are permanently connected to the Internet. However, it can be
324 used on intermittently connected hosts with suitable configuration adjustments.
325
326 Configuration files currently exist for the following operating systems: AIX,
327 BSD/OS (aka BSDI), Darwin (Mac OS X), DGUX, Dragonfly, FreeBSD, GNU/Hurd,
328 GNU/Linux, HI-OSF (Hitachi), HI-UX, HP-UX, IRIX, MIPS RISCOS, NetBSD, OpenBSD,
329 OpenUNIX, QNX, SCO, SCO SVR4.2 (aka UNIX-SV), Solaris (aka SunOS5), SunOS4,
330 Tru64-Unix (formerly Digital UNIX, formerly DEC-OSF1), Ultrix, and UnixWare.
331 Some of these operating systems are no longer current and cannot easily be
332 tested, so the configuration files may no longer work in practice.
333
334 There are also configuration files for compiling Exim in the Cygwin environment
335 that can be installed on systems running Windows. However, this document does
336 not contain any information about running Exim in the Cygwin environment.
337
338 The terms and conditions for the use and distribution of Exim are contained in
339 the file &_NOTICE_&. Exim is distributed under the terms of the GNU General
340 Public Licence, a copy of which may be found in the file &_LICENCE_&.
341
342 The use, supply, or promotion of Exim for the purpose of sending bulk,
343 unsolicited electronic mail is incompatible with the basic aims of Exim,
344 which revolve around the free provision of a service that enhances the quality
345 of personal communications. The author of Exim regards indiscriminate
346 mass-mailing as an antisocial, irresponsible abuse of the Internet.
347
348 Exim owes a great deal to Smail 3 and its author, Ron Karr. Without the
349 experience of running and working on the Smail 3 code, I could never have
350 contemplated starting to write a new MTA. Many of the ideas and user interfaces
351 were originally taken from Smail 3, though the actual code of Exim is entirely
352 new, and has developed far beyond the initial concept.
353
354 Many people, both in Cambridge and around the world, have contributed to the
355 development and the testing of Exim, and to porting it to various operating
356 systems. I am grateful to them all. The distribution now contains a file called
357 &_ACKNOWLEDGMENTS_&, in which I have started recording the names of
358 contributors.
359
360
361 .section "Exim documentation" "SECID1"
362 . Keep this example change bar when updating the documentation!
363
364 .new
365 .cindex "documentation"
366 This edition of the Exim specification applies to version &version() of Exim.
367 Substantive changes from the &previousversion; edition are marked in some
368 renditions of this document; this paragraph is so marked if the rendition is
369 capable of showing a change indicator.
370 .wen
371
372 This document is very much a reference manual; it is not a tutorial. The reader
373 is expected to have some familiarity with the SMTP mail transfer protocol and
374 with general Unix system administration. Although there are some discussions
375 and examples in places, the information is mostly organized in a way that makes
376 it easy to look up, rather than in a natural order for sequential reading.
377 Furthermore, this manual aims to cover every aspect of Exim in detail, including
378 a number of rarely-used, special-purpose features that are unlikely to be of
379 very wide interest.
380
381 .cindex "books about Exim"
382 An &"easier"& discussion of Exim which provides more in-depth explanatory,
383 introductory, and tutorial material can be found in a book entitled &'The Exim
384 SMTP Mail Server'& (second edition, 2007), published by UIT Cambridge
385 (&url(https://www.uit.co.uk/exim-book/)).
386
387 The book also contains a chapter that gives a general introduction to SMTP and
388 Internet mail. Inevitably, however, the book is unlikely to be fully up-to-date
389 with the latest release of Exim. (Note that the earlier book about Exim,
390 published by O'Reilly, covers Exim 3, and many things have changed in Exim 4.)
391
392 .cindex "Debian" "information sources"
393 If you are using a Debian distribution of Exim, you will find information about
394 Debian-specific features in the file
395 &_/usr/share/doc/exim4-base/README.Debian_&.
396 The command &(man update-exim.conf)& is another source of Debian-specific
397 information.
398
399 .cindex "&_doc/NewStuff_&"
400 .cindex "&_doc/ChangeLog_&"
401 .cindex "change log"
402 As Exim develops, there may be features in newer versions that have not
403 yet made it into this document, which is updated only when the most significant
404 digit of the fractional part of the version number changes. Specifications of
405 new features that are not yet in this manual are placed in the file
406 &_doc/NewStuff_& in the Exim distribution.
407
408 Some features may be classified as &"experimental"&. These may change
409 incompatibly while they are developing, or even be withdrawn. For this reason,
410 they are not documented in this manual. Information about experimental features
411 can be found in the file &_doc/experimental.txt_&.
412
413 All changes to Exim (whether new features, bug fixes, or other kinds of
414 change) are noted briefly in the file called &_doc/ChangeLog_&.
415
416 .cindex "&_doc/spec.txt_&"
417 This specification itself is available as an ASCII file in &_doc/spec.txt_& so
418 that it can easily be searched with a text editor. Other files in the &_doc_&
419 directory are:
420
421 .table2 100pt
422 .row &_OptionLists.txt_&     "list of all options in alphabetical order"
423 .row &_dbm.discuss.txt_&     "discussion about DBM libraries"
424 .row &_exim.8_&              "a man page of Exim's command line options"
425 .row &_experimental.txt_&    "documentation of experimental features"
426 .row &_filter.txt_&          "specification of the filter language"
427 .row &_Exim3.upgrade_&       "upgrade notes from release 2 to release 3"
428 .row &_Exim4.upgrade_&       "upgrade notes from release 3 to release 4"
429 .row &_openssl.txt_&         "installing a current OpenSSL release"
430 .endtable
431
432 The main specification and the specification of the filtering language are also
433 available in other formats (HTML, PostScript, PDF, and Texinfo). Section
434 &<<SECTavail>>& below tells you how to get hold of these.
435
436
437
438 .section "FTP site and websites" "SECID2"
439 .cindex "website"
440 .cindex "FTP site"
441 The primary site for Exim source distributions is the &%exim.org%& FTP site,
442 available over HTTPS, HTTP and FTP.  These services, and the &%exim.org%&
443 website, are hosted at the University of Cambridge.
444
445 .cindex "wiki"
446 .cindex "FAQ"
447 As well as Exim distribution tar files, the Exim website contains a number of
448 differently formatted versions of the documentation. A recent addition to the
449 online information is the Exim wiki (&url(https://wiki.exim.org)),
450 which contains what used to be a separate FAQ, as well as various other
451 examples, tips, and know-how that have been contributed by Exim users.
452 The wiki site should always redirect to the correct place, which is currently
453 provided by GitHub, and is open to editing by anyone with a GitHub account.
454
455 .cindex Bugzilla
456 An Exim Bugzilla exists at &url(https://bugs.exim.org). You can use
457 this to report bugs, and also to add items to the wish list. Please search
458 first to check that you are not duplicating a previous entry.
459 Please do not ask for configuration help in the bug-tracker.
460
461
462 .section "Mailing lists" "SECID3"
463 .cindex "mailing lists" "for Exim users"
464 The following Exim mailing lists exist:
465
466 .table2 140pt
467 .row &'exim-announce@lists.exim.org'&   "Moderated, low volume announcements list"
468 .row &'exim-users@lists.exim.org'&      "General discussion list"
469 .row &'exim-users-de@lists.exim.org'&   "General discussion list in German language"
470 .row &'exim-dev@lists.exim.org'&        "Discussion of bugs, enhancements, etc."
471 .row &'exim-cvs@lists.exim.org'&        "Automated commit messages from the VCS"
472 .endtable
473
474 You can subscribe to these lists, change your existing subscriptions, and view
475 or search the archives via the mailing lists link on the Exim home page.
476 .cindex "Debian" "mailing list for"
477 If you are using a Debian distribution of Exim, you may wish to subscribe to
478 the Debian-specific mailing list &'pkg-exim4-users@lists.alioth.debian.org'&
479 via this web page:
480 .display
481 &url(https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/pkg-exim4-users)
482 .endd
483 Please ask Debian-specific questions on that list and not on the general Exim
484 lists.
485
486 .section "Bug reports" "SECID5"
487 .cindex "bug reports"
488 .cindex "reporting bugs"
489 Reports of obvious bugs can be emailed to &'bugs@exim.org'& or reported
490 via the Bugzilla (&url(https://bugs.exim.org)). However, if you are unsure
491 whether some behaviour is a bug or not, the best thing to do is to post a
492 message to the &'exim-dev'& mailing list and have it discussed.
493
494
495
496 .section "Where to find the Exim distribution" "SECTavail"
497 .cindex "FTP site"
498 .cindex "HTTPS download site"
499 .cindex "distribution" "FTP site"
500 .cindex "distribution" "https site"
501 The master distribution site for the Exim distribution is
502 .display
503 &url(https://downloads.exim.org/)
504 .endd
505 The service is available over HTTPS, HTTP and FTP.
506 We encourage people to migrate to HTTPS.
507
508 The content served at &url(https://downloads.exim.org/) is identical to the
509 content served at &url(https://ftp.exim.org/pub/exim) and
510 &url(ftp://ftp.exim.org/pub/exim).
511
512 If accessing via a hostname containing &'ftp'&, then the file references that
513 follow are relative to the &_exim_& directories at these sites.
514 If accessing via the hostname &'downloads'& then the subdirectories described
515 here are top-level directories.
516
517 There are now quite a number of independent mirror sites around
518 the world. Those that I know about are listed in the file called &_Mirrors_&.
519
520 Within the top exim directory there are subdirectories called &_exim3_& (for
521 previous Exim 3 distributions), &_exim4_& (for the latest Exim 4
522 distributions), and &_Testing_& for testing versions. In the &_exim4_&
523 subdirectory, the current release can always be found in files called
524 .display
525 &_exim-n.nn.tar.xz_&
526 &_exim-n.nn.tar.gz_&
527 &_exim-n.nn.tar.bz2_&
528 .endd
529 where &'n.nn'& is the highest such version number in the directory. The three
530 files contain identical data; the only difference is the type of compression.
531 The &_.xz_& file is usually the smallest, while the &_.gz_& file is the
532 most portable to old systems.
533
534 .cindex "distribution" "signing details"
535 .cindex "distribution" "public key"
536 .cindex "public key for signed distribution"
537 The distributions will be PGP signed by an individual key of the Release
538 Coordinator.  This key will have a uid containing an email address in the
539 &'exim.org'& domain and will have signatures from other people, including
540 other Exim maintainers.  We expect that the key will be in the "strong set" of
541 PGP keys.  There should be a trust path to that key from the Exim Maintainer's
542 PGP keys, a version of which can be found in the release directory in the file
543 &_Exim-Maintainers-Keyring.asc_&.  All keys used will be available in public keyserver pools,
544 such as &'pool.sks-keyservers.net'&.
545
546 At the time of the last update, releases were being made by Jeremy Harris and signed
547 with key &'0xBCE58C8CE41F32DF'&.  Other recent keys used for signing are those
548 of Heiko Schlittermann, &'0x26101B62F69376CE'&,
549 and of Phil Pennock, &'0x4D1E900E14C1CC04'&.
550
551 The signatures for the tar bundles are in:
552 .display
553 &_exim-n.nn.tar.xz.asc_&
554 &_exim-n.nn.tar.gz.asc_&
555 &_exim-n.nn.tar.bz2.asc_&
556 .endd
557 For each released version, the log of changes is made available in a
558 separate file in the directory &_ChangeLogs_& so that it is possible to
559 find out what has changed without having to download the entire distribution.
560
561 .cindex "documentation" "available formats"
562 The main distribution contains ASCII versions of this specification and other
563 documentation; other formats of the documents are available in separate files
564 inside the &_exim4_& directory of the FTP site:
565 .display
566 &_exim-html-n.nn.tar.gz_&
567 &_exim-pdf-n.nn.tar.gz_&
568 &_exim-postscript-n.nn.tar.gz_&
569 &_exim-texinfo-n.nn.tar.gz_&
570 .endd
571 These tar files contain only the &_doc_& directory, not the complete
572 distribution, and are also available in &_.bz2_& and &_.xz_& forms.
573
574
575 .section "Limitations" "SECID6"
576 .ilist
577 .cindex "limitations of Exim"
578 .cindex "bang paths" "not handled by Exim"
579 Exim is designed for use as an Internet MTA, and therefore handles addresses in
580 RFC 2822 domain format only. It cannot handle UUCP &"bang paths"&, though
581 simple two-component bang paths can be converted by a straightforward rewriting
582 configuration. This restriction does not prevent Exim from being interfaced to
583 UUCP as a transport mechanism, provided that domain addresses are used.
584 .next
585 .cindex "domainless addresses"
586 .cindex "address" "without domain"
587 Exim insists that every address it handles has a domain attached. For incoming
588 local messages, domainless addresses are automatically qualified with a
589 configured domain value. Configuration options specify from which remote
590 systems unqualified addresses are acceptable. These are then qualified on
591 arrival.
592 .next
593 .cindex "transport" "external"
594 .cindex "external transports"
595 The only external transport mechanisms that are currently implemented are SMTP
596 and LMTP over a TCP/IP network (including support for IPv6). However, a pipe
597 transport is available, and there are facilities for writing messages to files
598 and pipes, optionally in &'batched SMTP'& format; these facilities can be used
599 to send messages to other transport mechanisms such as UUCP, provided they can
600 handle domain-style addresses. Batched SMTP input is also catered for.
601 .next
602 Exim is not designed for storing mail for dial-in hosts. When the volumes of
603 such mail are large, it is better to get the messages &"delivered"& into files
604 (that is, off Exim's queue) and subsequently passed on to the dial-in hosts by
605 other means.
606 .next
607 Although Exim does have basic facilities for scanning incoming messages, these
608 are not comprehensive enough to do full virus or spam scanning. Such operations
609 are best carried out using additional specialized software packages. If you
610 compile Exim with the content-scanning extension, straightforward interfaces to
611 a number of common scanners are provided.
612 .endlist
613
614
615 .section "Runtime configuration" "SECID7"
616 Exim's runtime configuration is held in a single text file that is divided
617 into a number of sections. The entries in this file consist of keywords and
618 values, in the style of Smail 3 configuration files. A default configuration
619 file which is suitable for simple online installations is provided in the
620 distribution, and is described in chapter &<<CHAPdefconfil>>& below.
621
622
623 .section "Calling interface" "SECID8"
624 .cindex "Sendmail compatibility" "command line interface"
625 Like many MTAs, Exim has adopted the Sendmail command line interface so that it
626 can be a straight replacement for &_/usr/lib/sendmail_& or
627 &_/usr/sbin/sendmail_& when sending mail, but you do not need to know anything
628 about Sendmail in order to run Exim. For actions other than sending messages,
629 Sendmail-compatible options also exist, but those that produce output (for
630 example, &%-bp%&, which lists the messages in the queue) do so in Exim's own
631 format. There are also some additional options that are compatible with Smail
632 3, and some further options that are new to Exim. Chapter &<<CHAPcommandline>>&
633 documents all Exim's command line options. This information is automatically
634 made into the man page that forms part of the Exim distribution.
635
636 Control of messages in the queue can be done via certain privileged command
637 line options. There is also an optional monitor program called &'eximon'&,
638 which displays current information in an X window, and which contains a menu
639 interface to Exim's command line administration options.
640
641
642
643 .section "Terminology" "SECID9"
644 .cindex "terminology definitions"
645 .cindex "body of message" "definition of"
646 The &'body'& of a message is the actual data that the sender wants to transmit.
647 It is the last part of a message and is separated from the &'header'& (see
648 below) by a blank line.
649
650 .cindex "bounce message" "definition of"
651 When a message cannot be delivered, it is normally returned to the sender in a
652 delivery failure message or a &"non-delivery report"& (NDR). The term
653 &'bounce'& is commonly used for this action, and the error reports are often
654 called &'bounce messages'&. This is a convenient shorthand for &"delivery
655 failure error report"&. Such messages have an empty sender address in the
656 message's &'envelope'& (see below) to ensure that they cannot themselves give
657 rise to further bounce messages.
658
659 The term &'default'& appears frequently in this manual. It is used to qualify a
660 value which is used in the absence of any setting in the configuration. It may
661 also qualify an action which is taken unless a configuration setting specifies
662 otherwise.
663
664 The term &'defer'& is used when the delivery of a message to a specific
665 destination cannot immediately take place for some reason (a remote host may be
666 down, or a user's local mailbox may be full). Such deliveries are &'deferred'&
667 until a later time.
668
669 The word &'domain'& is sometimes used to mean all but the first component of a
670 host's name. It is &'not'& used in that sense here, where it normally refers to
671 the part of an email address following the @ sign.
672
673 .cindex "envelope, definition of"
674 .cindex "sender" "definition of"
675 A message in transit has an associated &'envelope'&, as well as a header and a
676 body. The envelope contains a sender address (to which bounce messages should
677 be delivered), and any number of recipient addresses. References to the
678 sender or the recipients of a message usually mean the addresses in the
679 envelope. An MTA uses these addresses for delivery, and for returning bounce
680 messages, not the addresses that appear in the header lines.
681
682 .cindex "message" "header, definition of"
683 .cindex "header section" "definition of"
684 The &'header'& of a message is the first part of a message's text, consisting
685 of a number of lines, each of which has a name such as &'From:'&, &'To:'&,
686 &'Subject:'&, etc. Long header lines can be split over several text lines by
687 indenting the continuations. The header is separated from the body by a blank
688 line.
689
690 .cindex "local part" "definition of"
691 .cindex "domain" "definition of"
692 The term &'local part'&, which is taken from RFC 2822, is used to refer to the
693 part of an email address that precedes the @ sign. The part that follows the
694 @ sign is called the &'domain'& or &'mail domain'&.
695
696 .cindex "local delivery" "definition of"
697 .cindex "remote delivery, definition of"
698 The terms &'local delivery'& and &'remote delivery'& are used to distinguish
699 delivery to a file or a pipe on the local host from delivery by SMTP over
700 TCP/IP to another host. As far as Exim is concerned, all hosts other than the
701 host it is running on are &'remote'&.
702
703 .cindex "return path" "definition of"
704 &'Return path'& is another name that is used for the sender address in a
705 message's envelope.
706
707 .cindex "queue" "definition of"
708 The term &'queue'& is used to refer to the set of messages awaiting delivery
709 because this term is in widespread use in the context of MTAs. However, in
710 Exim's case, the reality is more like a pool than a queue, because there is
711 normally no ordering of waiting messages.
712
713 .cindex "queue runner" "definition of"
714 The term &'queue runner'& is used to describe a process that scans the queue
715 and attempts to deliver those messages whose retry times have come. This term
716 is used by other MTAs and also relates to the command &%runq%&, but in Exim
717 the waiting messages are normally processed in an unpredictable order.
718
719 .cindex "spool directory" "definition of"
720 The term &'spool directory'& is used for a directory in which Exim keeps the
721 messages in its queue &-- that is, those that it is in the process of
722 delivering. This should not be confused with the directory in which local
723 mailboxes are stored, which is called a &"spool directory"& by some people. In
724 the Exim documentation, &"spool"& is always used in the first sense.
725
726
727
728
729
730
731 . ////////////////////////////////////////////////////////////////////////////
732 . ////////////////////////////////////////////////////////////////////////////
733
734 .chapter "Incorporated code" "CHID2"
735 .cindex "incorporated code"
736 .cindex "regular expressions" "library"
737 .cindex "PCRE2"
738 .cindex "OpenDMARC"
739 A number of pieces of external code are included in the Exim distribution.
740
741 .ilist
742 Regular expressions are supported in the main Exim program and in the
743 Exim monitor using the freely-distributable PCRE2 library, copyright
744 &copy; University of Cambridge. The source to PCRE2 is not longer shipped with
745 Exim, so you will need to use the version of PCRE2 shipped with your system,
746 or obtain and install the full version of the library from
747 &url(https://github.com/PhilipHazel/pcre2/releases).
748 .next
749 .cindex "cdb" "acknowledgment"
750 Support for the cdb (Constant DataBase) lookup method is provided by code
751 contributed by Nigel Metheringham of (at the time he contributed it) Planet
752 Online Ltd. The implementation is completely contained within the code of Exim.
753 It does not link against an external cdb library. The code contains the
754 following statements:
755
756 .blockquote
757 Copyright &copy; 1998 Nigel Metheringham, Planet Online Ltd
758
759 This program is free software; you can redistribute it and/or modify it under
760 the terms of the GNU General Public License as published by the Free Software
761 Foundation; either version 2 of the License, or (at your option) any later
762 version.
763 This code implements Dan Bernstein's Constant DataBase (cdb) spec. Information,
764 the spec and sample code for cdb can be obtained from
765 &url(https://cr.yp.to/cdb.html). This implementation borrows
766 some code from Dan Bernstein's implementation (which has no license
767 restrictions applied to it).
768 .endblockquote
769 .next
770 .cindex "SPA authentication"
771 .cindex "Samba project"
772 .cindex "Microsoft Secure Password Authentication"
773 Client support for Microsoft's &'Secure Password Authentication'& is provided
774 by code contributed by Marc Prud'hommeaux. Server support was contributed by
775 Tom Kistner. This includes code taken from the Samba project, which is released
776 under the Gnu GPL.
777 .next
778 .cindex "Cyrus"
779 .cindex "&'pwcheck'& daemon"
780 .cindex "&'pwauthd'& daemon"
781 Support for calling the Cyrus &'pwcheck'& and &'saslauthd'& daemons is provided
782 by code taken from the Cyrus-SASL library and adapted by Alexander S.
783 Sabourenkov. The permission notice appears below, in accordance with the
784 conditions expressed therein.
785
786 .blockquote
787 Copyright &copy; 2001 Carnegie Mellon University.  All rights reserved.
788
789 Redistribution and use in source and binary forms, with or without
790 modification, are permitted provided that the following conditions
791 are met:
792
793 .olist
794 Redistributions of source code must retain the above copyright
795 notice, this list of conditions and the following disclaimer.
796 .next
797 Redistributions in binary form must reproduce the above copyright
798 notice, this list of conditions and the following disclaimer in
799 the documentation and/or other materials provided with the
800 distribution.
801 .next
802 The name &"Carnegie Mellon University"& must not be used to
803 endorse or promote products derived from this software without
804 prior written permission. For permission or any other legal
805 details, please contact
806 .display
807               Office of Technology Transfer
808               Carnegie Mellon University
809               5000 Forbes Avenue
810               Pittsburgh, PA  15213-3890
811               (412) 268-4387, fax: (412) 268-7395
812               tech-transfer@andrew.cmu.edu
813 .endd
814 .next
815 Redistributions of any form whatsoever must retain the following
816 acknowledgment:
817
818 &"This product includes software developed by Computing Services
819 at Carnegie Mellon University (&url(https://www.cmu.edu/computing/)."&
820
821 CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
822 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
823 AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
824 FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
825 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
826 AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
827 OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
828 .endlist
829 .endblockquote
830
831 .next
832 .cindex "Exim monitor" "acknowledgment"
833 .cindex "X-windows"
834 .cindex "Athena"
835 The Exim Monitor program, which is an X-Window application, includes
836 modified versions of the Athena StripChart and TextPop widgets.
837 This code is copyright by DEC and MIT, and their permission notice appears
838 below, in accordance with the conditions expressed therein.
839
840 .blockquote
841 Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
842 and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
843
844 All Rights Reserved
845
846 Permission to use, copy, modify, and distribute this software and its
847 documentation for any purpose and without fee is hereby granted,
848 provided that the above copyright notice appear in all copies and that
849 both that copyright notice and this permission notice appear in
850 supporting documentation, and that the names of Digital or MIT not be
851 used in advertising or publicity pertaining to distribution of the
852 software without specific, written prior permission.
853
854 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
855 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
856 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
857 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
858 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
859 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
860 SOFTWARE.
861 .endblockquote
862
863 .next
864 .cindex "opendmarc" "acknowledgment"
865 The DMARC implementation uses the OpenDMARC library which is Copyrighted by
866 The Trusted Domain Project. Portions of Exim source which use OpenDMARC
867 derived code are indicated in the respective source files. The full OpenDMARC
868 license is provided in the LICENSE.opendmarc file contained in the distributed
869 source code.
870
871 .next
872 Many people have contributed code fragments, some large, some small, that were
873 not covered by any specific license requirements. It is assumed that the
874 contributors are happy to see their code incorporated into Exim under the GPL.
875 .endlist
876
877
878
879
880
881 . ////////////////////////////////////////////////////////////////////////////
882 . ////////////////////////////////////////////////////////////////////////////
883
884 .chapter "How Exim receives and delivers mail" "CHID11" &&&
885          "Receiving and delivering mail"
886
887
888 .section "Overall philosophy" "SECID10"
889 .cindex "design philosophy"
890 Exim is designed to work efficiently on systems that are permanently connected
891 to the Internet and are handling a general mix of mail. In such circumstances,
892 most messages can be delivered immediately. Consequently, Exim does not
893 maintain independent queues of messages for specific domains or hosts, though
894 it does try to send several messages in a single SMTP connection after a host
895 has been down, and it also maintains per-host retry information.
896
897
898 .section "Policy control" "SECID11"
899 .cindex "policy control" "overview"
900 Policy controls are now an important feature of MTAs that are connected to the
901 Internet. Perhaps their most important job is to stop MTAs from being abused as
902 &"open relays"& by misguided individuals who send out vast amounts of
903 unsolicited junk and want to disguise its source. Exim provides flexible
904 facilities for specifying policy controls on incoming mail:
905
906 .ilist
907 .cindex "&ACL;" "introduction"
908 Exim 4 (unlike previous versions of Exim) implements policy controls on
909 incoming mail by means of &'Access Control Lists'& (ACLs). Each list is a
910 series of statements that may either grant or deny access. ACLs can be used at
911 several places in the SMTP dialogue while receiving a message from a remote
912 host. However, the most common places are after each RCPT command, and at the
913 very end of the message. The sysadmin can specify conditions for accepting or
914 rejecting individual recipients or the entire message, respectively, at these
915 two points (see chapter &<<CHAPACL>>&). Denial of access results in an SMTP
916 error code.
917 .next
918 An ACL is also available for locally generated, non-SMTP messages. In this
919 case, the only available actions are to accept or deny the entire message.
920 .next
921 When Exim is compiled with the content-scanning extension, facilities are
922 provided in the ACL mechanism for passing the message to external virus and/or
923 spam scanning software. The result of such a scan is passed back to the ACL,
924 which can then use it to decide what to do with the message.
925 .next
926 When a message has been received, either from a remote host or from the local
927 host, but before the final acknowledgment has been sent, a locally supplied C
928 function called &[local_scan()]& can be run to inspect the message and decide
929 whether to accept it or not (see chapter &<<CHAPlocalscan>>&). If the message
930 is accepted, the list of recipients can be modified by the function.
931 .next
932 Using the &[local_scan()]& mechanism is another way of calling external scanner
933 software. The &%SA-Exim%& add-on package works this way. It does not require
934 Exim to be compiled with the content-scanning extension.
935 .next
936 After a message has been accepted, a further checking mechanism is available in
937 the form of the &'system filter'& (see chapter &<<CHAPsystemfilter>>&). This
938 runs at the start of every delivery process.
939 .endlist
940
941
942
943 .section "User filters" "SECID12"
944 .cindex "filter" "introduction"
945 .cindex "Sieve filter"
946 In a conventional Exim configuration, users are able to run private filters by
947 setting up appropriate &_.forward_& files in their home directories. See
948 chapter &<<CHAPredirect>>& (about the &(redirect)& router) for the
949 configuration needed to support this, and the separate document entitled
950 &'Exim's interfaces to mail filtering'& for user details. Two different kinds
951 of filtering are available:
952
953 .ilist
954 Sieve filters are written in the standard filtering language that is defined
955 by RFC 3028.
956 .next
957 Exim filters are written in a syntax that is unique to Exim, but which is more
958 powerful than Sieve, which it pre-dates.
959 .endlist
960
961 User filters are run as part of the routing process, described below.
962
963
964
965 .section "Message identification" "SECTmessiden"
966 .cindex "message ids" "details of format"
967 .cindex "format" "of message id"
968 .cindex "id of message"
969 .cindex "base62"
970 .cindex "base36"
971 .cindex "Darwin"
972 .cindex "Cygwin"
973 .cindex "exim_msgdate"
974 Every message handled by Exim is given a &'message id'& which is 23
975 characters long. It is divided into three parts, separated by hyphens, for
976 example &`16VDhn-000000001bo-D342`&. Each part is a sequence of letters and digits,
977 normally encoding numbers in base 62. However, in the Darwin operating
978 system (Mac OS X) and when Exim is compiled to run under Cygwin, base 36
979 (avoiding the use of lower case letters) is used instead, because the message
980 id is used to construct filenames, and the names of files in those systems are
981 not always case-sensitive.
982
983 .cindex "pid (process id)" "re-use of"
984 The detail of the contents of the message id have changed as Exim has evolved.
985 Earlier versions relied on the operating system not re-using a process id (pid)
986 within one second. On modern operating systems, this assumption can no longer
987 be made, so the algorithm had to be changed. To retain backward compatibility,
988 the format of the message id was retained, which is why the following rules are
989 somewhat eccentric:
990
991 .ilist
992 The first six characters of the message id are the time at which the message
993 started to be received, to a granularity of one second. That is, this field
994 contains the number of seconds since the start of the epoch (the normal Unix
995 way of representing the date and time of day).
996 .next
997 After the first hyphen, the next
998 eleven
999 characters are the id of the process that received the message.
1000 .next
1001 There are two different possibilities for the final four characters:
1002 .olist
1003 .oindex "&%localhost_number%&"
1004 If &%localhost_number%& is not set, this value is the fractional part of the
1005 time of reception, normally in units of
1006 microseconds.
1007 but for systems
1008 that must use base 36 instead of base 62 (because of case-insensitive file
1009 systems), the units are
1010 2 us.
1011 .next
1012 If &%localhost_number%& is set, it is multiplied by
1013 500000 (250000) and added to
1014 the fractional part of the time, which in this case is in units of 2 us (4 us).
1015 .endlist
1016 .endlist
1017
1018 After a message has been received, Exim waits for the clock to tick at the
1019 appropriate resolution before proceeding, so that if another message is
1020 received by the same process, or by another process with the same (re-used)
1021 pid, it is guaranteed that the time will be different. In most cases, the clock
1022 will already have ticked while the message was being received.
1023
1024 The exim_msgdate utility (see section &<<SECTexim_msgdate>>&) can be
1025 used to display the date, and optionally the process id, of an Exim
1026 Message ID.
1027
1028
1029 .section "Receiving mail" "SECID13"
1030 .cindex "receiving mail"
1031 .cindex "message" "reception"
1032 The only way Exim can receive mail from another host is using SMTP over
1033 TCP/IP, in which case the sender and recipient addresses are transferred using
1034 SMTP commands. However, from a locally running process (such as a user's MUA),
1035 there are several possibilities:
1036
1037 .ilist
1038 If the process runs Exim with the &%-bm%& option, the message is read
1039 non-interactively (usually via a pipe), with the recipients taken from the
1040 command line, or from the body of the message if &%-t%& is also used.
1041 .next
1042 If the process runs Exim with the &%-bS%& option, the message is also read
1043 non-interactively, but in this case the recipients are listed at the start of
1044 the message in a series of SMTP RCPT commands, terminated by a DATA
1045 command. This is called &"batch SMTP"& format,
1046 but it isn't really SMTP. The SMTP commands are just another way of passing
1047 envelope addresses in a non-interactive submission.
1048 .next
1049 If the process runs Exim with the &%-bs%& option, the message is read
1050 interactively, using the SMTP protocol. A two-way pipe is normally used for
1051 passing data between the local process and the Exim process.
1052 This is &"real"& SMTP and is handled in the same way as SMTP over TCP/IP. For
1053 example, the ACLs for SMTP commands are used for this form of submission.
1054 .next
1055 A local process may also make a TCP/IP call to the host's loopback address
1056 (127.0.0.1) or any other of its IP addresses. When receiving messages, Exim
1057 does not treat the loopback address specially. It treats all such connections
1058 in the same way as connections from other hosts.
1059 .endlist
1060
1061
1062 .cindex "message sender, constructed by Exim"
1063 .cindex "sender" "constructed by Exim"
1064 In the three cases that do not involve TCP/IP, the sender address is
1065 constructed from the login name of the user that called Exim and a default
1066 qualification domain (which can be set by the &%qualify_domain%& configuration
1067 option). For local or batch SMTP, a sender address that is passed using the
1068 SMTP MAIL command is ignored. However, the system administrator may allow
1069 certain users (&"trusted users"&) to specify a different sender addresses
1070 unconditionally, or all users to specify certain forms of different sender
1071 address. The &%-f%& option or the SMTP MAIL command is used to specify these
1072 different addresses. See section &<<SECTtrustedadmin>>& for details of trusted
1073 users, and the &%untrusted_set_sender%& option for a way of allowing untrusted
1074 users to change sender addresses.
1075
1076 Messages received by either of the non-interactive mechanisms are subject to
1077 checking by the non-SMTP ACL if one is defined. Messages received using SMTP
1078 (either over TCP/IP or interacting with a local process) can be checked by a
1079 number of ACLs that operate at different times during the SMTP session. Either
1080 individual recipients or the entire message can be rejected if local policy
1081 requirements are not met. The &[local_scan()]& function (see chapter
1082 &<<CHAPlocalscan>>&) is run for all incoming messages.
1083
1084 Exim can be configured not to start a delivery process when a message is
1085 received; this can be unconditional, or depend on the number of incoming SMTP
1086 connections or the system load. In these situations, new messages wait on the
1087 queue until a queue runner process picks them up. However, in standard
1088 configurations under normal conditions, delivery is started as soon as a
1089 message is received.
1090
1091
1092
1093
1094
1095 .section "Handling an incoming message" "SECID14"
1096 .cindex "spool directory" "files that hold a message"
1097 .cindex "file" "how a message is held"
1098 When Exim accepts a message, it writes two files in its spool directory. The
1099 first contains the envelope information, the current status of the message, and
1100 the header lines, and the second contains the body of the message. The names of
1101 the two spool files consist of the message id, followed by &`-H`& for the
1102 file containing the envelope and header, and &`-D`& for the data file.
1103
1104 .cindex "spool directory" "&_input_& sub-directory"
1105 By default, all these message files are held in a single directory called
1106 &_input_& inside the general Exim spool directory. Some operating systems do
1107 not perform very well if the number of files in a directory gets large; to
1108 improve performance in such cases, the &%split_spool_directory%& option can be
1109 used. This causes Exim to split up the input files into 62 sub-directories
1110 whose names are single letters or digits. When this is done, the queue is
1111 processed one sub-directory at a time instead of all at once, which can improve
1112 overall performance even when there are not enough files in each directory to
1113 affect file system performance.
1114
1115 The envelope information consists of the address of the message's sender and
1116 the addresses of the recipients. This information is entirely separate from
1117 any addresses contained in the header lines. The status of the message includes
1118 a list of recipients who have already received the message. The format of the
1119 first spool file is described in chapter &<<CHAPspool>>&.
1120
1121 .cindex "rewriting" "addresses"
1122 Address rewriting that is specified in the rewrite section of the configuration
1123 (see chapter &<<CHAPrewrite>>&) is done once and for all on incoming addresses,
1124 both in the header lines and the envelope, at the time the message is accepted.
1125 If during the course of delivery additional addresses are generated (for
1126 example, via aliasing), these new addresses are rewritten as soon as they are
1127 generated. At the time a message is actually delivered (transported) further
1128 rewriting can take place; because this is a transport option, it can be
1129 different for different forms of delivery. It is also possible to specify the
1130 addition or removal of certain header lines at the time the message is
1131 delivered (see chapters &<<CHAProutergeneric>>& and
1132 &<<CHAPtransportgeneric>>&).
1133
1134
1135
1136 .section "Life of a message" "SECID15"
1137 .cindex "message" "life of"
1138 .cindex "message" "frozen"
1139 A message remains in the spool directory until it is completely delivered to
1140 its recipients or to an error address, or until it is deleted by an
1141 administrator or by the user who originally created it. In cases when delivery
1142 cannot proceed &-- for example when a message can neither be delivered to its
1143 recipients nor returned to its sender, the message is marked &"frozen"& on the
1144 spool, and no more deliveries are attempted.
1145
1146 .cindex "frozen messages" "thawing"
1147 .cindex "message" "thawing frozen"
1148 An administrator can &"thaw"& such messages when the problem has been
1149 corrected, and can also freeze individual messages by hand if necessary. In
1150 addition, an administrator can force a delivery error, causing a bounce message
1151 to be sent.
1152
1153 .oindex "&%timeout_frozen_after%&"
1154 .oindex "&%ignore_bounce_errors_after%&"
1155 There are options called &%ignore_bounce_errors_after%& and
1156 &%timeout_frozen_after%&, which discard frozen messages after a certain time.
1157 The first applies only to frozen bounces, the second to all frozen messages.
1158
1159 .cindex "message" "log file for"
1160 .cindex "log" "file for each message"
1161 While Exim is working on a message, it writes information about each delivery
1162 attempt to its main log file. This includes successful, unsuccessful, and
1163 delayed deliveries for each recipient (see chapter &<<CHAPlog>>&). The log
1164 lines are also written to a separate &'message log'& file for each message.
1165 These logs are solely for the benefit of the administrator and are normally
1166 deleted along with the spool files when processing of a message is complete.
1167 The use of individual message logs can be disabled by setting
1168 &%no_message_logs%&; this might give an improvement in performance on very busy
1169 systems.
1170
1171 .cindex "journal file"
1172 .cindex "file" "journal"
1173 All the information Exim itself needs to set up a delivery is kept in the first
1174 spool file, along with the header lines. When a successful delivery occurs, the
1175 address is immediately written at the end of a journal file, whose name is the
1176 message id followed by &`-J`&. At the end of a delivery run, if there are some
1177 addresses left to be tried again later, the first spool file (the &`-H`& file)
1178 is updated to indicate which these are, and the journal file is then deleted.
1179 Updating the spool file is done by writing a new file and renaming it, to
1180 minimize the possibility of data loss.
1181
1182 Should the system or Exim crash after a successful delivery but before
1183 the spool file has been updated, the journal is left lying around. The next
1184 time Exim attempts to deliver the message, it reads the journal file and
1185 updates the spool file before proceeding. This minimizes the chances of double
1186 deliveries caused by crashes.
1187
1188
1189
1190 .section "Processing an address for delivery" "SECTprocaddress"
1191 .cindex "drivers" "definition of"
1192 .cindex "router" "definition of"
1193 .cindex "transport" "definition of"
1194 The main delivery processing elements of Exim are called &'routers'& and
1195 &'transports'&, and collectively these are known as &'drivers'&. Code for a
1196 number of them is provided in the source distribution, and compile-time options
1197 specify which ones are included in the binary. Runtime options specify which
1198 ones are actually used for delivering messages.
1199
1200 .cindex "drivers" "instance definition"
1201 Each driver that is specified in the runtime configuration is an &'instance'&
1202 of that particular driver type. Multiple instances are allowed; for example,
1203 you can set up several different &(smtp)& transports, each with different
1204 option values that might specify different ports or different timeouts. Each
1205 instance has its own identifying name. In what follows we will normally use the
1206 instance name when discussing one particular instance (that is, one specific
1207 configuration of the driver), and the generic driver name when discussing
1208 the driver's features in general.
1209
1210 A &'router'& is a driver that operates on an address, either determining how
1211 its delivery should happen, by assigning it to a specific transport, or
1212 converting the address into one or more new addresses (for example, via an
1213 alias file). A router may also explicitly choose to fail an address, causing it
1214 to be bounced.
1215
1216 A &'transport'& is a driver that transmits a copy of the message from Exim's
1217 spool to some destination. There are two kinds of transport: for a &'local'&
1218 transport, the destination is a file or a pipe on the local host, whereas for a
1219 &'remote'& transport the destination is some other host. A message is passed
1220 to a specific transport as a result of successful routing. If a message has
1221 several recipients, it may be passed to a number of different transports.
1222
1223 .cindex "preconditions" "definition of"
1224 An address is processed by passing it to each configured router instance in
1225 turn, subject to certain preconditions, until a router accepts the address or
1226 specifies that it should be bounced. We will describe this process in more
1227 detail shortly. First, as a simple example, we consider how each recipient
1228 address in a message is processed in a small configuration of three routers.
1229
1230 To make this a more concrete example, it is described in terms of some actual
1231 routers, but remember, this is only an example. You can configure Exim's
1232 routers in many different ways, and there may be any number of routers in a
1233 configuration.
1234
1235 The first router that is specified in a configuration is often one that handles
1236 addresses in domains that are not recognized specifically by the local host.
1237 Typically these are addresses for arbitrary domains on the Internet. A precondition
1238 is set up which looks for the special domains known to the host (for example,
1239 its own domain name), and the router is run for addresses that do &'not'&
1240 match. Typically, this is a router that looks up domains in the DNS in order to
1241 find the hosts to which this address routes. If it succeeds, the address is
1242 assigned to a suitable SMTP transport; if it does not succeed, the router is
1243 configured to fail the address.
1244
1245 The second router is reached only when the domain is recognized as one that
1246 &"belongs"& to the local host. This router does redirection &-- also known as
1247 aliasing and forwarding. When it generates one or more new addresses from the
1248 original, each of them is routed independently from the start. Otherwise, the
1249 router may cause an address to fail, or it may simply decline to handle the
1250 address, in which case the address is passed to the next router.
1251
1252 The final router in many configurations is one that checks to see if the
1253 address belongs to a local mailbox. The precondition may involve a check to
1254 see if the local part is the name of a login account, or it may look up the
1255 local part in a file or a database. If its preconditions are not met, or if
1256 the router declines, we have reached the end of the routers. When this happens,
1257 the address is bounced.
1258
1259
1260
1261 .section "Processing an address for verification" "SECID16"
1262 .cindex "router" "for verification"
1263 .cindex "verifying address" "overview"
1264 As well as being used to decide how to deliver to an address, Exim's routers
1265 are also used for &'address verification'&. Verification can be requested as
1266 one of the checks to be performed in an ACL for incoming messages, on both
1267 sender and recipient addresses, and it can be tested using the &%-bv%& and
1268 &%-bvs%& command line options.
1269
1270 When an address is being verified, the routers are run in &"verify mode"&. This
1271 does not affect the way the routers work, but it is a state that can be
1272 detected. By this means, a router can be skipped or made to behave differently
1273 when verifying. A common example is a configuration in which the first router
1274 sends all messages to a message-scanning program unless they have been
1275 previously scanned. Thus, the first router accepts all addresses without any
1276 checking, making it useless for verifying. Normally, the &%no_verify%& option
1277 would be set for such a router, causing it to be skipped in verify mode.
1278
1279
1280
1281
1282 .section "Running an individual router" "SECTrunindrou"
1283 .cindex "router" "running details"
1284 .cindex "preconditions" "checking"
1285 .cindex "router" "result of running"
1286 As explained in the example above, a number of preconditions are checked before
1287 running a router. If any are not met, the router is skipped, and the address is
1288 passed to the next router. When all the preconditions on a router &'are'& met,
1289 the router is run. What happens next depends on the outcome, which is one of
1290 the following:
1291
1292 .ilist
1293 &'accept'&: The router accepts the address, and either assigns it to a
1294 transport or generates one or more &"child"& addresses. Processing the
1295 original address ceases
1296 .oindex "&%unseen%&"
1297 unless the &%unseen%& option is set on the router. This option
1298 can be used to set up multiple deliveries with different routing (for example,
1299 for keeping archive copies of messages). When &%unseen%& is set, the address is
1300 passed to the next router. Normally, however, an &'accept'& return marks the
1301 end of routing.
1302
1303 Any child addresses generated by the router are processed independently,
1304 starting with the first router by default. It is possible to change this by
1305 setting the &%redirect_router%& option to specify which router to start at for
1306 child addresses. Unlike &%pass_router%& (see below) the router specified by
1307 &%redirect_router%& may be anywhere in the router configuration.
1308 .next
1309 &'pass'&: The router recognizes the address, but cannot handle it itself. It
1310 requests that the address be passed to another router. By default, the address
1311 is passed to the next router, but this can be changed by setting the
1312 &%pass_router%& option. However, (unlike &%redirect_router%&) the named router
1313 must be below the current router (to avoid loops).
1314 .next
1315 &'decline'&: The router declines to accept the address because it does not
1316 recognize it at all. By default, the address is passed to the next router, but
1317 this can be prevented by setting the &%no_more%& option. When &%no_more%& is
1318 set, all the remaining routers are skipped. In effect, &%no_more%& converts
1319 &'decline'& into &'fail'&.
1320 .next
1321 &'fail'&: The router determines that the address should fail, and queues it for
1322 the generation of a bounce message. There is no further processing of the
1323 original address unless &%unseen%& is set on the router.
1324 .next
1325 &'defer'&: The router cannot handle the address at the present time. (A
1326 database may be offline, or a DNS lookup may have timed out.) No further
1327 processing of the address happens in this delivery attempt. It is tried again
1328 next time the message is considered for delivery.
1329 .next
1330 &'error'&: There is some error in the router (for example, a syntax error in
1331 its configuration). The action is as for defer.
1332 .endlist
1333
1334 If an address reaches the end of the routers without having been accepted by
1335 any of them, it is bounced as unrouteable. The default error message in this
1336 situation is &"unrouteable address"&, but you can set your own message by
1337 making use of the &%cannot_route_message%& option. This can be set for any
1338 router; the value from the last router that &"saw"& the address is used.
1339
1340 Sometimes while routing you want to fail a delivery when some conditions are
1341 met but others are not, instead of passing the address on for further routing.
1342 You can do this by having a second router that explicitly fails the delivery
1343 when the relevant conditions are met. The &(redirect)& router has a &"fail"&
1344 facility for this purpose.
1345
1346
1347 .section "Duplicate addresses" "SECID17"
1348 .cindex "case of local parts"
1349 .cindex "address duplicate, discarding"
1350 .cindex "duplicate addresses"
1351 Once routing is complete, Exim scans the addresses that are assigned to local
1352 and remote transports and discards any duplicates that it finds. During this
1353 check, local parts are treated case-sensitively. This happens only when
1354 actually delivering a message; when testing routers with &%-bt%&, all the
1355 routed addresses are shown.
1356
1357
1358
1359 .section "Router preconditions" "SECTrouprecon"
1360 .cindex "router" "preconditions, order of processing"
1361 .cindex "preconditions" "order of processing"
1362 The preconditions that are tested for each router are listed below, in the
1363 order in which they are tested. The individual configuration options are
1364 described in more detail in chapter &<<CHAProutergeneric>>&.
1365
1366 .olist
1367 .cindex affix "router precondition"
1368 The &%local_part_prefix%& and &%local_part_suffix%& options can specify that
1369 the local parts handled by the router may or must have certain prefixes and/or
1370 suffixes. If a mandatory affix (prefix or suffix) is not present, the router is
1371 skipped. These conditions are tested first. When an affix is present, it is
1372 removed from the local part before further processing, including the evaluation
1373 of any other conditions.
1374 .next
1375 Routers can be designated for use only when not verifying an address, that is,
1376 only when routing it for delivery (or testing its delivery routing). If the
1377 &%verify%& option is set false, the router is skipped when Exim is verifying an
1378 address.
1379 Setting the &%verify%& option actually sets two options, &%verify_sender%& and
1380 &%verify_recipient%&, which independently control the use of the router for
1381 sender and recipient verification. You can set these options directly if
1382 you want a router to be used for only one type of verification.
1383 Note that cutthrough delivery is classed as a recipient verification for this purpose.
1384 .next
1385 If the &%address_test%& option is set false, the router is skipped when Exim is
1386 run with the &%-bt%& option to test an address routing. This can be helpful
1387 when the first router sends all new messages to a scanner of some sort; it
1388 makes it possible to use &%-bt%& to test subsequent delivery routing without
1389 having to simulate the effect of the scanner.
1390 .next
1391 Routers can be designated for use only when verifying an address, as
1392 opposed to routing it for delivery. The &%verify_only%& option controls this.
1393 Again, cutthrough delivery counts as a verification.
1394 .next
1395 Individual routers can be explicitly skipped when running the routers to
1396 check an address given in the SMTP EXPN command (see the &%expn%& option).
1397
1398 .next
1399 If the &%domains%& option is set, the domain of the address must be in the set
1400 of domains that it defines.
1401 .cindex "tainted data" "de-tainting"
1402 .cindex "de-tainting" "using router domains option"
1403 A match verifies the variable &$domain$& (which carries tainted data)
1404 and assigns an untainted value to the &$domain_data$& variable.
1405 Such an untainted value is often needed in the transport.
1406 For specifics of the matching operation and the resulting untainted value,
1407 refer to section &<<SECTdomainlist>>&.
1408
1409 When an untainted value is wanted, use this option
1410 rather than the generic &%condition%& option.
1411
1412 .next
1413 .vindex "&$local_part_prefix$&"
1414 .vindex "&$local_part_prefix_v$&"
1415 .vindex "&$local_part$&"
1416 .vindex "&$local_part_suffix$&"
1417 .vindex "&$local_part_suffix_v$&"
1418 .cindex affix "router precondition"
1419 If the &%local_parts%& option is set, the local part of the address must be in
1420 the set of local parts that it defines.
1421 A match verifies the variable &$local_part$& (which carries tainted data)
1422 and assigns an untainted value to the &$local_part_data$& variable.
1423 Such an untainted value is often needed in the transport.
1424 For specifics of the matching operation and the resulting untainted value,
1425 refer to section &<<SECTlocparlis>>&.
1426
1427 When an untainted value is wanted, use this option
1428 rather than the generic &%condition%& option.
1429
1430 If &%local_part_prefix%& or
1431 &%local_part_suffix%& is in use, the prefix or suffix is removed from the local
1432 part before this check. If you want to do precondition tests on local parts
1433 that include affixes, you can do so by using a &%condition%& option (see below)
1434 that uses the variables &$local_part$&, &$local_part_prefix$&,
1435 &$local_part_prefix_v$&, &$local_part_suffix$&
1436 and &$local_part_suffix_v$& as necessary.
1437
1438 .next
1439 .vindex "&$local_user_uid$&"
1440 .vindex "&$local_user_gid$&"
1441 .vindex "&$home$&"
1442 If the &%check_local_user%& option is set, the local part must be the name of
1443 an account on the local host. If this check succeeds, the uid and gid of the
1444 local user are placed in &$local_user_uid$& and &$local_user_gid$& and the
1445 user's home directory is placed in &$home$&; these values can be used in the
1446 remaining preconditions.
1447
1448 .next
1449 If the &%router_home_directory%& option is set, it is expanded at this point,
1450 because it overrides the value of &$home$&. If this expansion were left till
1451 later, the value of &$home$& as set by &%check_local_user%& would be used in
1452 subsequent tests. Having two different values of &$home$& in the same router
1453 could lead to confusion.
1454
1455 .next
1456 If the &%senders%& option is set, the envelope sender address must be in the
1457 set of addresses that it defines.
1458
1459 .next
1460 If the &%require_files%& option is set, the existence or non-existence of
1461 specified files is tested.
1462
1463 .next
1464 .cindex "customizing" "precondition"
1465 If the &%condition%& option is set, it is evaluated and tested. This option
1466 uses an expanded string to allow you to set up your own custom preconditions.
1467 Expanded strings are described in chapter &<<CHAPexpand>>&.
1468
1469 Note that while using
1470 this option for address matching technically works,
1471 it does not set any de-tainted values.
1472 Such values are often needed, either for router-specific options or
1473 for transport options.
1474 Using the &%domains%& and &%local_parts%& options is usually the most
1475 convenient way to obtain them.
1476 .endlist
1477
1478
1479 Note that &%require_files%& comes near the end of the list, so you cannot use
1480 it to check for the existence of a file in which to lookup up a domain, local
1481 part, or sender. However, as these options are all expanded, you can use the
1482 &%exists%& expansion condition to make such tests within each condition. The
1483 &%require_files%& option is intended for checking files that the router may be
1484 going to use internally, or which are needed by a specific transport (for
1485 example, &_.procmailrc_&).
1486
1487
1488
1489 .section "Delivery in detail" "SECID18"
1490 .cindex "delivery" "in detail"
1491 When a message is to be delivered, the sequence of events is as follows:
1492
1493 .olist
1494 If a system-wide filter file is specified, the message is passed to it. The
1495 filter may add recipients to the message, replace the recipients, discard the
1496 message, cause a new message to be generated, or cause the message delivery to
1497 fail. The format of the system filter file is the same as for Exim user filter
1498 files, described in the separate document entitled &'Exim's interfaces to mail
1499 filtering'&.
1500 .cindex "Sieve filter" "not available for system filter"
1501 (&*Note*&: Sieve cannot be used for system filter files.)
1502
1503 Some additional features are available in system filters &-- see chapter
1504 &<<CHAPsystemfilter>>& for details. Note that a message is passed to the system
1505 filter only once per delivery attempt, however many recipients it has. However,
1506 if there are several delivery attempts because one or more addresses could not
1507 be immediately delivered, the system filter is run each time. The filter
1508 condition &%first_delivery%& can be used to detect the first run of the system
1509 filter.
1510 .next
1511 Each recipient address is offered to each configured router, in turn, subject to
1512 its preconditions, until one is able to handle it. If no router can handle the
1513 address, that is, if they all decline, the address is failed. Because routers
1514 can be targeted at particular domains, several locally handled domains can be
1515 processed entirely independently of each other.
1516 .next
1517 .cindex "routing" "loops in"
1518 .cindex "loop" "while routing"
1519 A router that accepts an address may assign it to a local or a remote
1520 transport. However, the transport is not run at this time. Instead, the address
1521 is placed on a list for the particular transport, which will be run later.
1522 Alternatively, the router may generate one or more new addresses (typically
1523 from alias, forward, or filter files). New addresses are fed back into this
1524 process from the top, but in order to avoid loops, a router ignores any address
1525 which has an identically-named ancestor that was processed by itself.
1526 .next
1527 When all the routing has been done, addresses that have been successfully
1528 handled are passed to their assigned transports. When local transports are
1529 doing real local deliveries, they handle only one address at a time, but if a
1530 local transport is being used as a pseudo-remote transport (for example, to
1531 collect batched SMTP messages for transmission by some other means) multiple
1532 addresses can be handled. Remote transports can always handle more than one
1533 address at a time, but can be configured not to do so, or to restrict multiple
1534 addresses to the same domain.
1535 .next
1536 Each local delivery to a file or a pipe runs in a separate process under a
1537 non-privileged uid, and these deliveries are run one at a time. Remote
1538 deliveries also run in separate processes, normally under a uid that is private
1539 to Exim (&"the Exim user"&), but in this case, several remote deliveries can be
1540 run in parallel. The maximum number of simultaneous remote deliveries for any
1541 one message is set by the &%remote_max_parallel%& option.
1542 The order in which deliveries are done is not defined, except that all local
1543 deliveries happen before any remote deliveries.
1544 .next
1545 .cindex "queue runner"
1546 When it encounters a local delivery during a queue run, Exim checks its retry
1547 database to see if there has been a previous temporary delivery failure for the
1548 address before running the local transport. If there was a previous failure,
1549 Exim does not attempt a new delivery until the retry time for the address is
1550 reached. However, this happens only for delivery attempts that are part of a
1551 queue run. Local deliveries are always attempted when delivery immediately
1552 follows message reception, even if retry times are set for them. This makes for
1553 better behaviour if one particular message is causing problems (for example,
1554 causing quota overflow, or provoking an error in a filter file).
1555 .next
1556 .cindex "delivery" "retry in remote transports"
1557 Remote transports do their own retry handling, since an address may be
1558 deliverable to one of a number of hosts, each of which may have a different
1559 retry time. If there have been previous temporary failures and no host has
1560 reached its retry time, no delivery is attempted, whether in a queue run or
1561 not. See chapter &<<CHAPretry>>& for details of retry strategies.
1562 .next
1563 If there were any permanent errors, a bounce message is returned to an
1564 appropriate address (the sender in the common case), with details of the error
1565 for each failing address. Exim can be configured to send copies of bounce
1566 messages to other addresses.
1567 .next
1568 .cindex "delivery" "deferral"
1569 If one or more addresses suffered a temporary failure, the message is left on
1570 the queue, to be tried again later. Delivery of these addresses is said to be
1571 &'deferred'&.
1572 .next
1573 When all the recipient addresses have either been delivered or bounced,
1574 handling of the message is complete. The spool files and message log are
1575 deleted, though the message log can optionally be preserved if required.
1576 .endlist
1577
1578
1579
1580
1581 .section "Retry mechanism" "SECID19"
1582 .cindex "delivery" "retry mechanism"
1583 .cindex "retry" "description of mechanism"
1584 .cindex "queue runner"
1585 Exim's mechanism for retrying messages that fail to get delivered at the first
1586 attempt is the queue runner process. You must either run an Exim daemon that
1587 uses the &%-q%& option with a time interval to start queue runners at regular
1588 intervals or use some other means (such as &'cron'&) to start them. If you do
1589 not arrange for queue runners to be run, messages that fail temporarily at the
1590 first attempt will remain in your queue forever. A queue runner process works
1591 its way through the queue, one message at a time, trying each delivery that has
1592 passed its retry time.
1593 You can run several queue runners at once.
1594
1595 Exim uses a set of configured rules to determine when next to retry the failing
1596 address (see chapter &<<CHAPretry>>&). These rules also specify when Exim
1597 should give up trying to deliver to the address, at which point it generates a
1598 bounce message. If no retry rules are set for a particular host, address, and
1599 error combination, no retries are attempted, and temporary errors are treated
1600 as permanent.
1601
1602
1603
1604 .subsection "Temporary delivery failure" SECID20
1605 .cindex "delivery" "temporary failure"
1606 There are many reasons why a message may not be immediately deliverable to a
1607 particular address. Failure to connect to a remote machine (because it, or the
1608 connection to it, is down) is one of the most common. Temporary failures may be
1609 detected during routing as well as during the transport stage of delivery.
1610 Local deliveries may be delayed if NFS files are unavailable, or if a mailbox
1611 is on a file system where the user is over quota. Exim can be configured to
1612 impose its own quotas on local mailboxes; where system quotas are set they will
1613 also apply.
1614
1615 If a host is unreachable for a period of time, a number of messages may be
1616 waiting for it by the time it recovers, and sending them in a single SMTP
1617 connection is clearly beneficial. Whenever a delivery to a remote host is
1618 deferred,
1619 .cindex "hints database" "deferred deliveries"
1620 Exim makes a note in its hints database, and whenever a successful
1621 SMTP delivery has happened, it looks to see if any other messages are waiting
1622 for the same host. If any are found, they are sent over the same SMTP
1623 connection, subject to a configuration limit as to the maximum number in any
1624 one connection.
1625
1626
1627
1628 .subsection "Permanent delivery failure" SECID21
1629 .cindex "delivery" "permanent failure"
1630 .cindex "bounce message" "when generated"
1631 When a message cannot be delivered to some or all of its intended recipients, a
1632 bounce message is generated. Temporary delivery failures turn into permanent
1633 errors when their timeout expires. All the addresses that fail in a given
1634 delivery attempt are listed in a single message. If the original message has
1635 many recipients, it is possible for some addresses to fail in one delivery
1636 attempt and others to fail subsequently, giving rise to more than one bounce
1637 message. The wording of bounce messages can be customized by the administrator.
1638 See chapter &<<CHAPemsgcust>>& for details.
1639
1640 .cindex "&'X-Failed-Recipients:'& header line"
1641 Bounce messages contain an &'X-Failed-Recipients:'& header line that lists the
1642 failed addresses, for the benefit of programs that try to analyse such messages
1643 automatically.
1644
1645 .cindex "bounce message" "recipient of"
1646 A bounce message is normally sent to the sender of the original message, as
1647 obtained from the message's envelope. For incoming SMTP messages, this is the
1648 address given in the MAIL command. However, when an address is expanded via a
1649 forward or alias file, an alternative address can be specified for delivery
1650 failures of the generated addresses. For a mailing list expansion (see section
1651 &<<SECTmailinglists>>&) it is common to direct bounce messages to the manager
1652 of the list.
1653
1654
1655
1656 .subsection "Failures to deliver bounce messages" SECID22
1657 .cindex "bounce message" "failure to deliver"
1658 If a bounce message (either locally generated or received from a remote host)
1659 itself suffers a permanent delivery failure, the message is left in the queue,
1660 but it is frozen, awaiting the attention of an administrator. There are options
1661 that can be used to make Exim discard such failed messages, or to keep them
1662 for only a short time (see &%timeout_frozen_after%& and
1663 &%ignore_bounce_errors_after%&).
1664
1665
1666
1667
1668
1669 . ////////////////////////////////////////////////////////////////////////////
1670 . ////////////////////////////////////////////////////////////////////////////
1671
1672 .chapter "Building and installing Exim" "CHID3"
1673 .scindex IIDbuex "building Exim"
1674
1675 .section "Unpacking" "SECID23"
1676 Exim is distributed as a gzipped or bzipped tar file which, when unpacked,
1677 creates a directory with the name of the current release (for example,
1678 &_exim-&version()_&) into which the following files are placed:
1679
1680 .table2 140pt
1681 .irow &_ACKNOWLEDGMENTS_& "contains some acknowledgments"
1682 .irow &_CHANGES_&         "contains a reference to where changes are &&&
1683   documented"
1684 .irow &_LICENCE_&         "the GNU General Public Licence"
1685 .irow &_Makefile_&        "top-level make file"
1686 .irow &_NOTICE_&          "conditions for the use of Exim"
1687 .irow &_README_&          "list of files, directories and simple build &&&
1688   instructions"
1689 .endtable
1690
1691 Other files whose names begin with &_README_& may also be present. The
1692 following subdirectories are created:
1693
1694 .table2 140pt
1695 .irow &_Local_&           "an empty directory for local configuration files"
1696 .irow &_OS_&              "OS-specific files"
1697 .irow &_doc_&             "documentation files"
1698 .irow &_exim_monitor_&    "source files for the Exim monitor"
1699 .irow &_scripts_&         "scripts used in the build process"
1700 .irow &_src_&             "remaining source files"
1701 .irow &_util_&            "independent utilities"
1702 .endtable
1703
1704 The main utility programs are contained in the &_src_& directory and are built
1705 with the Exim binary. The &_util_& directory contains a few optional scripts
1706 that may be useful to some sites.
1707
1708
1709 .section "Multiple machine architectures and operating systems" "SECID24"
1710 .cindex "building Exim" "multiple OS/architectures"
1711 The building process for Exim is arranged to make it easy to build binaries for
1712 a number of different architectures and operating systems from the same set of
1713 source files. Compilation does not take place in the &_src_& directory.
1714 Instead, a &'build directory'& is created for each architecture and operating
1715 system.
1716 .cindex "symbolic link" "to build directory"
1717 Symbolic links to the sources are installed in this directory, which is where
1718 the actual building takes place. In most cases, Exim can discover the machine
1719 architecture and operating system for itself, but the defaults can be
1720 overridden if necessary.
1721 .cindex compiler requirements
1722 .cindex compiler version
1723 A C99-capable compiler will be required for the build.
1724
1725
1726 .section "PCRE2 library" "SECTpcre"
1727 .cindex "PCRE2 library"
1728 Exim no longer has an embedded regular-expression library as the vast majority of
1729 modern systems include PCRE2 as a system library, although you may need to
1730 install the PCRE2 package or the PCRE2 development package for your operating
1731 system. If your system has a normal PCRE2 installation the Exim build
1732 process will need no further configuration. If the library or the
1733 headers are in an unusual location you will need to either set the PCRE2_LIBS
1734 and INCLUDE directives appropriately,
1735 or set PCRE2_CONFIG=yes to use the installed &(pcre-config)& command.
1736 If your operating system has no
1737 PCRE2 support then you will need to obtain and build the current PCRE2
1738 from &url(https://github.com/PhilipHazel/pcre2/releases).
1739 More information on PCRE2 is available at &url(https://www.pcre.org/).
1740
1741 .section "DBM libraries" "SECTdb"
1742 .cindex "DBM libraries" "discussion of"
1743 .cindex "hints database" "DBM files used for"
1744 Even if you do not use any DBM files in your configuration, Exim still needs a
1745 DBM library in order to operate, because it uses indexed files for its hints
1746 databases. Unfortunately, there are a number of DBM libraries in existence, and
1747 different operating systems often have different ones installed.
1748
1749 .cindex "Solaris" "DBM library for"
1750 .cindex "IRIX, DBM library for"
1751 .cindex "BSD, DBM library for"
1752 .cindex "Linux, DBM library for"
1753 If you are using Solaris, IRIX, one of the modern BSD systems, or a modern
1754 Linux distribution, the DBM configuration should happen automatically, and you
1755 may be able to ignore this section. Otherwise, you may have to learn more than
1756 you would like about DBM libraries from what follows.
1757
1758 .cindex "&'ndbm'& DBM library"
1759 Licensed versions of Unix normally contain a library of DBM functions operating
1760 via the &'ndbm'& interface, and this is what Exim expects by default. Free
1761 versions of Unix seem to vary in what they contain as standard. In particular,
1762 some early versions of Linux have no default DBM library, and different
1763 distributors have chosen to bundle different libraries with their packaged
1764 versions. However, the more recent releases seem to have standardized on the
1765 Berkeley DB library.
1766
1767 .new
1768 Ownership of the Berkeley DB library has moved to a major corporation;
1769 development seems to have stalled and documentation is not freely available.
1770 This is probably not tenable for the long term use by Exim.
1771 .wen
1772
1773 Different DBM libraries have different conventions for naming the files they
1774 use. When a program opens a file called &_dbmfile_&, there are several
1775 possibilities:
1776
1777 .olist
1778 A traditional &'ndbm'& implementation, such as that supplied as part of
1779 Solaris, operates on two files called &_dbmfile.dir_& and &_dbmfile.pag_&.
1780 .next
1781 .cindex "&'gdbm'& DBM library"
1782 The GNU library, &'gdbm'&, operates on a single file. If used via its &'ndbm'&
1783 compatibility interface it makes two different hard links to it with names
1784 &_dbmfile.dir_& and &_dbmfile.pag_&, but if used via its native interface, the
1785 filename is used unmodified.
1786 .next
1787 .cindex "Berkeley DB library"
1788 The Berkeley DB package, if called via its &'ndbm'& compatibility interface,
1789 operates on a single file called &_dbmfile.db_&, but otherwise looks to the
1790 programmer exactly the same as the traditional &'ndbm'& implementation.
1791 .next
1792 If the Berkeley package is used in its native mode, it operates on a single
1793 file called &_dbmfile_&; the programmer's interface is somewhat different to
1794 the traditional &'ndbm'& interface.
1795 .next
1796 To complicate things further, there are several very different versions of the
1797 Berkeley DB package. Version 1.85 was stable for a very long time, releases
1798 2.&'x'& and 3.&'x'& were current for a while,
1799 but the latest versions when Exim last revamped support were numbered 5.&'x'&.
1800 Maintenance of some of the earlier releases has ceased,
1801 and Exim no longer supports versions before 3.&'x'&.
1802 All versions of Berkeley DB could be obtained from
1803 &url(http://www.sleepycat.com/), which is now a redirect to their new owner's
1804 page with far newer versions listed.
1805 It is probably wise to plan to move your storage configurations away from
1806 Berkeley DB format, as today there are smaller and simpler alternatives more
1807 suited to Exim's usage model.
1808 .next
1809 .cindex "&'tdb'& DBM library"
1810 Yet another DBM library, called &'tdb'&, is available from
1811 &url(https://sourceforge.net/projects/tdb/files/). It has its own interface, and also
1812 operates on a single file.
1813 .next
1814 It is possible to use sqlite3 (&url(https://www.sqlite.org/index.html))
1815 for the DBM library.
1816 .endlist
1817
1818 .cindex "USE_DB"
1819 .cindex "DBM libraries" "configuration for building"
1820 Exim and its utilities can be compiled to use any of these interfaces. In order
1821 to use any version of the Berkeley DB package in native mode, you must set
1822 USE_DB in an appropriate configuration file (typically
1823 &_Local/Makefile_&). For example:
1824 .code
1825 USE_DB=yes
1826 .endd
1827 Similarly, for gdbm you set USE_GDBM, for tdb you set USE_TDB,
1828 and for sqlite3 you set USE_SQLITE.
1829 An error is diagnosed if you set more than one of these.
1830 You can set USE_NDBM if needed to override an operating system default.
1831
1832 At the lowest level, the build-time configuration sets none of these options,
1833 thereby assuming an interface of type (1). However, some operating system
1834 configuration files (for example, those for the BSD operating systems and
1835 Linux) assume type (4) by setting USE_DB as their default, and the
1836 configuration files for Cygwin set USE_GDBM. Anything you set in
1837 &_Local/Makefile_&, however, overrides these system defaults.
1838
1839 As well as setting USE_DB, USE_GDBM, or USE_TDB, it may also be
1840 necessary to set DBMLIB, to cause inclusion of the appropriate library, as
1841 in one of these lines:
1842 .code
1843 DBMLIB = -ldb
1844 DBMLIB = -ltdb
1845 DBMLIB = -lsqlite3
1846 DBMLIB = -lgdbm -lgdbm_compat
1847 .endd
1848 The last of those was for a Linux having GDBM provide emulated NDBM facilities.
1849 Settings like that will work if the DBM library is installed in the standard
1850 place. Sometimes it is not, and the library's header file may also not be in
1851 the default path. You may need to set INCLUDE to specify where the header
1852 file is, and to specify the path to the library more fully in DBMLIB, as in
1853 this example:
1854 .code
1855 INCLUDE=-I/usr/local/include/db-4.1
1856 DBMLIB=/usr/local/lib/db-4.1/libdb.a
1857 .endd
1858 There is further detailed discussion about the various DBM libraries in the
1859 file &_doc/dbm.discuss.txt_& in the Exim distribution.
1860
1861 .new
1862 When moving from one DBM library to another,
1863 for the hints databases it suffices to just remove all the files in the
1864 directory named &"db/"& under the spool directory.
1865 This is because hints are only for optimisation and will be rebuilt
1866 during normal operations.
1867 Non-hints DBM databases (used by &"dbm"& lookups in the configuration)
1868 will need individual rebuilds for the new DBM library.
1869 This is not done automatically
1870 .wen
1871
1872
1873
1874 .section "Pre-building configuration" "SECID25"
1875 .cindex "building Exim" "pre-building configuration"
1876 .cindex "configuration for building Exim"
1877 .cindex "&_Local/Makefile_&"
1878 .cindex "&_src/EDITME_&"
1879 Before building Exim, a local configuration file that specifies options
1880 independent of any operating system has to be created with the name
1881 &_Local/Makefile_&. A template for this file is supplied as the file
1882 &_src/EDITME_&, and it contains full descriptions of all the option settings
1883 therein. These descriptions are therefore not repeated here. If you are
1884 building Exim for the first time, the simplest thing to do is to copy
1885 &_src/EDITME_& to &_Local/Makefile_&, then read it and edit it appropriately.
1886
1887 There are three settings that you must supply, because Exim will not build
1888 without them. They are the location of the runtime configuration file
1889 (CONFIGURE_FILE), the directory in which Exim binaries will be installed
1890 (BIN_DIRECTORY), and the identity of the Exim user (EXIM_USER and
1891 maybe EXIM_GROUP as well). The value of CONFIGURE_FILE can in fact be
1892 a colon-separated list of filenames; Exim uses the first of them that exists.
1893
1894 There are a few other parameters that can be specified either at build time or
1895 at runtime, to enable the same binary to be used on a number of different
1896 machines. However, if the locations of Exim's spool directory and log file
1897 directory (if not within the spool directory) are fixed, it is recommended that
1898 you specify them in &_Local/Makefile_& instead of at runtime, so that errors
1899 detected early in Exim's execution (such as a malformed configuration file) can
1900 be logged.
1901
1902 .cindex "content scanning" "specifying at build time"
1903 Exim's interfaces for calling virus and spam scanning software directly from
1904 access control lists are not compiled by default. If you want to include these
1905 facilities, you need to set
1906 .code
1907 WITH_CONTENT_SCAN=yes
1908 .endd
1909 in your &_Local/Makefile_&. For details of the facilities themselves, see
1910 chapter &<<CHAPexiscan>>&.
1911
1912
1913 .cindex "&_Local/eximon.conf_&"
1914 .cindex "&_exim_monitor/EDITME_&"
1915 If you are going to build the Exim monitor, a similar configuration process is
1916 required. The file &_exim_monitor/EDITME_& must be edited appropriately for
1917 your installation and saved under the name &_Local/eximon.conf_&. If you are
1918 happy with the default settings described in &_exim_monitor/EDITME_&,
1919 &_Local/eximon.conf_& can be empty, but it must exist.
1920
1921 This is all the configuration that is needed in straightforward cases for known
1922 operating systems. However, the building process is set up so that it is easy
1923 to override options that are set by default or by operating-system-specific
1924 configuration files, for example, to change the C compiler, which
1925 defaults to &%gcc%&. See section &<<SECToverride>>& below for details of how to
1926 do this.
1927
1928
1929
1930 .section "Support for iconv()" "SECID26"
1931 .cindex "&[iconv()]& support"
1932 .cindex "RFC 2047"
1933 The contents of header lines in messages may be encoded according to the rules
1934 described RFC 2047. This makes it possible to transmit characters that are not
1935 in the ASCII character set, and to label them as being in a particular
1936 character set. When Exim is inspecting header lines by means of the &%$h_%&
1937 mechanism, it decodes them, and translates them into a specified character set
1938 (default is set at build time). The translation is possible only if the operating system
1939 supports the &[iconv()]& function.
1940
1941 However, some of the operating systems that supply &[iconv()]& do not support
1942 very many conversions. The GNU &%libiconv%& library (available from
1943 &url(https://www.gnu.org/software/libiconv/)) can be installed on such
1944 systems to remedy this deficiency, as well as on systems that do not supply
1945 &[iconv()]& at all. After installing &%libiconv%&, you should add
1946 .code
1947 HAVE_ICONV=yes
1948 .endd
1949 to your &_Local/Makefile_& and rebuild Exim.
1950
1951
1952
1953 .section "Including TLS/SSL encryption support" "SECTinctlsssl"
1954 .cindex "TLS" "including support for TLS"
1955 .cindex "encryption" "including support for"
1956 .cindex "OpenSSL" "building Exim with"
1957 .cindex "GnuTLS" "building Exim with"
1958 Exim is usually built to support encrypted SMTP connections, using the STARTTLS
1959 command as per RFC 2487. It can also support clients that expect to
1960 start a TLS session immediately on connection to a non-standard port (see the
1961 &%tls_on_connect_ports%& runtime option and the &%-tls-on-connect%& command
1962 line option).
1963
1964 If you want to build Exim with TLS support, you must first install either the
1965 OpenSSL or GnuTLS library. There is no cryptographic code in Exim itself for
1966 implementing SSL.
1967
1968 If you do not want TLS support you should set
1969 .code
1970 DISABLE_TLS=yes
1971 .endd
1972 in &_Local/Makefile_&.
1973
1974 If OpenSSL is installed, you should set
1975 .code
1976 USE_OPENSL=yes
1977 TLS_LIBS=-lssl -lcrypto
1978 .endd
1979 in &_Local/Makefile_&. You may also need to specify the locations of the
1980 OpenSSL library and include files. For example:
1981 .code
1982 USE_OPENSSL=yes
1983 TLS_LIBS=-L/usr/local/openssl/lib -lssl -lcrypto
1984 TLS_INCLUDE=-I/usr/local/openssl/include/
1985 .endd
1986 .cindex "pkg-config" "OpenSSL"
1987 If you have &'pkg-config'& available, then instead you can just use:
1988 .code
1989 USE_OPENSSL=yes
1990 USE_OPENSSL_PC=openssl
1991 .endd
1992 .cindex "USE_GNUTLS"
1993 If GnuTLS is installed, you should set
1994 .code
1995 USE_GNUTLS=yes
1996 TLS_LIBS=-lgnutls -ltasn1 -lgcrypt
1997 .endd
1998 in &_Local/Makefile_&, and again you may need to specify the locations of the
1999 library and include files. For example:
2000 .code
2001 USE_GNUTLS=yes
2002 TLS_LIBS=-L/usr/gnu/lib -lgnutls -ltasn1 -lgcrypt
2003 TLS_INCLUDE=-I/usr/gnu/include
2004 .endd
2005 .cindex "pkg-config" "GnuTLS"
2006 If you have &'pkg-config'& available, then instead you can just use:
2007 .code
2008 USE_GNUTLS=yes
2009 USE_GNUTLS_PC=gnutls
2010 .endd
2011
2012 You do not need to set TLS_INCLUDE if the relevant directory is already
2013 specified in INCLUDE. Details of how to configure Exim to make use of TLS are
2014 given in chapter &<<CHAPTLS>>&.
2015
2016
2017
2018
2019 .section "Use of tcpwrappers" "SECID27"
2020
2021 .cindex "tcpwrappers, building Exim to support"
2022 .cindex "USE_TCP_WRAPPERS"
2023 .cindex "TCP_WRAPPERS_DAEMON_NAME"
2024 .cindex "tcp_wrappers_daemon_name"
2025 Exim can be linked with the &'tcpwrappers'& library in order to check incoming
2026 SMTP calls using the &'tcpwrappers'& control files. This may be a convenient
2027 alternative to Exim's own checking facilities for installations that are
2028 already making use of &'tcpwrappers'& for other purposes. To do this, you
2029 should set USE_TCP_WRAPPERS in &_Local/Makefile_&, arrange for the file
2030 &_tcpd.h_& to be available at compile time, and also ensure that the library
2031 &_libwrap.a_& is available at link time, typically by including &%-lwrap%& in
2032 EXTRALIBS_EXIM. For example, if &'tcpwrappers'& is installed in &_/usr/local_&,
2033 you might have
2034 .code
2035 USE_TCP_WRAPPERS=yes
2036 CFLAGS=-O -I/usr/local/include
2037 EXTRALIBS_EXIM=-L/usr/local/lib -lwrap
2038 .endd
2039 in &_Local/Makefile_&. The daemon name to use in the &'tcpwrappers'& control
2040 files is &"exim"&. For example, the line
2041 .code
2042 exim : LOCAL  192.168.1.  .friendly.domain.example
2043 .endd
2044 in your &_/etc/hosts.allow_& file allows connections from the local host, from
2045 the subnet 192.168.1.0/24, and from all hosts in &'friendly.domain.example'&.
2046 All other connections are denied. The daemon name used by &'tcpwrappers'&
2047 can be changed at build time by setting TCP_WRAPPERS_DAEMON_NAME in
2048 &_Local/Makefile_&, or by setting tcp_wrappers_daemon_name in the
2049 configure file. Consult the &'tcpwrappers'& documentation for
2050 further details.
2051
2052
2053 .section "Including support for IPv6" "SECID28"
2054 .cindex "IPv6" "including support for"
2055 Exim contains code for use on systems that have IPv6 support. Setting
2056 &`HAVE_IPV6=YES`& in &_Local/Makefile_& causes the IPv6 code to be included;
2057 it may also be necessary to set IPV6_INCLUDE and IPV6_LIBS on systems
2058 where the IPv6 support is not fully integrated into the normal include and
2059 library files.
2060
2061 Two different types of DNS record for handling IPv6 addresses have been
2062 defined. AAAA records (analogous to A records for IPv4) are in use, and are
2063 currently seen as the mainstream. Another record type called A6 was proposed
2064 as better than AAAA because it had more flexibility. However, it was felt to be
2065 over-complex, and its status was reduced to &"experimental"&.
2066 Exim used to
2067 have a compile option for including A6 record support but this has now been
2068 withdrawn.
2069
2070
2071
2072 .section "Dynamically loaded lookup module support" "SECTdynamicmodules"
2073 .cindex "lookup modules"
2074 .cindex "dynamic modules"
2075 .cindex ".so building"
2076 On some platforms, Exim supports not compiling all lookup types directly into
2077 the main binary, instead putting some into external modules which can be loaded
2078 on demand.
2079 This permits packagers to build Exim with support for lookups with extensive
2080 library dependencies without requiring all users to install all of those
2081 dependencies.
2082 Most, but not all, lookup types can be built this way.
2083
2084 Set &`LOOKUP_MODULE_DIR`& to the directory into which the modules will be
2085 installed; Exim will only load modules from that directory, as a security
2086 measure.  You will need to set &`CFLAGS_DYNAMIC`& if not already defined
2087 for your OS; see &_OS/Makefile-Linux_& for an example.
2088 Some other requirements for adjusting &`EXTRALIBS`& may also be necessary,
2089 see &_src/EDITME_& for details.
2090
2091 Then, for each module to be loaded dynamically, define the relevant
2092 &`LOOKUP_`&<&'lookup_type'&> flags to have the value "2" instead of "yes".
2093 For example, this will build in lsearch but load sqlite and mysql support
2094 on demand:
2095 .code
2096 LOOKUP_LSEARCH=yes
2097 LOOKUP_SQLITE=2
2098 LOOKUP_MYSQL=2
2099 .endd
2100
2101
2102 .section "The building process" "SECID29"
2103 .cindex "build directory"
2104 Once &_Local/Makefile_& (and &_Local/eximon.conf_&, if required) have been
2105 created, run &'make'& at the top level. It determines the architecture and
2106 operating system types, and creates a build directory if one does not exist.
2107 For example, on a Sun system running Solaris 8, the directory
2108 &_build-SunOS5-5.8-sparc_& is created.
2109 .cindex "symbolic link" "to source files"
2110 Symbolic links to relevant source files are installed in the build directory.
2111
2112 If this is the first time &'make'& has been run, it calls a script that builds
2113 a make file inside the build directory, using the configuration files from the
2114 &_Local_& directory. The new make file is then passed to another instance of
2115 &'make'&. This does the real work, building a number of utility scripts, and
2116 then compiling and linking the binaries for the Exim monitor (if configured), a
2117 number of utility programs, and finally Exim itself. The command &`make
2118 makefile`& can be used to force a rebuild of the make file in the build
2119 directory, should this ever be necessary.
2120
2121 If you have problems building Exim, check for any comments there may be in the
2122 &_README_& file concerning your operating system, and also take a look at the
2123 FAQ, where some common problems are covered.
2124
2125
2126
2127 .section 'Output from &"make"&' "SECID283"
2128 The output produced by the &'make'& process for compile lines is often very
2129 unreadable, because these lines can be very long. For this reason, the normal
2130 output is suppressed by default, and instead output similar to that which
2131 appears when compiling the 2.6 Linux kernel is generated: just a short line for
2132 each module that is being compiled or linked. However, it is still possible to
2133 get the full output, by calling &'make'& like this:
2134 .code
2135 FULLECHO='' make -e
2136 .endd
2137 The value of FULLECHO defaults to &"@"&, the flag character that suppresses
2138 command reflection in &'make'&. When you ask for the full output, it is
2139 given in addition to the short output.
2140
2141
2142
2143 .section "Overriding build-time options for Exim" "SECToverride"
2144 .cindex "build-time options, overriding"
2145 The main make file that is created at the beginning of the building process
2146 consists of the concatenation of a number of files which set configuration
2147 values, followed by a fixed set of &'make'& instructions. If a value is set
2148 more than once, the last setting overrides any previous ones. This provides a
2149 convenient way of overriding defaults. The files that are concatenated are, in
2150 order:
2151 .display
2152 &_OS/Makefile-Default_&
2153 &_OS/Makefile-_&<&'ostype'&>
2154 &_Local/Makefile_&
2155 &_Local/Makefile-_&<&'ostype'&>
2156 &_Local/Makefile-_&<&'archtype'&>
2157 &_Local/Makefile-_&<&'ostype'&>-<&'archtype'&>
2158 &_OS/Makefile-Base_&
2159 .endd
2160 .cindex "&_Local/Makefile_&"
2161 .cindex "building Exim" "operating system type"
2162 .cindex "building Exim" "architecture type"
2163 where <&'ostype'&> is the operating system type and <&'archtype'&> is the
2164 architecture type. &_Local/Makefile_& is required to exist, and the building
2165 process fails if it is absent. The other three &_Local_& files are optional,
2166 and are often not needed.
2167
2168 The values used for <&'ostype'&> and <&'archtype'&> are obtained from scripts
2169 called &_scripts/os-type_& and &_scripts/arch-type_& respectively. If either of
2170 the environment variables EXIM_OSTYPE or EXIM_ARCHTYPE is set, their
2171 values are used, thereby providing a means of forcing particular settings.
2172 Otherwise, the scripts try to get values from the &%uname%& command. If this
2173 fails, the shell variables OSTYPE and ARCHTYPE are inspected. A number
2174 of &'ad hoc'& transformations are then applied, to produce the standard names
2175 that Exim expects. You can run these scripts directly from the shell in order
2176 to find out what values are being used on your system.
2177
2178
2179 &_OS/Makefile-Default_& contains comments about the variables that are set
2180 therein. Some (but not all) are mentioned below. If there is something that
2181 needs changing, review the contents of this file and the contents of the make
2182 file for your operating system (&_OS/Makefile-<ostype>_&) to see what the
2183 default values are.
2184
2185
2186 .cindex "building Exim" "overriding default settings"
2187 If you need to change any of the values that are set in &_OS/Makefile-Default_&
2188 or in &_OS/Makefile-<ostype>_&, or to add any new definitions, you do not
2189 need to change the original files. Instead, you should make the changes by
2190 putting the new values in an appropriate &_Local_& file. For example,
2191 .cindex "Tru64-Unix build-time settings"
2192 when building Exim in many releases of the Tru64-Unix (formerly Digital UNIX,
2193 formerly DEC-OSF1) operating system, it is necessary to specify that the C
2194 compiler is called &'cc'& rather than &'gcc'&. Also, the compiler must be
2195 called with the option &%-std1%&, to make it recognize some of the features of
2196 Standard C that Exim uses. (Most other compilers recognize Standard C by
2197 default.) To do this, you should create a file called &_Local/Makefile-OSF1_&
2198 containing the lines
2199 .code
2200 CC=cc
2201 CFLAGS=-std1
2202 .endd
2203 If you are compiling for just one operating system, it may be easier to put
2204 these lines directly into &_Local/Makefile_&.
2205
2206 Keeping all your local configuration settings separate from the distributed
2207 files makes it easy to transfer them to new versions of Exim simply by copying
2208 the contents of the &_Local_& directory.
2209
2210
2211 .cindex "NIS lookup type" "including support for"
2212 .cindex "NIS+ lookup type" "including support for"
2213 .cindex "LDAP" "including support for"
2214 .cindex "lookup" "inclusion in binary"
2215 Exim contains support for doing LDAP, NIS, NIS+, and other kinds of file
2216 lookup, but not all systems have these components installed, so the default is
2217 not to include the relevant code in the binary. All the different kinds of file
2218 and database lookup that Exim supports are implemented as separate code modules
2219 which are included only if the relevant compile-time options are set. In the
2220 case of LDAP, NIS, and NIS+, the settings for &_Local/Makefile_& are:
2221 .code
2222 LOOKUP_LDAP=yes
2223 LOOKUP_NIS=yes
2224 LOOKUP_NISPLUS=yes
2225 .endd
2226 and similar settings apply to the other lookup types. They are all listed in
2227 &_src/EDITME_&. In many cases the relevant include files and interface
2228 libraries need to be installed before compiling Exim.
2229 .cindex "cdb" "including support for"
2230 However, there are some optional lookup types (such as cdb) for which
2231 the code is entirely contained within Exim, and no external include
2232 files or libraries are required. When a lookup type is not included in the
2233 binary, attempts to configure Exim to use it cause runtime configuration
2234 errors.
2235
2236 .cindex "pkg-config" "lookups"
2237 .cindex "pkg-config" "authenticators"
2238 Many systems now use a tool called &'pkg-config'& to encapsulate information
2239 about how to compile against a library; Exim has some initial support for
2240 being able to use pkg-config for lookups and authenticators.  For any given
2241 makefile variable which starts &`LOOKUP_`& or &`AUTH_`&, you can add a new
2242 variable with the &`_PC`& suffix in the name and assign as the value the
2243 name of the package to be queried.  The results of querying via the
2244 &'pkg-config'& command will be added to the appropriate Makefile variables
2245 with &`+=`& directives, so your version of &'make'& will need to support that
2246 syntax.  For instance:
2247 .code
2248 LOOKUP_SQLITE=yes
2249 LOOKUP_SQLITE_PC=sqlite3
2250 AUTH_GSASL=yes
2251 AUTH_GSASL_PC=libgsasl
2252 AUTH_HEIMDAL_GSSAPI=yes
2253 AUTH_HEIMDAL_GSSAPI_PC=heimdal-gssapi
2254 .endd
2255
2256 .cindex "Perl" "including support for"
2257 Exim can be linked with an embedded Perl interpreter, allowing Perl
2258 subroutines to be called during string expansion. To enable this facility,
2259 .code
2260 EXIM_PERL=perl.o
2261 .endd
2262 must be defined in &_Local/Makefile_&. Details of this facility are given in
2263 chapter &<<CHAPperl>>&.
2264
2265 .cindex "X11 libraries, location of"
2266 The location of the X11 libraries is something that varies a lot between
2267 operating systems, and there may be different versions of X11 to cope
2268 with. Exim itself makes no use of X11, but if you are compiling the Exim
2269 monitor, the X11 libraries must be available.
2270 The following three variables are set in &_OS/Makefile-Default_&:
2271 .code
2272 X11=/usr/X11R6
2273 XINCLUDE=-I$(X11)/include
2274 XLFLAGS=-L$(X11)/lib
2275 .endd
2276 These are overridden in some of the operating-system configuration files. For
2277 example, in &_OS/Makefile-SunOS5_& there is
2278 .code
2279 X11=/usr/openwin
2280 XINCLUDE=-I$(X11)/include
2281 XLFLAGS=-L$(X11)/lib -R$(X11)/lib
2282 .endd
2283 If you need to override the default setting for your operating system, place a
2284 definition of all three of these variables into your
2285 &_Local/Makefile-<ostype>_& file.
2286
2287 .cindex "EXTRALIBS"
2288 If you need to add any extra libraries to the link steps, these can be put in a
2289 variable called EXTRALIBS, which appears in all the link commands, but by
2290 default is not defined. In contrast, EXTRALIBS_EXIM is used only on the
2291 command for linking the main Exim binary, and not for any associated utilities.
2292
2293 .cindex "DBM libraries" "configuration for building"
2294 There is also DBMLIB, which appears in the link commands for binaries that
2295 use DBM functions (see also section &<<SECTdb>>&). Finally, there is
2296 EXTRALIBS_EXIMON, which appears only in the link step for the Exim monitor
2297 binary, and which can be used, for example, to include additional X11
2298 libraries.
2299
2300 .cindex "configuration file" "editing"
2301 The make file copes with rebuilding Exim correctly if any of the configuration
2302 files are edited. However, if an optional configuration file is deleted, it is
2303 necessary to touch the associated non-optional file (that is,
2304 &_Local/Makefile_& or &_Local/eximon.conf_&) before rebuilding.
2305
2306
2307 .section "OS-specific header files" "SECID30"
2308 .cindex "&_os.h_&"
2309 .cindex "building Exim" "OS-specific C header files"
2310 The &_OS_& directory contains a number of files with names of the form
2311 &_os.h-<ostype>_&. These are system-specific C header files that should not
2312 normally need to be changed. There is a list of macro settings that are
2313 recognized in the file &_OS/os.configuring_&, which should be consulted if you
2314 are porting Exim to a new operating system.
2315
2316
2317
2318 .section "Overriding build-time options for the monitor" "SECID31"
2319 .cindex "building Eximon"
2320 A similar process is used for overriding things when building the Exim monitor,
2321 where the files that are involved are
2322 .display
2323 &_OS/eximon.conf-Default_&
2324 &_OS/eximon.conf-_&<&'ostype'&>
2325 &_Local/eximon.conf_&
2326 &_Local/eximon.conf-_&<&'ostype'&>
2327 &_Local/eximon.conf-_&<&'archtype'&>
2328 &_Local/eximon.conf-_&<&'ostype'&>-<&'archtype'&>
2329 .endd
2330 .cindex "&_Local/eximon.conf_&"
2331 As with Exim itself, the final three files need not exist, and in this case the
2332 &_OS/eximon.conf-<ostype>_& file is also optional. The default values in
2333 &_OS/eximon.conf-Default_& can be overridden dynamically by setting environment
2334 variables of the same name, preceded by EXIMON_. For example, setting
2335 EXIMON_LOG_DEPTH in the environment overrides the value of
2336 LOG_DEPTH at runtime.
2337 .ecindex IIDbuex
2338
2339
2340 .section "Installing Exim binaries and scripts" "SECID32"
2341 .cindex "installing Exim"
2342 .cindex "BIN_DIRECTORY"
2343 The command &`make install`& runs the &(exim_install)& script with no
2344 arguments. The script copies binaries and utility scripts into the directory
2345 whose name is specified by the BIN_DIRECTORY setting in &_Local/Makefile_&.
2346 .cindex "setuid" "installing Exim with"
2347 The install script copies files only if they are newer than the files they are
2348 going to replace. The Exim binary is required to be owned by root and have the
2349 &'setuid'& bit set, for normal configurations. Therefore, you must run &`make
2350 install`& as root so that it can set up the Exim binary in this way. However, in
2351 some special situations (for example, if a host is doing no local deliveries)
2352 it may be possible to run Exim without making the binary setuid root (see
2353 chapter &<<CHAPsecurity>>& for details).
2354
2355 .cindex "CONFIGURE_FILE"
2356 Exim's runtime configuration file is named by the CONFIGURE_FILE setting
2357 in &_Local/Makefile_&. If this names a single file, and the file does not
2358 exist, the default configuration file &_src/configure.default_& is copied there
2359 by the installation script. If a runtime configuration file already exists, it
2360 is left alone. If CONFIGURE_FILE is a colon-separated list, naming several
2361 alternative files, no default is installed.
2362
2363 .cindex "system aliases file"
2364 .cindex "&_/etc/aliases_&"
2365 One change is made to the default configuration file when it is installed: the
2366 default configuration contains a router that references a system aliases file.
2367 The path to this file is set to the value specified by
2368 SYSTEM_ALIASES_FILE in &_Local/Makefile_& (&_/etc/aliases_& by default).
2369 If the system aliases file does not exist, the installation script creates it,
2370 and outputs a comment to the user.
2371
2372 The created file contains no aliases, but it does contain comments about the
2373 aliases a site should normally have. Mail aliases have traditionally been
2374 kept in &_/etc/aliases_&. However, some operating systems are now using
2375 &_/etc/mail/aliases_&. You should check if yours is one of these, and change
2376 Exim's configuration if necessary.
2377
2378 The default configuration uses the local host's name as the only local domain,
2379 and is set up to do local deliveries into the shared directory &_/var/mail_&,
2380 running as the local user. System aliases and &_.forward_& files in users' home
2381 directories are supported, but no NIS or NIS+ support is configured. Domains
2382 other than the name of the local host are routed using the DNS, with delivery
2383 over SMTP.
2384
2385 It is possible to install Exim for special purposes (such as building a binary
2386 distribution) in a private part of the file system. You can do this by a
2387 command such as
2388 .code
2389 make DESTDIR=/some/directory/ install
2390 .endd
2391 This has the effect of pre-pending the specified directory to all the file
2392 paths, except the name of the system aliases file that appears in the default
2393 configuration. (If a default alias file is created, its name &'is'& modified.)
2394 For backwards compatibility, ROOT is used if DESTDIR is not set,
2395 but this usage is deprecated.
2396
2397 .cindex "installing Exim" "what is not installed"
2398 Running &'make install'& does not copy the Exim 4 conversion script
2399 &'convert4r4'&. You will probably run this only once if you are
2400 upgrading from Exim 3. None of the documentation files in the &_doc_&
2401 directory are copied, except for the info files when you have set
2402 INFO_DIRECTORY, as described in section &<<SECTinsinfdoc>>& below.
2403
2404 For the utility programs, old versions are renamed by adding the suffix &_.O_&
2405 to their names. The Exim binary itself, however, is handled differently. It is
2406 installed under a name that includes the version number and the compile number,
2407 for example, &_exim-&version()-1_&. The script then arranges for a symbolic link
2408 called &_exim_& to point to the binary. If you are updating a previous version
2409 of Exim, the script takes care to ensure that the name &_exim_& is never absent
2410 from the directory (as seen by other processes).
2411
2412 .cindex "installing Exim" "testing the script"
2413 If you want to see what the &'make install'& will do before running it for
2414 real, you can pass the &%-n%& option to the installation script by this
2415 command:
2416 .code
2417 make INSTALL_ARG=-n install
2418 .endd
2419 The contents of the variable INSTALL_ARG are passed to the installation
2420 script. You do not need to be root to run this test. Alternatively, you can run
2421 the installation script directly, but this must be from within the build
2422 directory. For example, from the top-level Exim directory you could use this
2423 command:
2424 .code
2425 (cd build-SunOS5-5.5.1-sparc; ../scripts/exim_install -n)
2426 .endd
2427 .cindex "installing Exim" "install script options"
2428 There are two other options that can be supplied to the installation script.
2429
2430 .ilist
2431 &%-no_chown%& bypasses the call to change the owner of the installed binary
2432 to root, and the call to make it a setuid binary.
2433 .next
2434 &%-no_symlink%& bypasses the setting up of the symbolic link &_exim_& to the
2435 installed binary.
2436 .endlist
2437
2438 INSTALL_ARG can be used to pass these options to the script. For example:
2439 .code
2440 make INSTALL_ARG=-no_symlink install
2441 .endd
2442 The installation script can also be given arguments specifying which files are
2443 to be copied. For example, to install just the Exim binary, and nothing else,
2444 without creating the symbolic link, you could use:
2445 .code
2446 make INSTALL_ARG='-no_symlink exim' install
2447 .endd
2448
2449
2450
2451 .section "Installing info documentation" "SECTinsinfdoc"
2452 .cindex "installing Exim" "&'info'& documentation"
2453 Not all systems use the GNU &'info'& system for documentation, and for this
2454 reason, the Texinfo source of Exim's documentation is not included in the main
2455 distribution. Instead it is available separately from the FTP site (see section
2456 &<<SECTavail>>&).
2457
2458 If you have defined INFO_DIRECTORY in &_Local/Makefile_& and the Texinfo
2459 source of the documentation is found in the source tree, running &`make
2460 install`& automatically builds the info files and installs them.
2461
2462
2463
2464 .section "Setting up the spool directory" "SECID33"
2465 .cindex "spool directory" "creating"
2466 When it starts up, Exim tries to create its spool directory if it does not
2467 exist. The Exim uid and gid are used for the owner and group of the spool
2468 directory. Sub-directories are automatically created in the spool directory as
2469 necessary.
2470
2471
2472
2473
2474 .section "Testing" "SECID34"
2475 .cindex "testing" "installation"
2476 Having installed Exim, you can check that the runtime configuration file is
2477 syntactically valid by running the following command, which assumes that the
2478 Exim binary directory is within your PATH environment variable:
2479 .code
2480 exim -bV
2481 .endd
2482 If there are any errors in the configuration file, Exim outputs error messages.
2483 Otherwise it outputs the version number and build date,
2484 the DBM library that is being used, and information about which drivers and
2485 other optional code modules are included in the binary.
2486 Some simple routing tests can be done by using the address testing option. For
2487 example,
2488 .display
2489 &`exim -bt`& <&'local username'&>
2490 .endd
2491 should verify that it recognizes a local mailbox, and
2492 .display
2493 &`exim -bt`& <&'remote address'&>
2494 .endd
2495 a remote one. Then try getting it to deliver mail, both locally and remotely.
2496 This can be done by passing messages directly to Exim, without going through a
2497 user agent. For example:
2498 .code
2499 exim -v postmaster@your.domain.example
2500 From: user@your.domain.example
2501 To: postmaster@your.domain.example
2502 Subject: Testing Exim
2503
2504 This is a test message.
2505 ^D
2506 .endd
2507 The &%-v%& option causes Exim to output some verification of what it is doing.
2508 In this case you should see copies of three log lines, one for the message's
2509 arrival, one for its delivery, and one containing &"Completed"&.
2510
2511 .cindex "delivery" "problems with"
2512 If you encounter problems, look at Exim's log files (&'mainlog'& and
2513 &'paniclog'&) to see if there is any relevant information there. Another source
2514 of information is running Exim with debugging turned on, by specifying the
2515 &%-d%& option. If a message is stuck on Exim's spool, you can force a delivery
2516 with debugging turned on by a command of the form
2517 .display
2518 &`exim -d -M`& <&'exim-message-id'&>
2519 .endd
2520 You must be root or an &"admin user"& in order to do this. The &%-d%& option
2521 produces rather a lot of output, but you can cut this down to specific areas.
2522 For example, if you use &%-d-all+route%& only the debugging information
2523 relevant to routing is included. (See the &%-d%& option in chapter
2524 &<<CHAPcommandline>>& for more details.)
2525
2526 .cindex '&"sticky"& bit'
2527 .cindex "lock files"
2528 One specific problem that has shown up on some sites is the inability to do
2529 local deliveries into a shared mailbox directory, because it does not have the
2530 &"sticky bit"& set on it. By default, Exim tries to create a lock file before
2531 writing to a mailbox file, and if it cannot create the lock file, the delivery
2532 is deferred. You can get round this either by setting the &"sticky bit"& on the
2533 directory, or by setting a specific group for local deliveries and allowing
2534 that group to create files in the directory (see the comments above the
2535 &(local_delivery)& transport in the default configuration file). Another
2536 approach is to configure Exim not to use lock files, but just to rely on
2537 &[fcntl()]& locking instead. However, you should do this only if all user
2538 agents also use &[fcntl()]& locking. For further discussion of locking issues,
2539 see chapter &<<CHAPappendfile>>&.
2540
2541 One thing that cannot be tested on a system that is already running an MTA is
2542 the receipt of incoming SMTP mail on the standard SMTP port. However, the
2543 &%-oX%& option can be used to run an Exim daemon that listens on some other
2544 port, or &'inetd'& can be used to do this. The &%-bh%& option and the
2545 &'exim_checkaccess'& utility can be used to check out policy controls on
2546 incoming SMTP mail.
2547
2548 Testing a new version on a system that is already running Exim can most easily
2549 be done by building a binary with a different CONFIGURE_FILE setting. From
2550 within the runtime configuration, all other file and directory names
2551 that Exim uses can be altered, in order to keep it entirely clear of the
2552 production version.
2553
2554
2555 .section "Replacing another MTA with Exim" "SECID35"
2556 .cindex "replacing another MTA"
2557 Building and installing Exim for the first time does not of itself put it in
2558 general use. The name by which the system's MTA is called by mail user agents
2559 is either &_/usr/sbin/sendmail_&, or &_/usr/lib/sendmail_& (depending on the
2560 operating system), and it is necessary to make this name point to the &'exim'&
2561 binary in order to get the user agents to pass messages to Exim. This is
2562 normally done by renaming any existing file and making &_/usr/sbin/sendmail_&
2563 or &_/usr/lib/sendmail_&
2564 .cindex "symbolic link" "to &'exim'& binary"
2565 a symbolic link to the &'exim'& binary. It is a good idea to remove any setuid
2566 privilege and executable status from the old MTA. It is then necessary to stop
2567 and restart the mailer daemon, if one is running.
2568
2569 .cindex "FreeBSD, MTA indirection"
2570 .cindex "&_/etc/mail/mailer.conf_&"
2571 Some operating systems have introduced alternative ways of switching MTAs. For
2572 example, if you are running FreeBSD, you need to edit the file
2573 &_/etc/mail/mailer.conf_& instead of setting up a symbolic link as just
2574 described. A typical example of the contents of this file for running Exim is
2575 as follows:
2576 .code
2577 sendmail            /usr/exim/bin/exim
2578 send-mail           /usr/exim/bin/exim
2579 mailq               /usr/exim/bin/exim -bp
2580 newaliases          /usr/bin/true
2581 .endd
2582 Once you have set up the symbolic link, or edited &_/etc/mail/mailer.conf_&,
2583 your Exim installation is &"live"&. Check it by sending a message from your
2584 favourite user agent.
2585
2586 You should consider what to tell your users about the change of MTA. Exim may
2587 have different capabilities to what was previously running, and there are
2588 various operational differences such as the text of messages produced by
2589 command line options and in bounce messages. If you allow your users to make
2590 use of Exim's filtering capabilities, you should make the document entitled
2591 &'Exim's interface to mail filtering'& available to them.
2592
2593
2594
2595 .section "Running the daemon" SECTdaemonLaunch
2596 The most common command line for launching the Exim daemon looks like
2597 .code
2598 exim -bd -q5m
2599 .endd
2600 This starts a daemon which
2601 .ilist
2602 listens for incoming smtp connections, launching handler processes for
2603 each new one
2604 .next
2605 starts a queue-runner process every five minutes, to inspect queued messages
2606 and run delivery attempts on any that have arrived at their retry time
2607 .endlist
2608 Should a queue run take longer than the time between queue-runner starts,
2609 they will run in parallel.
2610 Numbers of jobs of the various types are subject to policy controls
2611 defined in the configuration.
2612
2613
2614 .section "Upgrading Exim" "SECID36"
2615 .cindex "upgrading Exim"
2616 If you are already running Exim on your host, building and installing a new
2617 version automatically makes it available to MUAs, or any other programs that
2618 call the MTA directly. However, if you are running an Exim daemon, you do need
2619 .cindex restart "on HUP signal"
2620 .cindex signal "HUP, to restart"
2621 to send it a HUP signal, to make it re-execute itself, and thereby pick up the
2622 new binary. You do not need to stop processing mail in order to install a new
2623 version of Exim. The install script does not modify an existing runtime
2624 configuration file.
2625
2626
2627
2628
2629 .section "Stopping the Exim daemon on Solaris" "SECID37"
2630 .cindex "Solaris" "stopping Exim on"
2631 The standard command for stopping the mailer daemon on Solaris is
2632 .code
2633 /etc/init.d/sendmail stop
2634 .endd
2635 If &_/usr/lib/sendmail_& has been turned into a symbolic link, this script
2636 fails to stop Exim because it uses the command &'ps -e'& and greps the output
2637 for the text &"sendmail"&; this is not present because the actual program name
2638 (that is, &"exim"&) is given by the &'ps'& command with these options. A
2639 solution is to replace the line that finds the process id with something like
2640 .code
2641 pid=`cat /var/spool/exim/exim-daemon.pid`
2642 .endd
2643 to obtain the daemon's pid directly from the file that Exim saves it in.
2644
2645 Note, however, that stopping the daemon does not &"stop Exim"&. Messages can
2646 still be received from local processes, and if automatic delivery is configured
2647 (the normal case), deliveries will still occur.
2648
2649
2650
2651
2652 . ////////////////////////////////////////////////////////////////////////////
2653 . ////////////////////////////////////////////////////////////////////////////
2654
2655 .chapter "The Exim command line" "CHAPcommandline"
2656 .scindex IIDclo1 "command line" "options"
2657 .scindex IIDclo2 "options" "command line"
2658 Exim's command line takes the standard Unix form of a sequence of options,
2659 each starting with a hyphen character, followed by a number of arguments. The
2660 options are compatible with the main options of Sendmail, and there are also
2661 some additional options, some of which are compatible with Smail 3. Certain
2662 combinations of options do not make sense, and provoke an error if used.
2663 The form of the arguments depends on which options are set.
2664
2665
2666 .section "Setting options by program name" "SECID38"
2667 .cindex "&'mailq'&"
2668 If Exim is called under the name &'mailq'&, it behaves as if the option &%-bp%&
2669 were present before any other options.
2670 The &%-bp%& option requests a listing of the contents of the mail queue on the
2671 standard output.
2672 This feature is for compatibility with some systems that contain a command of
2673 that name in one of the standard libraries, symbolically linked to
2674 &_/usr/sbin/sendmail_& or &_/usr/lib/sendmail_&.
2675
2676 .cindex "&'rsmtp'&"
2677 If Exim is called under the name &'rsmtp'& it behaves as if the option &%-bS%&
2678 were present before any other options, for compatibility with Smail. The
2679 &%-bS%& option is used for reading in a number of messages in batched SMTP
2680 format.
2681
2682 .cindex "&'rmail'&"
2683 If Exim is called under the name &'rmail'& it behaves as if the &%-i%& and
2684 &%-oee%& options were present before any other options, for compatibility with
2685 Smail. The name &'rmail'& is used as an interface by some UUCP systems.
2686
2687 .cindex "&'runq'&"
2688 .cindex "queue runner"
2689 If Exim is called under the name &'runq'& it behaves as if the option &%-q%&
2690 were present before any other options, for compatibility with Smail. The &%-q%&
2691 option causes a single queue runner process to be started.
2692
2693 .cindex "&'newaliases'&"
2694 .cindex "alias file" "building"
2695 .cindex "Sendmail compatibility" "calling Exim as &'newaliases'&"
2696 If Exim is called under the name &'newaliases'& it behaves as if the option
2697 &%-bi%& were present before any other options, for compatibility with Sendmail.
2698 This option is used for rebuilding Sendmail's alias file. Exim does not have
2699 the concept of a single alias file, but can be configured to run a given
2700 command if called with the &%-bi%& option.
2701
2702
2703 .section "Trusted and admin users" "SECTtrustedadmin"
2704 Some Exim options are available only to &'trusted users'& and others are
2705 available only to &'admin users'&. In the description below, the phrases &"Exim
2706 user"& and &"Exim group"& mean the user and group defined by EXIM_USER and
2707 EXIM_GROUP in &_Local/Makefile_& or set by the &%exim_user%& and
2708 &%exim_group%& options. These do not necessarily have to use the name &"exim"&.
2709
2710 .ilist
2711 .cindex "trusted users" "definition of"
2712 .cindex "user" "trusted definition of"
2713 The trusted users are root, the Exim user, any user listed in the
2714 &%trusted_users%& configuration option, and any user whose current group or any
2715 supplementary group is one of those listed in the &%trusted_groups%&
2716 configuration option. Note that the Exim group is not automatically trusted.
2717
2718 .cindex '&"From"& line'
2719 .cindex "envelope from"
2720 .cindex "envelope sender"
2721 Trusted users are always permitted to use the &%-f%& option or a leading
2722 &"From&~"& line to specify the envelope sender of a message that is passed to
2723 Exim through the local interface (see the &%-bm%& and &%-f%& options below).
2724 See the &%untrusted_set_sender%& option for a way of permitting non-trusted
2725 users to set envelope senders.
2726
2727 .chindex From:
2728 .chindex Sender:
2729 For a trusted user, there is never any check on the contents of the &'From:'&
2730 header line, and a &'Sender:'& line is never added. Furthermore, any existing
2731 &'Sender:'& line in incoming local (non-TCP/IP) messages is not removed.
2732
2733 Trusted users may also specify a host name, host address, interface address,
2734 protocol name, ident value, and authentication data when submitting a message
2735 locally. Thus, they are able to insert messages into Exim's queue locally that
2736 have the characteristics of messages received from a remote host. Untrusted
2737 users may in some circumstances use &%-f%&, but can never set the other values
2738 that are available to trusted users.
2739 .next
2740 .cindex "user" "admin definition of"
2741 .cindex "admin user" "definition of"
2742 The admin users are root, the Exim user, and any user that is a member of the
2743 Exim group or of any group listed in the &%admin_groups%& configuration option.
2744 The current group does not have to be one of these groups.
2745
2746 Admin users are permitted to list the queue, and to carry out certain
2747 operations on messages, for example, to force delivery failures. It is also
2748 necessary to be an admin user in order to see the full information provided by
2749 the Exim monitor, and full debugging output.
2750
2751 By default, the use of the &%-M%&, &%-q%&, &%-R%&, and &%-S%& options to cause
2752 Exim to attempt delivery of messages on its queue is restricted to admin users.
2753 However, this restriction can be relaxed by setting the &%prod_requires_admin%&
2754 option false (that is, specifying &%no_prod_requires_admin%&).
2755
2756 Similarly, the use of the &%-bp%& option to list all the messages in the queue
2757 is restricted to admin users unless &%queue_list_requires_admin%& is set
2758 false.
2759 .endlist
2760
2761
2762 &*Warning*&: If you configure your system so that admin users are able to
2763 edit Exim's configuration file, you are giving those users an easy way of
2764 getting root. There is further discussion of this issue at the start of chapter
2765 &<<CHAPconf>>&.
2766
2767
2768
2769
2770 .section "Command line options" "SECID39"
2771 Exim's command line options are described in alphabetical order below. If none
2772 of the options that specifies a specific action (such as starting the daemon or
2773 a queue runner, or testing an address, or receiving a message in a specific
2774 format, or listing the queue) are present, and there is at least one argument
2775 on the command line, &%-bm%& (accept a local message on the standard input,
2776 with the arguments specifying the recipients) is assumed. Otherwise, Exim
2777 outputs a brief message about itself and exits.
2778
2779 . ////////////////////////////////////////////////////////////////////////////
2780 . Insert a stylized XML comment here, to identify the start of the command line
2781 . options. This is for the benefit of the Perl script that automatically
2782 . creates a man page for the options.
2783 . ////////////////////////////////////////////////////////////////////////////
2784
2785 .literal xml
2786 <!-- === Start of command line options === -->
2787 .literal off
2788
2789
2790 .vlist
2791 .cmdopt "--" "--"
2792 .cindex "options" "command line; terminating"
2793 This is a pseudo-option whose only purpose is to terminate the options and
2794 therefore to cause subsequent command line items to be treated as arguments
2795 rather than options, even if they begin with hyphens.
2796
2797 .cmdopt --help
2798 This option causes Exim to output a few sentences stating what it is.
2799 The same output is generated if the Exim binary is called with no options and
2800 no arguments.
2801
2802 .cmdopt --version
2803 This option is an alias for &%-bV%& and causes version information to be
2804 displayed.
2805
2806 .vitem &%-Ac%& &&&
2807        &%-Am%&
2808 .oindex "&%-Ac%&"
2809 .oindex "&%-Am%&"
2810 These options are used by Sendmail for selecting configuration files and are
2811 ignored by Exim.
2812
2813 .cmdopt -B <&'type'&>
2814 .oindex "&%-B%&"
2815 .cindex "8-bit characters"
2816 .cindex "Sendmail compatibility" "8-bit characters"
2817 This is a Sendmail option for selecting 7 or 8 bit processing. Exim is 8-bit
2818 clean; it ignores this option.
2819
2820 .cmdopt -bd
2821 .cindex "daemon"
2822 .cindex "SMTP" "listener"
2823 .cindex "queue runner"
2824 This option runs Exim as a daemon, awaiting incoming SMTP connections. Usually
2825 the &%-bd%& option is combined with the &%-q%&<&'time'&> option, to specify
2826 that the daemon should also initiate periodic queue runs.
2827
2828 The &%-bd%& option can be used only by an admin user. If either of the &%-d%&
2829 (debugging) or &%-v%& (verifying) options are set, the daemon does not
2830 disconnect from the controlling terminal. When running this way, it can be
2831 stopped by pressing ctrl-C.
2832
2833 By default, Exim listens for incoming connections to the standard SMTP port on
2834 all the host's running interfaces. However, it is possible to listen on other
2835 ports, on multiple ports, and only on specific interfaces. Chapter
2836 &<<CHAPinterfaces>>& contains a description of the options that control this.
2837
2838 When a listening daemon
2839 .cindex "daemon" "process id (pid)"
2840 .cindex "pid (process id)" "of daemon"
2841 is started without the use of &%-oX%& (that is, without overriding the normal
2842 configuration), it writes its process id to a file called &_exim-daemon.pid_&
2843 in Exim's spool directory. This location can be overridden by setting
2844 PID_FILE_PATH in &_Local/Makefile_&. The file is written while Exim is still
2845 running as root.
2846
2847 When &%-oX%& is used on the command line to start a listening daemon, the
2848 process id is not written to the normal pid file path. However, &%-oP%& can be
2849 used to specify a path on the command line if a pid file is required.
2850
2851 The SIGHUP signal
2852 .cindex "SIGHUP"
2853 .cindex restart "on HUP signal"
2854 .cindex signal "HUP, to restart"
2855 .cindex "daemon" "restarting"
2856 .cindex signal "to reload configuration"
2857 .cindex daemon "reload configuration"
2858 .cindex reload configuration
2859 can be used to cause the daemon to re-execute itself. This should be done
2860 whenever Exim's configuration file, or any file that is incorporated into it by
2861 means of the &%.include%& facility, is changed, and also whenever a new version
2862 of Exim is installed. It is not necessary to do this when other files that are
2863 referenced from the configuration (for example, alias files) are changed,
2864 because these are reread each time they are used.
2865
2866 Either a SIGTERM or a SIGINT signal should be used to cause the daemon
2867 to cleanly shut down.
2868 Subprocesses handling recceiving or delivering messages,
2869 or for scanning the queue,
2870 will not be affected by the termination of the daemon process.
2871
2872 .cmdopt -bdf
2873 This option has the same effect as &%-bd%& except that it never disconnects
2874 from the controlling terminal, even when no debugging is specified.
2875
2876 .cmdopt -be
2877 .cindex "testing" "string expansion"
2878 .cindex "expansion" "testing"
2879 Run Exim in expansion testing mode. Exim discards its root privilege, to
2880 prevent ordinary users from using this mode to read otherwise inaccessible
2881 files. If no arguments are given, Exim runs interactively, prompting for lines
2882 of data. Otherwise, it processes each argument in turn.
2883
2884 If Exim was built with USE_READLINE=yes in &_Local/Makefile_&, it tries
2885 to load the &%libreadline%& library dynamically whenever the &%-be%& option is
2886 used without command line arguments. If successful, it uses the &[readline()]&
2887 function, which provides extensive line-editing facilities, for reading the
2888 test data. A line history is supported.
2889
2890 Long expansion expressions can be split over several lines by using backslash
2891 continuations. As in Exim's runtime configuration, white space at the start of
2892 continuation lines is ignored. Each argument or data line is passed through the
2893 string expansion mechanism, and the result is output. Variable values from the
2894 configuration file (for example, &$qualify_domain$&) are available, but no
2895 message-specific values (such as &$message_exim_id$&) are set, because no message
2896 is being processed (but see &%-bem%& and &%-Mset%&).
2897
2898 &*Note*&: If you use this mechanism to test lookups, and you change the data
2899 files or databases you are using, you must exit and restart Exim before trying
2900 the same lookup again. Otherwise, because each Exim process caches the results
2901 of lookups, you will just get the same result as before.
2902
2903 Macro processing is done on lines before string-expansion: new macros can be
2904 defined and macros will be expanded.
2905 Because macros in the config file are often used for secrets, those are only
2906 available to admin users.
2907
2908 The word &"set"& at the start of a line, followed by a single space,
2909 is recognised specially as defining a value for a variable.
2910 .cindex "tainted data" "expansion testing"
2911 If the sequence &",t"& is inserted before the space,
2912 the value is marked as tainted.
2913 The syntax is otherwise the same as the ACL modifier &"set ="&.
2914
2915 .cmdopt -bem <&'filename'&>
2916 .cindex "testing" "string expansion"
2917 .cindex "expansion" "testing"
2918 This option operates like &%-be%& except that it must be followed by the name
2919 of a file. For example:
2920 .code
2921 exim -bem /tmp/testmessage
2922 .endd
2923 The file is read as a message (as if receiving a locally-submitted non-SMTP
2924 message) before any of the test expansions are done. Thus, message-specific
2925 variables such as &$message_size$& and &$header_from:$& are available. However,
2926 no &'Received:'& header is added to the message. If the &%-t%& option is set,
2927 recipients are read from the headers in the normal way, and are shown in the
2928 &$recipients$& variable. Note that recipients cannot be given on the command
2929 line, because further arguments are taken as strings to expand (just like
2930 &%-be%&).
2931
2932 .cmdopt -bF <&'filename'&>
2933 .cindex "system filter" "testing"
2934 .cindex "testing" "system filter"
2935 This option is the same as &%-bf%& except that it assumes that the filter being
2936 tested is a system filter. The additional commands that are available only in
2937 system filters are recognized.
2938
2939 .cmdopt -bf <&'filename'&>
2940 .cindex "filter" "testing"
2941 .cindex "testing" "filter file"
2942 .cindex "forward file" "testing"
2943 .cindex "testing" "forward file"
2944 .cindex "Sieve filter" "testing"
2945 This option runs Exim in user filter testing mode; the file is the filter file
2946 to be tested, and a test message must be supplied on the standard input. If
2947 there are no message-dependent tests in the filter, an empty file can be
2948 supplied.
2949
2950 If you want to test a system filter file, use &%-bF%& instead of &%-bf%&. You
2951 can use both &%-bF%& and &%-bf%& on the same command, in order to test a system
2952 filter and a user filter in the same run. For example:
2953 .code
2954 exim -bF /system/filter -bf /user/filter </test/message
2955 .endd
2956 This is helpful when the system filter adds header lines or sets filter
2957 variables that are used by the user filter.
2958
2959 If the test filter file does not begin with one of the special lines
2960 .code
2961 # Exim filter
2962 # Sieve filter
2963 .endd
2964 it is taken to be a normal &_.forward_& file, and is tested for validity under
2965 that interpretation. See sections &<<SECTitenonfilred>>& to
2966 &<<SECTspecitredli>>& for a description of the possible contents of non-filter
2967 redirection lists.
2968
2969 The result of an Exim command that uses &%-bf%&, provided no errors are
2970 detected, is a list of the actions that Exim would try to take if presented
2971 with the message for real. More details of filter testing are given in the
2972 separate document entitled &'Exim's interfaces to mail filtering'&.
2973
2974 When testing a filter file,
2975 .cindex "&""From""& line"
2976 .cindex "envelope from"
2977 .cindex "envelope sender"
2978 .oindex "&%-f%&" "for filter testing"
2979 the envelope sender can be set by the &%-f%& option,
2980 or by a &"From&~"& line at the start of the test message. Various parameters
2981 that would normally be taken from the envelope recipient address of the message
2982 can be set by means of additional command line options (see the next four
2983 options).
2984
2985 .cmdopt -bfd <&'domain'&>
2986 .vindex "&$qualify_domain$&"
2987 This sets the domain of the recipient address when a filter file is being
2988 tested by means of the &%-bf%& option. The default is the value of
2989 &$qualify_domain$&.
2990
2991 .cmdopt -bfl <&'local&~part'&>
2992 This sets the local part of the recipient address when a filter file is being
2993 tested by means of the &%-bf%& option. The default is the username of the
2994 process that calls Exim. A local part should be specified with any prefix or
2995 suffix stripped, because that is how it appears to the filter when a message is
2996 actually being delivered.
2997
2998 .cmdopt -bfp <&'prefix'&>
2999 .cindex affix "filter testing"
3000 This sets the prefix of the local part of the recipient address when a filter
3001 file is being tested by means of the &%-bf%& option. The default is an empty
3002 prefix.
3003
3004 .cmdopt -bfs <&'suffix'&>
3005 .cindex affix "filter testing"
3006 This sets the suffix of the local part of the recipient address when a filter
3007 file is being tested by means of the &%-bf%& option. The default is an empty
3008 suffix.
3009
3010 .cmdopt -bh <&'IP&~address'&>
3011 .cindex "testing" "incoming SMTP"
3012 .cindex "SMTP" "testing incoming"
3013 .cindex "testing" "relay control"
3014 .cindex "relaying" "testing configuration"
3015 .cindex "policy control" "testing"
3016 .cindex "debugging" "&%-bh%& option"
3017 This option runs a fake SMTP session as if from the given IP address, using the
3018 standard input and output. The IP address may include a port number at the end,
3019 after a full stop. For example:
3020 .code
3021 exim -bh 10.9.8.7.1234
3022 exim -bh fe80::a00:20ff:fe86:a061.5678
3023 .endd
3024 When an IPv6 address is given, it is converted into canonical form. In the case
3025 of the second example above, the value of &$sender_host_address$& after
3026 conversion to the canonical form is
3027 &`fe80:0000:0000:0a00:20ff:fe86:a061.5678`&.
3028
3029 Comments as to what is going on are written to the standard error file. These
3030 include lines beginning with &"LOG"& for anything that would have been logged.
3031 This facility is provided for testing configuration options for incoming
3032 messages, to make sure they implement the required policy. For example, you can
3033 test your relay controls using &%-bh%&.
3034
3035 &*Warning 1*&:
3036 .cindex "RFC 1413"
3037 You can test features of the configuration that rely on ident (RFC 1413)
3038 information by using the &%-oMt%& option. However, Exim cannot actually perform
3039 an ident callout when testing using &%-bh%& because there is no incoming SMTP
3040 connection.
3041
3042 &*Warning 2*&: Address verification callouts (see section &<<SECTcallver>>&)
3043 are also skipped when testing using &%-bh%&. If you want these callouts to
3044 occur, use &%-bhc%& instead.
3045
3046 Messages supplied during the testing session are discarded, and nothing is
3047 written to any of the real log files. There may be pauses when DNS (and other)
3048 lookups are taking place, and of course these may time out. The &%-oMi%& option
3049 can be used to specify a specific IP interface and port if this is important,
3050 and &%-oMaa%& and &%-oMai%& can be used to set parameters as if the SMTP
3051 session were authenticated.
3052
3053 The &'exim_checkaccess'& utility is a &"packaged"& version of &%-bh%& whose
3054 output just states whether a given recipient address from a given host is
3055 acceptable or not. See section &<<SECTcheckaccess>>&.
3056
3057 Features such as authentication and encryption, where the client input is not
3058 plain text, cannot easily be tested with &%-bh%&. Instead, you should use a
3059 specialized SMTP test program such as
3060 &url(https://www.jetmore.org/john/code/swaks/,swaks).
3061
3062 .cmdopt -bhc <&'IP&~address'&>
3063 This option operates in the same way as &%-bh%&, except that address
3064 verification callouts are performed if required. This includes consulting and
3065 updating the callout cache database.
3066
3067 .cmdopt -bi
3068 .cindex "alias file" "building"
3069 .cindex "building alias file"
3070 .cindex "Sendmail compatibility" "&%-bi%& option"
3071 Sendmail interprets the &%-bi%& option as a request to rebuild its alias file.
3072 Exim does not have the concept of a single alias file, and so it cannot mimic
3073 this behaviour. However, calls to &_/usr/lib/sendmail_& with the &%-bi%& option
3074 tend to appear in various scripts such as NIS make files, so the option must be
3075 recognized.
3076
3077 If &%-bi%& is encountered, the command specified by the &%bi_command%&
3078 configuration option is run, under the uid and gid of the caller of Exim. If
3079 the &%-oA%& option is used, its value is passed to the command as an argument.
3080 The command set by &%bi_command%& may not contain arguments. The command can
3081 use the &'exim_dbmbuild'& utility, or some other means, to rebuild alias files
3082 if this is required. If the &%bi_command%& option is not set, calling Exim with
3083 &%-bi%& is a no-op.
3084
3085 . // Keep :help first, then the rest in alphabetical order
3086 .cmdopt -bI:help
3087 .cindex "querying exim information"
3088 We shall provide various options starting &`-bI:`& for querying Exim for
3089 information.  The output of many of these will be intended for machine
3090 consumption.  This one is not.  The &%-bI:help%& option asks Exim for a
3091 synopsis of supported options beginning &`-bI:`&.  Use of any of these
3092 options shall cause Exim to exit after producing the requested output.
3093
3094 .cmdopt -bI:dscp
3095 .cindex "DSCP" "values"
3096 This option causes Exim to emit an alphabetically sorted list of all
3097 recognised DSCP names.
3098
3099 .cmdopt -bI:sieve
3100 .cindex "Sieve filter" "capabilities"
3101 This option causes Exim to emit an alphabetically sorted list of all supported
3102 Sieve protocol extensions on stdout, one per line.  This is anticipated to be
3103 useful for ManageSieve (RFC 5804) implementations, in providing that protocol's
3104 &`SIEVE`& capability response line.  As the precise list may depend upon
3105 compile-time build options, which this option will adapt to, this is the only
3106 way to guarantee a correct response.
3107
3108 .cmdopt -bm
3109 .cindex "local message reception"
3110 This option runs an Exim receiving process that accepts an incoming,
3111 locally-generated message on the standard input. The recipients are given as the
3112 command arguments (except when &%-t%& is also present &-- see below). Each
3113 argument can be a comma-separated list of RFC 2822 addresses. This is the
3114 default option for selecting the overall action of an Exim call; it is assumed
3115 if no other conflicting option is present.
3116
3117 If any addresses in the message are unqualified (have no domain), they are
3118 qualified by the values of the &%qualify_domain%& or &%qualify_recipient%&
3119 options, as appropriate. The &%-bnq%& option (see below) provides a way of
3120 suppressing this for special cases.
3121
3122 Policy checks on the contents of local messages can be enforced by means of
3123 the non-SMTP ACL. See section &<<SECnonSMTP>>& for details.
3124
3125 .cindex "return code" "for &%-bm%&"
3126 The return code is zero if the message is successfully accepted. Otherwise, the
3127 action is controlled by the &%-oe%&&'x'& option setting &-- see below.
3128
3129 The format
3130 .cindex "message" "format"
3131 .cindex "format" "message"
3132 .cindex "&""From""& line"
3133 .cindex "UUCP" "&""From""& line"
3134 .cindex "Sendmail compatibility" "&""From""& line"
3135 of the message must be as defined in RFC 2822, except that, for
3136 compatibility with Sendmail and Smail, a line in one of the forms
3137 .code
3138 From sender Fri Jan  5 12:55 GMT 1997
3139 From sender Fri, 5 Jan 97 12:55:01
3140 .endd
3141 (with the weekday optional, and possibly with additional text after the date)
3142 is permitted to appear at the start of the message. There appears to be no
3143 authoritative specification of the format of this line. Exim recognizes it by
3144 matching against the regular expression defined by the &%uucp_from_pattern%&
3145 option, which can be changed if necessary.
3146
3147 .oindex "&%-f%&" "overriding &""From""& line"
3148 The specified sender is treated as if it were given as the argument to the
3149 &%-f%& option, but if a &%-f%& option is also present, its argument is used in
3150 preference to the address taken from the message. The caller of Exim must be a
3151 trusted user for the sender of a message to be set in this way.
3152
3153 .cmdopt -bmalware <&'filename'&>
3154 .cindex "testing", "malware"
3155 .cindex "malware scan test"
3156 This debugging option causes Exim to scan the given file or directory
3157 (depending on the used scanner interface),
3158 using the malware scanning framework.  The option of &%av_scanner%& influences
3159 this option, so if &%av_scanner%&'s value is dependent upon an expansion then
3160 the expansion should have defaults which apply to this invocation.  ACLs are
3161 not invoked, so if &%av_scanner%& references an ACL variable then that variable
3162 will never be populated and &%-bmalware%& will fail.
3163
3164 Exim will have changed working directory before resolving the filename, so
3165 using fully qualified pathnames is advisable.  Exim will be running as the Exim
3166 user when it tries to open the file, rather than as the invoking user.
3167 This option requires admin privileges.
3168
3169 The &%-bmalware%& option will not be extended to be more generally useful,
3170 there are better tools for file-scanning.  This option exists to help
3171 administrators verify their Exim and AV scanner configuration.
3172
3173 .cmdopt -bnq
3174 .cindex "address qualification, suppressing"
3175 By default, Exim automatically qualifies unqualified addresses (those
3176 without domains) that appear in messages that are submitted locally (that
3177 is, not over TCP/IP). This qualification applies both to addresses in
3178 envelopes, and addresses in header lines. Sender addresses are qualified using
3179 &%qualify_domain%&, and recipient addresses using &%qualify_recipient%& (which
3180 defaults to the value of &%qualify_domain%&).
3181
3182 Sometimes, qualification is not wanted. For example, if &%-bS%& (batch SMTP) is
3183 being used to re-submit messages that originally came from remote hosts after
3184 content scanning, you probably do not want to qualify unqualified addresses in
3185 header lines. (Such lines will be present only if you have not enabled a header
3186 syntax check in the appropriate ACL.)
3187
3188 The &%-bnq%& option suppresses all qualification of unqualified addresses in
3189 messages that originate on the local host. When this is used, unqualified
3190 addresses in the envelope provoke errors (causing message rejection) and
3191 unqualified addresses in header lines are left alone.
3192
3193
3194 .cmdopt -bP
3195 .cindex "configuration options" "extracting"
3196 .cindex "options" "configuration &-- extracting"
3197 If this option is given with no arguments, it causes the values of all Exim's
3198 main configuration options to be written to the standard output. The values
3199 of one or more specific options can be requested by giving their names as
3200 arguments, for example:
3201 .code
3202 exim -bP qualify_domain hold_domains
3203 .endd
3204 .cindex "hiding configuration option values"
3205 .cindex "configuration options" "hiding value of"
3206 .cindex "options" "hiding value of"
3207 However, any option setting that is preceded by the word &"hide"& in the
3208 configuration file is not shown in full, except to an admin user. For other
3209 users, the output is as in this example:
3210 .code
3211 mysql_servers = <value not displayable>
3212 .endd
3213 If &%config%& is given as an argument, the config is
3214 output, as it was parsed, any include file resolved, any comment removed.
3215
3216 If &%config_file%& is given as an argument, the name of the runtime
3217 configuration file is output. (&%configure_file%& works too, for
3218 backward compatibility.)
3219 If a list of configuration files was supplied, the value that is output here
3220 is the name of the file that was actually used.
3221
3222 .cindex "options" "hiding name of"
3223 If the &%-n%& flag is given, then for most modes of &%-bP%& operation the
3224 name will not be output.
3225
3226 .cindex "daemon" "process id (pid)"
3227 .cindex "pid (process id)" "of daemon"
3228 If &%log_file_path%& or &%pid_file_path%& are given, the names of the
3229 directories where log files and daemon pid files are written are output,
3230 respectively. If these values are unset, log files are written in a
3231 sub-directory of the spool directory called &%log%&, and the pid file is
3232 written directly into the spool directory.
3233
3234 If &%-bP%& is followed by a name preceded by &`+`&, for example,
3235 .code
3236 exim -bP +local_domains
3237 .endd
3238 it searches for a matching named list of any type (domain, host, address, or
3239 local part) and outputs what it finds.
3240
3241 .cindex "options" "router &-- extracting"
3242 .cindex "options" "transport &-- extracting"
3243 .cindex "options" "authenticator &-- extracting"
3244 If one of the words &%router%&, &%transport%&, or &%authenticator%& is given,
3245 followed by the name of an appropriate driver instance, the option settings for
3246 that driver are output. For example:
3247 .code
3248 exim -bP transport local_delivery
3249 .endd
3250 The generic driver options are output first, followed by the driver's private
3251 options. A list of the names of drivers of a particular type can be obtained by
3252 using one of the words &%router_list%&, &%transport_list%&, or
3253 &%authenticator_list%&, and a complete list of all drivers with their option
3254 settings can be obtained by using &%routers%&, &%transports%&, or
3255 &%authenticators%&.
3256
3257 .cindex "environment"
3258 If &%environment%& is given as an argument, the set of environment
3259 variables is output, line by line. Using the &%-n%& flag suppresses the value of the
3260 variables.
3261
3262 .cindex "options" "macro &-- extracting"
3263 If invoked by an admin user, then &%macro%&, &%macro_list%& and &%macros%&
3264 are available, similarly to the drivers.  Because macros are sometimes used
3265 for storing passwords, this option is restricted.
3266 The output format is one item per line.
3267 For the "-bP macro <name>" form, if no such macro is found
3268 the exit status will be nonzero.
3269
3270 .cmdopt -bp
3271 .cindex "queue" "listing messages in"
3272 .cindex "listing" "messages in the queue"
3273 This option requests a listing of the contents of the mail queue on the
3274 standard output. If the &%-bp%& option is followed by a list of message ids,
3275 just those messages are listed. By default, this option can be used only by an
3276 admin user. However, the &%queue_list_requires_admin%& option can be set false
3277 to allow any user to see the queue.
3278
3279 Each message in the queue is displayed as in the following example:
3280 .code
3281 25m  2.9K 0t5C6f-0000c8-00 <alice@wonderland.fict.example>
3282           red.king@looking-glass.fict.example
3283           <other addresses>
3284 .endd
3285 .cindex "message" "size in queue listing"
3286 .cindex "size" "of message"
3287 The first line contains the length of time the message has been in the queue
3288 (in this case 25 minutes), the size of the message (2.9K), the unique local
3289 identifier for the message, and the message sender, as contained in the
3290 envelope. For bounce messages, the sender address is empty, and appears as
3291 &"<>"&. If the message was submitted locally by an untrusted user who overrode
3292 the default sender address, the user's login name is shown in parentheses
3293 before the sender address.
3294
3295 .cindex "frozen messages" "in queue listing"
3296 If the message is frozen (attempts to deliver it are suspended) then the text
3297 &"*** frozen ***"& is displayed at the end of this line.
3298
3299 The recipients of the message (taken from the envelope, not the headers) are
3300 displayed on subsequent lines. Those addresses to which the message has already
3301 been delivered are marked with the letter D. If an original address gets
3302 expanded into several addresses via an alias or forward file, the original is
3303 displayed with a D only when deliveries for all of its child addresses are
3304 complete.
3305
3306
3307 .cmdopt -bpa
3308 This option operates like &%-bp%&, but in addition it shows delivered addresses
3309 that were generated from the original top level address(es) in each message by
3310 alias or forwarding operations. These addresses are flagged with &"+D"& instead
3311 of just &"D"&.
3312
3313
3314 .cmdopt -bpc
3315 .cindex "queue" "count of messages on"
3316 This option counts the number of messages in the queue, and writes the total
3317 to the standard output. It is restricted to admin users, unless
3318 &%queue_list_requires_admin%& is set false.
3319
3320
3321 .cmdopt -bpi
3322 .cindex queue "list of message IDs"
3323 This option operates like &%-bp%&, but only outputs message ids
3324 (one per line).
3325
3326
3327 .cmdopt -bpr
3328 This option operates like &%-bp%&, but the output is not sorted into
3329 chronological order of message arrival. This can speed it up when there are
3330 lots of messages in the queue, and is particularly useful if the output is
3331 going to be post-processed in a way that doesn't need the sorting.
3332
3333 .cmdopt -bpra
3334 This option is a combination of &%-bpr%& and &%-bpa%&.
3335
3336 .cmdopt -bpri
3337 This option is a combination of &%-bpr%& and &%-bpi%&.
3338
3339 .cmdopt -bpru
3340 This option is a combination of &%-bpr%& and &%-bpu%&.
3341
3342
3343 .cmdopt -bpu
3344 This option operates like &%-bp%& but shows only undelivered top-level
3345 addresses for each message displayed. Addresses generated by aliasing or
3346 forwarding are not shown, unless the message was deferred after processing by a
3347 router with the &%one_time%& option set.
3348
3349
3350 .cmdopt -brt
3351 .cindex "testing" "retry configuration"
3352 .cindex "retry" "configuration testing"
3353 This option is for testing retry rules, and it must be followed by up to three
3354 arguments. It causes Exim to look for a retry rule that matches the values
3355 and to write it to the standard output. For example:
3356 .code
3357 exim -brt bach.comp.mus.example
3358 Retry rule: *.comp.mus.example  F,2h,15m; F,4d,30m;
3359 .endd
3360 See chapter &<<CHAPretry>>& for a description of Exim's retry rules. The first
3361 argument, which is required, can be a complete address in the form
3362 &'local_part@domain'&, or it can be just a domain name. If the second argument
3363 contains a dot, it is interpreted as an optional second domain name; if no
3364 retry rule is found for the first argument, the second is tried. This ties in
3365 with Exim's behaviour when looking for retry rules for remote hosts &-- if no
3366 rule is found that matches the host, one that matches the mail domain is
3367 sought. Finally, an argument that is the name of a specific delivery error, as
3368 used in setting up retry rules, can be given. For example:
3369 .code
3370 exim -brt haydn.comp.mus.example quota_3d
3371 Retry rule: *@haydn.comp.mus.example quota_3d  F,1h,15m
3372 .endd
3373
3374 .cmdopt -brw
3375 .cindex "testing" "rewriting"
3376 .cindex "rewriting" "testing"
3377 This option is for testing address rewriting rules, and it must be followed by
3378 a single argument, consisting of either a local part without a domain, or a
3379 complete address with a fully qualified domain. Exim outputs how this address
3380 would be rewritten for each possible place it might appear. See chapter
3381 &<<CHAPrewrite>>& for further details.
3382
3383 .cmdopt -bS
3384 .cindex "SMTP" "batched incoming"
3385 .cindex "batched SMTP input"
3386 This option is used for batched SMTP input, which is an alternative interface
3387 for non-interactive local message submission. A number of messages can be
3388 submitted in a single run. However, despite its name, this is not really SMTP
3389 input. Exim reads each message's envelope from SMTP commands on the standard
3390 input, but generates no responses. If the caller is trusted, or
3391 &%untrusted_set_sender%& is set, the senders in the SMTP MAIL commands are
3392 believed; otherwise the sender is always the caller of Exim.
3393
3394 The message itself is read from the standard input, in SMTP format (leading
3395 dots doubled), terminated by a line containing just a single dot. An error is
3396 provoked if the terminating dot is missing. A further message may then follow.
3397
3398 As for other local message submissions, the contents of incoming batch SMTP
3399 messages can be checked using the non-SMTP ACL (see section &<<SECnonSMTP>>&).
3400 Unqualified addresses are automatically qualified using &%qualify_domain%& and
3401 &%qualify_recipient%&, as appropriate, unless the &%-bnq%& option is used.
3402
3403 Some other SMTP commands are recognized in the input. HELO and EHLO act
3404 as RSET; VRFY, EXPN, ETRN, and HELP act as NOOP;
3405 QUIT quits, ignoring the rest of the standard input.
3406
3407 .cindex "return code" "for &%-bS%&"
3408 If any error is encountered, reports are written to the standard output and
3409 error streams, and Exim gives up immediately. The return code is 0 if no error
3410 was detected; it is 1 if one or more messages were accepted before the error
3411 was detected; otherwise it is 2.
3412
3413 More details of input using batched SMTP are given in section
3414 &<<SECTincomingbatchedSMTP>>&.
3415
3416 .cmdopt -bs
3417 .cindex "SMTP" "local input"
3418 .cindex "local SMTP input"
3419 This option causes Exim to accept one or more messages by reading SMTP commands
3420 on the standard input, and producing SMTP replies on the standard output. SMTP
3421 policy controls, as defined in ACLs (see chapter &<<CHAPACL>>&) are applied.
3422 Some user agents use this interface as a way of passing locally-generated
3423 messages to the MTA.
3424
3425 In
3426 .cindex "sender" "source of"
3427 this usage, if the caller of Exim is trusted, or &%untrusted_set_sender%& is
3428 set, the senders of messages are taken from the SMTP MAIL commands.
3429 Otherwise the content of these commands is ignored and the sender is set up as
3430 the calling user. Unqualified addresses are automatically qualified using
3431 &%qualify_domain%& and &%qualify_recipient%&, as appropriate, unless the
3432 &%-bnq%& option is used.
3433
3434 .cindex "inetd"
3435 The
3436 &%-bs%& option is also used to run Exim from &'inetd'&, as an alternative to
3437 using a listening daemon. Exim can distinguish the two cases by checking
3438 whether the standard input is a TCP/IP socket. When Exim is called from
3439 &'inetd'&, the source of the mail is assumed to be remote, and the comments
3440 above concerning senders and qualification do not apply. In this situation,
3441 Exim behaves in exactly the same way as it does when receiving a message via
3442 the listening daemon.
3443
3444 .cmdopt -bt
3445 .cindex "testing" "addresses"
3446 .cindex "address" "testing"
3447 This option runs Exim in address testing mode, in which each argument is taken
3448 as a recipient address to be tested for deliverability. The results are
3449 written to the standard output. If a test fails, and the caller is not an admin
3450 user, no details of the failure are output, because these might contain
3451 sensitive information such as usernames and passwords for database lookups.
3452
3453 If no arguments are given, Exim runs in an interactive manner, prompting with a
3454 right angle bracket for addresses to be tested.
3455
3456 Unlike the &%-be%& test option, you cannot arrange for Exim to use the
3457 &[readline()]& function, because it is running as &'root'& and there are
3458 security issues.
3459
3460 Each address is handled as if it were the recipient address of a message
3461 (compare the &%-bv%& option). It is passed to the routers and the result is
3462 written to the standard output. However, any router that has
3463 &%no_address_test%& set is bypassed. This can make &%-bt%& easier to use for
3464 genuine routing tests if your first router passes everything to a scanner
3465 program.
3466
3467 .cindex "return code" "for &%-bt%&"
3468 The return code is 2 if any address failed outright; it is 1 if no address
3469 failed outright but at least one could not be resolved for some reason. Return
3470 code 0 is given only when all addresses succeed.
3471
3472 .cindex "duplicate addresses"
3473 &*Note*&: When actually delivering a message, Exim removes duplicate recipient
3474 addresses after routing is complete, so that only one delivery takes place.
3475 This does not happen when testing with &%-bt%&; the full results of routing are
3476 always shown.
3477
3478 &*Warning*&: &%-bt%& can only do relatively simple testing. If any of the
3479 routers in the configuration makes any tests on the sender address of a
3480 message,
3481 .oindex "&%-f%&" "for address testing"
3482 you can use the &%-f%& option to set an appropriate sender when running
3483 &%-bt%& tests. Without it, the sender is assumed to be the calling user at the
3484 default qualifying domain. However, if you have set up (for example) routers
3485 whose behaviour depends on the contents of an incoming message, you cannot test
3486 those conditions using &%-bt%&. The &%-N%& option provides a possible way of
3487 doing such tests.
3488
3489 .cmdopt -bV
3490 .cindex "version number of Exim"
3491 This option causes Exim to write the current version number, compilation
3492 number, and compilation date of the &'exim'& binary to the standard output.
3493 It also lists the DBM library that is being used, the optional modules (such as
3494 specific lookup types), the drivers that are included in the binary, and the
3495 name of the runtime configuration file that is in use.
3496
3497 As part of its operation, &%-bV%& causes Exim to read and syntax check its
3498 configuration file. However, this is a static check only. It cannot check
3499 values that are to be expanded. For example, although a misspelt ACL verb is
3500 detected, an error in the verb's arguments is not. You cannot rely on &%-bV%&
3501 alone to discover (for example) all the typos in the configuration; some
3502 realistic testing is needed. The &%-bh%& and &%-N%& options provide more
3503 dynamic testing facilities.
3504
3505 .cmdopt -bv
3506 .cindex "verifying address" "using &%-bv%&"
3507 .cindex "address" "verification"
3508 This option runs Exim in address verification mode, in which each argument is
3509 taken as a recipient address to be verified by the routers. (This does
3510 not involve any verification callouts). During normal operation, verification
3511 happens mostly as a consequence processing a &%verify%& condition in an ACL
3512 (see chapter &<<CHAPACL>>&). If you want to test an entire ACL, possibly
3513 including callouts, see the &%-bh%& and &%-bhc%& options.
3514
3515 If verification fails, and the caller is not an admin user, no details of the
3516 failure are output, because these might contain sensitive information such as
3517 usernames and passwords for database lookups.
3518
3519 If no arguments are given, Exim runs in an interactive manner, prompting with a
3520 right angle bracket for addresses to be verified.
3521
3522 Unlike the &%-be%& test option, you cannot arrange for Exim to use the
3523 &[readline()]& function, because it is running as &'exim'& and there are
3524 security issues.
3525
3526 Verification differs from address testing (the &%-bt%& option) in that routers
3527 that have &%no_verify%& set are skipped, and if the address is accepted by a
3528 router that has &%fail_verify%& set, verification fails. The address is
3529 verified as a recipient if &%-bv%& is used; to test verification for a sender
3530 address, &%-bvs%& should be used.
3531
3532 If the &%-v%& option is not set, the output consists of a single line for each
3533 address, stating whether it was verified or not, and giving a reason in the
3534 latter case. Without &%-v%&, generating more than one address by redirection
3535 causes verification to end successfully, without considering the generated
3536 addresses. However, if just one address is generated, processing continues,
3537 and the generated address must verify successfully for the overall verification
3538 to succeed.
3539
3540 When &%-v%& is set, more details are given of how the address has been handled,
3541 and in the case of address redirection, all the generated addresses are also
3542 considered. Verification may succeed for some and fail for others.
3543
3544 The
3545 .cindex "return code" "for &%-bv%&"
3546 return code is 2 if any address failed outright; it is 1 if no address
3547 failed outright but at least one could not be resolved for some reason. Return
3548 code 0 is given only when all addresses succeed.
3549
3550 If any of the routers in the configuration makes any tests on the sender
3551 address of a message, you should use the &%-f%& option to set an appropriate
3552 sender when running &%-bv%& tests. Without it, the sender is assumed to be the
3553 calling user at the default qualifying domain.
3554
3555 .cmdopt -bvs
3556 This option acts like &%-bv%&, but verifies the address as a sender rather
3557 than a recipient address. This affects any rewriting and qualification that
3558 might happen.
3559
3560 .cmdopt -bw
3561 .cindex "daemon"
3562 .cindex "inetd"
3563 .cindex "inetd" "wait mode"
3564 This option runs Exim as a daemon, awaiting incoming SMTP connections,
3565 similarly to the &%-bd%& option.  All port specifications on the command-line
3566 and in the configuration file are ignored.  Queue-running may not be specified.
3567
3568 In this mode, Exim expects to be passed a socket as fd 0 (stdin) which is
3569 listening for connections.  This permits the system to start up and have
3570 inetd (or equivalent) listen on the SMTP ports, starting an Exim daemon for
3571 each port only when the first connection is received.
3572
3573 If the option is given as &%-bw%&<&'time'&> then the time is a timeout, after
3574 which the daemon will exit, which should cause inetd to listen once more.
3575
3576 .cmdopt -C <&'filelist'&>
3577 .cindex "configuration file" "alternate"
3578 .cindex "CONFIGURE_FILE"
3579 .cindex "alternate configuration file"
3580 This option causes Exim to find the runtime configuration file from the given
3581 list instead of from the list specified by the CONFIGURE_FILE
3582 compile-time setting. Usually, the list will consist of just a single filename,
3583 but it can be a colon-separated list of names. In this case, the first
3584 file that exists is used. Failure to open an existing file stops Exim from
3585 proceeding any further along the list, and an error is generated.
3586
3587 When this option is used by a caller other than root, and the list is different
3588 from the compiled-in list, Exim gives up its root privilege immediately, and
3589 runs with the real and effective uid and gid set to those of the caller.
3590 However, if a TRUSTED_CONFIG_LIST file is defined in &_Local/Makefile_&, that
3591 file contains a list of full pathnames, one per line, for configuration files
3592 which are trusted. Root privilege is retained for any configuration file so
3593 listed, as long as the caller is the Exim user (or the user specified in the
3594 CONFIGURE_OWNER option, if any), and as long as the configuration file is
3595 not writeable by inappropriate users or groups.
3596
3597 Leaving TRUSTED_CONFIG_LIST unset precludes the possibility of testing a
3598 configuration using &%-C%& right through message reception and delivery,
3599 even if the caller is root. The reception works, but by that time, Exim is
3600 running as the Exim user, so when it re-executes to regain privilege for the
3601 delivery, the use of &%-C%& causes privilege to be lost. However, root can
3602 test reception and delivery using two separate commands (one to put a message
3603 in the queue, using &%-odq%&, and another to do the delivery, using &%-M%&).
3604
3605 If ALT_CONFIG_PREFIX is defined &_in Local/Makefile_&, it specifies a
3606 prefix string with which any file named in a &%-C%& command line option
3607 must start. In addition, the filename must not contain the sequence &`/../`&.
3608 However, if the value of the &%-C%& option is identical to the value of
3609 CONFIGURE_FILE in &_Local/Makefile_&, Exim ignores &%-C%& and proceeds as
3610 usual. There is no default setting for ALT_CONFIG_PREFIX; when it is
3611 unset, any filename can be used with &%-C%&.
3612
3613 ALT_CONFIG_PREFIX can be used to confine alternative configuration files
3614 to a directory to which only root has access. This prevents someone who has
3615 broken into the Exim account from running a privileged Exim with an arbitrary
3616 configuration file.
3617
3618 The &%-C%& facility is useful for ensuring that configuration files are
3619 syntactically correct, but cannot be used for test deliveries, unless the
3620 caller is privileged, or unless it is an exotic configuration that does not
3621 require privilege. No check is made on the owner or group of the files
3622 specified by this option.
3623
3624
3625 .vitem &%-D%&<&'macro'&>=<&'value'&>
3626 .oindex "&%-D%&"
3627 .cindex "macro" "setting on command line"
3628 This option can be used to override macro definitions in the configuration file
3629 (see section &<<SECTmacrodefs>>&). However, like &%-C%&, if it is used by an
3630 unprivileged caller, it causes Exim to give up its root privilege.
3631 If DISABLE_D_OPTION is defined in &_Local/Makefile_&, the use of &%-D%& is
3632 completely disabled, and its use causes an immediate error exit.
3633
3634 If WHITELIST_D_MACROS is defined in &_Local/Makefile_& then it should be a
3635 colon-separated list of macros which are considered safe and, if &%-D%& only
3636 supplies macros from this list, and the values are acceptable, then Exim will
3637 not give up root privilege if the caller is root, the Exim run-time user, or
3638 the CONFIGURE_OWNER, if set.  This is a transition mechanism and is expected
3639 to be removed in the future.  Acceptable values for the macros satisfy the
3640 regexp: &`^[A-Za-z0-9_/.-]*$`&
3641
3642 The entire option (including equals sign if present) must all be within one
3643 command line item. &%-D%& can be used to set the value of a macro to the empty
3644 string, in which case the equals sign is optional. These two commands are
3645 synonymous:
3646 .code
3647 exim -DABC  ...
3648 exim -DABC= ...
3649 .endd
3650 To include spaces in a macro definition item, quotes must be used. If you use
3651 quotes, spaces are permitted around the macro name and the equals sign. For
3652 example:
3653 .code
3654 exim '-D ABC = something' ...
3655 .endd
3656 &%-D%& may be repeated up to 10 times on a command line.
3657 Only macro names up to 22 letters long can be set.
3658
3659
3660 .vitem &%-d%&<&'debug&~options'&>
3661 .oindex "&%-d%&"
3662 .cindex "debugging" "list of selectors"
3663 .cindex "debugging" "&%-d%& option"
3664 This option causes debugging information to be written to the standard
3665 error stream. It is restricted to admin users because debugging output may show
3666 database queries that contain password information. Also, the details of users'
3667 filter files should be protected. If a non-admin user uses &%-d%&, Exim
3668 writes an error message to the standard error stream and exits with a non-zero
3669 return code.
3670
3671 When &%-d%& is used, &%-v%& is assumed. If &%-d%& is given on its own, a lot of
3672 standard debugging data is output. This can be reduced, or increased to include
3673 some more rarely needed information, by directly following &%-d%& with a string
3674 made up of names preceded by plus or minus characters. These add or remove sets
3675 of debugging data, respectively. For example, &%-d+filter%& adds filter
3676 debugging, whereas &%-d-all+filter%& selects only filter debugging. Note that
3677 no spaces are allowed in the debug setting. The available debugging categories
3678 are:
3679 .itable none 0 0 2 20* left 80* left
3680 .irow acl            "ACL interpretation"
3681 .irow auth           "authenticators"
3682 .irow deliver        "general delivery logic"
3683 .irow dns            "DNS lookups (see also resolver)"
3684 .irow dnsbl          "DNS black list (aka RBL) code"
3685 .irow exec           "arguments for &[execv()]& calls"
3686 .irow expand         "detailed debugging for string expansions"
3687 .irow filter         "filter handling"
3688 .irow hints_lookup   "hints data lookups"
3689 .irow host_lookup    "all types of name-to-IP address handling"
3690 .irow ident          "ident lookup"
3691 .irow interface      "lists of local interfaces"
3692 .irow lists          "matching things in lists"
3693 .irow load           "system load checks"
3694 .irow local_scan     "can be used by &[local_scan()]& (see chapter &&&
3695                     &<<CHAPlocalscan>>&)"
3696 .irow lookup         "general lookup code and all lookups"
3697 .irow memory         "memory handling"
3698 .irow noutf8         "modifier: avoid UTF-8 line-drawing"
3699 .irow pid            "modifier: add pid to debug output lines"
3700 .irow process_info   "setting info for the process log"
3701 .irow queue_run      "queue runs"
3702 .irow receive        "general message reception logic"
3703 .irow resolver       "turn on the DNS resolver's debugging output"
3704 .irow retry          "retry handling"
3705 .irow rewrite        "address rewriting""
3706 .irow route          "address routing"
3707 .irow timestamp      "modifier: add timestamp to debug output lines"
3708 .irow tls            "TLS logic"
3709 .irow transport      "transports"
3710 .irow uid            "changes of uid/gid and looking up uid/gid"
3711 .irow verify         "address verification logic"
3712 .irow all            "almost all of the above (see below), and also &%-v%&"
3713 .endtable
3714 The &`all`& option excludes &`memory`& when used as &`+all`&, but includes it
3715 for &`-all`&. The reason for this is that &`+all`& is something that people
3716 tend to use when generating debug output for Exim maintainers. If &`+memory`&
3717 is included, an awful lot of output that is very rarely of interest is
3718 generated, so it now has to be explicitly requested. However, &`-all`& does
3719 turn everything off.
3720
3721 .cindex "resolver, debugging output"
3722 .cindex "DNS resolver, debugging output"
3723 The &`resolver`& option produces output only if the DNS resolver was compiled
3724 with DEBUG enabled. This is not the case in some operating systems. Also,
3725 unfortunately, debugging output from the DNS resolver is written to stdout
3726 rather than stderr.
3727
3728 The default (&%-d%& with no argument) omits &`expand`&, &`filter`&,
3729 &`interface`&, &`load`&, &`memory`&, &`pid`&, &`resolver`&, and &`timestamp`&.
3730 However, the &`pid`& selector is forced when debugging is turned on for a
3731 daemon, which then passes it on to any re-executed Exims. Exim also
3732 automatically adds the pid to debug lines when several remote deliveries are
3733 run in parallel.
3734
3735 The &`timestamp`& selector causes the current time to be inserted at the start
3736 of all debug output lines. This can be useful when trying to track down delays
3737 in processing.
3738
3739 .cindex debugging "UTF-8 in"
3740 .cindex UTF-8 "in debug output"
3741 The &`noutf8`& selector disables the use of
3742 UTF-8 line-drawing characters to group related information.
3743 When disabled. ascii-art is used instead.
3744 Using the &`+all`& option does not set this modifier,
3745
3746 If the &%debug_print%& option is set in any driver, it produces output whenever
3747 any debugging is selected, or if &%-v%& is used.
3748
3749 .vitem &%-dd%&<&'debug&~options'&>
3750 .oindex "&%-dd%&"
3751 This option behaves exactly like &%-d%& except when used on a command that
3752 starts a daemon process. In that case, debugging is turned off for the
3753 subprocesses that the daemon creates. Thus, it is useful for monitoring the
3754 behaviour of the daemon without creating as much output as full debugging does.
3755
3756 .cmdopt -dropcr
3757 This is an obsolete option that is now a no-op. It used to affect the way Exim
3758 handled CR and LF characters in incoming messages. What happens now is
3759 described in section &<<SECTlineendings>>&.
3760
3761 .cmdopt -E
3762 .cindex "bounce message" "generating"
3763 This option specifies that an incoming message is a locally-generated delivery
3764 failure report. It is used internally by Exim when handling delivery failures
3765 and is not intended for external use. Its only effect is to stop Exim
3766 generating certain messages to the postmaster, as otherwise message cascades
3767 could occur in some situations. As part of the same option, a message id may
3768 follow the characters &%-E%&. If it does, the log entry for the receipt of the
3769 new message contains the id, following &"R="&, as a cross-reference.
3770
3771 .vitem &%-e%&&'x'&
3772 .oindex "&%-e%&&'x'&"
3773 There are a number of Sendmail options starting with &%-oe%& which seem to be
3774 called by various programs without the leading &%o%& in the option. For
3775 example, the &%vacation%& program uses &%-eq%&. Exim treats all options of the
3776 form &%-e%&&'x'& as synonymous with the corresponding &%-oe%&&'x'& options.
3777
3778 .cmdopt -F <&'string'&>
3779 .cindex "sender" "name"
3780 .cindex "name" "of sender"
3781 This option sets the sender's full name for use when a locally-generated
3782 message is being accepted. In the absence of this option, the user's &'gecos'&
3783 entry from the password data is used. As users are generally permitted to alter
3784 their &'gecos'& entries, no security considerations are involved. White space
3785 between &%-F%& and the <&'string'&> is optional.
3786
3787 .cmdopt -f <&'address'&>
3788 .cindex "sender" "address"
3789 .cindex "address" "sender"
3790 .cindex "trusted users"
3791 .cindex "envelope from"
3792 .cindex "envelope sender"
3793 .cindex "user" "trusted"
3794 This option sets the address of the envelope sender of a locally-generated
3795 message (also known as the return path). The option can normally be used only
3796 by a trusted user, but &%untrusted_set_sender%& can be set to allow untrusted
3797 users to use it.
3798
3799 Processes running as root or the Exim user are always trusted. Other
3800 trusted users are defined by the &%trusted_users%& or &%trusted_groups%&
3801 options. In the absence of &%-f%&, or if the caller is not trusted, the sender
3802 of a local message is set to the caller's login name at the default qualify
3803 domain.
3804
3805 There is one exception to the restriction on the use of &%-f%&: an empty sender
3806 can be specified by any user, trusted or not, to create a message that can
3807 never provoke a bounce. An empty sender can be specified either as an empty
3808 string, or as a pair of angle brackets with nothing between them, as in these
3809 examples of shell commands:
3810 .code
3811 exim -f '<>' user@domain
3812 exim -f "" user@domain
3813 .endd
3814 In addition, the use of &%-f%& is not restricted when testing a filter file
3815 with &%-bf%& or when testing or verifying addresses using the &%-bt%& or
3816 &%-bv%& options.
3817
3818 Allowing untrusted users to change the sender address does not of itself make
3819 it possible to send anonymous mail. Exim still checks that the &'From:'& header
3820 refers to the local user, and if it does not, it adds a &'Sender:'& header,
3821 though this can be overridden by setting &%no_local_from_check%&.
3822
3823 White
3824 .cindex "&""From""& line"
3825 space between &%-f%& and the <&'address'&> is optional (that is, they can be
3826 given as two arguments or one combined argument). The sender of a
3827 locally-generated message can also be set (when permitted) by an initial
3828 &"From&~"& line in the message &-- see the description of &%-bm%& above &-- but
3829 if &%-f%& is also present, it overrides &"From&~"&.
3830
3831 .cmdopt -G
3832 .cindex "submission fixups, suppressing (command-line)"
3833 This option is equivalent to an ACL applying:
3834 .code
3835 control = suppress_local_fixups
3836 .endd
3837 for every message received.  Note that Sendmail will complain about such
3838 bad formatting, where Exim silently just does not fix it up.  This may change
3839 in future.
3840
3841 As this affects audit information, the caller must be a trusted user to use
3842 this option.
3843
3844 .cmdopt -h <&'number'&>
3845 .cindex "Sendmail compatibility" "&%-h%& option ignored"
3846 This option is accepted for compatibility with Sendmail, but has no effect. (In
3847 Sendmail it overrides the &"hop count"& obtained by counting &'Received:'&
3848 headers.)
3849
3850 .cmdopt -i
3851 .cindex "Solaris" "&'mail'& command"
3852 .cindex "dot" "in incoming non-SMTP message"
3853 This option, which has the same effect as &%-oi%&, specifies that a dot on a
3854 line by itself should not terminate an incoming, non-SMTP message.
3855 Solaris 2.4 (SunOS 5.4) Sendmail has a similar &%-i%& processing option
3856 &url(https://docs.oracle.com/cd/E19457-01/801-6680-1M/801-6680-1M.pdf),
3857 p. 1M-529), and therefore a &%-oi%& command line option, which both are used
3858 by its &'mailx'& command.
3859
3860 .cmdopt -L <&'tag'&>
3861 .cindex "syslog" "process name; set with flag"
3862 This option is equivalent to setting &%syslog_processname%& in the config
3863 file and setting &%log_file_path%& to &`syslog`&.
3864 Its use is restricted to administrators.  The configuration file has to be
3865 read and parsed, to determine access rights, before this is set and takes
3866 effect, so early configuration file errors will not honour this flag.
3867
3868 The tag should not be longer than 32 characters.
3869
3870 .cmdopt -M <&'message&~id'&>&~<&'message&~id'&>&~...
3871 .cindex "forcing delivery"
3872 .cindex "delivery" "forcing attempt"
3873 .cindex "frozen messages" "forcing delivery"
3874 This option requests Exim to run a delivery attempt on each message in turn. If
3875 any of the messages are frozen, they are automatically thawed before the
3876 delivery attempt. The settings of &%queue_domains%&, &%queue_smtp_domains%&,
3877 and &%hold_domains%& are ignored.
3878
3879 Retry
3880 .cindex "hints database" "overriding retry hints"
3881 hints for any of the addresses are overridden &-- Exim tries to deliver even if
3882 the normal retry time has not yet been reached. This option requires the caller
3883 to be an admin user. However, there is an option called &%prod_requires_admin%&
3884 which can be set false to relax this restriction (and also the same requirement
3885 for the &%-q%&, &%-R%&, and &%-S%& options).
3886
3887 The deliveries happen synchronously, that is, the original Exim process does
3888 not terminate until all the delivery attempts have finished. No output is
3889 produced unless there is a serious error. If you want to see what is happening,
3890 use the &%-v%& option as well, or inspect Exim's main log.
3891
3892 .cmdopt -Mar <&'message&~id'&>&~<&'address'&>&~<&'address'&>&~...
3893 .cindex "message" "adding recipients"
3894 .cindex "recipient" "adding"
3895 This option requests Exim to add the addresses to the list of recipients of the
3896 message (&"ar"& for &"add recipients"&). The first argument must be a message
3897 id, and the remaining ones must be email addresses. However, if the message is
3898 active (in the middle of a delivery attempt), it is not altered. This option
3899 can be used only by an admin user.
3900
3901 .vitem "&%-MC%&&~<&'transport'&>&~<&'hostname'&>&&&
3902         &~<&'host&~IP'&>&&&
3903         &~<&'sequence&~number'&>&&&
3904         &~<&'message&~id'&>"
3905 .oindex "&%-MC%&"
3906 .cindex "SMTP" "passed connection"
3907 .cindex "SMTP" "multiple deliveries"
3908 .cindex "multiple SMTP deliveries"
3909 This option is not intended for use by external callers. It is used internally
3910 by Exim to invoke another instance of itself to deliver a waiting message using
3911 an existing SMTP connection, which is passed as the standard input. Details are
3912 given in chapter &<<CHAPSMTP>>&. This must be the final option, and the caller
3913 must be root or the Exim user in order to use it.
3914
3915 .cmdopt -MCA
3916 This option is not intended for use by external callers. It is used internally
3917 by Exim in conjunction with the &%-MC%& option. It signifies that the
3918 connection to the remote host has been authenticated.
3919
3920 .cmdopt -MCD
3921 This option is not intended for use by external callers. It is used internally
3922 by Exim in conjunction with the &%-MC%& option. It signifies that the
3923 remote host supports the ESMTP &_DSN_& extension.
3924
3925 .cmdopt -MCd
3926 This option is not intended for use by external callers. It is used internally
3927 by Exim in conjunction with the &%-d%& option
3928 to pass on an information string on the purpose of the process.
3929
3930 .cmdopt -MCG <&'queue&~name'&>
3931 This option is not intended for use by external callers. It is used internally
3932 by Exim in conjunction with the &%-MC%& option. It signifies that an
3933 alternate queue is used, named by the following argument.
3934
3935 .cmdopt -MCK
3936 This option is not intended for use by external callers. It is used internally
3937 by Exim in conjunction with the &%-MC%& option. It signifies that a
3938 remote host supports the ESMTP &_CHUNKING_& extension.
3939
3940 .cmdopt -MCL
3941 This option is not intended for use by external callers. It is used internally
3942 by Exim in conjunction with the &%-MC%& option. It signifies that the server to
3943 which Exim is connected advertised limits on numbers of mails, recipients or
3944 recipient domains.
3945 The limits are given by the following three arguments.
3946
3947 .cmdopt -MCP
3948 This option is not intended for use by external callers. It is used internally
3949 by Exim in conjunction with the &%-MC%& option. It signifies that the server to
3950 which Exim is connected supports pipelining.
3951
3952 .cmdopt -MCp
3953 This option is not intended for use by external callers. It is used internally
3954 by Exim in conjunction with the &%-MC%& option. It signifies that the connection
3955 t a remote server is via a SOCKS proxy, using addresses and ports given by
3956 the following four arguments.
3957
3958 .cmdopt -MCQ <&'process&~id'&>&~<&'pipe&~fd'&>
3959 This option is not intended for use by external callers. It is used internally
3960 by Exim in conjunction with the &%-MC%& option when the original delivery was
3961 started by a queue runner. It passes on the process id of the queue runner,
3962 together with the file descriptor number of an open pipe. Closure of the pipe
3963 signals the final completion of the sequence of processes that are passing
3964 messages through the same SMTP connection.
3965
3966 .cmdopt -MCq <&'recipient&~address'&>&~<&'size'&>
3967 This option is not intended for use by external callers. It is used internally
3968 by Exim to implement quota checking for local users.
3969
3970 .cmdopt -MCS
3971 This option is not intended for use by external callers. It is used internally
3972 by Exim in conjunction with the &%-MC%& option, and passes on the fact that the
3973 ESMTP SIZE option should be used on messages delivered down the existing
3974 connection.
3975
3976 .cmdopt -MCT
3977 This option is not intended for use by external callers. It is used internally
3978 by Exim in conjunction with the &%-MC%& option, and passes on the fact that the
3979 host to which Exim is connected supports TLS encryption.
3980
3981 .vitem &%-MCr%&&~<&'SNI'&> &&&
3982        &%-MCs%&&~<&'SNI'&>
3983 .oindex "&%-MCs%&"
3984 .oindex "&%-MCr%&"
3985 These options are not intended for use by external callers. It is used internally
3986 by Exim in conjunction with the &%-MCt%& option, and passes on the fact that
3987 a TLS Server Name Indication was sent as part of the channel establishment.
3988 The argument gives the SNI string.
3989 The "r" variant indicates a DANE-verified connection.
3990
3991 .cmdopt -MCt <&'IP&~address'&>&~<&'port'&>&~<&'cipher'&>
3992 This option is not intended for use by external callers. It is used internally
3993 by Exim in conjunction with the &%-MC%& option, and passes on the fact that the
3994 connection is being proxied by a parent process for handling TLS encryption.
3995 The arguments give the local address and port being proxied, and the TLS cipher.
3996
3997 .cmdopt -Mc <&'message&~id'&>&~<&'message&~id'&>&~...
3998 .cindex "hints database" "not overridden by &%-Mc%&"
3999 .cindex "delivery" "manually started &-- not forced"
4000 This option requests Exim to run a delivery attempt on each message, in turn,
4001 but unlike the &%-M%& option, it does check for retry hints, and respects any
4002 that are found. This option is not very useful to external callers. It is
4003 provided mainly for internal use by Exim when it needs to re-invoke itself in
4004 order to regain root privilege for a delivery (see chapter &<<CHAPsecurity>>&).
4005 However, &%-Mc%& can be useful when testing, in order to run a delivery that
4006 respects retry times and other options such as &%hold_domains%& that are
4007 overridden when &%-M%& is used. Such a delivery does not count as a queue run.
4008 If you want to run a specific delivery as if in a queue run, you should use
4009 &%-q%& with a message id argument. A distinction between queue run deliveries
4010 and other deliveries is made in one or two places.
4011
4012 .cmdopt -Mes <&'message&~id'&>&~<&'address'&>
4013 .cindex "message" "changing sender"
4014 .cindex "sender" "changing"
4015 This option requests Exim to change the sender address in the message to the
4016 given address, which must be a fully qualified address or &"<>"& (&"es"& for
4017 &"edit sender"&). There must be exactly two arguments. The first argument must
4018 be a message id, and the second one an email address. However, if the message
4019 is active (in the middle of a delivery attempt), its status is not altered.
4020 This option can be used only by an admin user.
4021
4022 .cmdopt -Mf <&'message&~id'&>&~<&'message&~id'&>&~...
4023 .cindex "freezing messages"
4024 .cindex "message" "manually freezing"
4025 This option requests Exim to mark each listed message as &"frozen"&. This
4026 prevents any delivery attempts taking place until the message is &"thawed"&,
4027 either manually or as a result of the &%auto_thaw%& configuration option.
4028 However, if any of the messages are active (in the middle of a delivery
4029 attempt), their status is not altered. This option can be used only by an admin
4030 user.
4031
4032 .cmdopt -Mg <&'message&~id'&>&~<&'message&~id'&>&~...
4033 .cindex "giving up on messages"
4034 .cindex "message" "abandoning delivery attempts"
4035 .cindex "delivery" "abandoning further attempts"
4036 This option requests Exim to give up trying to deliver the listed messages,
4037 including any that are frozen. However, if any of the messages are active,
4038 their status is not altered. For non-bounce messages, a delivery error message
4039 is sent to the sender.
4040 Bounce messages are just discarded. This option can be used only by an admin
4041 user.
4042
4043 .cmdopt -MG <&'queue&~name'&>&~<&'message&~id'&>&~<&'message&~id'&>&~...
4044 .cindex queue named
4045 .cindex "named queues" "moving messages"
4046 .cindex "queue" "moving messages"
4047 This option requests that each listed message be moved from its current
4048 queue to the given named queue.
4049 The destination queue name argument is required, but can be an empty
4050 string to define the default queue.
4051 If the messages are not currently located in the default queue,
4052 a &%-qG<name>%& option will be required to define the source queue.
4053
4054 .cmdopt -Mmad <&'message&~id'&>&~<&'message&~id'&>&~...
4055 .cindex "delivery" "cancelling all"
4056 This option requests Exim to mark all the recipient addresses in the messages
4057 as already delivered (&"mad"& for &"mark all delivered"&). However, if any
4058 message is active (in the middle of a delivery attempt), its status is not
4059 altered. This option can be used only by an admin user.
4060
4061 .cmdopt -Mmd <&'message&~id'&>&~<&'address'&>&~<&'address'&>&~...
4062 .cindex "delivery" "cancelling by address"
4063 .cindex "recipient" "removing"
4064 .cindex "removing recipients"
4065 This option requests Exim to mark the given addresses as already delivered
4066 (&"md"& for &"mark delivered"&). The first argument must be a message id, and
4067 the remaining ones must be email addresses. These are matched to recipient
4068 addresses in the message in a case-sensitive manner. If the message is active
4069 (in the middle of a delivery attempt), its status is not altered. This option
4070 can be used only by an admin user.
4071
4072 .cmdopt -Mrm <&'message&~id'&>&~<&'message&~id'&>&~...
4073 .cindex "removing messages"
4074 .cindex "abandoning mail"
4075 .cindex "message" "manually discarding"
4076 This option requests Exim to remove the given messages from the queue. No
4077 bounce messages are sent; each message is simply forgotten. However, if any of
4078 the messages are active, their status is not altered. This option can be used
4079 only by an admin user or by the user who originally caused the message to be
4080 placed in the queue.
4081
4082 . .new
4083 . .vitem &%-MS%&
4084 . .oindex "&%-MS%&"
4085 . .cindex REQUIRETLS
4086 . This option is used to request REQUIRETLS processing on the message.
4087 . It is used internally by Exim in conjunction with -E when generating
4088 . a bounce message.
4089 . .wen
4090
4091 .cmdopt -Mset <&'message&~id'&>
4092 .cindex "testing" "string expansion"
4093 .cindex "expansion" "testing"
4094 This option is useful only in conjunction with &%-be%& (that is, when testing
4095 string expansions). Exim loads the given message from its spool before doing
4096 the test expansions, thus setting message-specific variables such as
4097 &$message_size$& and the header variables. The &$recipients$& variable is made
4098 available. This feature is provided to make it easier to test expansions that
4099 make use of these variables. However, this option can be used only by an admin
4100 user. See also &%-bem%&.
4101
4102 .cmdopt -Mt <&'message&~id'&>&~<&'message&~id'&>&~...
4103 .cindex "thawing messages"
4104 .cindex "unfreezing messages"
4105 .cindex "frozen messages" "thawing"
4106 .cindex "message" "thawing frozen"
4107 This option requests Exim to &"thaw"& any of the listed messages that are
4108 &"frozen"&, so that delivery attempts can resume. However, if any of the
4109 messages are active, their status is not altered. This option can be used only
4110 by an admin user.
4111
4112 .cmdopt -Mvb <&'message&~id'&>
4113 .cindex "listing" "message body"
4114 .cindex "message" "listing body of"
4115 This option causes the contents of the message body (-D) spool file to be
4116 written to the standard output. This option can be used only by an admin user.
4117
4118 .cmdopt -Mvc <&'message&~id'&>
4119 .cindex "message" "listing in RFC 2822 format"
4120 .cindex "listing" "message in RFC 2822 format"
4121 This option causes a copy of the complete message (header lines plus body) to
4122 be written to the standard output in RFC 2822 format. This option can be used
4123 only by an admin user.
4124
4125 .cmdopt -Mvh <&'message&~id'&>
4126 .cindex "listing" "message headers"
4127 .cindex "header lines" "listing"
4128 .cindex "message" "listing header lines"
4129 This option causes the contents of the message headers (-H) spool file to be
4130 written to the standard output. This option can be used only by an admin user.
4131
4132 .cmdopt -Mvl <&'message&~id'&>
4133 .cindex "listing" "message log"
4134 .cindex "message" "listing message log"
4135 This option causes the contents of the message log spool file to be written to
4136 the standard output. This option can be used only by an admin user.
4137
4138 .cmdopt -m
4139 This is a synonym for &%-om%& that is accepted by Sendmail
4140 (&url(https://docs.oracle.com/cd/E19457-01/801-6680-1M/801-6680-1M.pdf)
4141 p. 1M-258), so Exim treats it that way too.
4142
4143 .cmdopt -N
4144 .cindex "debugging" "&%-N%& option"
4145 .cindex "debugging" "suppressing delivery"
4146 This is a debugging option that inhibits delivery of a message at the transport
4147 level. It implies &%-v%&. Exim goes through many of the motions of delivery &--
4148 it just doesn't actually transport the message, but instead behaves as if it
4149 had successfully done so. However, it does not make any updates to the retry
4150 database, and the log entries for deliveries are flagged with &"*>"& rather
4151 than &"=>"&.
4152
4153 Because &%-N%& discards any message to which it applies, only root or the Exim
4154 user are allowed to use it with &%-bd%&, &%-q%&, &%-R%& or &%-M%&. In other
4155 words, an ordinary user can use it only when supplying an incoming message to
4156 which it will apply. Although transportation never fails when &%-N%& is set, an
4157 address may be deferred because of a configuration problem on a transport, or a
4158 routing problem. Once &%-N%& has been used for a delivery attempt, it sticks to
4159 the message, and applies to any subsequent delivery attempts that may happen
4160 for that message.
4161
4162 .cmdopt -n
4163 This option is interpreted by Sendmail to mean &"no aliasing"&.
4164 For normal modes of operation, it is ignored by Exim.
4165 When combined with &%-bP%& it makes the output more terse (suppresses
4166 option names, environment values and config pretty printing).
4167
4168 .cmdopt -O <&'data'&>
4169 This option is interpreted by Sendmail to mean &`set option`&. It is ignored by
4170 Exim.
4171
4172 .cmdopt -oA <&'file&~name'&>
4173 .cindex "Sendmail compatibility" "&%-oA%& option"
4174 This option is used by Sendmail in conjunction with &%-bi%& to specify an
4175 alternative alias filename. Exim handles &%-bi%& differently; see the
4176 description above.
4177
4178 .cmdopt -oB <&'n'&>
4179 .cindex "SMTP" "passed connection"
4180 .cindex "SMTP" "multiple deliveries"
4181 .cindex "multiple SMTP deliveries"
4182 This is a debugging option which limits the maximum number of messages that can
4183 be delivered down one SMTP connection, overriding the value set in any &(smtp)&
4184 transport. If <&'n'&> is omitted, the limit is set to 1.
4185
4186 .cmdopt -odb
4187 .cindex "background delivery"
4188 .cindex "delivery" "in the background"
4189 This option applies to all modes in which Exim accepts incoming messages,
4190 including the listening daemon. It requests &"background"& delivery of such
4191 messages, which means that the accepting process automatically starts a
4192 delivery process for each message received, but does not wait for the delivery
4193 processes to finish.
4194
4195 When all the messages have been received, the reception process exits,
4196 leaving the delivery processes to finish in their own time. The standard output
4197 and error streams are closed at the start of each delivery process.
4198 This is the default action if none of the &%-od%& options are present.
4199
4200 If one of the queueing options in the configuration file
4201 (&%queue_only%& or &%queue_only_file%&, for example) is in effect, &%-odb%&
4202 overrides it if &%queue_only_override%& is set true, which is the default
4203 setting. If &%queue_only_override%& is set false, &%-odb%& has no effect.
4204
4205 .cmdopt -odf
4206 .cindex "foreground delivery"
4207 .cindex "delivery" "in the foreground"
4208 This option requests &"foreground"& (synchronous) delivery when Exim has
4209 accepted a locally-generated message. (For the daemon it is exactly the same as
4210 &%-odb%&.) A delivery process is automatically started to deliver the message,
4211 and Exim waits for it to complete before proceeding.
4212
4213 The original Exim reception process does not finish until the delivery
4214 process for the final message has ended. The standard error stream is left open
4215 during deliveries.
4216
4217 However, like &%-odb%&, this option has no effect if &%queue_only_override%& is
4218 false and one of the queueing options in the configuration file is in effect.
4219
4220 If there is a temporary delivery error during foreground delivery, the
4221 message is left in the queue for later delivery, and the original reception
4222 process exits. See chapter &<<CHAPnonqueueing>>& for a way of setting up a
4223 restricted configuration that never queues messages.
4224
4225
4226 .cmdopt -odi
4227 This option is synonymous with &%-odf%&. It is provided for compatibility with
4228 Sendmail.
4229
4230 .cmdopt -odq
4231 .cindex "non-immediate delivery"
4232 .cindex "delivery" "suppressing immediate"
4233 .cindex "queueing incoming messages"
4234 This option applies to all modes in which Exim accepts incoming messages,
4235 including the listening daemon. It specifies that the accepting process should
4236 not automatically start a delivery process for each message received. Messages
4237 are placed in the queue, and remain there until a subsequent queue runner
4238 process encounters them. There are several configuration options (such as
4239 &%queue_only%&) that can be used to queue incoming messages under certain
4240 conditions. This option overrides all of them and also &%-odqs%&. It always
4241 forces queueing.
4242
4243 .cmdopt -odqs
4244 .cindex "SMTP" "delaying delivery"
4245 .cindex "first pass routing"
4246 This option is a hybrid between &%-odb%&/&%-odi%& and &%-odq%&.
4247 However, like &%-odb%& and &%-odi%&, this option has no effect if
4248 &%queue_only_override%& is false and one of the queueing options in the
4249 configuration file is in effect.
4250
4251 When &%-odqs%& does operate, a delivery process is started for each incoming
4252 message, in the background by default, but in the foreground if &%-odi%& is
4253 also present. The recipient addresses are routed, and local deliveries are done
4254 in the normal way. However, if any SMTP deliveries are required, they are not
4255 done at this time, so the message remains in the queue until a subsequent queue
4256 runner process encounters it. Because routing was done, Exim knows which
4257 messages are waiting for which hosts, and so a number of messages for the same
4258 host can be sent in a single SMTP connection. The &%queue_smtp_domains%&
4259 configuration option has the same effect for specific domains. See also the
4260 &%-qq%& option.
4261
4262 .cmdopt -oee
4263 .cindex "error" "reporting"
4264 If an error is detected while a non-SMTP message is being received (for
4265 example, a malformed address), the error is reported to the sender in a mail
4266 message.
4267
4268 .cindex "return code" "for &%-oee%&"
4269 Provided
4270 this error message is successfully sent, the Exim receiving process
4271 exits with a return code of zero. If not, the return code is 2 if the problem
4272 is that the original message has no recipients, or 1 for any other error.
4273 This is the default &%-oe%&&'x'& option if Exim is called as &'rmail'&.
4274
4275 .cmdopt -oem
4276 .cindex "error" "reporting"
4277 .cindex "return code" "for &%-oem%&"
4278 This is the same as &%-oee%&, except that Exim always exits with a non-zero
4279 return code, whether or not the error message was successfully sent.
4280 This is the default &%-oe%&&'x'& option, unless Exim is called as &'rmail'&.
4281
4282 .cmdopt -oep
4283 .cindex "error" "reporting"
4284 If an error is detected while a non-SMTP message is being received, the
4285 error is reported by writing a message to the standard error file (stderr).
4286 .cindex "return code" "for &%-oep%&"
4287 The return code is 1 for all errors.
4288
4289 .cmdopt -oeq
4290 .cindex "error" "reporting"
4291 This option is supported for compatibility with Sendmail, but has the same
4292 effect as &%-oep%&.
4293
4294 .cmdopt -oew
4295 .cindex "error" "reporting"
4296 This option is supported for compatibility with Sendmail, but has the same
4297 effect as &%-oem%&.
4298
4299 .cmdopt -oi
4300 .cindex "dot" "in incoming non-SMTP message"
4301 This option, which has the same effect as &%-i%&, specifies that a dot on a
4302 line by itself should not terminate an incoming, non-SMTP message. Otherwise, a
4303 single dot does terminate, though Exim does no special processing for other
4304 lines that start with a dot. This option is set by default if Exim is called as
4305 &'rmail'&. See also &%-ti%&.
4306
4307 .cmdopt -oitrue
4308 This option is treated as synonymous with &%-oi%&.
4309
4310 .cmdopt -oMa <&'host&~address'&>
4311 .cindex "sender" "host address, specifying for local message"
4312 A number of options starting with &%-oM%& can be used to set values associated
4313 with remote hosts on locally-submitted messages (that is, messages not received
4314 over TCP/IP). These options can be used by any caller in conjunction with the
4315 &%-bh%&, &%-be%&, &%-bf%&, &%-bF%&, &%-bt%&, or &%-bv%& testing options. In
4316 other circumstances, they are ignored unless the caller is trusted.
4317
4318 The &%-oMa%& option sets the sender host address. This may include a port
4319 number at the end, after a full stop (period). For example:
4320 .code
4321 exim -bs -oMa 10.9.8.7.1234
4322 .endd
4323 An alternative syntax is to enclose the IP address in square brackets,
4324 followed by a colon and the port number:
4325 .code
4326 exim -bs -oMa [10.9.8.7]:1234
4327 .endd
4328 The IP address is placed in the &$sender_host_address$& variable, and the
4329 port, if present, in &$sender_host_port$&. If both &%-oMa%& and &%-bh%&
4330 are present on the command line, the sender host IP address is taken from
4331 whichever one is last.
4332
4333 .cmdopt -oMaa <&'name'&>
4334 .cindex "authentication" "name, specifying for local message"
4335 See &%-oMa%& above for general remarks about the &%-oM%& options. The &%-oMaa%&
4336 option sets the value of &$sender_host_authenticated$& (the authenticator
4337 name). See chapter &<<CHAPSMTPAUTH>>& for a discussion of SMTP authentication.
4338 This option can be used with &%-bh%& and &%-bs%& to set up an
4339 authenticated SMTP session without actually using the SMTP AUTH command.
4340
4341 .cmdopt -oMai <&'string'&>
4342 .cindex "authentication" "id, specifying for local message"
4343 See &%-oMa%& above for general remarks about the &%-oM%& options. The &%-oMai%&
4344 option sets the value of &$authenticated_id$& (the id that was authenticated).
4345 This overrides the default value (the caller's login id, except with &%-bh%&,
4346 where there is no default) for messages from local sources. See chapter
4347 &<<CHAPSMTPAUTH>>& for a discussion of authenticated ids.
4348
4349 .cmdopt -oMas <&'address'&>
4350 .cindex "authentication" "sender, specifying for local message"
4351 See &%-oMa%& above for general remarks about the &%-oM%& options. The &%-oMas%&
4352 option sets the authenticated sender value in &$authenticated_sender$&. It
4353 overrides the sender address that is created from the caller's login id for
4354 messages from local sources, except when &%-bh%& is used, when there is no
4355 default. For both &%-bh%& and &%-bs%&, an authenticated sender that is
4356 specified on a MAIL command overrides this value. See chapter
4357 &<<CHAPSMTPAUTH>>& for a discussion of authenticated senders.
4358
4359 .cmdopt -oMi <&'interface&~address'&>
4360 .cindex "interface" "address, specifying for local message"
4361 See &%-oMa%& above for general remarks about the &%-oM%& options. The &%-oMi%&
4362 option sets the IP interface address value. A port number may be included,
4363 using the same syntax as for &%-oMa%&. The interface address is placed in
4364 &$received_ip_address$& and the port number, if present, in &$received_port$&.
4365
4366 .cmdopt -oMm <&'message&~reference'&>
4367 .cindex "message reference" "message reference, specifying for local message"
4368 See &%-oMa%& above for general remarks about the &%-oM%& options. The &%-oMm%&
4369 option sets the message reference, e.g. message-id, and is logged during
4370 delivery. This is useful when some kind of audit trail is required to tie
4371 messages together. The format of the message reference is checked and will
4372 abort if the format is invalid. The option will only be accepted if exim is
4373 running in trusted mode, not as any regular user.
4374
4375 The best example of a message reference is when Exim sends a bounce message.
4376 The message reference is the message-id of the original message for which Exim
4377 is sending the bounce.
4378
4379 .cmdopt -oMr <&'protocol&~name'&>
4380 .cindex "protocol, specifying for local message"
4381 .vindex "&$received_protocol$&"
4382 See &%-oMa%& above for general remarks about the &%-oM%& options. The &%-oMr%&
4383 option sets the received protocol value that is stored in
4384 &$received_protocol$&. However, it does not apply (and is ignored) when &%-bh%&
4385 or &%-bs%& is used. For &%-bh%&, the protocol is forced to one of the standard
4386 SMTP protocol names (see the description of &$received_protocol$& in section
4387 &<<SECTexpvar>>&). For &%-bs%&, the protocol is always &"local-"& followed by
4388 one of those same names. For &%-bS%& (batched SMTP) however, the protocol can
4389 be set by &%-oMr%&. Repeated use of this option is not supported.
4390
4391 .cmdopt -oMs <&'host&~name'&>
4392 .cindex "sender" "host name, specifying for local message"
4393 See &%-oMa%& above for general remarks about the &%-oM%& options. The &%-oMs%&
4394 option sets the sender host name in &$sender_host_name$&. When this option is
4395 present, Exim does not attempt to look up a host name from an IP address; it
4396 uses the name it is given.
4397
4398 .cmdopt -oMt <&'ident&~string'&>
4399 .cindex "sender" "ident string, specifying for local message"
4400 See &%-oMa%& above for general remarks about the &%-oM%& options. The &%-oMt%&
4401 option sets the sender ident value in &$sender_ident$&. The default setting for
4402 local callers is the login id of the calling process, except when &%-bh%& is
4403 used, when there is no default.
4404
4405 .cmdopt -om
4406 .cindex "Sendmail compatibility" "&%-om%& option ignored"
4407 In Sendmail, this option means &"me too"&, indicating that the sender of a
4408 message should receive a copy of the message if the sender appears in an alias
4409 expansion. Exim always does this, so the option does nothing.
4410
4411 .cmdopt -oo
4412 .cindex "Sendmail compatibility" "&%-oo%& option ignored"
4413 This option is ignored. In Sendmail it specifies &"old style headers"&,
4414 whatever that means.
4415
4416 .cmdopt -oP <&'path'&>
4417 .cindex "pid (process id)" "of daemon"
4418 .cindex "daemon" "process id (pid)"
4419 This option is useful only in conjunction with &%-bd%& or &%-q%& with a time
4420 value. The option specifies the file to which the process id of the daemon is
4421 written. When &%-oX%& is used with &%-bd%&, or when &%-q%& with a time is used
4422 without &%-bd%&, this is the only way of causing Exim to write a pid file,
4423 because in those cases, the normal pid file is not used.
4424
4425 .cmdopt -oPX
4426 .cindex "pid (process id)" "of daemon"
4427 .cindex "daemon" "process id (pid)"
4428 This option is not intended for general use.
4429 The daemon uses it when terminating due to a SIGTEM, possibly in
4430 combination with &%-oP%&&~<&'path'&>.
4431 It causes the pid file to be removed.
4432
4433 .cmdopt -or <&'time'&>
4434 .cindex "timeout" "for non-SMTP input"
4435 This option sets a timeout value for incoming non-SMTP messages. If it is not
4436 set, Exim will wait forever for the standard input. The value can also be set
4437 by the &%receive_timeout%& option. The format used for specifying times is
4438 described in section &<<SECTtimeformat>>&.
4439
4440 .cmdopt -os <&'time'&>
4441 .cindex "timeout" "for SMTP input"
4442 .cindex "SMTP" "input timeout"
4443 This option sets a timeout value for incoming SMTP messages. The timeout
4444 applies to each SMTP command and block of data. The value can also be set by
4445 the &%smtp_receive_timeout%& option; it defaults to 5 minutes. The format used
4446 for specifying times is described in section &<<SECTtimeformat>>&.
4447
4448 .cmdopt -ov
4449 This option has exactly the same effect as &%-v%&.
4450
4451 .cmdopt -oX <&'number&~or&~string'&>
4452 .cindex "TCP/IP" "setting listening ports"
4453 .cindex "TCP/IP" "setting listening interfaces"
4454 .cindex "port" "receiving TCP/IP"
4455 This option is relevant only when the &%-bd%& (start listening daemon) option
4456 is also given. It controls which ports and interfaces the daemon uses. Details
4457 of the syntax, and how it interacts with configuration file options, are given
4458 in chapter &<<CHAPinterfaces>>&. When &%-oX%& is used to start a daemon, no pid
4459 file is written unless &%-oP%& is also present to specify a pid filename.
4460
4461 .cmdopt -oY
4462 .cindex "daemon notifier socket"
4463 This option controls the creation of an inter-process communications endpoint
4464 by the Exim daemon.
4465 It is only relevant when the &%-bd%& (start listening daemon) option is also
4466 given.
4467 Normally the daemon creates this socket, unless a &%-oX%& and &*no*& &%-oP%&
4468 option is also present.
4469 If this option is given then the socket will not be created.  This is required
4470 if the system is running multiple daemons, in which case it should
4471 be used on all.
4472 The features supported by the socket will not be available in such cases.
4473
4474 The socket is currently used for
4475 .ilist
4476 fast ramp-up of queue runner processes
4477 .next
4478 caching compiled regexes
4479 .next
4480 obtaining a current queue size
4481 .endlist
4482
4483 .cmdopt -pd
4484 .cindex "Perl" "starting the interpreter"
4485 This option applies when an embedded Perl interpreter is linked with Exim (see
4486 chapter &<<CHAPperl>>&). It overrides the setting of the &%perl_at_start%&
4487 option, forcing the starting of the interpreter to be delayed until it is
4488 needed.
4489
4490 .cmdopt -ps
4491 .cindex "Perl" "starting the interpreter"
4492 This option applies when an embedded Perl interpreter is linked with Exim (see
4493 chapter &<<CHAPperl>>&). It overrides the setting of the &%perl_at_start%&
4494 option, forcing the starting of the interpreter to occur as soon as Exim is
4495 started.
4496
4497 .vitem &%-p%&<&'rval'&>:<&'sval'&>
4498 .oindex "&%-p%&"
4499 For compatibility with Sendmail, this option is equivalent to
4500 .display
4501 &`-oMr`& <&'rval'&> &`-oMs`& <&'sval'&>
4502 .endd
4503 It sets the incoming protocol and host name (for trusted callers). The
4504 host name and its colon can be omitted when only the protocol is to be set.
4505 Note the Exim already has two private options, &%-pd%& and &%-ps%&, that refer
4506 to embedded Perl. It is therefore impossible to set a protocol value of &`d`&
4507 or &`s`& using this option (but that does not seem a real limitation).
4508 Repeated use of this option is not supported.
4509
4510 .cmdopt -q
4511 .cindex "queue runner" "starting manually"
4512 This option is normally restricted to admin users. However, there is a
4513 configuration option called &%prod_requires_admin%& which can be set false to
4514 relax this restriction (and also the same requirement for the &%-M%&, &%-R%&,
4515 and &%-S%& options).
4516
4517 .cindex "queue runner" "description of operation"
4518 If other commandline options do not specify an action,
4519 the &%-q%& option starts one queue runner process. This scans the queue of
4520 waiting messages, and runs a delivery process for each one in turn. It waits
4521 for each delivery process to finish before starting the next one. A delivery
4522 process may not actually do any deliveries if the retry times for the addresses
4523 have not been reached. Use &%-qf%& (see below) if you want to override this.
4524
4525 If
4526 .cindex "SMTP" "passed connection"
4527 .cindex "SMTP" "multiple deliveries"
4528 .cindex "multiple SMTP deliveries"
4529 the delivery process spawns other processes to deliver other messages down
4530 passed SMTP connections, the queue runner waits for these to finish before
4531 proceeding.
4532
4533 When all the queued messages have been considered, the original queue runner
4534 process terminates. In other words, a single pass is made over the waiting
4535 mail, one message at a time. Use &%-q%& with a time (see below) if you want
4536 this to be repeated periodically.
4537
4538 Exim processes the waiting messages in an unpredictable order. It isn't very
4539 random, but it is likely to be different each time, which is all that matters.
4540 If one particular message screws up a remote MTA, other messages to the same
4541 MTA have a chance of getting through if they get tried first.
4542
4543 It is possible to cause the messages to be processed in lexical message id
4544 order, which is essentially the order in which they arrived, by setting the
4545 &%queue_run_in_order%& option, but this is not recommended for normal use.
4546
4547 .vitem &%-q%&<&'qflags'&>
4548 The &%-q%& option may be followed by one or more flag letters that change its
4549 behaviour. They are all optional, but if more than one is present, they must
4550 appear in the correct order. Each flag is described in a separate item below.
4551
4552 .vitem &%-qq...%&
4553 .oindex "&%-qq%&"
4554 .cindex "queue" "double scanning"
4555 .cindex "queue" "routing"
4556 .cindex "routing" "whole queue before delivery"
4557 .cindex "first pass routing"
4558 .cindex "queue runner" "two phase"
4559 An option starting with &%-qq%& requests a two-stage queue run. In the first
4560 stage, the queue is scanned as if the &%queue_smtp_domains%& option matched
4561 every domain. Addresses are routed, local deliveries happen, but no remote
4562 transports are run.
4563
4564 Performance will be best if the &%queue_run_in_order%& option is false.
4565 If that is so and
4566 the &%queue_fast_ramp%& option is true
4567 and a daemon-notifier socket is available
4568 then in the first phase of the run,
4569 once a threshold number of messages are routed for a given host,
4570 a delivery process is forked in parallel with the rest of the scan.
4571
4572 .cindex "hints database" "remembering routing"
4573 The hints database that remembers which messages are waiting for specific hosts
4574 is updated, as if delivery to those hosts had been deferred.
4575
4576 After the first queue scan complete,
4577 a second, normal queue scan is done, with routing and delivery taking
4578 place as normal.
4579 Messages that are routed to the same host should mostly be
4580 delivered down a single SMTP
4581 .cindex "SMTP" "passed connection"
4582 .cindex "SMTP" "multiple deliveries"
4583 .cindex "multiple SMTP deliveries"
4584 connection because of the hints that were set up during the first queue scan.
4585
4586 Two-phase queue runs should be used on systems which, even intermittently,
4587 have a large queue (such as mailing-list operators).
4588 They may also be useful for hosts that are connected to the Internet
4589 intermittently.
4590
4591 .vitem &%-q[q]i...%&
4592 .oindex "&%-qi%&"
4593 .cindex "queue" "initial delivery"
4594 If the &'i'& flag is present, the queue runner runs delivery processes only for
4595 those messages that haven't previously been tried. (&'i'& stands for &"initial
4596 delivery"&.) This can be helpful if you are putting messages in the queue using
4597 &%-odq%& and want a queue runner just to process the new messages.
4598
4599 .vitem &%-q[q][i]f...%&
4600 .oindex "&%-qf%&"
4601 .cindex "queue" "forcing delivery"
4602 .cindex "delivery" "forcing in queue run"
4603 If one &'f'& flag is present, a delivery attempt is forced for each non-frozen
4604 message, whereas without &'f'& only those non-frozen addresses that have passed
4605 their retry times are tried.
4606
4607 .vitem &%-q[q][i]ff...%&
4608 .oindex "&%-qff%&"
4609 .cindex "frozen messages" "forcing delivery"
4610 If &'ff'& is present, a delivery attempt is forced for every message, whether
4611 frozen or not.
4612
4613 .vitem &%-q[q][i][f[f]]l%&
4614 .oindex "&%-ql%&"
4615 .cindex "queue" "local deliveries only"
4616 The &'l'& (the letter &"ell"&) flag specifies that only local deliveries are to
4617 be done. If a message requires any remote deliveries, it remains in the queue
4618 for later delivery.
4619
4620 .vitem &%-q[q][i][f[f]][l][G<name>[/<time>]]]%&
4621 .oindex "&%-qG%&"
4622 .cindex queue named
4623 .cindex "named queues"  "deliver from"
4624 .cindex "queue" "delivering specific messages"
4625 If the &'G'& flag and a name is present, the queue runner operates on the
4626 queue with the given name rather than the default queue.
4627 The name should not contain a &'/'& character.
4628 For a periodic queue run (see below)
4629 append to the name a slash and a time value.
4630
4631 If other commandline options specify an action, a &'-qG<name>'& option
4632 will specify a queue to operate on.
4633 For example:
4634 .code
4635 exim -bp -qGquarantine
4636 mailq -qGquarantine
4637 exim -qGoffpeak -Rf @special.domain.example
4638 .endd
4639
4640 .vitem &%-q%&<&'qflags'&>&~<&'start&~id'&>&~<&'end&~id'&>
4641 When scanning the queue, Exim can be made to skip over messages whose ids are
4642 lexically less than a given value by following the &%-q%& option with a
4643 starting message id. For example:
4644 .code
4645 exim -q 0t5C6f-0000c8-00
4646 .endd
4647 Messages that arrived earlier than &`0t5C6f-0000c8-00`& are not inspected. If a
4648 second message id is given, messages whose ids are lexically greater than it
4649 are also skipped. If the same id is given twice, for example,
4650 .code
4651 exim -q 0t5C6f-0000c8-00 0t5C6f-0000c8-00
4652 .endd
4653 just one delivery process is started, for that message. This differs from
4654 &%-M%& in that retry data is respected, and it also differs from &%-Mc%& in
4655 that it counts as a delivery from a queue run. Note that the selection
4656 mechanism does not affect the order in which the messages are scanned. There
4657 are also other ways of selecting specific sets of messages for delivery in a
4658 queue run &-- see &%-R%& and &%-S%&.
4659
4660 .vitem &%-q%&<&'qflags'&><&'time'&>
4661 .cindex "queue runner" "starting periodically"
4662 .cindex "periodic queue running"
4663 When a time value is present, the &%-q%& option causes Exim to run as a daemon,
4664 starting a queue runner process at intervals specified by the given time value
4665 (whose format is described in section &<<SECTtimeformat>>&). This form of the
4666 &%-q%& option is commonly combined with the &%-bd%& option, in which case a
4667 single daemon process handles both functions. A common way of starting up a
4668 combined daemon at system boot time is to use a command such as
4669 .code
4670 /usr/exim/bin/exim -bd -q30m
4671 .endd
4672 Such a daemon listens for incoming SMTP calls, and also starts a queue runner
4673 process every 30 minutes.
4674
4675 .cindex "named queues" "queue runners"
4676 It is possible to set up runners for multiple named queues within one daemon,
4677 For example:
4678 .code
4679 exim -qGhipri/2m -q10m -qqGmailinglist/1h
4680 .endd
4681
4682 When a daemon is started by &%-q%& with a time value, but without &%-bd%&, no
4683 pid file is written unless one is explicitly requested by the &%-oP%& option.
4684
4685 .vitem &%-qR%&<&'rsflags'&>&~<&'string'&>
4686 .oindex "&%-qR%&"
4687 This option is synonymous with &%-R%&. It is provided for Sendmail
4688 compatibility.
4689
4690 .vitem &%-qS%&<&'rsflags'&>&~<&'string'&>
4691 .oindex "&%-qS%&"
4692 This option is synonymous with &%-S%&.
4693
4694 .vitem &%-R%&<&'rsflags'&>&~<&'string'&>
4695 .oindex "&%-R%&"
4696 .cindex "queue runner" "for specific recipients"
4697 .cindex "delivery" "to given domain"
4698 .cindex "domain" "delivery to"
4699 The <&'rsflags'&> may be empty, in which case the white space before the string
4700 is optional, unless the string is &'f'&, &'ff'&, &'r'&, &'rf'&, or &'rff'&,
4701 which are the possible values for <&'rsflags'&>. White space is required if
4702 <&'rsflags'&> is not empty.
4703
4704 This option is similar to &%-q%& with no time value, that is, it causes Exim to
4705 perform a single queue run, except that, when scanning the messages on the
4706 queue, Exim processes only those that have at least one undelivered recipient
4707 address containing the given string, which is checked in a case-independent
4708 way. If the <&'rsflags'&> start with &'r'&, <&'string'&> is interpreted as a
4709 regular expression; otherwise it is a literal string.
4710
4711 If you want to do periodic queue runs for messages with specific recipients,
4712 you can combine &%-R%& with &%-q%& and a time value. For example:
4713 .code
4714 exim -q25m -R @special.domain.example
4715 .endd
4716 This example does a queue run for messages with recipients in the given domain
4717 every 25 minutes. Any additional flags that are specified with &%-q%& are
4718 applied to each queue run.
4719
4720 Once a message is selected for delivery by this mechanism, all its addresses
4721 are processed. For the first selected message, Exim overrides any retry
4722 information and forces a delivery attempt for each undelivered address. This
4723 means that if delivery of any address in the first message is successful, any
4724 existing retry information is deleted, and so delivery attempts for that
4725 address in subsequently selected messages (which are processed without forcing)
4726 will run. However, if delivery of any address does not succeed, the retry
4727 information is updated, and in subsequently selected messages, the failing
4728 address will be skipped.
4729
4730 .cindex "frozen messages" "forcing delivery"
4731 If the <&'rsflags'&> contain &'f'& or &'ff'&, the delivery forcing applies to
4732 all selected messages, not just the first; frozen messages are included when
4733 &'ff'& is present.
4734
4735 The &%-R%& option makes it straightforward to initiate delivery of all messages
4736 to a given domain after a host has been down for some time. When the SMTP
4737 command ETRN is accepted by its ACL (see section &<<SECTETRN>>&), its default
4738 effect is to run Exim with the &%-R%& option, but it can be configured to run
4739 an arbitrary command instead.
4740
4741 .cmdopt -r
4742 This is a documented (for Sendmail) obsolete alternative name for &%-f%&.
4743
4744 .vitem &%-S%&<&'rsflags'&>&~<&'string'&>
4745 .oindex "&%-S%&"
4746 .cindex "delivery" "from given sender"
4747 .cindex "queue runner" "for specific senders"
4748 This option acts like &%-R%& except that it checks the string against each
4749 message's sender instead of against the recipients. If &%-R%& is also set, both
4750 conditions must be met for a message to be selected. If either of the options
4751 has &'f'& or &'ff'& in its flags, the associated action is taken.
4752
4753 .cmdopt -Tqt <&'times'&>
4754 This is an option that is exclusively for use by the Exim testing suite. It is not
4755 recognized when Exim is run normally. It allows for the setting up of explicit
4756 &"queue times"& so that various warning/retry features can be tested.
4757
4758 .cmdopt -t
4759 .cindex "recipient" "extracting from header lines"
4760 .chindex Bcc:
4761 .chindex Cc:
4762 .chindex To:
4763 When Exim is receiving a locally-generated, non-SMTP message on its standard
4764 input, the &%-t%& option causes the recipients of the message to be obtained
4765 from the &'To:'&, &'Cc:'&, and &'Bcc:'& header lines in the message instead of
4766 from the command arguments. The addresses are extracted before any rewriting
4767 takes place and the &'Bcc:'& header line, if present, is then removed.
4768
4769 .cindex "Sendmail compatibility" "&%-t%& option"
4770 If the command has any arguments, they specify addresses to which the message
4771 is &'not'& to be delivered. That is, the argument addresses are removed from
4772 the recipients list obtained from the headers. This is compatible with Smail 3
4773 and in accordance with the documented behaviour of several versions of
4774 Sendmail, as described in man pages on a number of operating systems (e.g.
4775 Solaris 8, IRIX 6.5, HP-UX 11). However, some versions of Sendmail &'add'&
4776 argument addresses to those obtained from the headers, and the O'Reilly
4777 Sendmail book documents it that way. Exim can be made to add argument addresses
4778 instead of subtracting them by setting the option
4779 &%extract_addresses_remove_arguments%& false.
4780
4781 .cindex "&%Resent-%& header lines" "with &%-t%&"
4782 If there are any &%Resent-%& header lines in the message, Exim extracts
4783 recipients from all &'Resent-To:'&, &'Resent-Cc:'&, and &'Resent-Bcc:'& header
4784 lines instead of from &'To:'&, &'Cc:'&, and &'Bcc:'&. This is for compatibility
4785 with Sendmail and other MTAs. (Prior to release 4.20, Exim gave an error if
4786 &%-t%& was used in conjunction with &%Resent-%& header lines.)
4787
4788 RFC 2822 talks about different sets of &%Resent-%& header lines (for when a
4789 message is resent several times). The RFC also specifies that they should be
4790 added at the front of the message, and separated by &'Received:'& lines. It is
4791 not at all clear how &%-t%& should operate in the present of multiple sets,
4792 nor indeed exactly what constitutes a &"set"&.
4793 In practice, it seems that MUAs do not follow the RFC. The &%Resent-%& lines
4794 are often added at the end of the header, and if a message is resent more than
4795 once, it is common for the original set of &%Resent-%& headers to be renamed as
4796 &%X-Resent-%& when a new set is added. This removes any possible ambiguity.
4797
4798 .cmdopt -ti
4799 This option is exactly equivalent to &%-t%& &%-i%&. It is provided for
4800 compatibility with Sendmail.
4801
4802 .cmdopt -tls-on-connect
4803 .cindex "TLS" "use without STARTTLS"
4804 .cindex "TLS" "automatic start"
4805 This option is available when Exim is compiled with TLS support. It forces all
4806 incoming SMTP connections to behave as if the incoming port is listed in the
4807 &%tls_on_connect_ports%& option. See section &<<SECTsupobssmt>>& and chapter
4808 &<<CHAPTLS>>& for further details.
4809
4810
4811 .cmdopt -U
4812 .cindex "Sendmail compatibility" "&%-U%& option ignored"
4813 Sendmail uses this option for &"initial message submission"&, and its
4814 documentation states that in future releases, it may complain about
4815 syntactically invalid messages rather than fixing them when this flag is not
4816 set. Exim ignores this option.
4817
4818 .cmdopt -v
4819 This option causes Exim to write information to the standard error stream,
4820 describing what it is doing. In particular, it shows the log lines for
4821 receiving and delivering a message, and if an SMTP connection is made, the SMTP
4822 dialogue is shown. Some of the log lines shown may not actually be written to
4823 the log if the setting of &%log_selector%& discards them. Any relevant
4824 selectors are shown with each log line. If none are shown, the logging is
4825 unconditional.
4826
4827 .cmdopt -x
4828 AIX uses &%-x%& for a private purpose (&"mail from a local mail program has
4829 National Language Support extended characters in the body of the mail item"&).
4830 It sets &%-x%& when calling the MTA from its &%mail%& command. Exim ignores
4831 this option.
4832
4833 .cmdopt -X <&'logfile'&>
4834 This option is interpreted by Sendmail to cause debug information to be sent
4835 to the named file.  It is ignored by Exim.
4836
4837 .cmdopt -z <&'log-line'&>
4838 This option writes its argument to Exim's logfile.
4839 Use is restricted to administrators; the intent is for operational notes.
4840 Quotes should be used to maintain a multi-word item as a single argument,
4841 under most shells.
4842 .endlist
4843
4844 .ecindex IIDclo1
4845 .ecindex IIDclo2
4846
4847
4848 . ////////////////////////////////////////////////////////////////////////////
4849 . Insert a stylized DocBook comment here, to identify the end of the command
4850 . line options. This is for the benefit of the Perl script that automatically
4851 . creates a man page for the options.
4852 . ////////////////////////////////////////////////////////////////////////////
4853
4854 .literal xml
4855 <!-- === End of command line options === -->
4856 .literal off
4857
4858
4859
4860
4861
4862 . ////////////////////////////////////////////////////////////////////////////
4863 . ////////////////////////////////////////////////////////////////////////////
4864
4865
4866 .chapter "The Exim runtime configuration file" "CHAPconf" &&&
4867          "The runtime configuration file"
4868
4869 .cindex "runtime configuration"
4870 .cindex "configuration file" "general description"
4871 .cindex "CONFIGURE_FILE"
4872 .cindex "configuration file" "errors in"
4873 .cindex "error" "in configuration file"
4874 .cindex "return code" "for bad configuration"
4875 Exim uses a single runtime configuration file that is read whenever an Exim
4876 binary is executed. Note that in normal operation, this happens frequently,
4877 because Exim is designed to operate in a distributed manner, without central
4878 control.
4879
4880 If a syntax error is detected while reading the configuration file, Exim
4881 writes a message on the standard error, and exits with a non-zero return code.
4882 The message is also written to the panic log. &*Note*&: Only simple syntax
4883 errors can be detected at this time. The values of any expanded options are
4884 not checked until the expansion happens, even when the expansion does not
4885 actually alter the string.
4886
4887 The name of the configuration file is compiled into the binary for security
4888 reasons, and is specified by the CONFIGURE_FILE compilation option. In
4889 most configurations, this specifies a single file. However, it is permitted to
4890 give a colon-separated list of filenames, in which case Exim uses the first
4891 existing file in the list.
4892
4893 .cindex "EXIM_USER"
4894 .cindex "EXIM_GROUP"
4895 .cindex "CONFIGURE_OWNER"
4896 .cindex "CONFIGURE_GROUP"
4897 .cindex "configuration file" "ownership"
4898 .cindex "ownership" "configuration file"
4899 The runtime configuration file must be owned by root or by the user that is
4900 specified at compile time by the CONFIGURE_OWNER option (if set). The
4901 configuration file must not be world-writeable, or group-writeable unless its
4902 group is the root group or the one specified at compile time by the
4903 CONFIGURE_GROUP option.
4904
4905 &*Warning*&: In a conventional configuration, where the Exim binary is setuid
4906 to root, anybody who is able to edit the runtime configuration file has an
4907 easy way to run commands as root. If you specify a user or group in the
4908 CONFIGURE_OWNER or CONFIGURE_GROUP options, then that user and/or any users
4909 who are members of that group will trivially be able to obtain root privileges.
4910
4911 Up to Exim version 4.72, the runtime configuration file was also permitted to
4912 be writeable by the Exim user and/or group. That has been changed in Exim 4.73
4913 since it offered a simple privilege escalation for any attacker who managed to
4914 compromise the Exim user account.
4915
4916 A default configuration file, which will work correctly in simple situations,
4917 is provided in the file &_src/configure.default_&. If CONFIGURE_FILE
4918 defines just one filename, the installation process copies the default
4919 configuration to a new file of that name if it did not previously exist. If
4920 CONFIGURE_FILE is a list, no default is automatically installed. Chapter
4921 &<<CHAPdefconfil>>& is a &"walk-through"& discussion of the default
4922 configuration.
4923
4924
4925
4926 .section "Using a different configuration file" "SECID40"
4927 .cindex "configuration file" "alternate"
4928 A one-off alternate configuration can be specified by the &%-C%& command line
4929 option, which may specify a single file or a list of files. However, when
4930 &%-C%& is used, Exim gives up its root privilege, unless called by root (or
4931 unless the argument for &%-C%& is identical to the built-in value from
4932 CONFIGURE_FILE), or is listed in the TRUSTED_CONFIG_LIST file and the caller
4933 is the Exim user or the user specified in the CONFIGURE_OWNER setting. &%-C%&
4934 is useful mainly for checking the syntax of configuration files before
4935 installing them. No owner or group checks are done on a configuration file
4936 specified by &%-C%&, if root privilege has been dropped.
4937
4938 Even the Exim user is not trusted to specify an arbitrary configuration file
4939 with the &%-C%& option to be used with root privileges, unless that file is
4940 listed in the TRUSTED_CONFIG_LIST file. This locks out the possibility of
4941 testing a configuration using &%-C%& right through message reception and
4942 delivery, even if the caller is root. The reception works, but by that time,
4943 Exim is running as the Exim user, so when it re-execs to regain privilege for
4944 the delivery, the use of &%-C%& causes privilege to be lost. However, root
4945 can test reception and delivery using two separate commands (one to put a
4946 message in the queue, using &%-odq%&, and another to do the delivery, using
4947 &%-M%&).
4948
4949 If ALT_CONFIG_PREFIX is defined &_in Local/Makefile_&, it specifies a
4950 prefix string with which any file named in a &%-C%& command line option must
4951 start. In addition, the filename must not contain the sequence &"&`/../`&"&.
4952 There is no default setting for ALT_CONFIG_PREFIX; when it is unset, any
4953 filename can be used with &%-C%&.
4954
4955 One-off changes to a configuration can be specified by the &%-D%& command line
4956 option, which defines and overrides values for macros used inside the
4957 configuration file. However, like &%-C%&, the use of this option by a
4958 non-privileged user causes Exim to discard its root privilege.
4959 If DISABLE_D_OPTION is defined in &_Local/Makefile_&, the use of &%-D%& is
4960 completely disabled, and its use causes an immediate error exit.
4961
4962 The WHITELIST_D_MACROS option in &_Local/Makefile_& permits the binary builder
4963 to declare certain macro names trusted, such that root privilege will not
4964 necessarily be discarded.
4965 WHITELIST_D_MACROS defines a colon-separated list of macros which are
4966 considered safe and, if &%-D%& only supplies macros from this list, and the
4967 values are acceptable, then Exim will not give up root privilege if the caller
4968 is root, the Exim run-time user, or the CONFIGURE_OWNER, if set.  This is a
4969 transition mechanism and is expected to be removed in the future.  Acceptable
4970 values for the macros satisfy the regexp: &`^[A-Za-z0-9_/.-]*$`&
4971
4972 Some sites may wish to use the same Exim binary on different machines that
4973 share a file system, but to use different configuration files on each machine.
4974 If CONFIGURE_FILE_USE_NODE is defined in &_Local/Makefile_&, Exim first
4975 looks for a file whose name is the configuration filename followed by a dot
4976 and the machine's node name, as obtained from the &[uname()]& function. If this
4977 file does not exist, the standard name is tried. This processing occurs for
4978 each filename in the list given by CONFIGURE_FILE or &%-C%&.
4979
4980 In some esoteric situations different versions of Exim may be run under
4981 different effective uids and the CONFIGURE_FILE_USE_EUID is defined to
4982 help with this. See the comments in &_src/EDITME_& for details.
4983
4984
4985
4986 .section "Configuration file format" "SECTconffilfor"
4987 .cindex "configuration file" "format of"
4988 .cindex "format" "configuration file"
4989 Exim's configuration file is divided into a number of different parts. General
4990 option settings must always appear at the start of the file. The other parts
4991 are all optional, and may appear in any order. Each part other than the first
4992 is introduced by the word &"begin"& followed by at least one literal
4993 space, and the name of the part. The optional parts are:
4994
4995 .ilist
4996 &'ACL'&: Access control lists for controlling incoming SMTP mail (see chapter
4997 &<<CHAPACL>>&).
4998 .next
4999 .cindex "AUTH" "configuration"
5000 &'authenticators'&: Configuration settings for the authenticator drivers. These
5001 are concerned with the SMTP AUTH command (see chapter &<<CHAPSMTPAUTH>>&).
5002 .next
5003 &'routers'&: Configuration settings for the router drivers. Routers process
5004 addresses and determine how the message is to be delivered (see chapters
5005 &<<CHAProutergeneric>>&&--&<<CHAPredirect>>&).
5006 .next
5007 &'transports'&: Configuration settings for the transport drivers. Transports
5008 define mechanisms for copying messages to destinations (see chapters
5009 &<<CHAPtransportgeneric>>&&--&<<CHAPsmtptrans>>&).
5010 .next
5011 &'retry'&: Retry rules, for use when a message cannot be delivered immediately.
5012 If there is no retry section, or if it is empty (that is, no retry rules are
5013 defined), Exim will not retry deliveries. In this situation, temporary errors
5014 are treated the same as permanent errors. Retry rules are discussed in chapter
5015 &<<CHAPretry>>&.
5016 .next
5017 &'rewrite'&: Global address rewriting rules, for use when a message arrives and
5018 when new addresses are generated during delivery. Rewriting is discussed in
5019 chapter &<<CHAPrewrite>>&.
5020 .next
5021 &'local_scan'&: Private options for the &[local_scan()]& function. If you
5022 want to use this feature, you must set
5023 .code
5024 LOCAL_SCAN_HAS_OPTIONS=yes
5025 .endd
5026 in &_Local/Makefile_& before building Exim. Details of the &[local_scan()]&
5027 facility are given in chapter &<<CHAPlocalscan>>&.
5028 .endlist
5029
5030 .cindex "configuration file" "leading white space in"
5031 .cindex "configuration file" "trailing white space in"
5032 .cindex "white space" "in configuration file"
5033 Leading and trailing white space in configuration lines is always ignored.
5034
5035 Blank lines in the file, and lines starting with a # character (ignoring
5036 leading white space) are treated as comments and are ignored. &*Note*&: A
5037 # character other than at the beginning of a line is not treated specially,
5038 and does not introduce a comment.
5039
5040 Any non-comment line can be continued by ending it with a backslash. Note that
5041 the general rule for white space means that trailing white space after the
5042 backslash and leading white space at the start of continuation
5043 lines is ignored. Comment lines beginning with # (but not empty lines) may
5044 appear in the middle of a sequence of continuation lines.
5045
5046 A convenient way to create a configuration file is to start from the
5047 default, which is supplied in &_src/configure.default_&, and add, delete, or
5048 change settings as required.
5049
5050 The ACLs, retry rules, and rewriting rules have their own syntax which is
5051 described in chapters &<<CHAPACL>>&, &<<CHAPretry>>&, and &<<CHAPrewrite>>&,
5052 respectively. The other parts of the configuration file have some syntactic
5053 items in common, and these are described below, from section &<<SECTcos>>&
5054 onwards. Before that, the inclusion, macro, and conditional facilities are
5055 described.
5056
5057
5058
5059 .section "File inclusions in the configuration file" "SECID41"
5060 .cindex "inclusions in configuration file"
5061 .cindex "configuration file" "including other files"
5062 .cindex "&`.include`& in configuration file"
5063 .cindex "&`.include_if_exists`& in configuration file"
5064 You can include other files inside Exim's runtime configuration file by
5065 using this syntax:
5066 .display
5067 &`.include`& <&'filename'&>
5068 &`.include_if_exists`& <&'filename'&>
5069 .endd
5070 on a line by itself. Double quotes round the filename are optional. If you use
5071 the first form, a configuration error occurs if the file does not exist; the
5072 second form does nothing for non-existent files.
5073 The first form allows a relative name. It is resolved relative to
5074 the directory of the including file. For the second form an absolute filename
5075 is required.
5076
5077 Includes may be nested to any depth, but remember that Exim reads its
5078 configuration file often, so it is a good idea to keep them to a minimum.
5079 If you change the contents of an included file, you must HUP the daemon,
5080 because an included file is read only when the configuration itself is read.
5081
5082 The processing of inclusions happens early, at a physical line level, so, like
5083 comment lines, an inclusion can be used in the middle of an option setting,
5084 for example:
5085 .code
5086 hosts_lookup = a.b.c \
5087                .include /some/file
5088 .endd
5089 Include processing happens after macro processing (see below). Its effect is to
5090 process the lines of the included file as if they occurred inline where the
5091 inclusion appears.
5092
5093
5094
5095 .section "Macros in the configuration file" "SECTmacrodefs"
5096 .cindex "macro" "description of"
5097 .cindex "configuration file" "macros"
5098 If a line in the main part of the configuration (that is, before the first
5099 &"begin"& line) begins with an upper case letter, it is taken as a macro
5100 definition, and must be of the form
5101 .display
5102 <&'name'&> = <&'rest of line'&>
5103 .endd
5104 The name must consist of letters, digits, and underscores, and need not all be
5105 in upper case, though that is recommended. The rest of the line, including any
5106 continuations, is the replacement text, and has leading and trailing white
5107 space removed. Quotes are not removed. The replacement text can never end with
5108 a backslash character, but this doesn't seem to be a serious limitation.
5109
5110 Macros may also be defined between router, transport, authenticator, or ACL
5111 definitions. They may not, however, be defined within an individual driver or
5112 ACL, or in the &%local_scan%&, retry, or rewrite sections of the configuration.
5113
5114 .section "Macro substitution" "SECID42"
5115 Once a macro is defined, all subsequent lines in the file (and any included
5116 files) are scanned for the macro name; if there are several macros, the line is
5117 scanned for each, in turn, in the order in which the macros are defined. The
5118 replacement text is not re-scanned for the current macro, though it is scanned
5119 for subsequently defined macros. For this reason, a macro name may not contain
5120 the name of a previously defined macro as a substring. You could, for example,
5121 define
5122 .display
5123 &`ABCD_XYZ = `&<&'something'&>
5124 &`ABCD = `&<&'something else'&>
5125 .endd
5126 but putting the definitions in the opposite order would provoke a configuration
5127 error. Macro expansion is applied to individual physical lines from the file,
5128 before checking for line continuation or file inclusion (see above). If a line
5129 consists solely of a macro name, and the expansion of the macro is empty, the
5130 line is ignored. A macro at the start of a line may turn the line into a
5131 comment line or a &`.include`& line.
5132
5133
5134 .section "Redefining macros" "SECID43"
5135 Once defined, the value of a macro can be redefined later in the configuration
5136 (or in an included file). Redefinition is specified by using &'=='& instead of
5137 &'='&. For example:
5138 .code
5139 MAC =  initial value
5140 ...
5141 MAC == updated value
5142 .endd
5143 Redefinition does not alter the order in which the macros are applied to the
5144 subsequent lines of the configuration file. It is still the same order in which
5145 the macros were originally defined. All that changes is the macro's value.
5146 Redefinition makes it possible to accumulate values. For example:
5147 .code
5148 MAC =  initial value
5149 ...
5150 MAC == MAC and something added
5151 .endd
5152 This can be helpful in situations where the configuration file is built
5153 from a number of other files.
5154
5155 .section "Overriding macro values" "SECID44"
5156 The values set for macros in the configuration file can be overridden by the
5157 &%-D%& command line option, but Exim gives up its root privilege when &%-D%& is
5158 used, unless called by root or the Exim user. A definition on the command line
5159 using the &%-D%& option causes all definitions and redefinitions within the
5160 file to be ignored.
5161
5162
5163
5164 .section "Example of macro usage" "SECID45"
5165 As an example of macro usage, consider a configuration where aliases are looked
5166 up in a MySQL database. It helps to keep the file less cluttered if long
5167 strings such as SQL statements are defined separately as macros, for example:
5168 .code
5169 ALIAS_QUERY = select mailbox from user where \
5170               login='${quote_mysql:$local_part}';
5171 .endd
5172 This can then be used in a &(redirect)& router setting like this:
5173 .code
5174 data = ${lookup mysql{ALIAS_QUERY}}
5175 .endd
5176 In earlier versions of Exim macros were sometimes used for domain, host, or
5177 address lists. In Exim 4 these are handled better by named lists &-- see
5178 section &<<SECTnamedlists>>&.
5179
5180
5181 .section "Builtin macros" "SECTbuiltinmacros"
5182 Exim defines some macros depending on facilities available, which may
5183 differ due to build-time definitions and from one release to another.
5184 All of these macros start with an underscore.
5185 They can be used to conditionally include parts of a configuration
5186 (see below).
5187
5188 The following classes of macros are defined:
5189 .display
5190 &` _HAVE_*                    `&  build-time defines
5191 &` _DRIVER_ROUTER_*           `&  router drivers
5192 &` _DRIVER_TRANSPORT_*        `&  transport drivers
5193 &` _DRIVER_AUTHENTICATOR_*    `&  authenticator drivers
5194 &` _EXP_COND_*                `&  expansion conditions
5195 &` _EXP_ITEM_*                `&  expansion items
5196 &` _EXP_OP_*                  `&  expansion operators
5197 &` _EXP_VAR_*                 `&  expansion variables
5198 &` _LOG_*                     `&  log_selector values
5199 &` _OPT_MAIN_*                `&  main config options
5200 &` _OPT_ROUTERS_*             `&  generic router options
5201 &` _OPT_TRANSPORTS_*          `&  generic transport options
5202 &` _OPT_AUTHENTICATORS_*      `&  generic authenticator options
5203 &` _OPT_ROUTER_*_*            `&  private router options
5204 &` _OPT_TRANSPORT_*_*         `&  private transport options
5205 &` _OPT_AUTHENTICATOR_*_*     `&  private authenticator options
5206 .endd
5207
5208 Use an &"exim -bP macros"& command to get the list of macros.
5209
5210
5211 .section "Conditional skips in the configuration file" "SECID46"
5212 .cindex "configuration file" "conditional skips"
5213 .cindex "&`.ifdef`&"
5214 You can use the directives &`.ifdef`&, &`.ifndef`&, &`.elifdef`&,
5215 &`.elifndef`&, &`.else`&, and &`.endif`& to dynamically include or exclude
5216 portions of the configuration file. The processing happens whenever the file is
5217 read (that is, when an Exim binary starts to run).
5218
5219 The implementation is very simple. Instances of the first four directives must
5220 be followed by text that includes the names of one or macros. The condition
5221 that is tested is whether or not any macro substitution has taken place in the
5222 line. Thus:
5223 .code
5224 .ifdef AAA
5225 message_size_limit = 50M
5226 .else
5227 message_size_limit = 100M
5228 .endif
5229 .endd
5230 sets a message size limit of 50M if the macro &`AAA`& is defined
5231 (or &`A`& or &`AA`&), and 100M
5232 otherwise. If there is more than one macro named on the line, the condition
5233 is true if any of them are defined. That is, it is an &"or"& condition. To
5234 obtain an &"and"& condition, you need to use nested &`.ifdef`&s.
5235
5236 Although you can use a macro expansion to generate one of these directives,
5237 it is not very useful, because the condition &"there was a macro substitution
5238 in this line"& will always be true.
5239
5240 Text following &`.else`& and &`.endif`& is ignored, and can be used as comment
5241 to clarify complicated nestings.
5242
5243
5244
5245 .section "Common option syntax" "SECTcos"
5246 .cindex "common option syntax"
5247 .cindex "syntax of common options"
5248 .cindex "configuration file" "common option syntax"
5249 For the main set of options, driver options, and &[local_scan()]& options,
5250 each setting is on a line by itself, and starts with a name consisting of
5251 lower-case letters and underscores. Many options require a data value, and in
5252 these cases the name must be followed by an equals sign (with optional white
5253 space) and then the value. For example:
5254 .code
5255 qualify_domain = mydomain.example.com
5256 .endd
5257 .cindex "hiding configuration option values"
5258 .cindex "configuration options" "hiding value of"
5259 .cindex "options" "hiding value of"
5260 Some option settings may contain sensitive data, for example, passwords for
5261 accessing databases. To stop non-admin users from using the &%-bP%& command
5262 line option to read these values, you can precede the option settings with the
5263 word &"hide"&. For example:
5264 .code
5265 hide mysql_servers = localhost/users/admin/secret-password
5266 .endd
5267 For non-admin users, such options are displayed like this:
5268 .code
5269 mysql_servers = <value not displayable>
5270 .endd
5271 If &"hide"& is used on a driver option, it hides the value of that option on
5272 all instances of the same driver.
5273
5274 The following sections describe the syntax used for the different data types
5275 that are found in option settings.
5276
5277
5278 .section "Boolean options" "SECID47"
5279 .cindex "format" "boolean"
5280 .cindex "boolean configuration values"
5281 .oindex "&%no_%&&'xxx'&"
5282 .oindex "&%not_%&&'xxx'&"
5283 Options whose type is given as boolean are on/off switches. There are two
5284 different ways of specifying such options: with and without a data value. If
5285 the option name is specified on its own without data, the switch is turned on;
5286 if it is preceded by &"no_"& or &"not_"& the switch is turned off. However,
5287 boolean options may be followed by an equals sign and one of the words
5288 &"true"&, &"false"&, &"yes"&, or &"no"&, as an alternative syntax. For example,
5289 the following two settings have exactly the same effect:
5290 .code
5291 queue_only
5292 queue_only = true
5293 .endd
5294 The following two lines also have the same (opposite) effect:
5295 .code
5296 no_queue_only
5297 queue_only = false
5298 .endd
5299 You can use whichever syntax you prefer.
5300
5301
5302
5303
5304 .section "Integer values" "SECID48"
5305 .cindex "integer configuration values"
5306 .cindex "format" "integer"
5307 If an option's type is given as &"integer"&, the value can be given in decimal,
5308 hexadecimal, or octal. If it starts with a digit greater than zero, a decimal
5309 number is assumed. Otherwise, it is treated as an octal number unless it starts
5310 with the characters &"0x"&, in which case the remainder is interpreted as a
5311 hexadecimal number.
5312
5313 If an integer value is followed by the letter K, it is multiplied by 1024; if
5314 it is followed by the letter M, it is multiplied by 1024x1024;
5315 if by the letter G, 1024x1024x1024.
5316 When the values
5317 of integer option settings are output, values which are an exact multiple of
5318 1024 or 1024x1024 are sometimes, but not always, printed using the letters K
5319 and M. The printing style is independent of the actual input format that was
5320 used.
5321
5322
5323 .section "Octal integer values" "SECID49"
5324 .cindex "integer format"
5325 .cindex "format" "octal integer"
5326 If an option's type is given as &"octal integer"&, its value is always
5327 interpreted as an octal number, whether or not it starts with the digit zero.
5328 Such options are always output in octal.
5329
5330
5331 .section "Fixed point numbers" "SECID50"
5332 .cindex "fixed point configuration values"
5333 .cindex "format" "fixed point"
5334 If an option's type is given as &"fixed-point"&, its value must be a decimal
5335 integer, optionally followed by a decimal point and up to three further digits.
5336
5337
5338
5339 .section "Time intervals" "SECTtimeformat"
5340 .cindex "time interval" "specifying in configuration"
5341 .cindex "format" "time interval"
5342 A time interval is specified as a sequence of numbers, each followed by one of
5343 the following letters, with no intervening white space:
5344
5345 .table2 30pt
5346 .irow &%s%& seconds
5347 .irow &%m%& minutes
5348 .irow &%h%& hours
5349 .irow &%d%& days
5350 .irow &%w%& weeks
5351 .endtable
5352
5353 For example, &"3h50m"& specifies 3 hours and 50 minutes. The values of time
5354 intervals are output in the same format. Exim does not restrict the values; it
5355 is perfectly acceptable, for example, to specify &"90m"& instead of &"1h30m"&.
5356
5357
5358
5359 .section "String values" "SECTstrings"
5360 .cindex "string" "format of configuration values"
5361 .cindex "format" "string"
5362 If an option's type is specified as &"string"&, the value can be specified with
5363 or without double-quotes. If it does not start with a double-quote, the value
5364 consists of the remainder of the line plus any continuation lines, starting at
5365 the first character after any leading white space, with trailing white space
5366 removed, and with no interpretation of the characters in the string. Because
5367 Exim removes comment lines (those beginning with #) at an early stage, they can
5368 appear in the middle of a multi-line string. The following two settings are
5369 therefore equivalent:
5370 .code
5371 trusted_users = uucp:mail
5372 trusted_users = uucp:\
5373                 # This comment line is ignored
5374                 mail
5375 .endd
5376 .cindex "string" "quoted"
5377 .cindex "escape characters in quoted strings"
5378 If a string does start with a double-quote, it must end with a closing
5379 double-quote, and any backslash characters other than those used for line
5380 continuation are interpreted as escape characters, as follows:
5381
5382 .table2 100pt
5383 .irow &`\\`&                     "single backslash"
5384 .irow &`\n`&                     "newline"
5385 .irow &`\r`&                     "carriage return"
5386 .irow &`\t`&                     "tab"
5387 .irow "&`\`&<&'octal digits'&>"  "up to 3 octal digits specify one character"
5388 .irow "&`\x`&<&'hex digits'&>"   "up to 2 hexadecimal digits specify one &&&
5389                                    character"
5390 .endtable
5391
5392 If a backslash is followed by some other character, including a double-quote
5393 character, that character replaces the pair.
5394
5395 Quoting is necessary only if you want to make use of the backslash escapes to
5396 insert special characters, or if you need to specify a value with leading or
5397 trailing spaces. These cases are rare, so quoting is almost never needed in
5398 current versions of Exim. In versions of Exim before 3.14, quoting was required
5399 in order to continue lines, so you may come across older configuration files
5400 and examples that apparently quote unnecessarily.
5401
5402
5403 .section "Expanded strings" "SECID51"
5404 .cindex "expansion" "definition of"
5405 Some strings in the configuration file are subjected to &'string expansion'&,
5406 by which means various parts of the string may be changed according to the
5407 circumstances (see chapter &<<CHAPexpand>>&). The input syntax for such strings
5408 is as just described; in particular, the handling of backslashes in quoted
5409 strings is done as part of the input process, before expansion takes place.
5410 However, backslash is also an escape character for the expander, so any
5411 backslashes that are required for that reason must be doubled if they are
5412 within a quoted configuration string.
5413
5414
5415 .section "User and group names" "SECID52"
5416 .cindex "user name" "format of"
5417 .cindex "format" "user name"
5418 .cindex "groups" "name format"
5419 .cindex "format" "group name"
5420 User and group names are specified as strings, using the syntax described
5421 above, but the strings are interpreted specially. A user or group name must
5422 either consist entirely of digits, or be a name that can be looked up using the
5423 &[getpwnam()]& or &[getgrnam()]& function, as appropriate.
5424
5425
5426 .section "List construction" "SECTlistconstruct"
5427 .cindex "list" "syntax of in configuration"
5428 .cindex "format" "list item in configuration"
5429 .cindex "string" "list, definition of"
5430 The data for some configuration options is a list of items, with colon as the
5431 default separator. Many of these options are shown with type &"string list"& in
5432 the descriptions later in this document. Others are listed as &"domain list"&,
5433 &"host list"&, &"address list"&, or &"local part list"&. Syntactically, they
5434 are all the same; however, those other than &"string list"& are subject to
5435 particular kinds of interpretation, as described in chapter
5436 &<<CHAPdomhosaddlists>>&.
5437
5438 In all these cases, the entire list is treated as a single string as far as the
5439 input syntax is concerned. The &%trusted_users%& setting in section
5440 &<<SECTstrings>>& above is an example. If a colon is actually needed in an item
5441 in a list, it must be entered as two colons. Leading and trailing white space
5442 on each item in a list is ignored. This makes it possible to include items that
5443 start with a colon, and in particular, certain forms of IPv6 address. For
5444 example, the list
5445 .code
5446 local_interfaces = 127.0.0.1 : ::::1
5447 .endd
5448 contains two IP addresses, the IPv4 address 127.0.0.1 and the IPv6 address ::1.
5449
5450 &*Note*&: Although leading and trailing white space is ignored in individual
5451 list items, it is not ignored when parsing the list. The spaces around the first
5452 colon in the example above are necessary. If they were not there, the list would
5453 be interpreted as the two items 127.0.0.1:: and 1.
5454
5455 .section "Changing list separators" "SECTlistsepchange"
5456 .cindex "list separator" "changing"
5457 .cindex "IPv6" "addresses in lists"
5458 Doubling colons in IPv6 addresses is an unwelcome chore, so a mechanism was
5459 introduced to allow the separator character to be changed. If a list begins
5460 with a left angle bracket, followed by any punctuation character, that
5461 character is used instead of colon as the list separator. For example, the list
5462 above can be rewritten to use a semicolon separator like this:
5463 .code
5464 local_interfaces = <; 127.0.0.1 ; ::1
5465 .endd
5466 This facility applies to all lists, with the exception of the list in
5467 &%log_file_path%&. It is recommended that the use of non-colon separators be
5468 confined to circumstances where they really are needed.
5469
5470 .cindex "list separator" "newline as"
5471 .cindex "newline" "as list separator"
5472 It is also possible to use newline and other control characters (those with
5473 code values less than 32, plus DEL) as separators in lists. Such separators
5474 must be provided literally at the time the list is processed. For options that
5475 are string-expanded, you can write the separator using a normal escape
5476 sequence. This will be processed by the expander before the string is
5477 interpreted as a list. For example, if a newline-separated list of domains is
5478 generated by a lookup, you can process it directly by a line such as this:
5479 .code
5480 domains = <\n ${lookup mysql{.....}}
5481 .endd
5482 This avoids having to change the list separator in such data. You are unlikely
5483 to want to use a control character as a separator in an option that is not
5484 expanded, because the value is literal text. However, it can be done by giving
5485 the value in quotes. For example:
5486 .code
5487 local_interfaces = "<\n 127.0.0.1 \n ::1"
5488 .endd
5489 Unlike printing character separators, which can be included in list items by
5490 doubling, it is not possible to include a control character as data when it is
5491 set as the separator. Two such characters in succession are interpreted as
5492 enclosing an empty list item.
5493
5494
5495
5496 .section "Empty items in lists" "SECTempitelis"
5497 .cindex "list" "empty item in"
5498 An empty item at the end of a list is always ignored. In other words, trailing
5499 separator characters are ignored. Thus, the list in
5500 .code
5501 senders = user@domain :
5502 .endd
5503 contains only a single item. If you want to include an empty string as one item
5504 in a list, it must not be the last item. For example, this list contains three
5505 items, the second of which is empty:
5506 .code
5507 senders = user1@domain : : user2@domain
5508 .endd
5509 &*Note*&: There must be white space between the two colons, as otherwise they
5510 are interpreted as representing a single colon data character (and the list
5511 would then contain just one item). If you want to specify a list that contains
5512 just one, empty item, you can do it as in this example:
5513 .code
5514 senders = :
5515 .endd
5516 In this case, the first item is empty, and the second is discarded because it
5517 is at the end of the list.
5518
5519
5520
5521
5522 .section "Format of driver configurations" "SECTfordricon"
5523 .cindex "drivers" "configuration format"
5524 There are separate parts in the configuration for defining routers, transports,
5525 and authenticators. In each part, you are defining a number of driver
5526 instances, each with its own set of options. Each driver instance is defined by
5527 a sequence of lines like this:
5528 .display
5529 <&'instance name'&>:
5530   <&'option'&>
5531   ...
5532   <&'option'&>
5533 .endd
5534 In the following example, the instance name is &(localuser)&, and it is
5535 followed by three options settings:
5536 .code
5537 localuser:
5538   driver = accept
5539   check_local_user
5540   transport = local_delivery
5541 .endd
5542 For each driver instance, you specify which Exim code module it uses &-- by the
5543 setting of the &%driver%& option &-- and (optionally) some configuration
5544 settings. For example, in the case of transports, if you want a transport to
5545 deliver with SMTP you would use the &(smtp)& driver; if you want to deliver to
5546 a local file you would use the &(appendfile)& driver. Each of the drivers is
5547 described in detail in its own separate chapter later in this manual.
5548
5549 You can have several routers, transports, or authenticators that are based on
5550 the same underlying driver (each must have a different instance name).
5551
5552 The order in which routers are defined is important, because addresses are
5553 passed to individual routers one by one, in order. The order in which
5554 transports are defined does not matter at all. The order in which
5555 authenticators are defined is used only when Exim, as a client, is searching
5556 them to find one that matches an authentication mechanism offered by the
5557 server.
5558
5559 .cindex "generic options"
5560 .cindex "options" "generic &-- definition of"
5561 Within a driver instance definition, there are two kinds of option: &'generic'&
5562 and &'private'&. The generic options are those that apply to all drivers of the
5563 same type (that is, all routers, all transports or all authenticators). The
5564 &%driver%& option is a generic option that must appear in every definition.
5565 .cindex "private options"
5566 The private options are special for each driver, and none need appear, because
5567 they all have default values.
5568
5569 The options may appear in any order, except that the &%driver%& option must
5570 precede any private options, since these depend on the particular driver. For
5571 this reason, it is recommended that &%driver%& always be the first option.
5572
5573 Driver instance names, which are used for reference in log entries and
5574 elsewhere, can be any sequence of letters, digits, and underscores (starting
5575 with a letter) and must be unique among drivers of the same type. A router and
5576 a transport (for example) can each have the same name, but no two router
5577 instances can have the same name. The name of a driver instance should not be
5578 confused with the name of the underlying driver module. For example, the
5579 configuration lines:
5580 .code
5581 remote_smtp:
5582   driver = smtp
5583 .endd
5584 create an instance of the &(smtp)& transport driver whose name is
5585 &(remote_smtp)&. The same driver code can be used more than once, with
5586 different instance names and different option settings each time. A second
5587 instance of the &(smtp)& transport, with different options, might be defined
5588 thus:
5589 .code
5590 special_smtp:
5591   driver = smtp
5592   port = 1234
5593   command_timeout = 10s
5594 .endd
5595 The names &(remote_smtp)& and &(special_smtp)& would be used to reference
5596 these transport instances from routers, and these names would appear in log
5597 lines.
5598
5599 Comment lines may be present in the middle of driver specifications. The full
5600 list of option settings for any particular driver instance, including all the
5601 defaulted values, can be extracted by making use of the &%-bP%& command line
5602 option.
5603
5604
5605
5606
5607
5608
5609 . ////////////////////////////////////////////////////////////////////////////
5610 . ////////////////////////////////////////////////////////////////////////////
5611
5612 .chapter "The default configuration file" "CHAPdefconfil"
5613 .scindex IIDconfiwal "configuration file" "default &""walk through""&"
5614 .cindex "default" "configuration file &""walk through""&"
5615 The default configuration file supplied with Exim as &_src/configure.default_&
5616 is sufficient for a host with simple mail requirements. As an introduction to
5617 the way Exim is configured, this chapter &"walks through"& the default
5618 configuration, giving brief explanations of the settings. Detailed descriptions
5619 of the options are given in subsequent chapters. The default configuration file
5620 itself contains extensive comments about ways you might want to modify the
5621 initial settings. However, note that there are many options that are not
5622 mentioned at all in the default configuration.
5623
5624
5625
5626 .section "Macros" "SECTdefconfmacros"
5627 All macros should be defined before any options.
5628
5629 One macro is specified, but commented out, in the default configuration:
5630 .code
5631 # ROUTER_SMARTHOST=MAIL.HOSTNAME.FOR.CENTRAL.SERVER.EXAMPLE
5632 .endd
5633 If all off-site mail is expected to be delivered to a "smarthost", then set the
5634 hostname here and uncomment the macro.  This will affect which router is used
5635 later on.  If this is left commented out, then Exim will perform direct-to-MX
5636 deliveries using a &(dnslookup)& router.
5637
5638 In addition to macros defined here, Exim includes a number of built-in macros
5639 to enable configuration to be guarded by a binary built with support for a
5640 given feature.  See section &<<SECTbuiltinmacros>>& for more details.
5641
5642
5643 .section "Main configuration settings" "SECTdefconfmain"
5644 The main (global) configuration option settings section must always come first
5645 in the file, after the macros.
5646 The first thing you'll see in the file, after some initial comments, is the line
5647 .code
5648 # primary_hostname =
5649 .endd
5650 This is a commented-out setting of the &%primary_hostname%& option. Exim needs
5651 to know the official, fully qualified name of your host, and this is where you
5652 can specify it. However, in most cases you do not need to set this option. When
5653 it is unset, Exim uses the &[uname()]& system function to obtain the host name.
5654
5655 The first three non-comment configuration lines are as follows:
5656 .code
5657 domainlist local_domains    = @
5658 domainlist relay_to_domains =
5659 hostlist   relay_from_hosts = 127.0.0.1
5660 .endd
5661 These are not, in fact, option settings. They are definitions of two named
5662 domain lists and one named host list. Exim allows you to give names to lists of
5663 domains, hosts, and email addresses, in order to make it easier to manage the
5664 configuration file (see section &<<SECTnamedlists>>&).
5665
5666 The first line defines a domain list called &'local_domains'&; this is used
5667 later in the configuration to identify domains that are to be delivered
5668 on the local host.
5669
5670 .cindex "@ in a domain list"
5671 There is just one item in this list, the string &"@"&. This is a special form
5672 of entry which means &"the name of the local host"&. Thus, if the local host is
5673 called &'a.host.example'&, mail to &'any.user@a.host.example'& is expected to
5674 be delivered locally. Because the local host's name is referenced indirectly,
5675 the same configuration file can be used on different hosts.
5676
5677 The second line defines a domain list called &'relay_to_domains'&, but the
5678 list itself is empty. Later in the configuration we will come to the part that
5679 controls mail relaying through the local host; it allows relaying to any
5680 domains in this list. By default, therefore, no relaying on the basis of a mail
5681 domain is permitted.
5682
5683 The third line defines a host list called &'relay_from_hosts'&. This list is
5684 used later in the configuration to permit relaying from any host or IP address
5685 that matches the list. The default contains just the IP address of the IPv4
5686 loopback interface, which means that processes on the local host are able to
5687 submit mail for relaying by sending it over TCP/IP to that interface. No other
5688 hosts are permitted to submit messages for relaying.
5689
5690 Just to be sure there's no misunderstanding: at this point in the configuration
5691 we aren't actually setting up any controls. We are just defining some domains
5692 and hosts that will be used in the controls that are specified later.
5693
5694 The next two configuration lines are genuine option settings:
5695 .code
5696 acl_smtp_rcpt = acl_check_rcpt
5697 acl_smtp_data = acl_check_data
5698 .endd
5699 These options specify &'Access Control Lists'& (ACLs) that are to be used
5700 during an incoming SMTP session for every recipient of a message (every RCPT
5701 command), and after the contents of the message have been received,
5702 respectively. The names of the lists are &'acl_check_rcpt'& and
5703 &'acl_check_data'&, and we will come to their definitions below, in the ACL
5704 section of the configuration. The RCPT ACL controls which recipients are
5705 accepted for an incoming message &-- if a configuration does not provide an ACL
5706 to check recipients, no SMTP mail can be accepted. The DATA ACL allows the
5707 contents of a message to be checked.
5708
5709 Two commented-out option settings are next:
5710 .code
5711 # av_scanner = clamd:/tmp/clamd
5712 # spamd_address = 127.0.0.1 783
5713 .endd
5714 These are example settings that can be used when Exim is compiled with the
5715 content-scanning extension. The first specifies the interface to the virus
5716 scanner, and the second specifies the interface to SpamAssassin. Further
5717 details are given in chapter &<<CHAPexiscan>>&.
5718
5719 Three more commented-out option settings follow:
5720 .code
5721 # tls_advertise_hosts = *
5722 # tls_certificate = /etc/ssl/exim.crt
5723 # tls_privatekey = /etc/ssl/exim.pem
5724 .endd
5725 These are example settings that can be used when Exim is compiled with
5726 support for TLS (aka SSL) as described in section &<<SECTinctlsssl>>&. The
5727 first one specifies the list of clients that are allowed to use TLS when
5728 connecting to this server; in this case, the wildcard means all clients. The
5729 other options specify where Exim should find its TLS certificate and private
5730 key, which together prove the server's identity to any clients that connect.
5731 More details are given in chapter &<<CHAPTLS>>&.
5732
5733 Another two commented-out option settings follow:
5734 .code
5735 # daemon_smtp_ports = 25 : 465 : 587
5736 # tls_on_connect_ports = 465
5737 .endd
5738 .cindex "port" "465 and 587"
5739 .cindex "port" "for message submission"
5740 .cindex "message" "submission, ports for"
5741 .cindex "submissions protocol"
5742 .cindex "smtps protocol"
5743 .cindex "ssmtp protocol"
5744 .cindex "SMTP" "submissions protocol"
5745 .cindex "SMTP" "ssmtp protocol"
5746 .cindex "SMTP" "smtps protocol"
5747 These options provide better support for roaming users who wish to use this
5748 server for message submission. They are not much use unless you have turned on
5749 TLS (as described in the previous paragraph) and authentication (about which
5750 more in section &<<SECTdefconfauth>>&).
5751 Mail submission from mail clients (MUAs) should be separate from inbound mail
5752 to your domain (MX delivery) for various good reasons (eg, ability to impose
5753 much saner TLS protocol and ciphersuite requirements without unintended
5754 consequences).
5755 RFC 6409 (previously 4409) specifies use of port 587 for SMTP Submission,
5756 which uses STARTTLS, so this is the &"submission"& port.
5757 RFC 8314 specifies use of port 465 as the &"submissions"& protocol,
5758 which should be used in preference to 587.
5759 You should also consider deploying SRV records to help clients find
5760 these ports.
5761 Older names for &"submissions"& are &"smtps"& and &"ssmtp"&.
5762
5763 Two more commented-out options settings follow:
5764 .code
5765 # qualify_domain =
5766 # qualify_recipient =
5767 .endd
5768 The first of these specifies a domain that Exim uses when it constructs a
5769 complete email address from a local login name. This is often needed when Exim
5770 receives a message from a local process. If you do not set &%qualify_domain%&,
5771 the value of &%primary_hostname%& is used. If you set both of these options,
5772 you can have different qualification domains for sender and recipient
5773 addresses. If you set only the first one, its value is used in both cases.
5774
5775 .cindex "domain literal" "recognizing format"
5776 The following line must be uncommented if you want Exim to recognize
5777 addresses of the form &'user@[10.11.12.13]'& that is, with a &"domain literal"&
5778 (an IP address within square brackets) instead of a named domain.
5779 .code
5780 # allow_domain_literals
5781 .endd
5782 The RFCs still require this form, but many people think that in the modern
5783 Internet it makes little sense to permit mail to be sent to specific hosts by
5784 quoting their IP addresses. This ancient format has been used by people who
5785 try to abuse hosts by using them for unwanted relaying. However, some
5786 people believe there are circumstances (for example, messages addressed to
5787 &'postmaster'&) where domain literals are still useful.
5788
5789 The next configuration line is a kind of trigger guard:
5790 .code
5791 never_users = root
5792 .endd
5793 It specifies that no delivery must ever be run as the root user. The normal
5794 convention is to set up &'root'& as an alias for the system administrator. This
5795 setting is a guard against slips in the configuration.
5796 The list of users specified by &%never_users%& is not, however, the complete
5797 list; the build-time configuration in &_Local/Makefile_& has an option called
5798 FIXED_NEVER_USERS specifying a list that cannot be overridden. The
5799 contents of &%never_users%& are added to this list. By default
5800 FIXED_NEVER_USERS also specifies root.
5801
5802 When a remote host connects to Exim in order to send mail, the only information
5803 Exim has about the host's identity is its IP address. The next configuration
5804 line,
5805 .code
5806 host_lookup = *
5807 .endd
5808 specifies that Exim should do a reverse DNS lookup on all incoming connections,
5809 in order to get a host name. This improves the quality of the logging
5810 information, but if you feel it is too expensive, you can remove it entirely,
5811 or restrict the lookup to hosts on &"nearby"& networks.
5812 Note that it is not always possible to find a host name from an IP address,
5813 because not all DNS reverse zones are maintained, and sometimes DNS servers are
5814 unreachable.
5815
5816 The next two lines are concerned with &'ident'& callbacks, as defined by RFC
5817 1413 (hence their names):
5818 .code
5819 rfc1413_hosts = *
5820 rfc1413_query_timeout = 0s
5821 .endd
5822 These settings cause Exim to avoid ident callbacks for all incoming SMTP calls.
5823 Few hosts offer RFC1413 service these days; calls have to be
5824 terminated by a timeout and this needlessly delays the startup
5825 of an incoming SMTP connection.
5826 If you have hosts for which you trust RFC1413 and need this
5827 information, you can change this.
5828
5829 This line enables an efficiency SMTP option.  It is negotiated by clients
5830 and not expected to cause problems but can be disabled if needed.
5831 .code
5832 prdr_enable = true
5833 .endd
5834
5835 When Exim receives messages over SMTP connections, it expects all addresses to
5836 be fully qualified with a domain, as required by the SMTP definition. However,
5837 if you are running a server to which simple clients submit messages, you may
5838 find that they send unqualified addresses. The two commented-out options:
5839 .code
5840 # sender_unqualified_hosts =
5841 # recipient_unqualified_hosts =
5842 .endd
5843 show how you can specify hosts that are permitted to send unqualified sender
5844 and recipient addresses, respectively.
5845
5846 The &%log_selector%& option is used to increase the detail of logging
5847 over the default:
5848 .code
5849 log_selector = +smtp_protocol_error +smtp_syntax_error \
5850                +tls_certificate_verified
5851 .endd
5852
5853 The &%percent_hack_domains%& option is also commented out:
5854 .code
5855 # percent_hack_domains =
5856 .endd
5857 It provides a list of domains for which the &"percent hack"& is to operate.
5858 This is an almost obsolete form of explicit email routing. If you do not know
5859 anything about it, you can safely ignore this topic.
5860
5861 The next two settings in the main part of the default configuration are
5862 concerned with messages that have been &"frozen"& on Exim's queue. When a
5863 message is frozen, Exim no longer continues to try to deliver it. Freezing
5864 occurs when a bounce message encounters a permanent failure because the sender
5865 address of the original message that caused the bounce is invalid, so the
5866 bounce cannot be delivered. This is probably the most common case, but there
5867 are also other conditions that cause freezing, and frozen messages are not
5868 always bounce messages.
5869 .code
5870 ignore_bounce_errors_after = 2d
5871 timeout_frozen_after = 7d
5872 .endd
5873 The first of these options specifies that failing bounce messages are to be
5874 discarded after 2 days in the queue. The second specifies that any frozen
5875 message (whether a bounce message or not) is to be timed out (and discarded)
5876 after a week. In this configuration, the first setting ensures that no failing
5877 bounce message ever lasts a week.
5878
5879 Exim queues it's messages in a spool directory. If you expect to have
5880 large queues, you may consider using this option. It splits the spool
5881 directory into subdirectories to avoid file system degradation from
5882 many files in a single directory, resulting in better performance.
5883 Manual manipulation of queued messages becomes more complex (though fortunately
5884 not often needed).
5885 .code
5886 # split_spool_directory = true
5887 .endd
5888
5889 In an ideal world everybody follows the standards. For non-ASCII
5890 messages RFC 2047 is a standard, allowing a maximum line length of 76
5891 characters. Exim adheres that standard and won't process messages which
5892 violate this standard. (Even ${rfc2047:...} expansions will fail.)
5893 In particular, the Exim maintainers have had multiple reports of
5894 problems from Russian administrators of issues until they disable this
5895 check, because of some popular, yet buggy, mail composition software.
5896 .code
5897 # check_rfc2047_length = false
5898 .endd
5899
5900 If you need to be strictly RFC compliant you may wish to disable the
5901 8BITMIME advertisement. Use this, if you exchange mails with systems
5902 that are not 8-bit clean.
5903 .code
5904 # accept_8bitmime = false
5905 .endd
5906
5907 Libraries you use may depend on specific environment settings.  This
5908 imposes a security risk (e.g. PATH). There are two lists:
5909 &%keep_environment%& for the variables to import as they are, and
5910 &%add_environment%& for variables we want to set to a fixed value.
5911 Note that TZ is handled separately, by the &%timezone%& runtime
5912 option and by the TIMEZONE_DEFAULT buildtime option.
5913 .code
5914 # keep_environment = ^LDAP
5915 # add_environment = PATH=/usr/bin::/bin
5916 .endd
5917
5918
5919 .section "ACL configuration" "SECID54"
5920 .cindex "default" "ACLs"
5921 .cindex "&ACL;" "default configuration"
5922 In the default configuration, the ACL section follows the main configuration.
5923 It starts with the line
5924 .code
5925 begin acl
5926 .endd
5927 and it contains the definitions of two ACLs, called &'acl_check_rcpt'& and
5928 &'acl_check_data'&, that were referenced in the settings of &%acl_smtp_rcpt%&
5929 and &%acl_smtp_data%& above.
5930
5931 .cindex "RCPT" "ACL for"
5932 The first ACL is used for every RCPT command in an incoming SMTP message. Each
5933 RCPT command specifies one of the message's recipients. The ACL statements
5934 are considered in order, until the recipient address is either accepted or
5935 rejected. The RCPT command is then accepted or rejected, according to the
5936 result of the ACL processing.
5937 .code
5938 acl_check_rcpt:
5939 .endd
5940 This line, consisting of a name terminated by a colon, marks the start of the
5941 ACL, and names it.
5942 .code
5943 accept  hosts = :
5944 .endd
5945 This ACL statement accepts the recipient if the sending host matches the list.
5946 But what does that strange list mean? It doesn't actually contain any host
5947 names or IP addresses. The presence of the colon puts an empty item in the
5948 list; Exim matches this only if the incoming message did not come from a remote
5949 host, because in that case, the remote hostname is empty. The colon is
5950 important. Without it, the list itself is empty, and can never match anything.
5951
5952 What this statement is doing is to accept unconditionally all recipients in
5953 messages that are submitted by SMTP from local processes using the standard
5954 input and output (that is, not using TCP/IP). A number of MUAs operate in this
5955 manner.
5956 .code
5957 deny    domains       = +local_domains
5958         local_parts   = ^[.] : ^.*[@%!/|]
5959         message       = Restricted characters in address
5960
5961 deny    domains       = !+local_domains
5962         local_parts   = ^[./|] : ^.*[@%!] : ^.*/\\.\\./
5963         message       = Restricted characters in address
5964 .endd
5965 These statements are concerned with local parts that contain any of the
5966 characters &"@"&, &"%"&, &"!"&, &"/"&, &"|"&, or dots in unusual places.
5967 Although these characters are entirely legal in local parts (in the case of
5968 &"@"& and leading dots, only if correctly quoted), they do not commonly occur
5969 in Internet mail addresses.
5970
5971 The first three have in the past been associated with explicitly routed
5972 addresses (percent is still sometimes used &-- see the &%percent_hack_domains%&
5973 option). Addresses containing these characters are regularly tried by spammers
5974 in an attempt to bypass relaying restrictions, and also by open relay testing
5975 programs. Unless you really need them it is safest to reject these characters
5976 at this early stage. This configuration is heavy-handed in rejecting these
5977 characters for all messages it accepts from remote hosts. This is a deliberate
5978 policy of being as safe as possible.
5979
5980 The first rule above is stricter, and is applied to messages that are addressed
5981 to one of the local domains handled by this host. This is implemented by the
5982 first condition, which restricts it to domains that are listed in the
5983 &'local_domains'& domain list. The &"+"& character is used to indicate a
5984 reference to a named list. In this configuration, there is just one domain in
5985 &'local_domains'&, but in general there may be many.
5986
5987 The second condition on the first statement uses two regular expressions to
5988 block local parts that begin with a dot or contain &"@"&, &"%"&, &"!"&, &"/"&,
5989 or &"|"&. If you have local accounts that include these characters, you will
5990 have to modify this rule.
5991
5992 Empty components (two dots in a row) are not valid in RFC 2822, but Exim
5993 allows them because they have been encountered in practice. (Consider the
5994 common convention of local parts constructed as
5995 &"&'first-initial.second-initial.family-name'&"& when applied to someone like
5996 the author of Exim, who has no second initial.) However, a local part starting
5997 with a dot or containing &"/../"& can cause trouble if it is used as part of a
5998 filename (for example, for a mailing list). This is also true for local parts
5999 that contain slashes. A pipe symbol can also be troublesome if the local part
6000 is incorporated unthinkingly into a shell command line.
6001
6002 The second rule above applies to all other domains, and is less strict. This
6003 allows your own users to send outgoing messages to sites that use slashes
6004 and vertical bars in their local parts. It blocks local parts that begin
6005 with a dot, slash, or vertical bar, but allows these characters within the
6006 local part. However, the sequence &"/../"& is barred. The use of &"@"&, &"%"&,
6007 and &"!"& is blocked, as before. The motivation here is to prevent your users
6008 (or your users' viruses) from mounting certain kinds of attack on remote sites.
6009 .code
6010 accept  local_parts   = postmaster
6011         domains       = +local_domains
6012 .endd
6013 This statement, which has two conditions, accepts an incoming address if the
6014 local part is &'postmaster'& and the domain is one of those listed in the
6015 &'local_domains'& domain list. The &"+"& character is used to indicate a
6016 reference to a named list. In this configuration, there is just one domain in
6017 &'local_domains'&, but in general there may be many.
6018
6019 The presence of this statement means that mail to postmaster is never blocked
6020 by any of the subsequent tests. This can be helpful while sorting out problems
6021 in cases where the subsequent tests are incorrectly denying access.
6022 .code
6023 require verify        = sender
6024 .endd
6025 This statement requires the sender address to be verified before any subsequent
6026 ACL statement can be used. If verification fails, the incoming recipient
6027 address is refused. Verification consists of trying to route the address, to
6028 see if a bounce message could be delivered to it. In the case of remote
6029 addresses, basic verification checks only the domain, but &'callouts'& can be
6030 used for more verification if required. Section &<<SECTaddressverification>>&
6031 discusses the details of address verification.
6032 .code
6033 accept  hosts         = +relay_from_hosts
6034         control       = submission
6035 .endd
6036 This statement accepts the address if the message is coming from one of the
6037 hosts that are defined as being allowed to relay through this host. Recipient
6038 verification is omitted here, because in many cases the clients are dumb MUAs
6039 that do not cope well with SMTP error responses. For the same reason, the
6040 second line specifies &"submission mode"& for messages that are accepted. This
6041 is described in detail in section &<<SECTsubmodnon>>&; it causes Exim to fix
6042 messages that are deficient in some way, for example, because they lack a
6043 &'Date:'& header line. If you are actually relaying out from MTAs, you should
6044 probably add recipient verification here, and disable submission mode.
6045 .code
6046 accept  authenticated = *
6047         control       = submission
6048 .endd
6049 This statement accepts the address if the client host has authenticated itself.
6050 Submission mode is again specified, on the grounds that such messages are most
6051 likely to come from MUAs. The default configuration does not define any
6052 authenticators, though it does include some nearly complete commented-out
6053 examples described in &<<SECTdefconfauth>>&. This means that no client can in
6054 fact authenticate until you complete the authenticator definitions.
6055 .code
6056 require message = relay not permitted
6057         domains = +local_domains : +relay_to_domains
6058 .endd
6059 This statement rejects the address if its domain is neither a local domain nor
6060 one of the domains for which this host is a relay.
6061 .code
6062 require verify = recipient
6063 .endd
6064 This statement requires the recipient address to be verified; if verification
6065 fails, the address is rejected.
6066 .code
6067 # deny    dnslists    = black.list.example
6068 #         message     = rejected because $sender_host_address \
6069 #                       is in a black list at $dnslist_domain\n\
6070 #                       $dnslist_text
6071 #
6072 # warn    dnslists    = black.list.example
6073 #         add_header  = X-Warning: $sender_host_address is in \
6074 #                       a black list at $dnslist_domain
6075 #         log_message = found in $dnslist_domain
6076 .endd
6077 These commented-out lines are examples of how you could configure Exim to check
6078 sending hosts against a DNS black list. The first statement rejects messages
6079 from blacklisted hosts, whereas the second just inserts a warning header
6080 line.
6081 .code
6082 # require verify = csa
6083 .endd
6084 This commented-out line is an example of how you could turn on client SMTP
6085 authorization (CSA) checking. Such checks do DNS lookups for special SRV
6086 records.
6087 .code
6088 accept
6089 .endd
6090 The final statement in the first ACL unconditionally accepts any recipient
6091 address that has successfully passed all the previous tests.
6092 .code
6093 acl_check_data:
6094 .endd
6095 This line marks the start of the second ACL, and names it. Most of the contents
6096 of this ACL are commented out:
6097 .code
6098 # deny    malware   = *
6099 #         message   = This message contains a virus \
6100 #                     ($malware_name).
6101 .endd
6102 These lines are examples of how to arrange for messages to be scanned for
6103 viruses when Exim has been compiled with the content-scanning extension, and a
6104 suitable virus scanner is installed. If the message is found to contain a
6105 virus, it is rejected with the given custom error message.
6106 .code
6107 # warn    spam      = nobody
6108 #         message   = X-Spam_score: $spam_score\n\
6109 #                     X-Spam_score_int: $spam_score_int\n\
6110 #                     X-Spam_bar: $spam_bar\n\
6111 #                     X-Spam_report: $spam_report
6112 .endd
6113 These lines are an example of how to arrange for messages to be scanned by
6114 SpamAssassin when Exim has been compiled with the content-scanning extension,
6115 and SpamAssassin has been installed. The SpamAssassin check is run with
6116 &`nobody`& as its user parameter, and the results are added to the message as a
6117 series of extra header line. In this case, the message is not rejected,
6118 whatever the spam score.
6119 .code
6120 accept
6121 .endd
6122 This final line in the DATA ACL accepts the message unconditionally.
6123
6124
6125 .section "Router configuration" "SECID55"
6126 .cindex "default" "routers"
6127 .cindex "routers" "default"
6128 The router configuration comes next in the default configuration, introduced
6129 by the line
6130 .code
6131 begin routers
6132 .endd
6133 Routers are the modules in Exim that make decisions about where to send
6134 messages. An address is passed to each router, in turn, until it is either
6135 accepted, or failed. This means that the order in which you define the routers
6136 matters. Each router is fully described in its own chapter later in this
6137 manual. Here we give only brief overviews.
6138 .code
6139 # domain_literal:
6140 #   driver = ipliteral
6141 #   domains = !+local_domains
6142 #   transport = remote_smtp
6143 .endd
6144 .cindex "domain literal" "default router"
6145 This router is commented out because the majority of sites do not want to
6146 support domain literal addresses (those of the form &'user@[10.9.8.7]'&). If
6147 you uncomment this router, you also need to uncomment the setting of
6148 &%allow_domain_literals%& in the main part of the configuration.
6149
6150 Which router is used next depends upon whether or not the ROUTER_SMARTHOST
6151 macro has been defined, per
6152 .code
6153 .ifdef ROUTER_SMARTHOST
6154 smarthost:
6155 #...
6156 .else
6157 dnslookup:
6158 #...
6159 .endif
6160 .endd
6161
6162 If ROUTER_SMARTHOST has been defined, either at the top of the file or on the
6163 command-line, then we route all non-local mail to that smarthost; otherwise, we'll
6164 perform DNS lookups for direct-to-MX lookup.  Any mail which is to a local domain will
6165 skip these routers because of the &%domains%& option.
6166
6167 .code
6168 smarthost:
6169   driver = manualroute
6170   domains = ! +local_domains
6171   transport = smarthost_smtp
6172   route_data = ROUTER_SMARTHOST
6173   ignore_target_hosts = <; 0.0.0.0 ; 127.0.0.0/8 ; ::1
6174   no_more
6175 .endd
6176 This router only handles mail which is not to any local domains; this is
6177 specified by the line
6178 .code
6179 domains = ! +local_domains
6180 .endd
6181 The &%domains%& option lists the domains to which this router applies, but the
6182 exclamation mark is a negation sign, so the router is used only for domains
6183 that are not in the domain list called &'local_domains'& (which was defined at
6184 the start of the configuration). The plus sign before &'local_domains'&
6185 indicates that it is referring to a named list. Addresses in other domains are
6186 passed on to the following routers.
6187
6188 The name of the router driver is &(manualroute)& because we are manually
6189 specifying how mail should be routed onwards, instead of using DNS MX.
6190 While the name of this router instance is arbitrary, the &%driver%& option must
6191 be one of the driver modules that is in the Exim binary.
6192
6193 With no pre-conditions other than &%domains%&, all mail for non-local domains
6194 will be handled by this router, and the &%no_more%& setting will ensure that no
6195 other routers will be used for messages matching the pre-conditions.  See
6196 &<<SECTrouprecon>>& for more on how the pre-conditions apply.  For messages which
6197 are handled by this router, we provide a hostname to deliver to in &%route_data%&
6198 and the macro supplies the value; the address is then queued for the
6199 &(smarthost_smtp)& transport.
6200
6201 .code
6202 dnslookup:
6203   driver = dnslookup
6204   domains = ! +local_domains
6205   transport = remote_smtp
6206   ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8
6207   no_more
6208 .endd
6209 The &%domains%& option behaves as per smarthost, above.
6210
6211 The name of the router driver is &(dnslookup)&,
6212 and is specified by the &%driver%& option. Do not be confused by the fact that
6213 the name of this router instance is the same as the name of the driver. The
6214 instance name is arbitrary, but the name set in the &%driver%& option must be
6215 one of the driver modules that is in the Exim binary.
6216
6217 The &(dnslookup)& router routes addresses by looking up their domains in the
6218 DNS in order to obtain a list of hosts to which the address is routed. If the
6219 router succeeds, the address is queued for the &(remote_smtp)& transport, as
6220 specified by the &%transport%& option. If the router does not find the domain
6221 in the DNS, no further routers are tried because of the &%no_more%& setting, so
6222 the address fails and is bounced.
6223
6224 The &%ignore_target_hosts%& option specifies a list of IP addresses that are to
6225 be entirely ignored. This option is present because a number of cases have been
6226 encountered where MX records in the DNS point to host names
6227 whose IP addresses are 0.0.0.0 or are in the 127 subnet (typically 127.0.0.1).
6228 Completely ignoring these IP addresses causes Exim to fail to route the
6229 email address, so it bounces. Otherwise, Exim would log a routing problem, and
6230 continue to try to deliver the message periodically until the address timed
6231 out.
6232 .code
6233 system_aliases:
6234   driver = redirect
6235   allow_fail
6236   allow_defer
6237   data = ${lookup{$local_part}lsearch{/etc/aliases}}
6238 # user = exim
6239   file_transport = address_file
6240   pipe_transport = address_pipe
6241 .endd
6242 Control reaches this and subsequent routers only for addresses in the local
6243 domains. This router checks to see whether the local part is defined as an
6244 alias in the &_/etc/aliases_& file, and if so, redirects it according to the
6245 data that it looks up from that file. If no data is found for the local part,
6246 the value of the &%data%& option is empty, causing the address to be passed to
6247 the next router.
6248
6249 &_/etc/aliases_& is a conventional name for the system aliases file that is
6250 often used. That is why it is referenced by from the default configuration
6251 file. However, you can change this by setting SYSTEM_ALIASES_FILE in
6252 &_Local/Makefile_& before building Exim.
6253 .code
6254 userforward:
6255   driver = redirect
6256   check_local_user
6257 # local_part_suffix = +* : -*
6258 # local_part_suffix_optional
6259   file = $home/.forward
6260 # allow_filter
6261   no_verify
6262   no_expn
6263   check_ancestor
6264   file_transport = address_file
6265   pipe_transport = address_pipe
6266   reply_transport = address_reply
6267 .endd
6268 This is the most complicated router in the default configuration. It is another
6269 redirection router, but this time it is looking for forwarding data set up by
6270 individual users. The &%check_local_user%& setting specifies a check that the
6271 local part of the address is the login name of a local user. If it is not, the
6272 router is skipped. The two commented options that follow &%check_local_user%&,
6273 namely:
6274 .code
6275 # local_part_suffix = +* : -*
6276 # local_part_suffix_optional
6277 .endd
6278 .vindex "&$local_part_suffix$&"
6279 show how you can specify the recognition of local part suffixes. If the first
6280 is uncommented, a suffix beginning with either a plus or a minus sign, followed
6281 by any sequence of characters, is removed from the local part and placed in the
6282 variable &$local_part_suffix$&. The second suffix option specifies that the
6283 presence of a suffix in the local part is optional. When a suffix is present,
6284 the check for a local login uses the local part with the suffix removed.
6285
6286 When a local user account is found, the file called &_.forward_& in the user's
6287 home directory is consulted. If it does not exist, or is empty, the router
6288 declines. Otherwise, the contents of &_.forward_& are interpreted as
6289 redirection data (see chapter &<<CHAPredirect>>& for more details).
6290
6291 .cindex "Sieve filter" "enabling in default router"
6292 Traditional &_.forward_& files contain just a list of addresses, pipes, or
6293 files. Exim supports this by default. However, if &%allow_filter%& is set (it
6294 is commented out by default), the contents of the file are interpreted as a set
6295 of Exim or Sieve filtering instructions, provided the file begins with &"#Exim
6296 filter"& or &"#Sieve filter"&, respectively. User filtering is discussed in the
6297 separate document entitled &'Exim's interfaces to mail filtering'&.
6298
6299 The &%no_verify%& and &%no_expn%& options mean that this router is skipped when
6300 verifying addresses, or when running as a consequence of an SMTP EXPN command.
6301 There are two reasons for doing this:
6302
6303 .olist
6304 Whether or not a local user has a &_.forward_& file is not really relevant when
6305 checking an address for validity; it makes sense not to waste resources doing
6306 unnecessary work.
6307 .next
6308 More importantly, when Exim is verifying addresses or handling an EXPN
6309 command during an SMTP session, it is running as the Exim user, not as root.
6310 The group is the Exim group, and no additional groups are set up.
6311 It may therefore not be possible for Exim to read users' &_.forward_& files at
6312 this time.
6313 .endlist
6314
6315 The setting of &%check_ancestor%& prevents the router from generating a new
6316 address that is the same as any previous address that was redirected. (This
6317 works round a problem concerning a bad interaction between aliasing and
6318 forwarding &-- see section &<<SECTredlocmai>>&).
6319
6320 The final three option settings specify the transports that are to be used when
6321 forwarding generates a direct delivery to a file, or to a pipe, or sets up an
6322 auto-reply, respectively. For example, if a &_.forward_& file contains
6323 .code
6324 a.nother@elsewhere.example, /home/spqr/archive
6325 .endd
6326 the delivery to &_/home/spqr/archive_& is done by running the &%address_file%&
6327 transport.
6328 .code
6329 localuser:
6330   driver = accept
6331   check_local_user
6332 # local_part_suffix = +* : -*
6333 # local_part_suffix_optional
6334   transport = local_delivery
6335 .endd
6336 The final router sets up delivery into local mailboxes, provided that the local
6337 part is the name of a local login, by accepting the address and assigning it to
6338 the &(local_delivery)& transport. Otherwise, we have reached the end of the
6339 routers, so the address is bounced. The commented suffix settings fulfil the
6340 same purpose as they do for the &(userforward)& router.
6341
6342
6343 .section "Transport configuration" "SECID56"
6344 .cindex "default" "transports"
6345 .cindex "transports" "default"
6346 Transports define mechanisms for actually delivering messages. They operate
6347 only when referenced from routers, so the order in which they are defined does
6348 not matter. The transports section of the configuration starts with
6349 .code
6350 begin transports
6351 .endd
6352 Two remote transports and four local transports are defined.
6353 .code
6354 remote_smtp:
6355   driver = smtp
6356   message_size_limit = ${if > {$max_received_linelength}{998} {1}{0}}
6357 .ifdef _HAVE_PRDR
6358   hosts_try_prdr = *
6359 .endif
6360 .endd
6361 This transport is used for delivering messages over SMTP connections.
6362 The list of remote hosts comes from the router.
6363 The &%message_size_limit%& usage is a hack to avoid sending on messages
6364 with over-long lines.
6365
6366 The &%hosts_try_prdr%& option enables an efficiency SMTP option.  It is
6367 negotiated between client and server and not expected to cause problems
6368 but can be disabled if needed.  The built-in macro _HAVE_PRDR guards the
6369 use of the &%hosts_try_prdr%& configuration option.
6370
6371 The other remote transport is used when delivering to a specific smarthost
6372 with whom there must be some kind of existing relationship, instead of the
6373 usual federated system.
6374
6375 .code
6376 smarthost_smtp:
6377   driver = smtp
6378   message_size_limit = ${if > {$max_received_linelength}{998} {1}{0}}
6379   multi_domain
6380   #
6381 .ifdef _HAVE_TLS
6382   # Comment out any of these which you have to, then file a Support
6383   # request with your smarthost provider to get things fixed:
6384   hosts_require_tls = *
6385   tls_verify_hosts = *
6386   # As long as tls_verify_hosts is enabled, this this will have no effect,
6387   # but if you have to comment it out then this will at least log whether
6388   # you succeed or not:
6389   tls_try_verify_hosts = *
6390   #
6391   # The SNI name should match the name which we'll expect to verify;
6392   # many mail systems don't use SNI and this doesn't matter, but if it does,
6393   # we need to send a name which the remote site will recognize.
6394   # This _should_ be the name which the smarthost operators specified as
6395   # the hostname for sending your mail to.
6396   tls_sni = ROUTER_SMARTHOST
6397   #
6398 .ifdef _HAVE_OPENSSL
6399   tls_require_ciphers = HIGH:!aNULL:@STRENGTH
6400 .endif
6401 .ifdef _HAVE_GNUTLS
6402   tls_require_ciphers = SECURE192:-VERS-SSL3.0:-VERS-TLS1.0:-VERS-TLS1.1
6403 .endif
6404 .endif
6405 .ifdef _HAVE_PRDR
6406   hosts_try_prdr = *
6407 .endif
6408 .endd
6409 After the same &%message_size_limit%& hack, we then specify that this Transport
6410 can handle messages to multiple domains in one run.  The assumption here is
6411 that you're routing all non-local mail to the same place and that place is
6412 happy to take all messages from you as quickly as possible.
6413 All other options depend upon built-in macros; if Exim was built without TLS support
6414 then no other options are defined.
6415 If TLS is available, then we configure "stronger than default" TLS ciphersuites
6416 and versions using the &%tls_require_ciphers%& option, where the value to be
6417 used depends upon the library providing TLS.
6418 Beyond that, the options adopt the stance that you should have TLS support available
6419 from your smarthost on today's Internet, so we turn on requiring TLS for the
6420 mail to be delivered, and requiring that the certificate be valid, and match
6421 the expected hostname.  The &%tls_sni%& option can be used by service providers
6422 to select an appropriate certificate to present to you and here we re-use the
6423 ROUTER_SMARTHOST macro, because that is unaffected by CNAMEs present in DNS.
6424 You want to specify the hostname which you'll expect to validate for, and that
6425 should not be subject to insecure tampering via DNS results.
6426
6427 For the &%hosts_try_prdr%& option see the previous transport.
6428
6429 All other options are defaulted.
6430 .code
6431 local_delivery:
6432   driver = appendfile
6433   file = /var/mail/$local_part_data
6434   delivery_date_add
6435   envelope_to_add
6436   return_path_add
6437 # group = mail
6438 # mode = 0660
6439 .endd
6440 This &(appendfile)& transport is used for local delivery to user mailboxes in
6441 traditional BSD mailbox format.
6442
6443 We prefer to avoid using &$local_part$& directly to define the mailbox filename,
6444 as it is provided by a potential bad actor.
6445 Instead we use &$local_part_data$&,
6446 the result of looking up &$local_part$& in the user database
6447 (done by using &%check_local_user%& in the the router).
6448
6449 By default &(appendfile)& runs under the uid and gid of the
6450 local user, which requires the sticky bit to be set on the &_/var/mail_&
6451 directory. Some systems use the alternative approach of running mail deliveries
6452 under a particular group instead of using the sticky bit. The commented options
6453 show how this can be done.
6454
6455 Exim adds three headers to the message as it delivers it: &'Delivery-date:'&,
6456 &'Envelope-to:'& and &'Return-path:'&. This action is requested by the three
6457 similarly-named options above.
6458 .code
6459 address_pipe:
6460   driver = pipe
6461   return_output
6462 .endd
6463 This transport is used for handling deliveries to pipes that are generated by
6464 redirection (aliasing or users' &_.forward_& files). The &%return_output%&
6465 option specifies that any output on stdout or stderr generated by the pipe is to
6466 be returned to the sender.
6467 .code
6468 address_file:
6469   driver = appendfile
6470   delivery_date_add
6471   envelope_to_add
6472   return_path_add
6473 .endd
6474 This transport is used for handling deliveries to files that are generated by
6475 redirection. The name of the file is not specified in this instance of
6476 &(appendfile)&, because it comes from the &(redirect)& router.
6477 .code
6478 address_reply:
6479   driver = autoreply
6480 .endd
6481 This transport is used for handling automatic replies generated by users'
6482 filter files.
6483
6484
6485
6486 .section "Default retry rule" "SECID57"
6487 .cindex "retry" "default rule"
6488 .cindex "default" "retry rule"
6489 The retry section of the configuration file contains rules which affect the way
6490 Exim retries deliveries that cannot be completed at the first attempt. It is
6491 introduced by the line
6492 .code
6493 begin retry
6494 .endd
6495 In the default configuration, there is just one rule, which applies to all
6496 errors:
6497 .code
6498 *   *   F,2h,15m; G,16h,1h,1.5; F,4d,6h
6499 .endd
6500 This causes any temporarily failing address to be retried every 15 minutes for
6501 2 hours, then at intervals starting at one hour and increasing by a factor of
6502 1.5 until 16 hours have passed, then every 6 hours up to 4 days. If an address
6503 is not delivered after 4 days of temporary failure, it is bounced. The time is
6504 measured from first failure, not from the time the message was received.
6505
6506 If the retry section is removed from the configuration, or is empty (that is,
6507 if no retry rules are defined), Exim will not retry deliveries. This turns
6508 temporary errors into permanent errors.
6509
6510
6511 .section "Rewriting configuration" "SECID58"
6512 The rewriting section of the configuration, introduced by
6513 .code
6514 begin rewrite
6515 .endd
6516 contains rules for rewriting addresses in messages as they arrive. There are no
6517 rewriting rules in the default configuration file.
6518
6519
6520
6521 .section "Authenticators configuration" "SECTdefconfauth"
6522 .cindex "AUTH" "configuration"
6523 The authenticators section of the configuration, introduced by
6524 .code
6525 begin authenticators
6526 .endd
6527 defines mechanisms for the use of the SMTP AUTH command. The default
6528 configuration file contains two commented-out example authenticators
6529 which support plaintext username/password authentication using the
6530 standard PLAIN mechanism and the traditional but non-standard LOGIN
6531 mechanism, with Exim acting as the server. PLAIN and LOGIN are enough
6532 to support most MUA software.
6533
6534 The example PLAIN authenticator looks like this:
6535 .code
6536 #PLAIN:
6537 #  driver                  = plaintext
6538 #  server_set_id           = $auth2
6539 #  server_prompts          = :
6540 #  server_condition        = Authentication is not yet configured
6541 #  server_advertise_condition = ${if def:tls_in_cipher }
6542 .endd
6543 And the example LOGIN authenticator looks like this:
6544 .code
6545 #LOGIN:
6546 #  driver                  = plaintext
6547 #  server_set_id           = $auth1
6548 #  server_prompts          = <| Username: | Password:
6549 #  server_condition        = Authentication is not yet configured
6550 #  server_advertise_condition = ${if def:tls_in_cipher }
6551 .endd
6552
6553 The &%server_set_id%& option makes Exim remember the authenticated username
6554 in &$authenticated_id$&, which can be used later in ACLs or routers. The
6555 &%server_prompts%& option configures the &(plaintext)& authenticator so
6556 that it implements the details of the specific authentication mechanism,
6557 i.e. PLAIN or LOGIN. The &%server_advertise_condition%& setting controls
6558 when Exim offers authentication to clients; in the examples, this is only
6559 when TLS or SSL has been started, so to enable the authenticators you also
6560 need to add support for TLS as described in section &<<SECTdefconfmain>>&.
6561
6562 The &%server_condition%& setting defines how to verify that the username and
6563 password are correct. In the examples it just produces an error message.
6564 To make the authenticators work, you can use a string expansion
6565 expression like one of the examples in chapter &<<CHAPplaintext>>&.
6566
6567 Beware that the sequence of the parameters to PLAIN and LOGIN differ; the
6568 usercode and password are in different positions.
6569 Chapter &<<CHAPplaintext>>& covers both.
6570
6571 .ecindex IIDconfiwal
6572
6573
6574
6575 . ////////////////////////////////////////////////////////////////////////////
6576 . ////////////////////////////////////////////////////////////////////////////
6577
6578 .chapter "Regular expressions" "CHAPregexp"
6579
6580 .cindex "regular expressions" "library"
6581 .cindex "PCRE2"
6582 Exim supports the use of regular expressions in many of its options. It
6583 uses the PCRE2 regular expression library; this provides regular expression
6584 matching that is compatible with Perl 5. The syntax and semantics of
6585 regular expressions is discussed in
6586 online Perl manpages, in
6587 many Perl reference books, and also in
6588 Jeffrey Friedl's &'Mastering Regular Expressions'&, which is published by
6589 O'Reilly (see &url(http://www.oreilly.com/catalog/regex2/)).
6590 . --- the http: URL here redirects to another page with the ISBN in the URL
6591 . --- where trying to use https: just redirects back to http:, so sticking
6592 . --- to the old URL for now.  2018-09-07.
6593
6594 The documentation for the syntax and semantics of the regular expressions that
6595 are supported by PCRE2 is included in the PCRE2 distribution, and no further
6596 description is included here. The PCRE2 functions are called from Exim using
6597 the default option settings (that is, with no PCRE2 options set), except that
6598 the PCRE2_CASELESS option is set when the matching is required to be
6599 case-insensitive.
6600
6601 In most cases, when a regular expression is required in an Exim configuration,
6602 it has to start with a circumflex, in order to distinguish it from plain text
6603 or an &"ends with"& wildcard. In this example of a configuration setting, the
6604 second item in the colon-separated list is a regular expression.
6605 .code
6606 domains = a.b.c : ^\\d{3} : *.y.z : ...
6607 .endd
6608 The doubling of the backslash is required because of string expansion that
6609 precedes interpretation &-- see section &<<SECTlittext>>& for more discussion
6610 of this issue, and a way of avoiding the need for doubling backslashes. The
6611 regular expression that is eventually used in this example contains just one
6612 backslash. The circumflex is included in the regular expression, and has the
6613 normal effect of &"anchoring"& it to the start of the string that is being
6614 matched.
6615
6616 There are, however, two cases where a circumflex is not required for the
6617 recognition of a regular expression: these are the &%match%& condition in a
6618 string expansion, and the &%matches%& condition in an Exim filter file. In
6619 these cases, the relevant string is always treated as a regular expression; if
6620 it does not start with a circumflex, the expression is not anchored, and can
6621 match anywhere in the subject string.
6622
6623 In all cases, if you want a regular expression to match at the end of a string,
6624 you must code the $ metacharacter to indicate this. For example:
6625 .code
6626 domains = ^\\d{3}\\.example
6627 .endd
6628 matches the domain &'123.example'&, but it also matches &'123.example.com'&.
6629 You need to use:
6630 .code
6631 domains = ^\\d{3}\\.example\$
6632 .endd
6633 if you want &'example'& to be the top-level domain. The backslash before the
6634 $ is needed because string expansion also interprets dollar characters.
6635
6636
6637
6638 . ////////////////////////////////////////////////////////////////////////////
6639 . ////////////////////////////////////////////////////////////////////////////
6640
6641 .chapter "File and database lookups" "CHAPfdlookup"
6642 .scindex IIDfidalo1 "file" "lookups"
6643 .scindex IIDfidalo2 "database" "lookups"
6644 .cindex "lookup" "description of"
6645 Exim can be configured to look up data in files or databases as it processes
6646 messages. Two different kinds of syntax are used:
6647
6648 .olist
6649 A string that is to be expanded may contain explicit lookup requests. These
6650 cause parts of the string to be replaced by data that is obtained from the
6651 lookup. Lookups of this type are conditional expansion items. Different results
6652 can be defined for the cases of lookup success and failure. See chapter
6653 &<<CHAPexpand>>&, where string expansions are described in detail.
6654 The key for the lookup is &*specified*& as part of the string to be expanded.
6655 .next
6656 Lists of domains, hosts, and email addresses can contain lookup requests as a
6657 way of avoiding excessively long linear lists. In this case, the data that is
6658 returned by the lookup is often (but not always) discarded; whether the lookup
6659 succeeds or fails is what really counts. These kinds of list are described in
6660 chapter &<<CHAPdomhosaddlists>>&.
6661 Depending on the lookup type (see below)
6662 the key for the lookup may need to be &*specified*& as above
6663 or may be &*implicit*&,
6664 given by the context in which the list is being checked.
6665 .endlist
6666
6667 String expansions, lists, and lookups interact with each other in such a way
6668 that there is no order in which to describe any one of them that does not
6669 involve references to the others. Each of these three chapters makes more sense
6670 if you have read the other two first. If you are reading this for the first
6671 time, be aware that some of it will make a lot more sense after you have read
6672 chapters &<<CHAPdomhosaddlists>>& and &<<CHAPexpand>>&.
6673
6674 .section "Examples of different lookup syntax" "SECID60"
6675 It is easy to confuse the two different kinds of lookup, especially as the
6676 lists that may contain the second kind are always expanded before being
6677 processed as lists. Therefore, they may also contain lookups of the first kind.
6678 Be careful to distinguish between the following two examples:
6679 .code
6680 domains = ${lookup{$sender_host_address}lsearch{/some/file}}
6681 domains = lsearch;/some/file
6682 .endd
6683 .ilist
6684 The first uses a string expansion, the result of which must be a domain list.
6685 The key for an expansion-style lookup must be given explicitly.
6686 No strings have been specified for a successful or a failing lookup; the
6687 defaults in this case are the looked-up data and an empty string, respectively.
6688 The expansion takes place before the string is processed as a list, and the
6689 file that is searched could contain lines like this:
6690 .code
6691 192.168.3.4: domain1:domain2:...
6692 192.168.1.9: domain3:domain4:...
6693 .endd
6694 When the lookup succeeds, the result of the expansion is a list of domains (and
6695 possibly other types of item that are allowed in domain lists).
6696 .cindex "tainted data" "de-tainting"
6697 .cindex "de-tainting" "using a lookup expansion"
6698 The result of the expansion is not tainted.
6699
6700 .next
6701 In the second example, the lookup is a single item in a domain list. It causes
6702 Exim to use a lookup to see if the domain that is being processed can be found
6703 in the file.
6704 The file could contains lines like this:
6705 .code
6706 domain1:
6707 domain2:
6708 .endd
6709 Any data that follows the keys is not relevant when checking that the domain
6710 matches the list item.
6711
6712 The key for a list-style lookup is implicit, from the lookup context, if
6713 the lookup is a single-key type (see below).
6714 For query-style lookup types the query must be given explicitly.
6715 .endlist
6716
6717 It is possible, though no doubt confusing, to use both kinds of lookup at once.
6718 Consider a file containing lines like this:
6719 .code
6720 192.168.5.6: lsearch;/another/file
6721 .endd
6722 If the value of &$sender_host_address$& is 192.168.5.6, expansion of the
6723 first &%domains%& setting above generates the second setting, which therefore
6724 causes a second lookup to occur.
6725
6726 The lookup type may optionally be followed by a comma
6727 and a comma-separated list of options.
6728 Each option is a &"name=value"& pair.
6729 Whether an option is meaningful depends on the lookup type.
6730
6731 All lookups support the option &"cache=no_rd"&.
6732 If this is given then the cache that Exim manages for lookup results
6733 is not checked before doing the lookup.
6734 The result of the lookup is still written to the cache.
6735
6736 The rest of this chapter describes the different lookup types that are
6737 available. Any of them can be used in any part of the configuration where a
6738 lookup is permitted.
6739
6740
6741 .section "Lookup types" "SECID61"
6742 .cindex "lookup" "types of"
6743 .cindex "single-key lookup" "definition of"
6744 Two different types of data lookup are implemented:
6745
6746 .ilist
6747 The &'single-key'& type requires the specification of a file in which to look,
6748 and a single key to search for. The key must be a non-empty string for the
6749 lookup to succeed. The lookup type determines how the file is searched.
6750 .cindex "tainted data" "single-key lookups"
6751 The file string may not be tainted.
6752
6753 .cindex "tainted data" "de-tainting"
6754 .cindex "de-tainting" "using a single-key lookup"
6755 All single-key lookups support the option &"ret=key"&.
6756 If this is given and the lookup
6757 (either underlying implementation or cached value)
6758 returns data, the result is replaced with a non-tainted
6759 version of the lookup key.
6760
6761 .next
6762 .cindex "query-style lookup" "definition of"
6763 The &'query-style'& type accepts a generalized database query. No particular
6764 key value is assumed by Exim for query-style lookups. You can use whichever
6765 Exim variables you need to construct the database query.
6766
6767 For the string-expansion kind of lookups, the query is given in the first
6768 bracketed argument of the &${lookup ...}$& expansion.
6769 For the list-argument kind of lookup the query is given by the remainder of the
6770 list item after the first semicolon.
6771
6772 .cindex "tainted data" "quoting for lookups"
6773 If tainted data is used in the query then it should be quoted by
6774 using the &*${quote_*&<&'lookup-type'&>&*:*&<&'string'&>&*}*& expansion operator
6775 appropriate for the lookup.
6776 .endlist
6777
6778 The code for each lookup type is in a separate source file that is included in
6779 the binary of Exim only if the corresponding compile-time option is set. The
6780 default settings in &_src/EDITME_& are:
6781 .code
6782 LOOKUP_DBM=yes
6783 LOOKUP_LSEARCH=yes
6784 .endd
6785 which means that only linear searching and DBM lookups are included by default.
6786 For some types of lookup (e.g. SQL databases), you need to install appropriate
6787 libraries and header files before building Exim.
6788
6789
6790
6791
6792 .section "Single-key lookup types" "SECTsinglekeylookups"
6793 .cindex "lookup" "single-key types"
6794 .cindex "single-key lookup" "list of types"
6795 The following single-key lookup types are implemented:
6796
6797 .subsection cdb
6798 .cindex "cdb" "description of"
6799 .cindex "lookup" "cdb"
6800 .cindex "binary zero" "in lookup key"
6801 The given file is searched as a Constant DataBase file, using the key
6802 string without a terminating binary zero. The cdb format is designed for
6803 indexed files that are read frequently and never updated, except by total
6804 re-creation. As such, it is particularly suitable for large files containing
6805 aliases or other indexed data referenced by an MTA. Information about cdb and
6806 tools for building the files can be found in several places:
6807 .display
6808 &url(https://cr.yp.to/cdb.html)
6809 &url(https://www.corpit.ru/mjt/tinycdb.html)
6810 &url(https://packages.debian.org/stable/utils/freecdb)
6811 &url(https://github.com/philpennock/cdbtools) (in Go)
6812 .endd
6813 A cdb distribution is not needed in order to build Exim with cdb support,
6814 because the code for reading cdb files is included directly in Exim itself.
6815 However, no means of building or testing cdb files is provided with Exim, so
6816 you need to obtain a cdb distribution in order to do this.
6817
6818 .subsection dbm
6819 .cindex "DBM" "lookup type"
6820 .cindex "lookup" "dbm"
6821 .cindex "binary zero" "in lookup key"
6822 Calls to DBM library functions are used to extract data from the given
6823 DBM file by looking up the record with the given key. A terminating binary
6824 zero is included in the key that is passed to the DBM library. See section
6825 &<<SECTdb>>& for a discussion of DBM libraries.
6826
6827 .cindex "Berkeley DB library" "file format"
6828 For all versions of Berkeley DB, Exim uses the DB_HASH style of database
6829 when building DBM files using the &%exim_dbmbuild%& utility. However, when
6830 using Berkeley DB versions 3 or 4, it opens existing databases for reading with
6831 the DB_UNKNOWN option. This enables it to handle any of the types of database
6832 that the library supports, and can be useful for accessing DBM files created by
6833 other applications. (For earlier DB versions, DB_HASH is always used.)
6834
6835 .subsection dbmjz
6836 .cindex "lookup" "dbmjz"
6837 .cindex "lookup" "dbm &-- embedded NULs"
6838 .cindex "sasldb2"
6839 .cindex "dbmjz lookup type"
6840 This is the same as &(dbm)&, except that the lookup key is
6841 interpreted as an Exim list; the elements of the list are joined together with
6842 ASCII NUL characters to form the lookup key.  An example usage would be to
6843 authenticate incoming SMTP calls using the passwords from Cyrus SASL's
6844 &_/etc/sasldb2_& file with the &(gsasl)& authenticator or Exim's own
6845 &(cram_md5)& authenticator.
6846
6847 .subsection dbmnz
6848 .cindex "lookup" "dbmnz"
6849 .cindex "lookup" "dbm &-- terminating zero"
6850 .cindex "binary zero" "in lookup key"
6851 .cindex "Courier"
6852 .cindex "&_/etc/userdbshadow.dat_&"
6853 .cindex "dbmnz lookup type"
6854 This is the same as &(dbm)&, except that a terminating binary zero
6855 is not included in the key that is passed to the DBM library. You may need this
6856 if you want to look up data in files that are created by or shared with some
6857 other application that does not use terminating zeros. For example, you need to
6858 use &(dbmnz)& rather than &(dbm)& if you want to authenticate incoming SMTP
6859 calls using the passwords from Courier's &_/etc/userdbshadow.dat_& file. Exim's
6860 utility program for creating DBM files (&'exim_dbmbuild'&) includes the zeros
6861 by default, but has an option to omit them (see section &<<SECTdbmbuild>>&).
6862
6863 .subsection dsearch
6864 .cindex "lookup" "dsearch"
6865 .cindex "dsearch lookup type"
6866 The given file must be an absolute directory path; this is searched for an entry
6867 whose name is the key by calling the &[lstat()]& function.
6868 Unless the options (below) permit a path,
6869 the key may not contain any forward slash characters.
6870 If &[lstat()]& succeeds then so does the lookup.
6871 .cindex "tainted data" "dsearch result"
6872 The result is regarded as untainted.
6873
6874 Options for the lookup can be given by appending them after the word "dsearch",
6875 separated by a comma.  Options, if present, are a comma-separated list having
6876 each element starting with a tag name and an equals.
6877
6878 Three options are supported, for the return value and for filtering match
6879 candidates.
6880 The "ret" option requests an alternate result value of
6881 the entire path for the entry. Example:
6882 .code
6883 ${lookup {passwd} dsearch,ret=full {/etc}}
6884 .endd
6885 The default result is just the requested entry.
6886
6887 The "filter" option requests that only directory entries of a given type
6888 are matched. The match value is one of "file", "dir" or "subdir" (the latter
6889 not matching "." or ".."). Example:
6890 .code
6891 ${lookup {passwd} dsearch,filter=file {/etc}}
6892 .endd
6893 The default matching is for any entry type, including directories
6894 and symlinks.
6895
6896 The "key" option relaxes the restriction that only a simple path component can
6897 be searched for, to permit a sequence of path components. Example:
6898 .code
6899 ${lookup {foo/bar} dsearch,key=path {/etc}}
6900 .endd
6901 If this option is used, a ".." component in the key is specifically disallowed.
6902 The default operation is that the key may only be a single path component.
6903
6904 An example of how this
6905 lookup can be used to support virtual domains is given in section
6906 &<<SECTvirtualdomains>>&.
6907
6908 .subsection iplsearch
6909 .cindex "lookup" "iplsearch"
6910 .cindex "iplsearch lookup type"
6911 The given file is a text file containing keys and data. A key is
6912 terminated by a colon or white space or the end of the line. The keys in the
6913 file must be IP addresses, or IP addresses with CIDR masks. Keys that involve
6914 IPv6 addresses must be enclosed in quotes to prevent the first internal colon
6915 being interpreted as a key terminator. For example:
6916 .code
6917 1.2.3.4:           data for 1.2.3.4
6918 192.168.0.0/16:    data for 192.168.0.0/16
6919 "abcd::cdab":      data for abcd::cdab
6920 "abcd:abcd::/32"   data for abcd:abcd::/32
6921 .endd
6922 The key for an &(iplsearch)& lookup must be an IP address (without a mask). The
6923 file is searched linearly, using the CIDR masks where present, until a matching
6924 key is found. The first key that matches is used; there is no attempt to find a
6925 &"best"& match. Apart from the way the keys are matched, the processing for
6926 &(iplsearch)& is the same as for &(lsearch)&.
6927
6928 &*Warning 1*&: Unlike most other single-key lookup types, a file of data for
6929 &(iplsearch)& can &'not'& be turned into a DBM or cdb file, because those
6930 lookup types support only literal keys.
6931
6932 &*Warning 2*&: In a host list, you must always use &(net-iplsearch)& so that
6933 the implicit key is the host's IP address rather than its name
6934 (see section &<<SECThoslispatsikey>>&).
6935
6936 &*Warning 3*&: Do not use an IPv4-mapped IPv6 address for a key; use the
6937 IPv4, in dotted-quad form. (Exim converts IPv4-mapped IPv6 addresses to this
6938 notation before executing the lookup.)
6939
6940 One option is supported, "ret=full", to request the return of the entire line
6941 rather than omitting the key portion.
6942 Note however that the key portion will have been de-quoted.
6943
6944 .subsection json
6945 .cindex lookup json
6946 .cindex json "lookup type"
6947 .cindex JSON expansions
6948 The given file is a text file with a JSON structure.
6949 An element of the structure is extracted, defined by the search key.
6950 The key is a list of subelement selectors
6951 (colon-separated by default but changeable in the usual way)
6952 which are applied in turn to select smaller and smaller portions
6953 of the JSON structure.
6954 If a selector is numeric, it must apply to a JSON array; the (zero-based)
6955 nunbered array element is selected.
6956 Otherwise it must apply to a JSON object; the named element is selected.
6957 The final resulting element can be a simple JSON type or a JSON object
6958 or array; for the latter two a string-representation of the JSON
6959 is returned.
6960 For elements of type string, the returned value is de-quoted.
6961
6962
6963 .subsection lmdb
6964 .cindex LMDB
6965 .cindex lookup lmdb
6966 .cindex database lmdb
6967 The given file is an LMDB database.
6968 LMDB is a memory-mapped key-value store,
6969 with API modeled loosely on that of BerkeleyDB.
6970 See &url(https://symas.com/products/lightning-memory-mapped-database/)
6971 for the feature set and operation modes.
6972
6973 Exim provides read-only access via the LMDB C library.
6974 The library can be obtained from &url(https://github.com/LMDB/lmdb)
6975 or your operating system package repository.
6976 To enable LMDB support in Exim set LOOKUP_LMDB=yes in &_Local/Makefile_&.
6977
6978 You will need to separately create the LMDB database file,
6979 possibly using the &"mdb_load"& utility.
6980
6981
6982 .subsection lsearch
6983 .cindex "linear search"
6984 .cindex "lookup" "lsearch"
6985 .cindex "lsearch lookup type"
6986 .cindex "case sensitivity" "in lsearch lookup"
6987 The given file is a text file that is searched linearly for a
6988 line beginning with the search key, terminated by a colon or white space or the
6989 end of the line. The search is case-insensitive; that is, upper and lower case
6990 letters are treated as the same. The first occurrence of the key that is found
6991 in the file is used.
6992
6993 White space between the key and the colon is permitted. The remainder of the
6994 line, with leading and trailing white space removed, is the data. This can be
6995 continued onto subsequent lines by starting them with any amount of white
6996 space, but only a single space character is included in the data at such a
6997 junction. If the data begins with a colon, the key must be terminated by a
6998 colon, for example:
6999 .code
7000 baduser:  :fail:
7001 .endd
7002 Empty lines and lines beginning with # are ignored, even if they occur in the
7003 middle of an item. This is the traditional textual format of alias files. Note
7004 that the keys in an &(lsearch)& file are literal strings. There is no
7005 wildcarding of any kind.
7006
7007 .cindex "lookup" "lsearch &-- colons in keys"
7008 .cindex "white space" "in lsearch key"
7009 In most &(lsearch)& files, keys are not required to contain colons or #
7010 characters, or white space. However, if you need this feature, it is available.
7011 If a key begins with a doublequote character, it is terminated only by a
7012 matching quote (or end of line), and the normal escaping rules apply to its
7013 contents (see section &<<SECTstrings>>&). An optional colon is permitted after
7014 quoted keys (exactly as for unquoted keys). There is no special handling of
7015 quotes for the data part of an &(lsearch)& line.
7016
7017 .subsection nis
7018 .cindex "NIS lookup type"
7019 .cindex "lookup" "NIS"
7020 .cindex "binary zero" "in lookup key"
7021 The given file is the name of a NIS map, and a NIS lookup is done with
7022 the given key, without a terminating binary zero. There is a variant called
7023 &(nis0)& which does include the terminating binary zero in the key. This is
7024 reportedly needed for Sun-style alias files. Exim does not recognize NIS
7025 aliases; the full map names must be used.
7026
7027 .subsection (n)wildlsearch
7028 .cindex "wildlsearch lookup type"
7029 .cindex "lookup" "wildlsearch"
7030 .cindex "nwildlsearch lookup type"
7031 .cindex "lookup" "nwildlsearch"
7032 &(wildlsearch)& or &(nwildlsearch)&: These search a file linearly, like
7033 &(lsearch)&, but instead of being interpreted as a literal string, each key in
7034 the file may be wildcarded. The difference between these two lookup types is
7035 that for &(wildlsearch)&, each key in the file is string-expanded before being
7036 used, whereas for &(nwildlsearch)&, no expansion takes place.
7037
7038 .cindex "case sensitivity" "in (n)wildlsearch lookup"
7039 Like &(lsearch)&, the testing is done case-insensitively. However, keys in the
7040 file that are regular expressions can be made case-sensitive by the use of
7041 &`(-i)`& within the pattern. The following forms of wildcard are recognized:
7042
7043 .olist
7044 The string may begin with an asterisk to mean &"ends with"&. For example:
7045 .code
7046 *.a.b.c       data for anything.a.b.c
7047 *fish         data for anythingfish
7048 .endd
7049 .next
7050 The string may begin with a circumflex to indicate a regular expression. For
7051 example, for &(wildlsearch)&:
7052 .code
7053 ^\N\d+\.a\.b\N    data for <digits>.a.b
7054 .endd
7055 Note the use of &`\N`& to disable expansion of the contents of the regular
7056 expression. If you are using &(nwildlsearch)&, where the keys are not
7057 string-expanded, the equivalent entry is:
7058 .code
7059 ^\d+\.a\.b        data for <digits>.a.b
7060 .endd
7061 The case-insensitive flag is set at the start of compiling the regular
7062 expression, but it can be turned off by using &`(-i)`& at an appropriate point.
7063 For example, to make the entire pattern case-sensitive:
7064 .code
7065 ^(?-i)\d+\.a\.b        data for <digits>.a.b
7066 .endd
7067
7068 If the regular expression contains white space or colon characters, you must
7069 either quote it (see &(lsearch)& above), or represent these characters in other
7070 ways. For example, &`\s`& can be used for white space and &`\x3A`& for a
7071 colon. This may be easier than quoting, because if you quote, you have to
7072 escape all the backslashes inside the quotes.
7073
7074 &*Note*&: It is not possible to capture substrings in a regular expression
7075 match for later use, because the results of all lookups are cached. If a lookup
7076 is repeated, the result is taken from the cache, and no actual pattern matching
7077 takes place. The values of all the numeric variables are unset after a
7078 &((n)wildlsearch)& match.
7079
7080 .next
7081 Although I cannot see it being of much use, the general matching function that
7082 is used to implement &((n)wildlsearch)& means that the string may begin with a
7083 lookup name terminated by a semicolon, and followed by lookup data. For
7084 example:
7085 .code
7086 cdb;/some/file  data for keys that match the file
7087 .endd
7088 The data that is obtained from the nested lookup is discarded.
7089 .endlist olist
7090
7091 Keys that do not match any of these patterns are interpreted literally. The
7092 continuation rules for the data are the same as for &(lsearch)&, and keys may
7093 be followed by optional colons.
7094
7095 &*Warning*&: Unlike most other single-key lookup types, a file of data for
7096 &((n)wildlsearch)& can &'not'& be turned into a DBM or cdb file, because those
7097 lookup types support only literal keys.
7098
7099 .subsection spf
7100 .cindex "spf lookup type"
7101 .cindex "lookup" "spf"
7102 If Exim is built with SPF support, manual lookups can be done
7103 (as opposed to the standard ACL condition method).
7104 For details see section &<<SECSPF>>&.
7105
7106
7107 .section "Query-style lookup types" "SECTquerystylelookups"
7108 .cindex "lookup" "query-style types"
7109 .cindex "query-style lookup" "list of types"
7110 The supported query-style lookup types are listed below. Further details about
7111 many of them are given in later sections.
7112
7113 .subsection dnsdb
7114 .cindex "DNS" "as a lookup type"
7115 .cindex "lookup" "DNS"
7116 This does a DNS search for one or more records whose domain names
7117 are given in the supplied query. The resulting data is the contents of the
7118 records. See section &<<SECTdnsdb>>&.
7119
7120 .subsection ibase
7121 .cindex "InterBase lookup type"
7122 .cindex "lookup" "InterBase"
7123 This does a lookup in an InterBase database.
7124
7125 .subsection ldap
7126 .cindex "LDAP" "lookup type"
7127 .cindex "lookup" "LDAP"
7128 This does an LDAP lookup using a query in the form of a URL, and
7129 returns attributes from a single entry. There is a variant called &(ldapm)&
7130 that permits values from multiple entries to be returned. A third variant
7131 called &(ldapdn)& returns the Distinguished Name of a single entry instead of
7132 any attribute values. See section &<<SECTldap>>&.
7133
7134 .subsection mysql
7135 .cindex "MySQL" "lookup type"
7136 .cindex "lookup" "MySQL"
7137 The format of the query is an SQL statement that is passed to a
7138 MySQL database. See section &<<SECTsql>>&.
7139
7140 .subsection nisplus
7141 .cindex "NIS+ lookup type"
7142 .cindex "lookup" "NIS+"
7143 This does a NIS+ lookup using a query that can specify the name of
7144 the field to be returned. See section &<<SECTnisplus>>&.
7145
7146 .subsection oracle
7147 .cindex "Oracle" "lookup type"
7148 .cindex "lookup" "Oracle"
7149 The format of the query is an SQL statement that is passed to an
7150 Oracle database. See section &<<SECTsql>>&.
7151
7152 .subsection passwd
7153 .cindex "lookup" "passwd"
7154 .cindex "passwd lookup type"
7155 .cindex "&_/etc/passwd_&"
7156 This is a query-style lookup with queries that are just user names. The
7157 lookup calls &[getpwnam()]& to interrogate the system password data, and on
7158 success, the result string is the same as you would get from an &(lsearch)&
7159 lookup on a traditional &_/etc/passwd file_&, though with &`*`& for the
7160 password value. For example:
7161 .code
7162 *:42:42:King Rat:/home/kr:/bin/bash
7163 .endd
7164
7165 .subsection pgsql
7166 .cindex "PostgreSQL lookup type"
7167 .cindex "lookup" "PostgreSQL"
7168 The format of the query is an SQL statement that is passed to a
7169 PostgreSQL database. See section &<<SECTsql>>&.
7170
7171 .subsection redis
7172 .cindex "Redis lookup type"
7173 .cindex lookup Redis
7174 The format of the query is either a simple get or simple set,
7175 passed to a Redis database. See section &<<SECTsql>>&.
7176
7177 .subsection sqlite
7178 .cindex "sqlite lookup type"
7179 .cindex "lookup" "sqlite"
7180 The format of the query is
7181 an SQL statement that is passed to an SQLite database. See section &<<SECTsqlite>>&.
7182
7183 .subsection testdb
7184 This is a lookup type that is used for testing Exim. It is
7185 not likely to be useful in normal operation.
7186
7187 .subsection whoson
7188 .cindex "whoson lookup type"
7189 .cindex "lookup" "whoson"
7190 &'Whoson'& (&url(http://whoson.sourceforge.net)) is a protocol that
7191 allows a server to check whether a particular (dynamically allocated) IP
7192 address is currently allocated to a known (trusted) user and, optionally, to
7193 obtain the identity of the said user. For SMTP servers, &'Whoson'& was popular
7194 at one time for &"POP before SMTP"& authentication, but that approach has been
7195 superseded by SMTP authentication. In Exim, &'Whoson'& can be used to implement
7196 &"POP before SMTP"& checking using ACL statements such as
7197 .code
7198 require condition = \
7199   ${lookup whoson {$sender_host_address}{yes}{no}}
7200 .endd
7201 The query consists of a single IP address. The value returned is the name of
7202 the authenticated user, which is stored in the variable &$value$&. However, in
7203 this example, the data in &$value$& is not used; the result of the lookup is
7204 one of the fixed strings &"yes"& or &"no"&.
7205
7206
7207
7208 .section "Temporary errors in lookups" "SECID63"
7209 .cindex "lookup" "temporary error in"
7210 Lookup functions can return temporary error codes if the lookup cannot be
7211 completed. For example, an SQL or LDAP database might be unavailable. For this
7212 reason, it is not advisable to use a lookup that might do this for critical
7213 options such as a list of local domains.
7214
7215 When a lookup cannot be completed in a router or transport, delivery
7216 of the message (to the relevant address) is deferred, as for any other
7217 temporary error. In other circumstances Exim may assume the lookup has failed,
7218 or may give up altogether.
7219
7220
7221
7222 .section "Default values in single-key lookups" "SECTdefaultvaluelookups"
7223 .cindex "wildcard lookups"
7224 .cindex "lookup" "default values"
7225 .cindex "lookup" "wildcard"
7226 .cindex "lookup" "* added to type"
7227 .cindex "default" "in single-key lookups"
7228 In this context, a &"default value"& is a value specified by the administrator
7229 that is to be used if a lookup fails.
7230
7231 &*Note:*& This section applies only to single-key lookups. For query-style
7232 lookups, the facilities of the query language must be used. An attempt to
7233 specify a default for a query-style lookup provokes an error.
7234
7235 If &"*"& is added to a single-key lookup type (for example, &%lsearch*%&)
7236 and the initial lookup fails, the key &"*"& is looked up in the file to
7237 provide a default value. See also the section on partial matching below.
7238
7239 .cindex "*@ with single-key lookup"
7240 .cindex "lookup" "*@ added to type"
7241 .cindex "alias file" "per-domain default"
7242 Alternatively, if &"*@"& is added to a single-key lookup type (for example
7243 &%dbm*@%&) then, if the initial lookup fails and the key contains an @
7244 character, a second lookup is done with everything before the last @ replaced
7245 by *. This makes it possible to provide per-domain defaults in alias files
7246 that include the domains in the keys. If the second lookup fails (or doesn't
7247 take place because there is no @ in the key), &"*"& is looked up.
7248 For example, a &(redirect)& router might contain:
7249 .code
7250 data = ${lookup{$local_part@$domain}lsearch*@{/etc/mix-aliases}}
7251 .endd
7252 Suppose the address that is being processed is &'jane@eyre.example'&. Exim
7253 looks up these keys, in this order:
7254 .code
7255 jane@eyre.example
7256 *@eyre.example
7257 *
7258 .endd
7259 The data is taken from whichever key it finds first. &*Note*&: In an
7260 &(lsearch)& file, this does not mean the first of these keys in the file. A
7261 complete scan is done for each key, and only if it is not found at all does
7262 Exim move on to try the next key.
7263
7264
7265
7266 .section "Partial matching in single-key lookups" "SECTpartiallookup"
7267 .cindex "partial matching"
7268 .cindex "wildcard lookups"
7269 .cindex "lookup" "partial matching"
7270 .cindex "lookup" "wildcard"
7271 .cindex "asterisk" "in search type"
7272 The normal operation of a single-key lookup is to search the file for an exact
7273 match with the given key. However, in a number of situations where domains are
7274 being looked up, it is useful to be able to do partial matching. In this case,
7275 information in the file that has a key starting with &"*."& is matched by any
7276 domain that ends with the components that follow the full stop. For example, if
7277 a key in a DBM file is
7278 .code
7279 *.dates.fict.example
7280 .endd
7281 then when partial matching is enabled this is matched by (amongst others)
7282 &'2001.dates.fict.example'& and &'1984.dates.fict.example'&. It is also matched
7283 by &'dates.fict.example'&, if that does not appear as a separate key in the
7284 file.
7285
7286 &*Note*&: Partial matching is not available for query-style lookups. It is
7287 also not available for any lookup items in address lists (see section
7288 &<<SECTaddresslist>>&).
7289
7290 Partial matching is implemented by doing a series of separate lookups using
7291 keys constructed by modifying the original subject key. This means that it can
7292 be used with any of the single-key lookup types, provided that
7293 partial matching keys
7294 beginning with a special prefix (default &"*."&) are included in the data file.
7295 Keys in the file that do not begin with the prefix are matched only by
7296 unmodified subject keys when partial matching is in use.
7297
7298 Partial matching is requested by adding the string &"partial-"& to the front of
7299 the name of a single-key lookup type, for example, &%partial-dbm%&. When this
7300 is done, the subject key is first looked up unmodified; if that fails, &"*."&
7301 is added at the start of the subject key, and it is looked up again. If that
7302 fails, further lookups are tried with dot-separated components removed from the
7303 start of the subject key, one-by-one, and &"*."& added on the front of what
7304 remains.
7305
7306 A minimum number of two non-* components are required. This can be adjusted
7307 by including a number before the hyphen in the search type. For example,
7308 &%partial3-lsearch%& specifies a minimum of three non-* components in the
7309 modified keys. Omitting the number is equivalent to &"partial2-"&. If the
7310 subject key is &'2250.dates.fict.example'& then the following keys are looked
7311 up when the minimum number of non-* components is two:
7312 .code
7313 2250.dates.fict.example
7314 *.2250.dates.fict.example
7315 *.dates.fict.example
7316 *.fict.example
7317 .endd
7318 As soon as one key in the sequence is successfully looked up, the lookup
7319 finishes.
7320
7321 .cindex "lookup" "partial matching &-- changing prefix"
7322 .cindex "prefix" "for partial matching"
7323 The use of &"*."& as the partial matching prefix is a default that can be
7324 changed. The motivation for this feature is to allow Exim to operate with file
7325 formats that are used by other MTAs. A different prefix can be supplied in
7326 parentheses instead of the hyphen after &"partial"&. For example:
7327 .code
7328 domains = partial(.)lsearch;/some/file
7329 .endd
7330 In this example, if the domain is &'a.b.c'&, the sequence of lookups is
7331 &`a.b.c`&, &`.a.b.c`&, and &`.b.c`& (the default minimum of 2 non-wild
7332 components is unchanged). The prefix may consist of any punctuation characters
7333 other than a closing parenthesis. It may be empty, for example:
7334 .code
7335 domains = partial1()cdb;/some/file
7336 .endd
7337 For this example, if the domain is &'a.b.c'&, the sequence of lookups is
7338 &`a.b.c`&, &`b.c`&, and &`c`&.
7339
7340 If &"partial0"& is specified, what happens at the end (when the lookup with
7341 just one non-wild component has failed, and the original key is shortened right
7342 down to the null string) depends on the prefix:
7343
7344 .ilist
7345 If the prefix has zero length, the whole lookup fails.
7346 .next
7347 If the prefix has length 1, a lookup for just the prefix is done. For
7348 example, the final lookup for &"partial0(.)"& is for &`.`& alone.
7349 .next
7350 Otherwise, if the prefix ends in a dot, the dot is removed, and the
7351 remainder is looked up. With the default prefix, therefore, the final lookup is
7352 for &"*"& on its own.
7353 .next
7354 Otherwise, the whole prefix is looked up.
7355 .endlist
7356
7357
7358 If the search type ends in &"*"& or &"*@"& (see section
7359 &<<SECTdefaultvaluelookups>>& above), the search for an ultimate default that
7360 this implies happens after all partial lookups have failed. If &"partial0"& is
7361 specified, adding &"*"& to the search type has no effect with the default
7362 prefix, because the &"*"& key is already included in the sequence of partial
7363 lookups. However, there might be a use for lookup types such as
7364 &"partial0(.)lsearch*"&.
7365
7366 The use of &"*"& in lookup partial matching differs from its use as a wildcard
7367 in domain lists and the like. Partial matching works only in terms of
7368 dot-separated components; a key such as &`*fict.example`&
7369 in a database file is useless, because the asterisk in a partial matching
7370 subject key is always followed by a dot.
7371
7372 When the lookup is done from a string-expansion,
7373 the variables &$1$& and &$2$& contain the wild and non-wild parts of the key
7374 during the expansion of the replacement text.
7375 They return to their previous values at the end of the lookup item.
7376
7377
7378
7379
7380 .section "Lookup caching" "SECID64"
7381 .cindex "lookup" "caching"
7382 .cindex "caching" "lookup data"
7383 Exim caches all lookup results in order to avoid needless repetition of
7384 lookups. However, because (apart from the daemon) Exim operates as a collection
7385 of independent, short-lived processes, this caching applies only within a
7386 single Exim process. There is no inter-process lookup caching facility.
7387
7388 If an option &"cache=no_rd"& is used on the lookup then
7389 the cache is only written to, cached data is not used for the operation
7390 and a real lookup is done.
7391
7392 For single-key lookups, Exim keeps the relevant files open in case there is
7393 another lookup that needs them. In some types of configuration this can lead to
7394 many files being kept open for messages with many recipients. To avoid hitting
7395 the operating system limit on the number of simultaneously open files, Exim
7396 closes the least recently used file when it needs to open more files than its
7397 own internal limit, which can be changed via the &%lookup_open_max%& option.
7398
7399 The single-key lookup files are closed and the lookup caches are flushed at
7400 strategic points during delivery &-- for example, after all routing is
7401 complete.
7402
7403
7404
7405
7406 .section "Quoting lookup data" "SECID65"
7407 .cindex "lookup" "quoting"
7408 .cindex "quoting" "in lookups"
7409 When data from an incoming message is included in a query-style lookup, there
7410 is the possibility of special characters in the data messing up the syntax of
7411 the query. For example, a NIS+ query that contains
7412 .code
7413 [name=$local_part]
7414 .endd
7415 will be broken if the local part happens to contain a closing square bracket.
7416 For NIS+, data can be enclosed in double quotes like this:
7417 .code
7418 [name="$local_part"]
7419 .endd
7420 but this still leaves the problem of a double quote in the data. The rule for
7421 NIS+ is that double quotes must be doubled. Other lookup types have different
7422 rules, and to cope with the differing requirements, an expansion operator
7423 of the following form is provided:
7424 .code
7425 ${quote_<lookup-type>:<string>}
7426 .endd
7427 For example, the way to write the NIS+ query is
7428 .code
7429 [name="${quote_nisplus:$local_part}"]
7430 .endd
7431 .cindex "tainted data" "in lookups"
7432 &*All*& tainted data used in a query-style lookup must be quoted
7433 using a mechanism appropriate for the lookup type.
7434 See chapter &<<CHAPexpand>>& for full coverage of string expansions. The quote
7435 operator can be used for all lookup types, but has no effect for single-key
7436 lookups, since no quoting is ever needed in their key strings.
7437
7438
7439
7440
7441 .section "More about dnsdb" "SECTdnsdb"
7442 .cindex "dnsdb lookup"
7443 .cindex "lookup" "dnsdb"
7444 .cindex "DNS" "as a lookup type"
7445 The &(dnsdb)& lookup type uses the DNS as its database. A simple query consists
7446 of a record type and a domain name, separated by an equals sign. For example,
7447 an expansion string could contain:
7448 .code
7449 ${lookup dnsdb{mx=a.b.example}{$value}fail}
7450 .endd
7451 If the lookup succeeds, the result is placed in &$value$&, which in this case
7452 is used on its own as the result. If the lookup does not succeed, the
7453 &`fail`& keyword causes a &'forced expansion failure'& &-- see section
7454 &<<SECTforexpfai>>& for an explanation of what this means.
7455
7456 The supported DNS record types are A, CNAME, MX, NS, PTR, SOA, SPF, SRV, TLSA
7457 and TXT, and, when Exim is compiled with IPv6 support, AAAA.
7458 If no type is given, TXT is assumed.
7459
7460 For any record type, if multiple records are found, the data is returned as a
7461 concatenation, with newline as the default separator. The order, of course,
7462 depends on the DNS resolver. You can specify a different separator character
7463 between multiple records by putting a right angle-bracket followed immediately
7464 by the new separator at the start of the query. For example:
7465 .code
7466 ${lookup dnsdb{>: a=host1.example}}
7467 .endd
7468 It is permitted to specify a space as the separator character. Further
7469 white space is ignored.
7470 For lookup types that return multiple fields per record,
7471 an alternate field separator can be specified using a comma after the main
7472 separator character, followed immediately by the field separator.
7473
7474 .cindex "PTR record" "in &(dnsdb)& lookup"
7475 When the type is PTR,
7476 the data can be an IP address, written as normal; inversion and the addition of
7477 &%in-addr.arpa%& or &%ip6.arpa%& happens automatically. For example:
7478 .code
7479 ${lookup dnsdb{ptr=192.168.4.5}{$value}fail}
7480 .endd
7481 If the data for a PTR record is not a syntactically valid IP address, it is not
7482 altered and nothing is added.
7483
7484 .cindex "MX record" "in &(dnsdb)& lookup"
7485 .cindex "SRV record" "in &(dnsdb)& lookup"
7486 For an MX lookup, both the preference value and the host name are returned for
7487 each record, separated by a space. For an SRV lookup, the priority, weight,
7488 port, and host name are returned for each record, separated by spaces.
7489 The field separator can be modified as above.
7490
7491 .cindex "TXT record" "in &(dnsdb)& lookup"
7492 .cindex "SPF record" "in &(dnsdb)& lookup"
7493 For TXT records with multiple items of data, only the first item is returned,
7494 unless a field separator is specified.
7495 To concatenate items without a separator, use a semicolon instead.
7496 For SPF records the
7497 default behaviour is to concatenate multiple items without using a separator.
7498 .code
7499 ${lookup dnsdb{>\n,: txt=a.b.example}}
7500 ${lookup dnsdb{>\n; txt=a.b.example}}
7501 ${lookup dnsdb{spf=example.org}}
7502 .endd
7503 It is permitted to specify a space as the separator character. Further
7504 white space is ignored.
7505
7506 .cindex "SOA record" "in &(dnsdb)& lookup"
7507 For an SOA lookup, while no result is obtained the lookup is redone with
7508 successively more leading components dropped from the given domain.
7509 Only the primary-nameserver field is returned unless a field separator is
7510 specified.
7511 .code
7512 ${lookup dnsdb{>:,; soa=a.b.example.com}}
7513 .endd
7514
7515 .subsection "Dnsdb lookup modifiers" SECTdnsdb_mod
7516 .cindex "dnsdb modifiers"
7517 .cindex "modifiers" "dnsdb"
7518 .cindex "options" "dnsdb"
7519 Modifiers for &(dnsdb)& lookups are given by optional keywords,
7520 each followed by a comma,
7521 that may appear before the record type.
7522
7523 The &(dnsdb)& lookup fails only if all the DNS lookups fail. If there is a
7524 temporary DNS error for any of them, the behaviour is controlled by
7525 a defer-option modifier.
7526 The possible keywords are
7527 &"defer_strict"&, &"defer_never"&, and &"defer_lax"&.
7528 With &"strict"& behaviour, any temporary DNS error causes the
7529 whole lookup to defer. With &"never"& behaviour, a temporary DNS error is
7530 ignored, and the behaviour is as if the DNS lookup failed to find anything.
7531 With &"lax"& behaviour, all the queries are attempted, but a temporary DNS
7532 error causes the whole lookup to defer only if none of the other lookups
7533 succeed. The default is &"lax"&, so the following lookups are equivalent:
7534 .code
7535 ${lookup dnsdb{defer_lax,a=one.host.com:two.host.com}}
7536 ${lookup dnsdb{a=one.host.com:two.host.com}}
7537 .endd
7538 Thus, in the default case, as long as at least one of the DNS lookups
7539 yields some data, the lookup succeeds.
7540
7541 .cindex "DNSSEC" "dns lookup"
7542 Use of &(DNSSEC)& is controlled by a dnssec modifier.
7543 The possible keywords are
7544 &"dnssec_strict"&, &"dnssec_lax"&, and &"dnssec_never"&.
7545 With &"strict"& or &"lax"& DNSSEC information is requested
7546 with the lookup.
7547 With &"strict"& a response from the DNS resolver that
7548 is not labelled as authenticated data
7549 is treated as equivalent to a temporary DNS error.
7550 The default is &"lax"&.
7551
7552 See also the &$lookup_dnssec_authenticated$& variable.
7553
7554 .cindex timeout "dns lookup"
7555 .cindex "DNS" timeout
7556 Timeout for the dnsdb lookup can be controlled by a retrans modifier.
7557 The form is &"retrans_VAL"& where VAL is an Exim time specification
7558 (e.g. &"5s"&).
7559 The default value is set by the main configuration option &%dns_retrans%&.
7560
7561 Retries for the dnsdb lookup can be controlled by a retry modifier.
7562 The form if &"retry_VAL"& where VAL is an integer.
7563 The default count is set by the main configuration option &%dns_retry%&.
7564
7565 .cindex caching "of dns lookup"
7566 .cindex TTL "of dns lookup"
7567 .cindex DNS TTL
7568 Dnsdb lookup results are cached within a single process (and its children).
7569 The cache entry lifetime is limited to the smallest time-to-live (TTL)
7570 value of the set of returned DNS records.
7571
7572
7573 .subsection "Pseudo dnsdb record types" SECID66
7574 .cindex "MX record" "in &(dnsdb)& lookup"
7575 By default, both the preference value and the host name are returned for
7576 each MX record, separated by a space. If you want only host names, you can use
7577 the pseudo-type MXH:
7578 .code
7579 ${lookup dnsdb{mxh=a.b.example}}
7580 .endd
7581 In this case, the preference values are omitted, and just the host names are
7582 returned.
7583
7584 .cindex "name server for enclosing domain"
7585 Another pseudo-type is ZNS (for &"zone NS"&). It performs a lookup for NS
7586 records on the given domain, but if none are found, it removes the first
7587 component of the domain name, and tries again. This process continues until NS
7588 records are found or there are no more components left (or there is a DNS
7589 error). In other words, it may return the name servers for a top-level domain,
7590 but it never returns the root name servers. If there are no NS records for the
7591 top-level domain, the lookup fails. Consider these examples:
7592 .code
7593 ${lookup dnsdb{zns=xxx.quercite.com}}
7594 ${lookup dnsdb{zns=xxx.edu}}
7595 .endd
7596 Assuming that in each case there are no NS records for the full domain name,
7597 the first returns the name servers for &%quercite.com%&, and the second returns
7598 the name servers for &%edu%&.
7599
7600 You should be careful about how you use this lookup because, unless the
7601 top-level domain does not exist, the lookup always returns some host names. The
7602 sort of use to which this might be put is for seeing if the name servers for a
7603 given domain are on a blacklist. You can probably assume that the name servers
7604 for the high-level domains such as &%com%& or &%co.uk%& are not going to be on
7605 such a list.
7606
7607 .cindex "CSA" "in &(dnsdb)& lookup"
7608 A third pseudo-type is CSA (Client SMTP Authorization). This looks up SRV
7609 records according to the CSA rules, which are described in section
7610 &<<SECTverifyCSA>>&. Although &(dnsdb)& supports SRV lookups directly, this is
7611 not sufficient because of the extra parent domain search behaviour of CSA. The
7612 result of a successful lookup such as:
7613 .code
7614 ${lookup dnsdb {csa=$sender_helo_name}}
7615 .endd
7616 has two space-separated fields: an authorization code and a target host name.
7617 The authorization code can be &"Y"& for yes, &"N"& for no, &"X"& for explicit
7618 authorization required but absent, or &"?"& for unknown.
7619
7620 .cindex "A+" "in &(dnsdb)& lookup"
7621 The pseudo-type A+ performs an AAAA
7622 and then an A lookup.  All results are returned; defer processing
7623 (see below) is handled separately for each lookup.  Example:
7624 .code
7625 ${lookup dnsdb {>; a+=$sender_helo_name}}
7626 .endd
7627
7628
7629 .subsection "Multiple dnsdb lookups" SECID67
7630 In the previous sections, &(dnsdb)& lookups for a single domain are described.
7631 However, you can specify a list of domains or IP addresses in a single
7632 &(dnsdb)& lookup. The list is specified in the normal Exim way, with colon as
7633 the default separator, but with the ability to change this. For example:
7634 .code
7635 ${lookup dnsdb{one.domain.com:two.domain.com}}
7636 ${lookup dnsdb{a=one.host.com:two.host.com}}
7637 ${lookup dnsdb{ptr = <; 1.2.3.4 ; 4.5.6.8}}
7638 .endd
7639 In order to retain backwards compatibility, there is one special case: if
7640 the lookup type is PTR and no change of separator is specified, Exim looks
7641 to see if the rest of the string is precisely one IPv6 address. In this
7642 case, it does not treat it as a list.
7643
7644 The data from each lookup is concatenated, with newline separators by default,
7645 in the same way that multiple DNS records for a single item are handled. A
7646 different separator can be specified, as described above.
7647
7648
7649
7650
7651 .section "More about LDAP" "SECTldap"
7652 .cindex "LDAP" "lookup, more about"
7653 .cindex "lookup" "LDAP"
7654 .cindex "Solaris" "LDAP"
7655 The original LDAP implementation came from the University of Michigan; this has
7656 become &"Open LDAP"&, and there are now two different releases. Another
7657 implementation comes from Netscape, and Solaris 7 and subsequent releases
7658 contain inbuilt LDAP support. Unfortunately, though these are all compatible at
7659 the lookup function level, their error handling is different. For this reason
7660 it is necessary to set a compile-time variable when building Exim with LDAP, to
7661 indicate which LDAP library is in use. One of the following should appear in
7662 your &_Local/Makefile_&:
7663 .code
7664 LDAP_LIB_TYPE=UMICHIGAN
7665 LDAP_LIB_TYPE=OPENLDAP1
7666 LDAP_LIB_TYPE=OPENLDAP2
7667 LDAP_LIB_TYPE=NETSCAPE
7668 LDAP_LIB_TYPE=SOLARIS
7669 .endd
7670 If LDAP_LIB_TYPE is not set, Exim assumes &`OPENLDAP1`&, which has the
7671 same interface as the University of Michigan version.
7672
7673 There are three LDAP lookup types in Exim. These behave slightly differently in
7674 the way they handle the results of a query:
7675
7676 .ilist
7677 &(ldap)& requires the result to contain just one entry; if there are more, it
7678 gives an error.
7679 .next
7680 &(ldapdn)& also requires the result to contain just one entry, but it is the
7681 Distinguished Name that is returned rather than any attribute values.
7682 .next
7683 &(ldapm)& permits the result to contain more than one entry; the attributes
7684 from all of them are returned.
7685 .endlist
7686
7687
7688 For &(ldap)& and &(ldapm)&, if a query finds only entries with no attributes,
7689 Exim behaves as if the entry did not exist, and the lookup fails. The format of
7690 the data returned by a successful lookup is described in the next section.
7691 First we explain how LDAP queries are coded.
7692
7693
7694 .subsection "Format of LDAP queries" SECTforldaque
7695 .cindex "LDAP" "query format"
7696 An LDAP query takes the form of a URL as defined in RFC 2255. For example, in
7697 the configuration of a &(redirect)& router one might have this setting:
7698 .code
7699 data = ${lookup ldap \
7700   {ldap:///cn=$local_part,o=University%20of%20Cambridge,\
7701   c=UK?mailbox?base?}}
7702 .endd
7703 .cindex "LDAP" "with TLS"
7704 The URL may begin with &`ldap`& or &`ldaps`& if your LDAP library supports
7705 secure (encrypted) LDAP connections. The second of these ensures that an
7706 encrypted TLS connection is used.
7707
7708 With sufficiently modern LDAP libraries, Exim supports forcing TLS over regular
7709 LDAP connections, rather than the SSL-on-connect &`ldaps`&.
7710 See the &%ldap_start_tls%& option.
7711
7712 Starting with Exim 4.83, the initialization of LDAP with TLS is more tightly
7713 controlled. Every part of the TLS configuration can be configured by settings in
7714 &_exim.conf_&. Depending on the version of the client libraries installed on
7715 your system, some of the initialization may have required setting options in
7716 &_/etc/ldap.conf_& or &_~/.ldaprc_& to get TLS working with self-signed
7717 certificates. This revealed a nuance where the current UID that exim was
7718 running as could affect which config files it read. With Exim 4.83, these
7719 methods become optional, only taking effect if not specifically set in
7720 &_exim.conf_&.
7721
7722
7723 .subsection "LDAP quoting" SECID68
7724 .cindex "LDAP" "quoting"
7725 Two levels of quoting are required in LDAP queries, the first for LDAP itself
7726 and the second because the LDAP query is represented as a URL. Furthermore,
7727 within an LDAP query, two different kinds of quoting are required. For this
7728 reason, there are two different LDAP-specific quoting operators.
7729
7730 The &%quote_ldap%& operator is designed for use on strings that are part of
7731 filter specifications. Conceptually, it first does the following conversions on
7732 the string:
7733 .code
7734 *   =>   \2A
7735 (   =>   \28
7736 )   =>   \29
7737 \   =>   \5C
7738 .endd
7739 in accordance with RFC 2254. The resulting string is then quoted according
7740 to the rules for URLs, that is, all non-alphanumeric characters except
7741 .code
7742 ! $ ' - . _ ( ) * +
7743 .endd
7744 are converted to their hex values, preceded by a percent sign. For example:
7745 .code
7746 ${quote_ldap: a(bc)*, a<yz>; }
7747 .endd
7748 yields
7749 .code
7750 %20a%5C28bc%5C29%5C2A%2C%20a%3Cyz%3E%3B%20
7751 .endd
7752 Removing the URL quoting, this is (with a leading and a trailing space):
7753 .code
7754 a\28bc\29\2A, a<yz>;
7755 .endd
7756 The &%quote_ldap_dn%& operator is designed for use on strings that are part of
7757 base DN specifications in queries. Conceptually, it first converts the string
7758 by inserting a backslash in front of any of the following characters:
7759 .code
7760 , + " \ < > ;
7761 .endd
7762 It also inserts a backslash before any leading spaces or # characters, and
7763 before any trailing spaces. (These rules are in RFC 2253.) The resulting string
7764 is then quoted according to the rules for URLs. For example:
7765 .code
7766 ${quote_ldap_dn: a(bc)*, a<yz>; }
7767 .endd
7768 yields
7769 .code
7770 %5C%20a(bc)*%5C%2C%20a%5C%3Cyz%5C%3E%5C%3B%5C%20
7771 .endd
7772 Removing the URL quoting, this is (with a trailing space):
7773 .code
7774 \ a(bc)*\, a\<yz\>\;\
7775 .endd
7776 There are some further comments about quoting in the section on LDAP
7777 authentication below.
7778
7779
7780 .subsection "LDAP connections" SECID69
7781 .cindex "LDAP" "connections"
7782 The connection to an LDAP server may either be over TCP/IP, or, when OpenLDAP
7783 is in use, via a Unix domain socket. The example given above does not specify
7784 an LDAP server. A server that is reached by TCP/IP can be specified in a query
7785 by starting it with
7786 .code
7787 ldap://<hostname>:<port>/...
7788 .endd
7789 If the port (and preceding colon) are omitted, the standard LDAP port (389) is
7790 used. When no server is specified in a query, a list of default servers is
7791 taken from the &%ldap_default_servers%& configuration option. This supplies a
7792 colon-separated list of servers which are tried in turn until one successfully
7793 handles a query, or there is a serious error. Successful handling either
7794 returns the requested data, or indicates that it does not exist. Serious errors
7795 are syntactical, or multiple values when only a single value is expected.
7796 Errors which cause the next server to be tried are connection failures, bind
7797 failures, and timeouts.
7798
7799 For each server name in the list, a port number can be given. The standard way
7800 of specifying a host and port is to use a colon separator (RFC 1738). Because
7801 &%ldap_default_servers%& is a colon-separated list, such colons have to be
7802 doubled. For example
7803 .code
7804 ldap_default_servers = ldap1.example.com::145:ldap2.example.com
7805 .endd
7806 If &%ldap_default_servers%& is unset, a URL with no server name is passed
7807 to the LDAP library with no server name, and the library's default (normally
7808 the local host) is used.
7809
7810 If you are using the OpenLDAP library, you can connect to an LDAP server using
7811 a Unix domain socket instead of a TCP/IP connection. This is specified by using
7812 &`ldapi`& instead of &`ldap`& in LDAP queries. What follows here applies only
7813 to OpenLDAP. If Exim is compiled with a different LDAP library, this feature is
7814 not available.
7815
7816 For this type of connection, instead of a host name for the server, a pathname
7817 for the socket is required, and the port number is not relevant. The pathname
7818 can be specified either as an item in &%ldap_default_servers%&, or inline in
7819 the query. In the former case, you can have settings such as
7820 .code
7821 ldap_default_servers = /tmp/ldap.sock : backup.ldap.your.domain
7822 .endd
7823 When the pathname is given in the query, you have to escape the slashes as
7824 &`%2F`& to fit in with the LDAP URL syntax. For example:
7825 .code
7826 ${lookup ldap {ldapi://%2Ftmp%2Fldap.sock/o=...
7827 .endd
7828 When Exim processes an LDAP lookup and finds that the &"hostname"& is really
7829 a pathname, it uses the Unix domain socket code, even if the query actually
7830 specifies &`ldap`& or &`ldaps`&. In particular, no encryption is used for a
7831 socket connection. This behaviour means that you can use a setting of
7832 &%ldap_default_servers%& such as in the example above with traditional &`ldap`&
7833 or &`ldaps`& queries, and it will work. First, Exim tries a connection via
7834 the Unix domain socket; if that fails, it tries a TCP/IP connection to the
7835 backup host.
7836
7837 If an explicit &`ldapi`& type is given in a query when a host name is
7838 specified, an error is diagnosed. However, if there are more items in
7839 &%ldap_default_servers%&, they are tried. In other words:
7840
7841 .ilist
7842 Using a pathname with &`ldap`& or &`ldaps`& forces the use of the Unix domain
7843 interface.
7844 .next
7845 Using &`ldapi`& with a host name causes an error.
7846 .endlist
7847
7848
7849 Using &`ldapi`& with no host or path in the query, and no setting of
7850 &%ldap_default_servers%&, does whatever the library does by default.
7851
7852
7853
7854 .subsection "LDAP authentication and control information" SECID70
7855 .cindex "LDAP" "authentication"
7856 The LDAP URL syntax provides no way of passing authentication and other control
7857 information to the server. To make this possible, the URL in an LDAP query may
7858 be preceded by any number of <&'name'&>=<&'value'&> settings, separated by
7859 spaces. If a value contains spaces it must be enclosed in double quotes, and
7860 when double quotes are used, backslash is interpreted in the usual way inside
7861 them. The following names are recognized:
7862 .itable none 0 0 2 20* left 80* left
7863 .irow DEREFERENCE "set the dereferencing parameter"
7864 .irow NETTIME     "set a timeout for a network operation"
7865 .irow USER        "set the DN, for authenticating the LDAP bind"
7866 .irow PASS        "set the password, likewise"
7867 .irow REFERRALS   "set the referrals parameter"
7868 .irow SERVERS     "set alternate server list for this query only"
7869 .irow SIZE        "set the limit for the number of entries returned"
7870 .irow TIME        "set the maximum waiting time for a query"
7871 .endtable
7872 The value of the DEREFERENCE parameter must be one of the words &"never"&,
7873 &"searching"&, &"finding"&, or &"always"&. The value of the REFERRALS parameter
7874 must be &"follow"& (the default) or &"nofollow"&. The latter stops the LDAP
7875 library from trying to follow referrals issued by the LDAP server.
7876
7877 .cindex LDAP timeout
7878 .cindex timeout "LDAP lookup"
7879 The name CONNECT is an obsolete name for NETTIME, retained for
7880 backwards compatibility. This timeout (specified as a number of seconds) is
7881 enforced from the client end for operations that can be carried out over a
7882 network. Specifically, it applies to network connections and calls to the
7883 &'ldap_result()'& function. If the value is greater than zero, it is used if
7884 LDAP_OPT_NETWORK_TIMEOUT is defined in the LDAP headers (OpenLDAP), or
7885 if LDAP_X_OPT_CONNECT_TIMEOUT is defined in the LDAP headers (Netscape
7886 SDK 4.1). A value of zero forces an explicit setting of &"no timeout"& for
7887 Netscape SDK; for OpenLDAP no action is taken.
7888
7889 The TIME parameter (also a number of seconds) is passed to the server to
7890 set a server-side limit on the time taken to complete a search.
7891
7892 The SERVERS parameter allows you to specify an alternate list of ldap servers
7893 to use for an individual lookup.  The global &%ldap_default_servers%& option provides a
7894 default list of ldap servers, and a single lookup can specify a single ldap
7895 server to use.  But when you need to do a lookup with a list of servers that is
7896 different than the default list (maybe different order, maybe a completely
7897 different set of servers), the SERVERS parameter allows you to specify this
7898 alternate list (colon-separated).
7899
7900 Here is an example of an LDAP query in an Exim lookup that uses some of these
7901 values. This is a single line, folded to fit on the page:
7902 .code
7903 ${lookup ldap
7904   {user="cn=manager,o=University of Cambridge,c=UK" pass=secret
7905   ldap:///o=University%20of%20Cambridge,c=UK?sn?sub?(cn=foo)}
7906   {$value}fail}
7907 .endd
7908 The encoding of spaces as &`%20`& is a URL thing which should not be done for
7909 any of the auxiliary data. Exim configuration settings that include lookups
7910 which contain password information should be preceded by &"hide"& to prevent
7911 non-admin users from using the &%-bP%& option to see their values.
7912
7913 The auxiliary data items may be given in any order. The default is no
7914 connection timeout (the system timeout is used), no user or password, no limit
7915 on the number of entries returned, and no time limit on queries.
7916
7917 When a DN is quoted in the USER= setting for LDAP authentication, Exim
7918 removes any URL quoting that it may contain before passing it to the LDAP library.
7919 Apparently
7920 some libraries do this for themselves, but some do not. Removing the URL
7921 quoting has two advantages:
7922
7923 .ilist
7924 It makes it possible to use the same &%quote_ldap_dn%& expansion for USER=
7925 DNs as with DNs inside actual queries.
7926 .next
7927 It permits spaces inside USER= DNs.
7928 .endlist
7929
7930 For example, a setting such as
7931 .code
7932 USER=cn=${quote_ldap_dn:$1}
7933 .endd
7934 should work even if &$1$& contains spaces.
7935
7936 Expanded data for the PASS= value should be quoted using the &%quote%&
7937 expansion operator, rather than the LDAP quote operators. The only reason this
7938 field needs quoting is to ensure that it conforms to the Exim syntax, which
7939 does not allow unquoted spaces. For example:
7940 .code
7941 PASS=${quote:$3}
7942 .endd
7943 The LDAP authentication mechanism can be used to check passwords as part of
7944 SMTP authentication. See the &%ldapauth%& expansion string condition in chapter
7945 &<<CHAPexpand>>&.
7946
7947
7948
7949 .subsection "Format of data returned by LDAP" SECID71
7950 .cindex "LDAP" "returned data formats"
7951 The &(ldapdn)& lookup type returns the Distinguished Name from a single entry
7952 as a sequence of values, for example
7953 .code
7954 cn=manager,o=University of Cambridge,c=UK
7955 .endd
7956 The &(ldap)& lookup type generates an error if more than one entry matches the
7957 search filter, whereas &(ldapm)& permits this case, and inserts a newline in
7958 the result between the data from different entries. It is possible for multiple
7959 values to be returned for both &(ldap)& and &(ldapm)&, but in the former case
7960 you know that whatever values are returned all came from a single entry in the
7961 directory.
7962
7963 In the common case where you specify a single attribute in your LDAP query, the
7964 result is not quoted, and does not contain the attribute name. If the attribute
7965 has multiple values, they are separated by commas. Any comma that is
7966 part of an attribute's value is doubled.
7967
7968 If you specify multiple attributes, the result contains space-separated, quoted
7969 strings, each preceded by the attribute name and an equals sign. Within the
7970 quotes, the quote character, backslash, and newline are escaped with
7971 backslashes, and commas are used to separate multiple values for the attribute.
7972 Any commas in attribute values are doubled
7973 (permitting treatment of the values as a comma-separated list).
7974 Apart from the escaping, the string within quotes takes the same form as the
7975 output when a single attribute is requested. Specifying no attributes is the
7976 same as specifying all of an entry's attributes.
7977
7978 Here are some examples of the output format. The first line of each pair is an
7979 LDAP query, and the second is the data that is returned. The attribute called
7980 &%attr1%& has two values, one of them with an embedded comma, whereas
7981 &%attr2%& has only one value. Both attributes are derived from &%attr%&
7982 (they have SUP &%attr%& in their schema definitions).
7983
7984 .code
7985 ldap:///o=base?attr1?sub?(uid=fred)
7986 value1.1,value1,,2
7987
7988 ldap:///o=base?attr2?sub?(uid=fred)
7989 value two
7990
7991 ldap:///o=base?attr?sub?(uid=fred)
7992 value1.1,value1,,2,value two
7993
7994 ldap:///o=base?attr1,attr2?sub?(uid=fred)
7995 attr1="value1.1,value1,,2" attr2="value two"
7996
7997 ldap:///o=base??sub?(uid=fred)
7998 objectClass="top" attr1="value1.1,value1,,2" attr2="value two"
7999 .endd
8000 You can
8001 make use of Exim's &%-be%& option to run expansion tests and thereby check the
8002 results of LDAP lookups.
8003 The &%extract%& operator in string expansions can be used to pick out
8004 individual fields from data that consists of &'key'&=&'value'& pairs.
8005 The &%listextract%& operator should be used to pick out individual values
8006 of attributes, even when only a single value is expected.
8007 The doubling of embedded commas allows you to use the returned data as a
8008 comma separated list (using the "<," syntax for changing the input list separator).
8009
8010
8011
8012
8013 .section "More about NIS+" "SECTnisplus"
8014 .cindex "NIS+ lookup type"
8015 .cindex "lookup" "NIS+"
8016 NIS+ queries consist of a NIS+ &'indexed name'& followed by an optional colon
8017 and field name. If this is given, the result of a successful query is the
8018 contents of the named field; otherwise the result consists of a concatenation
8019 of &'field-name=field-value'& pairs, separated by spaces. Empty values and
8020 values containing spaces are quoted. For example, the query
8021 .code
8022 [name=mg1456],passwd.org_dir
8023 .endd
8024 might return the string
8025 .code
8026 name=mg1456 passwd="" uid=999 gid=999 gcos="Martin Guerre"
8027 home=/home/mg1456 shell=/bin/bash shadow=""
8028 .endd
8029 (split over two lines here to fit on the page), whereas
8030 .code
8031 [name=mg1456],passwd.org_dir:gcos
8032 .endd
8033 would just return
8034 .code
8035 Martin Guerre
8036 .endd
8037 with no quotes. A NIS+ lookup fails if NIS+ returns more than one table entry
8038 for the given indexed key. The effect of the &%quote_nisplus%& expansion
8039 operator is to double any quote characters within the text.
8040
8041
8042
8043 .section "SQL lookups" "SECTsql"
8044 .cindex "SQL lookup types"
8045 .cindex "MySQL" "lookup type"
8046 .cindex "PostgreSQL lookup type"
8047 .cindex "lookup" "MySQL"
8048 .cindex "lookup" "PostgreSQL"
8049 .cindex "Oracle" "lookup type"
8050 .cindex "lookup" "Oracle"
8051 .cindex "InterBase lookup type"
8052 .cindex "lookup" "InterBase"
8053 .cindex "Redis lookup type"
8054 .cindex lookup Redis
8055 Exim can support lookups in InterBase, MySQL, Oracle, PostgreSQL, Redis,
8056 and SQLite
8057 databases. Queries for these databases contain SQL statements, so an example
8058 might be
8059 .code
8060 ${lookup mysql{select mailbox from users where id='userx'}\
8061   {$value}fail}
8062 .endd
8063 If the result of the query contains more than one field, the data for each
8064 field in the row is returned, preceded by its name, so the result of
8065 .code
8066 ${lookup pgsql{select home,name from users where id='userx'}\
8067   {$value}}
8068 .endd
8069 might be
8070 .code
8071 home=/home/userx name="Mister X"
8072 .endd
8073 Empty values and values containing spaces are double quoted, with embedded
8074 quotes escaped by a backslash. If the result of the query contains just one
8075 field, the value is passed back verbatim, without a field name, for example:
8076 .code
8077 Mister X
8078 .endd
8079 If the result of the query yields more than one row, it is all concatenated,
8080 with a newline between the data for each row.
8081
8082
8083 .subsection "More about MySQL, PostgreSQL, Oracle, InterBase, and Redis" SECID72
8084 .cindex "MySQL" "lookup type"
8085 .cindex "PostgreSQL lookup type"
8086 .cindex "lookup" "MySQL"
8087 .cindex "lookup" "PostgreSQL"
8088 .cindex "Oracle" "lookup type"
8089 .cindex "lookup" "Oracle"
8090 .cindex "InterBase lookup type"
8091 .cindex "lookup" "InterBase"
8092 .cindex "Redis lookup type"
8093 .cindex lookup Redis
8094 If any MySQL, PostgreSQL, Oracle, InterBase or Redis lookups are used, the
8095 &%mysql_servers%&, &%pgsql_servers%&, &%oracle_servers%&, &%ibase_servers%&,
8096 or &%redis_servers%&
8097 option (as appropriate) must be set to a colon-separated list of server
8098 information.
8099 .oindex &%mysql_servers%&
8100 .oindex &%pgsql_servers%&
8101 .oindex &%oracle_servers%&
8102 .oindex &%ibase_servers%&
8103 .oindex &%redis_servers%&
8104 (For MySQL and PostgreSQL, the global option need not be set if all
8105 queries contain their own server information &-- see section
8106 &<<SECTspeserque>>&.)
8107 For all but Redis
8108 each item in the list is a slash-separated list of four
8109 items: host name, database name, user name, and password. In the case of
8110 Oracle, the host name field is used for the &"service name"&, and the database
8111 name field is not used and should be empty. For example:
8112 .code
8113 hide oracle_servers = oracle.plc.example//userx/abcdwxyz
8114 .endd
8115 Because password data is sensitive, you should always precede the setting with
8116 &"hide"&, to prevent non-admin users from obtaining the setting via the &%-bP%&
8117 option. Here is an example where two MySQL servers are listed:
8118 .code
8119 hide mysql_servers = localhost/users/root/secret:\
8120                      otherhost/users/root/othersecret
8121 .endd
8122 For MySQL and PostgreSQL, a host may be specified as <&'name'&>:<&'port'&> but
8123 because this is a colon-separated list, the colon has to be doubled. For each
8124 query, these parameter groups are tried in order until a connection is made and
8125 a query is successfully processed. The result of a query may be that no data is
8126 found, but that is still a successful query. In other words, the list of
8127 servers provides a backup facility, not a list of different places to look.
8128
8129 For Redis the global option need not be specified if all queries contain their
8130 own server information &-- see section &<<SECTspeserque>>&.
8131 If specified, the option must be set to a colon-separated list of server
8132 information.
8133 Each item in the list is a slash-separated list of three items:
8134 host, database number, and password.
8135 .olist
8136 The host is required and may be either an IPv4 address and optional
8137 port number (separated by a colon, which needs doubling due to the
8138 higher-level list), or a Unix socket pathname enclosed in parentheses
8139 .next
8140 The database number is optional; if present that number is selected in the backend
8141 .next
8142 The password is optional; if present it is used to authenticate to the backend
8143 .endlist
8144
8145 The &%quote_mysql%&, &%quote_pgsql%&, and &%quote_oracle%& expansion operators
8146 convert newline, tab, carriage return, and backspace to \n, \t, \r, and \b
8147 respectively, and the characters single-quote, double-quote, and backslash
8148 itself are escaped with backslashes.
8149
8150 The &%quote_redis%& expansion operator
8151 escapes whitespace and backslash characters with a backslash.
8152
8153 .subsection "Specifying the server in the query" SECTspeserque
8154 For MySQL, PostgreSQL and Redis lookups (but not currently for Oracle and InterBase),
8155 it is possible to specify a list of servers with an individual query. This is
8156 done by appending a comma-separated option to the query type:
8157 .display
8158 &`,servers=`&&'server1:server2:server3:...'&
8159 .endd
8160 Each item in the list may take one of two forms:
8161 .olist
8162 If it contains no slashes it is assumed to be just a host name. The appropriate
8163 global option (&%mysql_servers%& or &%pgsql_servers%&) is searched for a host
8164 of the same name, and the remaining parameters (database, user, password) are
8165 taken from there.
8166 .next
8167 If it contains any slashes, it is taken as a complete parameter set.
8168 .endlist
8169 The list of servers is used in exactly the same way as the global list.
8170 Once a connection to a server has happened and a query has been
8171 successfully executed, processing of the lookup ceases.
8172
8173 This feature is intended for use in master/slave situations where updates
8174 are occurring and you want to update the master rather than a slave. If the
8175 master is in the list as a backup for reading, you might have a global setting
8176 like this:
8177 .code
8178 mysql_servers = slave1/db/name/pw:\
8179                 slave2/db/name/pw:\
8180                 master/db/name/pw
8181 .endd
8182 In an updating lookup, you could then write:
8183 .code
8184 ${lookup mysql,servers=master {UPDATE ...} }
8185 .endd
8186 That query would then be sent only to the master server. If, on the other hand,
8187 the master is not to be used for reading, and so is not present in the global
8188 option, you can still update it by a query of this form:
8189 .code
8190 ${lookup pgsql,servers=master/db/name/pw {UPDATE ...} }
8191 .endd
8192
8193 A now-deprecated syntax places the servers specification before the query,
8194 semicolon separated:
8195 .code
8196 ${lookup mysql{servers=master; UPDATE ...} }
8197 .endd
8198 The new version avoids issues with tainted
8199 arguments explicitly expanded as part of the query.
8200 The entire string within the braces becomes tainted,
8201 including the server sepcification - which is not permissible.
8202 If the older sytax is used, a warning message will be logged.
8203 This syntax will be removed in a future release.
8204
8205 &*Note*&: server specifications in list-style lookups are still problematic.
8206
8207
8208 .subsection "Special MySQL features" SECID73
8209 For MySQL, an empty host name or the use of &"localhost"& in &%mysql_servers%&
8210 causes a connection to the server on the local host by means of a Unix domain
8211 socket. An alternate socket can be specified in parentheses.
8212 An option group name for MySQL option files can be specified in square brackets;
8213 the default value is &"exim"&.
8214 The full syntax of each item in &%mysql_servers%& is:
8215 .display
8216 <&'hostname'&>::<&'port'&>(<&'socket name'&>)[<&'option group'&>]/&&&
8217   <&'database'&>/<&'user'&>/<&'password'&>
8218 .endd
8219 Any of the four sub-parts of the first field can be omitted. For normal use on
8220 the local host it can be left blank or set to just &"localhost"&.
8221
8222 No database need be supplied &-- but if it is absent here, it must be given in
8223 the queries.
8224
8225 If a MySQL query is issued that does not request any data (an insert, update,
8226 or delete command), the result of the lookup is the number of rows affected.
8227
8228 &*Warning*&: This can be misleading. If an update does not actually change
8229 anything (for example, setting a field to the value it already has), the result
8230 is zero because no rows are affected.
8231
8232 To get an encryted connection, use a Mysql option file with the required
8233 parameters for the connection.
8234
8235
8236 .subsection "Special PostgreSQL features" SECID74
8237 PostgreSQL lookups can also use Unix domain socket connections to the database.
8238 This is usually faster and costs less CPU time than a TCP/IP connection.
8239 However it can be used only if the mail server runs on the same machine as the
8240 database server. A configuration line for PostgreSQL via Unix domain sockets
8241 looks like this:
8242 .code
8243 hide pgsql_servers = (/tmp/.s.PGSQL.5432)/db/user/password : ...
8244 .endd
8245 In other words, instead of supplying a host name, a path to the socket is
8246 given. The path name is enclosed in parentheses so that its slashes aren't
8247 visually confused with the delimiters for the other server parameters.
8248
8249 If a PostgreSQL query is issued that does not request any data (an insert,
8250 update, or delete command), the result of the lookup is the number of rows
8251 affected.
8252
8253 .subsection "More about SQLite" SECTsqlite
8254 .cindex "lookup" "SQLite"
8255 .cindex "sqlite lookup type"
8256 SQLite is different to the other SQL lookups because a filename is required in
8257 addition to the SQL query. An SQLite database is a single file, and there is no
8258 daemon as in the other SQL databases.
8259
8260 .oindex &%sqlite_dbfile%&
8261 There are two ways of
8262 specifying the file.
8263 The first is by using the &%sqlite_dbfile%& main option.
8264 The second, which allows separate files for each query,
8265 is to use an option appended, comma-separated, to the &"sqlite"&
8266 lookup type word.  The option is the word &"file"&, then an equals,
8267 then the filename.
8268 The filename in this case cannot contain whitespace or open-brace charachters.
8269
8270 A deprecated method is available, prefixing the query with the filename
8271 separated by white space.
8272 This means that
8273 .cindex "tainted data" "sqlite file"
8274 the query cannot use any tainted values, as that taints
8275 the entire query including the filename - resulting in a refusal to open
8276 the file.
8277
8278 In all the above cases the filename must be an absolute path.
8279
8280 Here is a lookup expansion example:
8281 .code
8282 sqlite_dbfile = /some/thing/sqlitedb
8283 ...
8284 ${lookup sqlite {select name from aliases where id='userx';}}
8285 .endd
8286 In a list, the syntax is similar. For example:
8287 .code
8288 domainlist relay_to_domains = sqlite;\
8289    select * from relays where ip='$sender_host_address';
8290 .endd
8291 The only character affected by the &%quote_sqlite%& operator is a single
8292 quote, which it doubles.
8293
8294 .cindex timeout SQLite
8295 .cindex sqlite "lookup timeout"
8296 The SQLite library handles multiple simultaneous accesses to the database
8297 internally. Multiple readers are permitted, but only one process can
8298 update at once. Attempts to access the database while it is being updated
8299 are rejected after a timeout period, during which the SQLite library
8300 waits for the lock to be released. In Exim, the default timeout is set
8301 to 5 seconds, but it can be changed by means of the &%sqlite_lock_timeout%&
8302 option.
8303
8304 .subsection "More about Redis" SECTredis
8305 .cindex "lookup" "Redis"
8306 .cindex "redis lookup type"
8307 Redis is a non-SQL database. Commands are simple get and set.
8308 Examples:
8309 .code
8310 ${lookup redis{set keyname ${quote_redis:objvalue plus}}}
8311 ${lookup redis{get keyname}}
8312 .endd
8313
8314 As of release 4.91, "lightweight" support for Redis Cluster is available.
8315 Requires &%redis_servers%& list to contain all the servers in the cluster, all
8316 of which must be reachable from the running exim instance. If the cluster has
8317 master/slave replication, the list must contain all the master and slave
8318 servers.
8319
8320 When the Redis Cluster returns a "MOVED" response to a query, Exim does not
8321 immediately follow the redirection but treats the response as a DEFER, moving on
8322 to the next server in the &%redis_servers%& list until the correct server is
8323 reached.
8324
8325 .ecindex IIDfidalo1
8326 .ecindex IIDfidalo2
8327
8328
8329 . ////////////////////////////////////////////////////////////////////////////
8330 . ////////////////////////////////////////////////////////////////////////////
8331
8332 .chapter "Domain, host, address, and local part lists" &&&
8333          "CHAPdomhosaddlists" &&&
8334          "Domain, host, and address lists"
8335 .scindex IIDdohoadli "lists of domains; hosts; etc."
8336 A number of Exim configuration options contain lists of domains, hosts,
8337 email addresses, or local parts. For example, the &%hold_domains%& option
8338 contains a list of domains whose delivery is currently suspended. These lists
8339 are also used as data in ACL statements (see chapter &<<CHAPACL>>&), and as
8340 arguments to expansion conditions such as &%match_domain%&.
8341
8342 Each item in one of these lists is a pattern to be matched against a domain,
8343 host, email address, or local part, respectively. In the sections below, the
8344 different types of pattern for each case are described, but first we cover some
8345 general facilities that apply to all four kinds of list.
8346
8347 Note that other parts of Exim use a &'string list'& which does not
8348 support all the complexity available in
8349 domain, host, address and local part lists.
8350
8351
8352
8353 .section "Results of list checking" SECTlistresults
8354 The primary result of doing a list check is a truth value.
8355 In some contexts additional information is stored
8356 about the list element that matched:
8357 .vlist
8358 .vitem hosts
8359 A &%hosts%& ACL condition
8360 will store a result in the &$host_data$& variable.
8361 .vitem local_parts
8362 A &%local_parts%& router option or &%local_parts%& ACL condition
8363 will store a result in the &$local_part_data$& variable.
8364 .vitem domains
8365 A &%domains%& router option or &%domains%& ACL condition
8366 will store a result in the &$domain_data$& variable.
8367 .vitem senders
8368 A &%senders%& router option or &%senders%& ACL condition
8369 will store a result in the &$sender_data$& variable.
8370 .vitem recipients
8371 A &%recipients%& ACL condition
8372 will store a result in the &$recipient_data$& variable.
8373 .endlist
8374
8375 The detail of the additional information depends on the
8376 type of match and is given below as the &*value*& information.
8377
8378
8379
8380
8381 .section "Expansion of lists" "SECTlistexpand"
8382 .cindex "expansion" "of lists"
8383 Each list is expanded as a single string before it is used.
8384 .cindex "tainted data" tracking
8385 &*Note*&: As a result, if any componend was tainted then the
8386 entire result string becomes tainted.
8387
8388 &'Exception: the router headers_remove option, where list-item
8389 splitting is done before string-expansion.'&
8390
8391 The result of
8392 expansion must be a list, possibly containing empty items, which is split up
8393 into separate items for matching. By default, colon is the separator character,
8394 but this can be varied if necessary. See sections &<<SECTlistconstruct>>& and
8395 &<<SECTempitelis>>& for details of the list syntax; the second of these
8396 discusses the way to specify empty list items.
8397
8398
8399 If the string expansion is forced to fail, Exim behaves as if the item it is
8400 testing (domain, host, address, or local part) is not in the list. Other
8401 expansion failures cause temporary errors.
8402
8403 If an item in a list is a regular expression, backslashes, dollars and possibly
8404 other special characters in the expression must be protected against
8405 misinterpretation by the string expander. The easiest way to do this is to use
8406 the &`\N`& expansion feature to indicate that the contents of the regular
8407 expression should not be expanded. For example, in an ACL you might have:
8408 .code
8409 deny senders = \N^\d{8}\w@.*\.baddomain\.example$\N : \
8410                ${lookup{$domain}lsearch{/badsenders/bydomain}}
8411 .endd
8412 The first item is a regular expression that is protected from expansion by
8413 &`\N`&, whereas the second uses the expansion to obtain a list of unwanted
8414 senders based on the receiving domain.
8415
8416
8417
8418
8419 .subsection "Negated items in lists" SECID76
8420 .cindex "list" "negation"
8421 .cindex "negation" "in lists"
8422 Items in a list may be positive or negative. Negative items are indicated by a
8423 leading exclamation mark, which may be followed by optional white space. A list
8424 defines a set of items (domains, etc). When Exim processes one of these lists,
8425 it is trying to find out whether a domain, host, address, or local part
8426 (respectively) is in the set that is defined by the list. It works like this:
8427
8428 The list is scanned from left to right. If a positive item is matched, the
8429 subject that is being checked is in the set; if a negative item is matched, the
8430 subject is not in the set. If the end of the list is reached without the
8431 subject having matched any of the patterns, it is in the set if the last item
8432 was a negative one, but not if it was a positive one. For example, the list in
8433 .code
8434 domainlist relay_to_domains = !a.b.c : *.b.c
8435 .endd
8436 matches any domain ending in &'.b.c'& except for &'a.b.c'&. Domains that match
8437 neither &'a.b.c'& nor &'*.b.c'& do not match, because the last item in the
8438 list is positive. However, if the setting were
8439 .code
8440 domainlist relay_to_domains = !a.b.c
8441 .endd
8442 then all domains other than &'a.b.c'& would match because the last item in the
8443 list is negative. In other words, a list that ends with a negative item behaves
8444 as if it had an extra item &`:*`& on the end.
8445
8446 Another way of thinking about positive and negative items in lists is to read
8447 the connector as &"or"& after a positive item and as &"and"& after a negative
8448 item.
8449
8450
8451
8452 .subsection "File names in lists" SECTfilnamlis
8453 .cindex "list" "filename in"
8454 If an item in a domain, host, address, or local part list is an absolute
8455 filename (beginning with a slash character), each line of the file is read and
8456 processed as if it were an independent item in the list, except that further
8457 filenames are not allowed,
8458 and no expansion of the data from the file takes place.
8459 Empty lines in the file are ignored, and the file may also contain comment
8460 lines:
8461
8462 .ilist
8463 For domain and host lists, if a # character appears anywhere in a line of the
8464 file, it and all following characters are ignored.
8465 .next
8466 Because local parts may legitimately contain # characters, a comment in an
8467 address list or local part list file is recognized only if # is preceded by
8468 white space or the start of the line. For example:
8469 .code
8470 not#comment@x.y.z   # but this is a comment
8471 .endd
8472 .endlist
8473
8474 Putting a filename in a list has the same effect as inserting each line of the
8475 file as an item in the list (blank lines and comments excepted). However, there
8476 is one important difference: the file is read each time the list is processed,
8477 so if its contents vary over time, Exim's behaviour changes.
8478
8479 If a filename is preceded by an exclamation mark, the sense of any match
8480 within the file is inverted. For example, if
8481 .code
8482 hold_domains = !/etc/nohold-domains
8483 .endd
8484 and the file contains the lines
8485 .code
8486 !a.b.c
8487 *.b.c
8488 .endd
8489 then &'a.b.c'& is in the set of domains defined by &%hold_domains%&, whereas
8490 any domain matching &`*.b.c`& is not.
8491
8492
8493
8494 .subsection "An lsearch file is not an out-of-line list" SECID77
8495 As will be described in the sections that follow, lookups can be used in lists
8496 to provide indexed methods of checking list membership. There has been some
8497 confusion about the way &(lsearch)& lookups work in lists. Because
8498 an &(lsearch)& file contains plain text and is scanned sequentially, it is
8499 sometimes thought that it is allowed to contain wild cards and other kinds of
8500 non-constant pattern. This is not the case. The keys in an &(lsearch)& file are
8501 always fixed strings, just as for any other single-key lookup type.
8502
8503 If you want to use a file to contain wild-card patterns that form part of a
8504 list, just give the filename on its own, without a search type, as described
8505 in the previous section. You could also use the &(wildlsearch)& or
8506 &(nwildlsearch)&, but there is no advantage in doing this.
8507
8508
8509
8510
8511 .subsection "Named lists" SECTnamedlists
8512 .cindex "named lists"
8513 .cindex "list" "named"
8514 A list of domains, hosts, email addresses, or local parts can be given a name
8515 which is then used to refer to the list elsewhere in the configuration. This is
8516 particularly convenient if the same list is required in several different
8517 places. It also allows lists to be given meaningful names, which can improve
8518 the readability of the configuration. For example, it is conventional to define
8519 a domain list called &'local_domains'& for all the domains that are handled
8520 locally on a host, using a configuration line such as
8521 .code
8522 domainlist local_domains = localhost:my.dom.example
8523 .endd
8524 Named lists are referenced by giving their name preceded by a plus sign, so,
8525 for example, a router that is intended to handle local domains would be
8526 configured with the line
8527 .code
8528 domains = +local_domains
8529 .endd
8530 The first router in a configuration is often one that handles all domains
8531 except the local ones, using a configuration with a negated item like this:
8532 .code
8533 dnslookup:
8534   driver = dnslookup
8535   domains = ! +local_domains
8536   transport = remote_smtp
8537   no_more
8538 .endd
8539 The four kinds of named list are created by configuration lines starting with
8540 the words &%domainlist%&, &%hostlist%&, &%addresslist%&, or &%localpartlist%&,
8541 respectively. Then there follows the name that you are defining, followed by an
8542 equals sign and the list itself. For example:
8543 .code
8544 hostlist    relay_from_hosts = 192.168.23.0/24 : my.friend.example
8545 addresslist bad_senders = cdb;/etc/badsenders
8546 .endd
8547 A named list may refer to other named lists:
8548 .code
8549 domainlist  dom1 = first.example : second.example
8550 domainlist  dom2 = +dom1 : third.example
8551 domainlist  dom3 = fourth.example : +dom2 : fifth.example
8552 .endd
8553 &*Warning*&: If the last item in a referenced list is a negative one, the
8554 effect may not be what you intended, because the negation does not propagate
8555 out to the higher level. For example, consider:
8556 .code
8557 domainlist  dom1 = !a.b
8558 domainlist  dom2 = +dom1 : *.b
8559 .endd
8560 The second list specifies &"either in the &%dom1%& list or &'*.b'&"&. The first
8561 list specifies just &"not &'a.b'&"&, so the domain &'x.y'& matches it. That
8562 means it matches the second list as well. The effect is not the same as
8563 .code
8564 domainlist  dom2 = !a.b : *.b
8565 .endd
8566 where &'x.y'& does not match. It's best to avoid negation altogether in
8567 referenced lists if you can.
8568
8569 .cindex "hiding named list values"
8570 .cindex "named lists" "hiding value of"
8571 Some named list definitions may contain sensitive data, for example, passwords for
8572 accessing databases. To stop non-admin users from using the &%-bP%& command
8573 line option to read these values, you can precede the definition with the
8574 word &"hide"&. For example:
8575 .code
8576 hide domainlist filter_for_domains = ldap;PASS=secret ldap::/// ...
8577 .endd
8578
8579
8580 Named lists may have a performance advantage. When Exim is routing an
8581 address or checking an incoming message, it caches the result of tests on named
8582 lists. So, if you have a setting such as
8583 .code
8584 domains = +local_domains
8585 .endd
8586 on several of your routers
8587 or in several ACL statements,
8588 the actual test is done only for the first one. However, the caching works only
8589 if there are no expansions within the list itself or any sublists that it
8590 references. In other words, caching happens only for lists that are known to be
8591 the same each time they are referenced.
8592
8593 By default, there may be up to 16 named lists of each type. This limit can be
8594 extended by changing a compile-time variable. The use of domain and host lists
8595 is recommended for concepts such as local domains, relay domains, and relay
8596 hosts. The default configuration is set up like this.
8597
8598
8599
8600 .subsection "Named lists compared with macros" SECID78
8601 .cindex "list" "named compared with macro"
8602 .cindex "macro" "compared with named list"
8603 At first sight, named lists might seem to be no different from macros in the
8604 configuration file. However, macros are just textual substitutions. If you
8605 write
8606 .code
8607 ALIST = host1 : host2
8608 auth_advertise_hosts = !ALIST
8609 .endd
8610 it probably won't do what you want, because that is exactly the same as
8611 .code
8612 auth_advertise_hosts = !host1 : host2
8613 .endd
8614 Notice that the second host name is not negated. However, if you use a host
8615 list, and write
8616 .code
8617 hostlist alist = host1 : host2
8618 auth_advertise_hosts = ! +alist
8619 .endd
8620 the negation applies to the whole list, and so that is equivalent to
8621 .code
8622 auth_advertise_hosts = !host1 : !host2
8623 .endd
8624
8625
8626 .subsection "Named list caching" SECID79
8627 .cindex "list" "caching of named"
8628 .cindex "caching" "named lists"
8629 While processing a message, Exim caches the result of checking a named list if
8630 it is sure that the list is the same each time. In practice, this means that
8631 the cache operates only if the list contains no $ characters, which guarantees
8632 that it will not change when it is expanded. Sometimes, however, you may have
8633 an expanded list that you know will be the same each time within a given
8634 message. For example:
8635 .code
8636 domainlist special_domains = \
8637            ${lookup{$sender_host_address}cdb{/some/file}}
8638 .endd
8639 This provides a list of domains that depends only on the sending host's IP
8640 address. If this domain list is referenced a number of times (for example,
8641 in several ACL lines, or in several routers) the result of the check is not
8642 cached by default, because Exim does not know that it is going to be the
8643 same list each time.
8644
8645 By appending &`_cache`& to &`domainlist`& you can tell Exim to go ahead and
8646 cache the result anyway. For example:
8647 .code
8648 domainlist_cache special_domains = ${lookup{...
8649 .endd
8650 If you do this, you should be absolutely sure that caching is going to do
8651 the right thing in all cases. When in doubt, leave it out.
8652
8653
8654
8655 .section "Domain lists" "SECTdomainlist"
8656 .cindex "domain list" "patterns for"
8657 .cindex "list" "domain list"
8658 Domain lists contain patterns that are to be matched against a mail domain.
8659 The following types of item may appear in domain lists:
8660
8661 .ilist
8662 .cindex "primary host name"
8663 .cindex "host name" "matched in domain list"
8664 .oindex "&%primary_hostname%&"
8665 .cindex "domain list" "matching primary host name"
8666 .cindex "@ in a domain list"
8667 If a pattern consists of a single @ character, it matches the local host name,
8668 as set by the &%primary_hostname%& option (or defaulted). This makes it
8669 possible to use the same configuration file on several different hosts that
8670 differ only in their names.
8671
8672 The value for a match will be the primary host name.
8673
8674
8675 .next
8676 .cindex "@[] in a domain list"
8677 .cindex "domain list" "matching local IP interfaces"
8678 .cindex "domain literal"
8679 If a pattern consists of the string &`@[]`& it matches an IP address enclosed
8680 in square brackets (as in an email address that contains a domain literal), but
8681 only if that IP address is recognized as local for email routing purposes. The
8682 &%local_interfaces%& and &%extra_local_interfaces%& options can be used to
8683 control which of a host's several IP addresses are treated as local.
8684 In today's Internet, the use of domain literals is controversial;
8685 see the &%allow_domain_literals%& main option.
8686
8687 The value for a match will be the string &`@[]`&.
8688
8689
8690 .next
8691 .cindex "@mx_any"
8692 .cindex "@mx_primary"
8693 .cindex "@mx_secondary"
8694 .cindex "domain list" "matching MX pointers to local host"
8695 If a pattern consists of the string &`@mx_any`& it matches any domain that
8696 has an MX record pointing to the local host or to any host that is listed in
8697 .oindex "&%hosts_treat_as_local%&"
8698 &%hosts_treat_as_local%&. The items &`@mx_primary`& and &`@mx_secondary`&
8699 are similar, except that the first matches only when a primary MX target is the
8700 local host, and the second only when no primary MX target is the local host,
8701 but a secondary MX target is. &"Primary"& means an MX record with the lowest
8702 preference value &-- there may of course be more than one of them.
8703
8704 The MX lookup that takes place when matching a pattern of this type is
8705 performed with the resolver options for widening names turned off. Thus, for
8706 example, a single-component domain will &'not'& be expanded by adding the
8707 resolver's default domain. See the &%qualify_single%& and &%search_parents%&
8708 options of the &(dnslookup)& router for a discussion of domain widening.
8709
8710 Sometimes you may want to ignore certain IP addresses when using one of these
8711 patterns. You can specify this by following the pattern with &`/ignore=`&<&'ip
8712 list'&>, where <&'ip list'&> is a list of IP addresses. These addresses are
8713 ignored when processing the pattern (compare the &%ignore_target_hosts%& option
8714 on a router). For example:
8715 .code
8716 domains = @mx_any/ignore=127.0.0.1
8717 .endd
8718 This example matches any domain that has an MX record pointing to one of
8719 the local host's IP addresses other than 127.0.0.1.
8720
8721 The list of IP addresses is in fact processed by the same code that processes
8722 host lists, so it may contain CIDR-coded network specifications and it may also
8723 contain negative items.
8724
8725 Because the list of IP addresses is a sublist within a domain list, you have to
8726 be careful about delimiters if there is more than one address. Like any other
8727 list, the default delimiter can be changed. Thus, you might have:
8728 .code
8729 domains = @mx_any/ignore=<;127.0.0.1;0.0.0.0 : \
8730           an.other.domain : ...
8731 .endd
8732 so that the sublist uses semicolons for delimiters. When IPv6 addresses are
8733 involved, it is easiest to change the delimiter for the main list as well:
8734 .code
8735 domains = <? @mx_any/ignore=<;127.0.0.1;::1 ? \
8736           an.other.domain ? ...
8737 .endd
8738 The value for a match will be the list element string (starting &`@mx_`&).
8739
8740
8741 .next
8742 .cindex "asterisk" "in domain list"
8743 .cindex "domain list" "asterisk in"
8744 .cindex "domain list" "matching &""ends with""&"
8745 If a pattern starts with an asterisk, the remaining characters of the pattern
8746 are compared with the terminating characters of the domain. The use of &"*"& in
8747 domain lists differs from its use in partial matching lookups. In a domain
8748 list, the character following the asterisk need not be a dot, whereas partial
8749 matching works only in terms of dot-separated components. For example, a domain
8750 list item such as &`*key.ex`& matches &'donkey.ex'& as well as
8751 &'cipher.key.ex'&.
8752
8753 The value for a match will be the list element string (starting with the asterisk).
8754 Additionally, &$0$& will be set to the matched string
8755 and &$1$& to the variable portion which the asterisk matched.
8756
8757 .next
8758 .cindex "regular expressions" "in domain list"
8759 .cindex "domain list" "matching regular expression"
8760 If a pattern starts with a circumflex character, it is treated as a regular
8761 expression, and matched against the domain using a regular expression matching
8762 function. The circumflex is treated as part of the regular expression.
8763 Email domains are case-independent, so this regular expression match is by
8764 default case-independent, but you can make it case-dependent by starting it
8765 with &`(?-i)`&. References to descriptions of the syntax of regular expressions
8766 are given in chapter &<<CHAPregexp>>&.
8767
8768 &*Warning*&: Because domain lists are expanded before being processed, you
8769 must escape any backslash and dollar characters in the regular expression, or
8770 use the special &`\N`& sequence (see chapter &<<CHAPexpand>>&) to specify that
8771 it is not to be expanded (unless you really do want to build a regular
8772 expression by expansion, of course).
8773
8774 The value for a match will be the list element string (starting with the circumflex).
8775 Additionally, &$0$& will be set to the string matching the regular expression,
8776 and &$1$& (onwards) to any submatches identified by parentheses.
8777
8778
8779
8780 .next
8781 .cindex "lookup" "in domain list"
8782 .cindex "domain list" "matching by lookup"
8783 If a pattern starts with the name of a single-key lookup type followed by a
8784 semicolon (for example, &"dbm;"& or &"lsearch;"&), the remainder of the pattern
8785 must be a filename in a suitable format for the lookup type. For example, for
8786 &"cdb;"& it must be an absolute path:
8787 .code
8788 domains = cdb;/etc/mail/local_domains.cdb
8789 .endd
8790 The appropriate type of lookup is done on the file using the domain name as the
8791 key. In most cases, the value resulting from the lookup is not used; Exim is interested
8792 only in whether or not the key is present in the file. However, when a lookup
8793 is used for the &%domains%& option on a router
8794 or a &%domains%& condition in an ACL statement, the value is preserved in the
8795 &$domain_data$& variable and can be referred to in other router options or
8796 other statements in the same ACL.
8797 .cindex "tainted data" "de-tainting"
8798 .cindex "de-tainting" "using ACL domains condition"
8799 The value will be untainted.
8800
8801 &*Note*&: If the data result of the lookup (as opposed to the key)
8802 is empty, then this empty value is stored in &$domain_data$&.
8803 The option to return the key for the lookup, as the value,
8804 may be what is wanted.
8805
8806
8807 .next
8808 Any of the single-key lookup type names may be preceded by
8809 &`partial`&<&'n'&>&`-`&, where the <&'n'&> is optional, for example,
8810 .code
8811 domains = partial-dbm;/partial/domains
8812 .endd
8813 This causes partial matching logic to be invoked; a description of how this
8814 works is given in section &<<SECTpartiallookup>>&.
8815
8816 .next
8817 .cindex "asterisk" "in lookup type"
8818 Any of the single-key lookup types may be followed by an asterisk. This causes
8819 a default lookup for a key consisting of a single asterisk to be done if the
8820 original lookup fails. This is not a useful feature when using a domain list to
8821 select particular domains (because any domain would match), but it might have
8822 value if the result of the lookup is being used via the &$domain_data$&
8823 expansion variable.
8824
8825 .next
8826 If the pattern starts with the name of a query-style lookup type followed by a
8827 semicolon (for example, &"nisplus;"& or &"ldap;"&), the remainder of the
8828 pattern must be an appropriate query for the lookup type, as described in
8829 chapter &<<CHAPfdlookup>>&. For example:
8830 .code
8831 hold_domains = mysql;select domain from holdlist \
8832   where domain = '${quote_mysql:$domain}';
8833 .endd
8834 In most cases, the value resulting from the lookup is not used (so for an SQL query, for
8835 example, it doesn't matter what field you select). Exim is interested only in
8836 whether or not the query succeeds. However, when a lookup is used for the
8837 &%domains%& option on a router, the value is preserved in the &$domain_data$&
8838 variable and can be referred to in other options.
8839 .cindex "tainted data" "de-tainting"
8840 .cindex "de-tainting" "using router domains option"
8841 The value will be untainted.
8842
8843 .next
8844 If the pattern starts with the name of a lookup type
8845 of either kind (single-key or query-style) it may be
8846 followed by a comma and options,
8847 The options are lookup-type specific and consist of a comma-separated list.
8848 Each item starts with a tag and and equals "=" sign.
8849
8850 .next
8851 .cindex "domain list" "matching literal domain name"
8852 If none of the above cases apply, a caseless textual comparison is made
8853 between the pattern and the domain.
8854
8855 The value for a match will be the list element string.
8856 .cindex "tainted data" "de-tainting"
8857 Note that this is commonly untainted
8858 (depending on the way the list was created).
8859 Specifically, explicit text in the configuration file in not tainted.
8860 This is a useful way of obtaining an untainted equivalent to
8861 the domain, for later operations.
8862
8863 However if the list (including one-element lists)
8864 is created by expanding a variable containing tainted data,
8865 it is tainted and so will the match value be.
8866 .endlist
8867
8868
8869 Here is an example that uses several different kinds of pattern:
8870 .code
8871 domainlist funny_domains = \
8872   @ : \
8873   lib.unseen.edu : \
8874   *.foundation.fict.example : \
8875   \N^[1-2]\d{3}\.fict\.example$\N : \
8876   partial-dbm;/opt/data/penguin/book : \
8877   nis;domains.byname : \
8878   nisplus;[name=$domain,status=local],domains.org_dir
8879 .endd
8880 There are obvious processing trade-offs among the various matching modes. Using
8881 an asterisk is faster than a regular expression, and listing a few names
8882 explicitly probably is too. The use of a file or database lookup is expensive,
8883 but may be the only option if hundreds of names are required. Because the
8884 patterns are tested in order, it makes sense to put the most commonly matched
8885 patterns earlier.
8886
8887
8888
8889 .section "Host lists" "SECThostlist"
8890 .cindex "host list" "patterns in"
8891 .cindex "list" "host list"
8892 Host lists are used to control what remote hosts are allowed to do. For
8893 example, some hosts may be allowed to use the local host as a relay, and some
8894 may be permitted to use the SMTP ETRN command. Hosts can be identified in
8895 two different ways, by name or by IP address. In a host list, some types of
8896 pattern are matched to a host name, and some are matched to an IP address.
8897 You need to be particularly careful with this when single-key lookups are
8898 involved, to ensure that the right value is being used as the key.
8899
8900
8901 .subsection "Special host list patterns" SECID80
8902 .cindex "empty item in hosts list"
8903 .cindex "host list" "empty string in"
8904 If a host list item is the empty string, it matches only when no remote host is
8905 involved. This is the case when a message is being received from a local
8906 process using SMTP on the standard input, that is, when a TCP/IP connection is
8907 not used.
8908
8909 .cindex "asterisk" "in host list"
8910 The special pattern &"*"& in a host list matches any host or no host. Neither
8911 the IP address nor the name is actually inspected.
8912
8913
8914
8915 .subsection "Host list patterns that match by IP address" SECThoslispatip
8916 .cindex "host list" "matching IP addresses"
8917 If an IPv4 host calls an IPv6 host and the call is accepted on an IPv6 socket,
8918 the incoming address actually appears in the IPv6 host as
8919 &`::ffff:`&<&'v4address'&>. When such an address is tested against a host
8920 list, it is converted into a traditional IPv4 address first. (Not all operating
8921 systems accept IPv4 calls on IPv6 sockets, as there have been some security
8922 concerns.)
8923
8924 The following types of pattern in a host list check the remote host by
8925 inspecting its IP address:
8926
8927 .ilist
8928 If the pattern is a plain domain name (not a regular expression, not starting
8929 with *, not a lookup of any kind), Exim calls the operating system function
8930 to find the associated IP address(es). Exim uses the newer
8931 &[getipnodebyname()]& function when available, otherwise &[gethostbyname()]&.
8932 This typically causes a forward DNS lookup of the name. The result is compared
8933 with the IP address of the subject host.
8934
8935 If there is a temporary problem (such as a DNS timeout) with the host name
8936 lookup, a temporary error occurs. For example, if the list is being used in an
8937 ACL condition, the ACL gives a &"defer"& response, usually leading to a
8938 temporary SMTP error code. If no IP address can be found for the host name,
8939 what happens is described in section &<<SECTbehipnot>>& below.
8940
8941 .next
8942 .cindex "@ in a host list"
8943 If the pattern is &"@"&, the primary host name is substituted and used as a
8944 domain name, as just described.
8945
8946 .next
8947 If the pattern is an IP address, it is matched against the IP address of the
8948 subject host. IPv4 addresses are given in the normal &"dotted-quad"& notation.
8949 IPv6 addresses can be given in colon-separated format, but the colons have to
8950 be doubled so as not to be taken as item separators when the default list
8951 separator is used. IPv6 addresses are recognized even when Exim is compiled
8952 without IPv6 support. This means that if they appear in a host list on an
8953 IPv4-only host, Exim will not treat them as host names. They are just addresses
8954 that can never match a client host.
8955
8956 .next
8957 .cindex "@[] in a host list"
8958 If the pattern is &"@[]"&, it matches the IP address of any IP interface on
8959 the local host. For example, if the local host is an IPv4 host with one
8960 interface address 10.45.23.56, these two ACL statements have the same effect:
8961 .code
8962 accept hosts = 127.0.0.1 : 10.45.23.56
8963 accept hosts = @[]
8964 .endd
8965 .next
8966 .cindex "CIDR notation"
8967 If the pattern is an IP address followed by a slash and a mask length, for
8968 example
8969 .code
8970 10.11.42.0/24
8971 .endd
8972 , it is matched against the IP address of the subject
8973 host under the given mask. This allows an entire network of hosts to be
8974 included (or excluded) by a single item. The mask uses CIDR notation; it
8975 specifies the number of address bits that must match, starting from the most
8976 significant end of the address.
8977
8978 &*Note*&: The mask is &'not'& a count of addresses, nor is it the high number
8979 of a range of addresses. It is the number of bits in the network portion of the
8980 address. The above example specifies a 24-bit netmask, so it matches all 256
8981 addresses in the 10.11.42.0 network. An item such as
8982 .code
8983 192.168.23.236/31
8984 .endd
8985 matches just two addresses, 192.168.23.236 and 192.168.23.237. A mask value of
8986 32 for an IPv4 address is the same as no mask at all; just a single address
8987 matches.
8988
8989 Here is another example which shows an IPv4 and an IPv6 network:
8990 .code
8991 recipient_unqualified_hosts = 192.168.0.0/16: \
8992                               3ffe::ffff::836f::::/48
8993 .endd
8994 The doubling of list separator characters applies only when these items
8995 appear inline in a host list. It is not required when indirecting via a file.
8996 For example:
8997 .code
8998 recipient_unqualified_hosts = /opt/exim/unqualnets
8999 .endd
9000 could make use of a file containing
9001 .code
9002 172.16.0.0/12
9003 3ffe:ffff:836f::/48
9004 .endd
9005 to have exactly the same effect as the previous example. When listing IPv6
9006 addresses inline, it is usually more convenient to use the facility for
9007 changing separator characters. This list contains the same two networks:
9008 .code
9009 recipient_unqualified_hosts = <; 172.16.0.0/12; \
9010                                  3ffe:ffff:836f::/48
9011 .endd
9012 The separator is changed to semicolon by the leading &"<;"& at the start of the
9013 list.
9014 .endlist
9015
9016
9017
9018 .subsection "Host list patterns for single-key lookups by host address" &&&
9019          SECThoslispatsikey
9020 .cindex "host list" "lookup of IP address"
9021 When a host is to be identified by a single-key lookup of its complete IP
9022 address, the pattern takes this form:
9023 .display
9024 &`net-<`&&'single-key-search-type'&&`>;<`&&'search-data'&&`>`&
9025 .endd
9026 For example:
9027 .code
9028 hosts_lookup = net-cdb;/hosts-by-ip.db
9029 .endd
9030 The text form of the IP address of the subject host is used as the lookup key.
9031 IPv6 addresses are converted to an unabbreviated form, using lower case
9032 letters, with dots as separators because colon is the key terminator in
9033 &(lsearch)& files. [Colons can in fact be used in keys in &(lsearch)& files by
9034 quoting the keys, but this is a facility that was added later.] The data
9035 returned by the lookup is not used.
9036
9037 .cindex "IP address" "masking"
9038 .cindex "host list" "masked IP address"
9039 Single-key lookups can also be performed using masked IP addresses, using
9040 patterns of this form:
9041 .display
9042 &`net<`&&'number'&&`>-<`&&'single-key-search-type'&&`>;<`&&'search-data'&&`>`&
9043 .endd
9044 For example:
9045 .code
9046 net24-dbm;/networks.db
9047 .endd
9048 The IP address of the subject host is masked using <&'number'&> as the mask
9049 length. A textual string is constructed from the masked value, followed by the
9050 mask, and this is used as the lookup key. For example, if the host's IP address
9051 is 192.168.34.6, the key that is looked up for the above example is
9052 &"192.168.34.0/24"&.
9053
9054 When an IPv6 address is converted to a string, dots are normally used instead
9055 of colons, so that keys in &(lsearch)& files need not contain colons (which
9056 terminate &(lsearch)& keys). This was implemented some time before the ability
9057 to quote keys was made available in &(lsearch)& files. However, the more
9058 recently implemented &(iplsearch)& files do require colons in IPv6 keys
9059 (notated using the quoting facility) so as to distinguish them from IPv4 keys.
9060 For this reason, when the lookup type is &(iplsearch)&, IPv6 addresses are
9061 converted using colons and not dots.
9062 In all cases except IPv4-mapped IPv6, full, unabbreviated IPv6
9063 addresses are always used.
9064 The latter are converted to IPv4 addresses, in dotted-quad form.
9065
9066 Ideally, it would be nice to tidy up this anomalous situation by changing to
9067 colons in all cases, given that quoting is now available for &(lsearch)&.
9068 However, this would be an incompatible change that might break some existing
9069 configurations.
9070
9071 &*Warning*&: Specifying &%net32-%& (for an IPv4 address) or &%net128-%& (for an
9072 IPv6 address) is not the same as specifying just &%net-%& without a number. In
9073 the former case the key strings include the mask value, whereas in the latter
9074 case the IP address is used on its own.
9075
9076
9077
9078 .subsection "Host list patterns that match by host name" SECThoslispatnam
9079 .cindex "host" "lookup failures"
9080 .cindex "unknown host name"
9081 .cindex "host list" "matching host name"
9082 There are several types of pattern that require Exim to know the name of the
9083 remote host. These are either wildcard patterns or lookups by name. (If a
9084 complete hostname is given without any wildcarding, it is used to find an IP
9085 address to match against, as described in section &<<SECThoslispatip>>&
9086 above.)
9087
9088 If the remote host name is not already known when Exim encounters one of these
9089 patterns, it has to be found from the IP address.
9090 Although many sites on the Internet are conscientious about maintaining reverse
9091 DNS data for their hosts, there are also many that do not do this.
9092 Consequently, a name cannot always be found, and this may lead to unwanted
9093 effects. Take care when configuring host lists with wildcarded name patterns.
9094 Consider what will happen if a name cannot be found.
9095
9096 Because of the problems of determining host names from IP addresses, matching
9097 against host names is not as common as matching against IP addresses.
9098
9099 By default, in order to find a host name, Exim first does a reverse DNS lookup;
9100 if no name is found in the DNS, the system function (&[gethostbyaddr()]& or
9101 &[getipnodebyaddr()]& if available) is tried. The order in which these lookups
9102 are done can be changed by setting the &%host_lookup_order%& option. For
9103 security, once Exim has found one or more names, it looks up the IP addresses
9104 for these names and compares them with the IP address that it started with.
9105 Only those names whose IP addresses match are accepted. Any other names are
9106 discarded. If no names are left, Exim behaves as if the host name cannot be
9107 found. In the most common case there is only one name and one IP address.
9108
9109 There are some options that control what happens if a host name cannot be
9110 found. These are described in section &<<SECTbehipnot>>& below.
9111
9112 .cindex "host" "alias for"
9113 .cindex "alias for host"
9114 As a result of aliasing, hosts may have more than one name. When processing any
9115 of the following types of pattern, all the host's names are checked:
9116
9117 .ilist
9118 .cindex "asterisk" "in host list"
9119 If a pattern starts with &"*"& the remainder of the item must match the end of
9120 the host name. For example, &`*.b.c`& matches all hosts whose names end in
9121 &'.b.c'&. This special simple form is provided because this is a very common
9122 requirement. Other kinds of wildcarding require the use of a regular
9123 expression.
9124 .next
9125 .cindex "regular expressions" "in host list"
9126 .cindex "host list" "regular expression in"
9127 If the item starts with &"^"& it is taken to be a regular expression which is
9128 matched against the host name. Host names are case-independent, so this regular
9129 expression match is by default case-independent, but you can make it
9130 case-dependent by starting it with &`(?-i)`&. References to descriptions of the
9131 syntax of regular expressions are given in chapter &<<CHAPregexp>>&. For
9132 example,
9133 .code
9134 ^(a|b)\.c\.d$
9135 .endd
9136 is a regular expression that matches either of the two hosts &'a.c.d'& or
9137 &'b.c.d'&. When a regular expression is used in a host list, you must take care
9138 that backslash and dollar characters are not misinterpreted as part of the
9139 string expansion. The simplest way to do this is to use &`\N`& to mark that
9140 part of the string as non-expandable. For example:
9141 .code
9142 sender_unqualified_hosts = \N^(a|b)\.c\.d$\N : ....
9143 .endd
9144 &*Warning*&: If you want to match a complete host name, you must include the
9145 &`$`& terminating metacharacter in the regular expression, as in the above
9146 example. Without it, a match at the start of the host name is all that is
9147 required.
9148 .endlist
9149
9150
9151
9152
9153 .subsection "Behaviour when an IP address or name cannot be found" SECTbehipnot
9154 .cindex "host" "lookup failures, permanent"
9155 While processing a host list, Exim may need to look up an IP address from a
9156 name (see section &<<SECThoslispatip>>&), or it may need to look up a host name
9157 from an IP address (see section &<<SECThoslispatnam>>&). In either case, the
9158 behaviour when it fails to find the information it is seeking is the same.
9159
9160 &*Note*&: This section applies to permanent lookup failures. It does &'not'&
9161 apply to temporary DNS errors, whose handling is described in the next section.
9162
9163 .cindex "&`+include_unknown`&"
9164 .cindex "&`+ignore_unknown`&"
9165 Exim parses a host list from left to right. If it encounters a permanent
9166 lookup failure in any item in the host list before it has found a match,
9167 Exim treats it as a failure and the default behavior is as if the host
9168 does not match the list. This may not always be what you want to happen.
9169 To change Exim's behaviour, the special items &`+include_unknown`& or
9170 &`+ignore_unknown`& may appear in the list (at top level &-- they are
9171 not recognized in an indirected file).
9172
9173 .ilist
9174 If any item that follows &`+include_unknown`& requires information that
9175 cannot found, Exim behaves as if the host does match the list. For example,
9176 .code
9177 host_reject_connection = +include_unknown:*.enemy.ex
9178 .endd
9179 rejects connections from any host whose name matches &`*.enemy.ex`&, and also
9180 any hosts whose name it cannot find.
9181
9182 .next
9183 If any item that follows &`+ignore_unknown`& requires information that cannot
9184 be found, Exim ignores that item and proceeds to the rest of the list. For
9185 example:
9186 .code
9187 accept hosts = +ignore_unknown : friend.example : \
9188                192.168.4.5
9189 .endd
9190 accepts from any host whose name is &'friend.example'& and from 192.168.4.5,
9191 whether or not its host name can be found. Without &`+ignore_unknown`&, if no
9192 name can be found for 192.168.4.5, it is rejected.
9193 .endlist
9194
9195 Both &`+include_unknown`& and &`+ignore_unknown`& may appear in the same
9196 list. The effect of each one lasts until the next, or until the end of the
9197 list.
9198
9199 .subsection "Mixing wildcarded host names and addresses in host lists" &&&
9200          SECTmixwilhos
9201 .cindex "host list" "mixing names and addresses in"
9202
9203 This section explains the host/ip processing logic with the same concepts
9204 as the previous section, but specifically addresses what happens when a
9205 wildcarded hostname is one of the items in the hostlist.
9206
9207 .ilist
9208 If you have name lookups or wildcarded host names and
9209 IP addresses in the same host list, you should normally put the IP
9210 addresses first. For example, in an ACL you could have:
9211 .code
9212 accept hosts = 10.9.8.7 : *.friend.example
9213 .endd
9214 The reason you normally would order it this way lies in the
9215 left-to-right way that Exim processes lists.  It can test IP addresses
9216 without doing any DNS lookups, but when it reaches an item that requires
9217 a host name, it fails if it cannot find a host name to compare with the
9218 pattern. If the above list is given in the opposite order, the
9219 &%accept%& statement fails for a host whose name cannot be found, even
9220 if its IP address is 10.9.8.7.
9221
9222 .next
9223 If you really do want to do the name check first, and still recognize the IP
9224 address, you can rewrite the ACL like this:
9225 .code
9226 accept hosts = *.friend.example
9227 accept hosts = 10.9.8.7
9228 .endd
9229 If the first &%accept%& fails, Exim goes on to try the second one. See chapter
9230 &<<CHAPACL>>& for details of ACLs. Alternatively, you can use
9231 &`+ignore_unknown`&, which was discussed in depth in the first example in
9232 this section.
9233 .endlist
9234
9235
9236 .subsection "Temporary DNS errors when looking up host information" &&&
9237          SECTtemdnserr
9238 .cindex "host" "lookup failures, temporary"
9239 .cindex "&`+include_defer`&"
9240 .cindex "&`+ignore_defer`&"
9241 A temporary DNS lookup failure normally causes a defer action (except when
9242 &%dns_again_means_nonexist%& converts it into a permanent error). However,
9243 host lists can include &`+ignore_defer`& and &`+include_defer`&, analogous to
9244 &`+ignore_unknown`& and &`+include_unknown`&, as described in the previous
9245 section. These options should be used with care, probably only in non-critical
9246 host lists such as whitelists.
9247
9248
9249
9250 .subsection "Host list patterns for single-key lookups by host name" &&&
9251          SECThoslispatnamsk
9252 .cindex "unknown host name"
9253 .cindex "host list" "matching host name"
9254 If a pattern is of the form
9255 .display
9256 <&'single-key-search-type'&>;<&'search-data'&>
9257 .endd
9258 for example
9259 .code
9260 dbm;/host/accept/list
9261 .endd
9262 a single-key lookup is performed, using the host name as its key. If the
9263 lookup succeeds, the host matches the item. The actual data that is looked up
9264 is not used.
9265
9266 &*Reminder*&: With this kind of pattern, you must have host &'names'& as
9267 keys in the file, not IP addresses. If you want to do lookups based on IP
9268 addresses, you must precede the search type with &"net-"&
9269 (see section &<<SECThoslispatsikey>>&).
9270 There is, however, no reason why you could not use
9271 two items in the same list, one doing an address lookup and one doing a name
9272 lookup, both using the same file.
9273
9274
9275
9276 .subsection "Host list patterns for query-style lookups" SECID81
9277 If a pattern is of the form
9278 .display
9279 <&'query-style-search-type'&>;<&'query'&>
9280 .endd
9281 the query is obeyed, and if it succeeds, the host matches the item. The actual
9282 data that is looked up is not used. The variables &$sender_host_address$& and
9283 &$sender_host_name$& can be used in the query. For example:
9284 .code
9285 hosts_lookup = pgsql;\
9286   select ip from hostlist where ip='$sender_host_address'
9287 .endd
9288 The value of &$sender_host_address$& for an IPv6 address contains colons. You
9289 can use the &%sg%& expansion item to change this if you need to. If you want to
9290 use masked IP addresses in database queries, you can use the &%mask%& expansion
9291 operator.
9292
9293 If the query contains a reference to &$sender_host_name$&, Exim automatically
9294 looks up the host name if it has not already done so. (See section
9295 &<<SECThoslispatnam>>& for comments on finding host names.)
9296
9297 Historical note: prior to release 4.30, Exim would always attempt to find a
9298 host name before running the query, unless the search type was preceded by
9299 &`net-`&. This is no longer the case. For backwards compatibility, &`net-`& is
9300 still recognized for query-style lookups, but its presence or absence has no
9301 effect. (Of course, for single-key lookups, &`net-`& &'is'& important.
9302 See section &<<SECThoslispatsikey>>&.)
9303
9304
9305
9306
9307
9308 .section "Address lists" "SECTaddresslist"
9309 .cindex "list" "address list"
9310 .cindex "address list" "empty item"
9311 .cindex "address list" "patterns"
9312 Address lists contain patterns that are matched against mail addresses. There
9313 is one special case to be considered: the sender address of a bounce message is
9314 always empty. You can test for this by providing an empty item in an address
9315 list. For example, you can set up a router to process bounce messages by
9316 using this option setting:
9317 .code
9318 senders = :
9319 .endd
9320 The presence of the colon creates an empty item. If you do not provide any
9321 data, the list is empty and matches nothing. The empty sender can also be
9322 detected by a regular expression that matches an empty string,
9323 and by a query-style lookup that succeeds when &$sender_address$& is empty.
9324
9325 Non-empty items in an address list can be straightforward email addresses. For
9326 example:
9327 .code
9328 senders = jbc@askone.example : hs@anacreon.example
9329 .endd
9330 A certain amount of wildcarding is permitted. If a pattern contains an @
9331 character, but is not a regular expression and does not begin with a
9332 semicolon-terminated lookup type (described below), the local part of the
9333 subject address is compared with the local part of the pattern, which may start
9334 with an asterisk. If the local parts match, the domain is checked in exactly
9335 the same way as for a pattern in a domain list. For example, the domain can be
9336 wildcarded, refer to a named list, or be a lookup:
9337 .code
9338 deny senders = *@*.spamming.site:\
9339                *@+hostile_domains:\
9340                bozo@partial-lsearch;/list/of/dodgy/sites:\
9341                *@dbm;/bad/domains.db
9342 .endd
9343 .cindex "local part" "starting with !"
9344 .cindex "address list" "local part starting with !"
9345 If a local part that begins with an exclamation mark is required, it has to be
9346 specified using a regular expression, because otherwise the exclamation mark is
9347 treated as a sign of negation, as is standard in lists.
9348
9349 If a non-empty pattern that is not a regular expression or a lookup does not
9350 contain an @ character, it is matched against the domain part of the subject
9351 address. The only two formats that are recognized this way are a literal
9352 domain, or a domain pattern that starts with *. In both these cases, the effect
9353 is the same as if &`*@`& preceded the pattern. For example:
9354 .code
9355 deny senders = enemy.domain : *.enemy.domain
9356 .endd
9357
9358 The following kinds of more complicated address list pattern can match any
9359 address, including the empty address that is characteristic of bounce message
9360 senders:
9361
9362 .ilist
9363 .cindex "regular expressions" "in address list"
9364 .cindex "address list" "regular expression in"
9365 If (after expansion) a pattern starts with &"^"&, a regular expression match is
9366 done against the complete address, with the pattern as the regular expression.
9367 You must take care that backslash and dollar characters are not misinterpreted
9368 as part of the string expansion. The simplest way to do this is to use &`\N`&
9369 to mark that part of the string as non-expandable. For example:
9370 .code
9371 deny senders = \N^.*this.*@example\.com$\N : \
9372                \N^\d{8}.+@spamhaus.example$\N : ...
9373 .endd
9374 The &`\N`& sequences are removed by the expansion, so these items do indeed
9375 start with &"^"& by the time they are being interpreted as address patterns.
9376
9377 .next
9378 .cindex "address list" "lookup for complete address"
9379 Complete addresses can be looked up by using a pattern that starts with a
9380 lookup type terminated by a semicolon, followed by the data for the lookup. For
9381 example:
9382 .code
9383 deny senders = cdb;/etc/blocked.senders : \
9384   mysql;select address from blocked where \
9385   address='${quote_mysql:$sender_address}'
9386 .endd
9387 Both query-style and single-key lookup types can be used. For a single-key
9388 lookup type, Exim uses the complete address as the key. However, empty keys are
9389 not supported for single-key lookups, so a match against the empty address
9390 always fails. This restriction does not apply to query-style lookups.
9391
9392 Partial matching for single-key lookups (section &<<SECTpartiallookup>>&)
9393 cannot be used, and is ignored if specified, with an entry being written to the
9394 panic log.
9395 .cindex "*@ with single-key lookup"
9396 However, you can configure lookup defaults, as described in section
9397 &<<SECTdefaultvaluelookups>>&, but this is useful only for the &"*@"& type of
9398 default. For example, with this lookup:
9399 .code
9400 accept senders = lsearch*@;/some/file
9401 .endd
9402 the file could contains lines like this:
9403 .code
9404 user1@domain1.example
9405 *@domain2.example
9406 .endd
9407 and for the sender address &'nimrod@jaeger.example'&, the sequence of keys
9408 that are tried is:
9409 .code
9410 nimrod@jaeger.example
9411 *@jaeger.example
9412 *
9413 .endd
9414 &*Warning 1*&: Do not include a line keyed by &"*"& in the file, because that
9415 would mean that every address matches, thus rendering the test useless.
9416
9417 &*Warning 2*&: Do not confuse these two kinds of item:
9418 .code
9419 deny recipients = dbm*@;/some/file
9420 deny recipients = *@dbm;/some/file
9421 .endd
9422 The first does a whole address lookup, with defaulting, as just described,
9423 because it starts with a lookup type. The second matches the local part and
9424 domain independently, as described in a bullet point below.
9425 .endlist
9426
9427
9428 The following kinds of address list pattern can match only non-empty addresses.
9429 If the subject address is empty, a match against any of these pattern types
9430 always fails.
9431
9432
9433 .ilist
9434 .cindex "@@ with single-key lookup"
9435 .cindex "address list" "@@ lookup type"
9436 .cindex "address list" "split local part and domain"
9437 If a pattern starts with &"@@"& followed by a single-key lookup item
9438 (for example, &`@@lsearch;/some/file`&), the address that is being checked is
9439 split into a local part and a domain. The domain is looked up in the file. If
9440 it is not found, there is no match. If it is found, the data that is looked up
9441 from the file is treated as a colon-separated list of local part patterns, each
9442 of which is matched against the subject local part in turn.
9443
9444 .cindex "asterisk" "in address list"
9445 The lookup may be a partial one, and/or one involving a search for a default
9446 keyed by &"*"& (see section &<<SECTdefaultvaluelookups>>&). The local part
9447 patterns that are looked up can be regular expressions or begin with &"*"&, or
9448 even be further lookups. They may also be independently negated. For example,
9449 with
9450 .code
9451 deny senders = @@dbm;/etc/reject-by-domain
9452 .endd
9453 the data from which the DBM file is built could contain lines like
9454 .code
9455 baddomain.com:  !postmaster : *
9456 .endd
9457 to reject all senders except &%postmaster%& from that domain.
9458
9459 .cindex "local part" "starting with !"
9460 If a local part that actually begins with an exclamation mark is required, it
9461 has to be specified using a regular expression. In &(lsearch)& files, an entry
9462 may be split over several lines by indenting the second and subsequent lines,
9463 but the separating colon must still be included at line breaks. White space
9464 surrounding the colons is ignored. For example:
9465 .code
9466 aol.com:  spammer1 : spammer2 : ^[0-9]+$ :
9467   spammer3 : spammer4
9468 .endd
9469 As in all colon-separated lists in Exim, a colon can be included in an item by
9470 doubling.
9471
9472 If the last item in the list starts with a right angle-bracket, the remainder
9473 of the item is taken as a new key to look up in order to obtain a continuation
9474 list of local parts. The new key can be any sequence of characters. Thus one
9475 might have entries like
9476 .code
9477 aol.com: spammer1 : spammer 2 : >*
9478 xyz.com: spammer3 : >*
9479 *:       ^\d{8}$
9480 .endd
9481 in a file that was searched with &%@@dbm*%&, to specify a match for 8-digit
9482 local parts for all domains, in addition to the specific local parts listed for
9483 each domain. Of course, using this feature costs another lookup each time a
9484 chain is followed, but the effort needed to maintain the data is reduced.
9485
9486 .cindex "loop" "in lookups"
9487 It is possible to construct loops using this facility, and in order to catch
9488 them, the chains may be no more than fifty items long.
9489
9490 .next
9491 The @@<&'lookup'&> style of item can also be used with a query-style
9492 lookup, but in this case, the chaining facility is not available. The lookup
9493 can only return a single list of local parts.
9494 .endlist
9495
9496 &*Warning*&: There is an important difference between the address list items
9497 in these two examples:
9498 .code
9499 senders = +my_list
9500 senders = *@+my_list
9501 .endd
9502 In the first one, &`my_list`& is a named address list, whereas in the second
9503 example it is a named domain list.
9504
9505
9506
9507
9508 .subsection "Case of letters in address lists" SECTcasletadd
9509 .cindex "case of local parts"
9510 .cindex "address list" "case forcing"
9511 .cindex "case forcing in address lists"
9512 Domains in email addresses are always handled caselessly, but for local parts
9513 case may be significant on some systems (see &%caseful_local_part%& for how
9514 Exim deals with this when routing addresses). However, RFC 2505 (&'Anti-Spam
9515 Recommendations for SMTP MTAs'&) suggests that matching of addresses to
9516 blocking lists should be done in a case-independent manner. Since most address
9517 lists in Exim are used for this kind of control, Exim attempts to do this by
9518 default.
9519
9520 The domain portion of an address is always lowercased before matching it to an
9521 address list. The local part is lowercased by default, and any string
9522 comparisons that take place are done caselessly. This means that the data in
9523 the address list itself, in files included as plain filenames, and in any file
9524 that is looked up using the &"@@"& mechanism, can be in any case. However, the
9525 keys in files that are looked up by a search type other than &(lsearch)& (which
9526 works caselessly) must be in lower case, because these lookups are not
9527 case-independent.
9528
9529 .cindex "&`+caseful`&"
9530 To allow for the possibility of caseful address list matching, if an item in
9531 an address list is the string &"+caseful"&, the original case of the local
9532 part is restored for any comparisons that follow, and string comparisons are no
9533 longer case-independent. This does not affect the domain, which remains in
9534 lower case. However, although independent matches on the domain alone are still
9535 performed caselessly, regular expressions that match against an entire address
9536 become case-sensitive after &"+caseful"& has been seen.
9537
9538
9539
9540 .section "Local part lists" "SECTlocparlis"
9541 .cindex "list" "local part list"
9542 .cindex "local part" "list"
9543 These behave in the same way as domain and host lists, with the following
9544 changes:
9545
9546 Case-sensitivity in local part lists is handled in the same way as for address
9547 lists, as just described. The &"+caseful"& item can be used if required. In a
9548 setting of the &%local_parts%& option in a router with &%caseful_local_part%&
9549 set false, the subject is lowercased and the matching is initially
9550 case-insensitive. In this case, &"+caseful"& will restore case-sensitive
9551 matching in the local part list, but not elsewhere in the router. If
9552 &%caseful_local_part%& is set true in a router, matching in the &%local_parts%&
9553 option is case-sensitive from the start.
9554
9555 If a local part list is indirected to a file (see section &<<SECTfilnamlis>>&),
9556 comments are handled in the same way as address lists &-- they are recognized
9557 only if the # is preceded by white space or the start of the line.
9558 Otherwise, local part lists are matched in the same way as domain lists, except
9559 that the special items that refer to the local host (&`@`&, &`@[]`&,
9560 &`@mx_any`&, &`@mx_primary`&, and &`@mx_secondary`&) are not recognized.
9561 Refer to section &<<SECTdomainlist>>& for details of the other available item
9562 types.
9563 .ecindex IIDdohoadli
9564
9565
9566
9567
9568 . ////////////////////////////////////////////////////////////////////////////
9569 . ////////////////////////////////////////////////////////////////////////////
9570
9571 .chapter "String expansions" "CHAPexpand"
9572 .scindex IIDstrexp "expansion" "of strings"
9573 Many strings in Exim's runtime configuration are expanded before use. Some of
9574 them are expanded every time they are used; others are expanded only once.
9575
9576 When a string is being expanded it is copied verbatim from left to right except
9577 .cindex expansion "string concatenation"
9578 when a dollar or backslash character is encountered. A dollar specifies the
9579 start of a portion of the string that is interpreted and replaced as described
9580 below in section &<<SECTexpansionitems>>& onwards. Backslash is used as an
9581 escape character, as described in the following section.
9582
9583 .cindex "tainted data" tracking
9584 If any porttion of the result string is tainted, the entire result is.
9585
9586 Whether a string is expanded depends upon the context.  Usually this is solely
9587 dependent upon the option for which a value is sought; in this documentation,
9588 options for which string expansion is performed are marked with &dagger; after
9589 the data type.  ACL rules always expand strings.  A couple of expansion
9590 conditions do not expand some of the brace-delimited branches, for security
9591 reasons,
9592 .cindex "tainted data" expansion
9593 .cindex "tainted data" definition
9594 .cindex expansion "tainted data"
9595 and expansion of data deriving from the sender (&"tainted data"&)
9596 is not permitted (including acessing a file using a tainted name).
9597
9598 Common ways of obtaining untainted equivalents of variables with
9599 tainted values
9600 .cindex "tainted data" "de-tainting"
9601 come down to using the tainted value as a lookup key in a trusted database.
9602 This database could be the filesystem structure,
9603 or the password file,
9604 or accessed via a DBMS.
9605 Specific methods are indexed under &"de-tainting"&.
9606
9607
9608
9609 .section "Literal text in expanded strings" "SECTlittext"
9610 .cindex "expansion" "including literal text"
9611 An uninterpreted dollar can be included in an expanded string by putting a
9612 backslash in front of it. A backslash can be used to prevent any special
9613 character being treated specially in an expansion, including backslash itself.
9614 If the string appears in quotes in the configuration file, two backslashes are
9615 required because the quotes themselves cause interpretation of backslashes when
9616 the string is read in (see section &<<SECTstrings>>&).
9617
9618 .cindex "expansion" "non-expandable substrings"
9619 A portion of the string can specified as non-expandable by placing it between
9620 two occurrences of &`\N`&. This is particularly useful for protecting regular
9621 expressions, which often contain backslashes and dollar signs. For example:
9622 .code
9623 deny senders = \N^\d{8}[a-z]@some\.site\.example$\N
9624 .endd
9625 On encountering the first &`\N`&, the expander copies subsequent characters
9626 without interpretation until it reaches the next &`\N`& or the end of the
9627 string.
9628
9629
9630
9631 .section "Character escape sequences in expanded strings" "SECID82"
9632 .cindex "expansion" "escape sequences"
9633 A backslash followed by one of the letters &"n"&, &"r"&, or &"t"& in an
9634 expanded string is recognized as an escape sequence for the character newline,
9635 carriage return, or tab, respectively. A backslash followed by up to three
9636 octal digits is recognized as an octal encoding for a single character, and a
9637 backslash followed by &"x"& and up to two hexadecimal digits is a hexadecimal
9638 encoding.
9639
9640 These escape sequences are also recognized in quoted strings when they are read
9641 in. Their interpretation in expansions as well is useful for unquoted strings,
9642 and for other cases such as looked-up strings that are then expanded.
9643
9644
9645 .section "Testing string expansions" "SECID83"
9646 .cindex "expansion" "testing"
9647 .cindex "testing" "string expansion"
9648 .oindex "&%-be%&"
9649 Many expansions can be tested by calling Exim with the &%-be%& option. This
9650 takes the command arguments, or lines from the standard input if there are no
9651 arguments, runs them through the string expansion code, and writes the results
9652 to the standard output. Variables based on configuration values are set up, but
9653 since no message is being processed, variables such as &$local_part$& have no
9654 value. Nevertheless the &%-be%& option can be useful for checking out file and
9655 database lookups, and the use of expansion operators such as &%sg%&, &%substr%&
9656 and &%nhash%&.
9657
9658 When reading lines from the standard input,
9659 macros can be defined and ACL variables can be set.
9660 For example:
9661 .code
9662 MY_MACRO = foo
9663 set acl_m_myvar = bar
9664 .endd
9665 Such macros and variables can then be used in later input lines.
9666
9667 Exim gives up its root privilege when it is called with the &%-be%& option, and
9668 instead runs under the uid and gid it was called with, to prevent users from
9669 using &%-be%& for reading files to which they do not have access.
9670
9671 .oindex "&%-bem%&"
9672 If you want to test expansions that include variables whose values are taken
9673 from a message, there are two other options that can be used. The &%-bem%&
9674 option is like &%-be%& except that it is followed by a filename. The file is
9675 read as a message before doing the test expansions. For example:
9676 .code
9677 exim -bem /tmp/test.message '$h_subject:'
9678 .endd
9679 The &%-Mset%& option is used in conjunction with &%-be%& and is followed by an
9680 Exim message identifier. For example:
9681 .code
9682 exim -be -Mset 1GrA8W-0004WS-LQ '$recipients'
9683 .endd
9684 This loads the message from Exim's spool before doing the test expansions, and
9685 is therefore restricted to admin users.
9686
9687
9688 .section "Forced expansion failure" "SECTforexpfai"
9689 .cindex "expansion" "forced failure"
9690 A number of expansions that are described in the following section have
9691 alternative &"true"& and &"false"& substrings, enclosed in brace characters
9692 (which are sometimes called &"curly brackets"&). Which of the two strings is
9693 used depends on some condition that is evaluated as part of the expansion. If,
9694 instead of a &"false"& substring, the word &"fail"& is used (not in braces),
9695 the entire string expansion fails in a way that can be detected by the code
9696 that requested the expansion. This is called &"forced expansion failure"&, and
9697 its consequences depend on the circumstances. In some cases it is no different
9698 from any other expansion failure, but in others a different action may be
9699 taken. Such variations are mentioned in the documentation of the option that is
9700 being expanded.
9701
9702
9703
9704
9705 .section "Expansion items" "SECTexpansionitems"
9706 The following items are recognized in expanded strings. White space may be used
9707 between sub-items that are keywords or substrings enclosed in braces inside an
9708 outer set of braces, to improve readability. &*Warning*&: Within braces,
9709 white space is significant.
9710
9711 .vlist
9712 .vitem &*$*&<&'variable&~name'&>&~or&~&*${*&<&'variable&~name'&>&*}*&
9713 .cindex "expansion" "variables"
9714 Substitute the contents of the named variable, for example:
9715 .code
9716 $local_part
9717 ${domain}
9718 .endd
9719 The second form can be used to separate the name from subsequent alphanumeric
9720 characters. This form (using braces) is available only for variables; it does
9721 &'not'& apply to message headers. The names of the variables are given in
9722 section &<<SECTexpvar>>& below. If the name of a non-existent variable is
9723 given, the expansion fails.
9724
9725 .vitem &*${*&<&'op'&>&*:*&<&'string'&>&*}*&
9726 .cindex "expansion" "operators"
9727 The string is first itself expanded, and then the operation specified by
9728 <&'op'&> is applied to it. For example:
9729 .code
9730 ${lc:$local_part}
9731 .endd
9732 The string starts with the first character after the colon, which may be
9733 leading white space. A list of operators is given in section &<<SECTexpop>>&
9734 below. The operator notation is used for simple expansion items that have just
9735 one argument, because it reduces the number of braces and therefore makes the
9736 string easier to understand.
9737
9738 .vitem &*$bheader_*&<&'header&~name'&>&*:*&&~or&~&*$bh_*&<&'header&~name'&>&*:*&
9739 This item inserts &"basic"& header lines. It is described with the &%header%&
9740 expansion item below.
9741
9742
9743 .vitem "&*${acl{*&<&'name'&>&*}{*&<&'arg'&>&*}...}*&"
9744 .cindex "expansion" "calling an acl"
9745 .cindex "&%acl%&" "call from expansion"
9746 The name and zero to nine argument strings are first expanded separately.  The expanded
9747 arguments are assigned to the variables &$acl_arg1$& to &$acl_arg9$& in order.
9748 Any unused are made empty.  The variable &$acl_narg$& is set to the number of
9749 arguments.  The named ACL (see chapter &<<CHAPACL>>&) is called
9750 and may use the variables; if another acl expansion is used the values
9751 are restored after it returns.  If the ACL sets
9752 a value using a "message =" modifier and returns accept or deny, the value becomes
9753 the result of the expansion.
9754 If no message is set and the ACL returns accept or deny
9755 the expansion result is an empty string.
9756 If the ACL returns defer the result is a forced-fail.  Otherwise the expansion fails.
9757
9758
9759 .vitem "&*${authresults{*&<&'authserv-id'&>&*}}*&"
9760 .cindex authentication "results header"
9761 .chindex Authentication-Results:
9762 .cindex authentication "expansion item"
9763 This item returns a string suitable for insertion as an
9764 &'Authentication-Results:'&
9765 header line.
9766 The given <&'authserv-id'&> is included in the result; typically this
9767 will be a domain name identifying the system performing the authentications.
9768 Methods that might be present in the result include:
9769 .code
9770 none
9771 iprev
9772 auth
9773 spf
9774 dkim
9775 .endd
9776
9777 Example use (as an ACL modifier):
9778 .code
9779       add_header = :at_start:${authresults {$primary_hostname}}
9780 .endd
9781 This is safe even if no authentication results are available
9782 and would generally be placed in the DATA ACL.
9783
9784
9785 .vitem "&*${certextract{*&<&'field'&>&*}{*&<&'certificate'&>&*}&&&
9786        {*&<&'string2'&>&*}{*&<&'string3'&>&*}}*&"
9787 .cindex "expansion" "extracting certificate fields"
9788 .cindex "&%certextract%&" "certificate fields"
9789 .cindex "certificate" "extracting fields"
9790 The <&'certificate'&> must be a variable of type certificate.
9791 The field name is expanded and used to retrieve the relevant field from
9792 the certificate.  Supported fields are:
9793 .display
9794 &`version        `&
9795 &`serial_number  `&
9796 &`subject        `& RFC4514 DN
9797 &`issuer         `& RFC4514 DN
9798 &`notbefore      `& time
9799 &`notafter       `& time
9800 &`sig_algorithm  `&
9801 &`signature      `&
9802 &`subj_altname   `& tagged list
9803 &`ocsp_uri       `& list
9804 &`crl_uri        `& list
9805 .endd
9806 If the field is found,
9807 <&'string2'&> is expanded, and replaces the whole item;
9808 otherwise <&'string3'&> is used. During the expansion of <&'string2'&> the
9809 variable &$value$& contains the value that has been extracted. Afterwards, it
9810 is restored to any previous value it might have had.
9811
9812 If {<&'string3'&>} is omitted, the item is replaced by an empty string if the
9813 key is not found. If {<&'string2'&>} is also omitted, the value that was
9814 extracted is used.
9815
9816 Some field names take optional modifiers, appended and separated by commas.
9817
9818 The field selectors marked as "RFC4514" above
9819 output a Distinguished Name string which is
9820 not quite
9821 parseable by Exim as a comma-separated tagged list
9822 (the exceptions being elements containing commas).
9823 RDN elements of a single type may be selected by
9824 a modifier of the type label; if so the expansion
9825 result is a list (newline-separated by default).
9826 The separator may be changed by another modifier of
9827 a right angle-bracket followed immediately by the new separator.
9828 Recognised RDN type labels include "CN", "O", "OU" and "DC".
9829
9830 The field selectors marked as "time" above
9831 take an optional modifier of "int"
9832 for which the result is the number of seconds since epoch.
9833 Otherwise the result is a human-readable string
9834 in the timezone selected by the main "timezone" option.
9835
9836 The field selectors marked as "list" above return a list,
9837 newline-separated by default,
9838 (embedded separator characters in elements are doubled).
9839 The separator may be changed by a modifier of
9840 a right angle-bracket followed immediately by the new separator.
9841
9842 The field selectors marked as "tagged" above
9843 prefix each list element with a type string and an equals sign.
9844 Elements of only one type may be selected by a modifier
9845 which is one of "dns", "uri" or "mail";
9846 if so the element tags are omitted.
9847
9848 If not otherwise noted field values are presented in human-readable form.
9849
9850 .vitem "&*${dlfunc{*&<&'file'&>&*}{*&<&'function'&>&*}{*&<&'arg'&>&*}&&&
9851        {*&<&'arg'&>&*}...}*&"
9852 .cindex &%dlfunc%&
9853 This expansion dynamically loads and then calls a locally-written C function.
9854 This functionality is available only if Exim is compiled with
9855 .code
9856 EXPAND_DLFUNC=yes
9857 .endd
9858 set in &_Local/Makefile_&. Once loaded, Exim remembers the dynamically loaded
9859 object so that it doesn't reload the same object file in the same Exim process
9860 (but of course Exim does start new processes frequently).
9861
9862 There may be from zero to eight arguments to the function.
9863
9864 When compiling
9865 a local function that is to be called in this way,
9866 first &_DLFUNC_IMPL_& should be defined,
9867 and second &_local_scan.h_& should be included.
9868 The Exim variables and functions that are defined by that API
9869 are also available for dynamically loaded functions. The function itself
9870 must have the following type:
9871 .code
9872 int dlfunction(uschar **yield, int argc, uschar *argv[])
9873 .endd
9874 Where &`uschar`& is a typedef for &`unsigned char`& in &_local_scan.h_&. The
9875 function should return one of the following values:
9876
9877 &`OK`&: Success. The string that is placed in the variable &'yield'& is put
9878 into the expanded string that is being built.
9879
9880 &`FAIL`&: A non-forced expansion failure occurs, with the error message taken
9881 from &'yield'&, if it is set.
9882
9883 &`FAIL_FORCED`&: A forced expansion failure occurs, with the error message
9884 taken from &'yield'& if it is set.
9885
9886 &`ERROR`&: Same as &`FAIL`&, except that a panic log entry is written.
9887
9888 When compiling a function that is to be used in this way with gcc,
9889 you need to add &%-shared%& to the gcc command. Also, in the Exim build-time
9890 configuration, you must add &%-export-dynamic%& to EXTRALIBS.
9891
9892
9893 .vitem "&*${env{*&<&'key'&>&*}{*&<&'string1'&>&*}{*&<&'string2'&>&*}}*&"
9894 .cindex "expansion" "extracting value from environment"
9895 .cindex "environment" "values from"
9896 The key is first expanded separately, and leading and trailing white space
9897 removed.
9898 This is then searched for as a name in the environment.
9899 If a variable is found then its value is placed in &$value$&
9900 and <&'string1'&> is expanded, otherwise <&'string2'&> is expanded.
9901
9902 Instead of {<&'string2'&>} the word &"fail"& (not in curly brackets) can
9903 appear, for example:
9904 .code
9905 ${env{USER}{$value} fail }
9906 .endd
9907 This forces an expansion failure (see section &<<SECTforexpfai>>&);
9908 {<&'string1'&>} must be present for &"fail"& to be recognized.
9909
9910 If {<&'string2'&>} is omitted an empty string is substituted on
9911 search failure.
9912 If {<&'string1'&>} is omitted the search result is substituted on
9913 search success.
9914
9915 The environment is adjusted by the &%keep_environment%& and
9916 &%add_environment%& main section options.
9917
9918
9919 .vitem "&*${extract{*&<&'key'&>&*}{*&<&'string1'&>&*}{*&<&'string2'&>&*}&&&
9920        {*&<&'string3'&>&*}}*&"
9921 .cindex "expansion" "extracting substrings by key"
9922 .cindex "&%extract%&" "substrings by key"
9923 The key and <&'string1'&> are first expanded separately. Leading and trailing
9924 white space is removed from the key (but not from any of the strings). The key
9925 must not be empty and must not consist entirely of digits.
9926 The expanded <&'string1'&> must be of the form:
9927 .display
9928 <&'key1'&> = <&'value1'&>  <&'key2'&> = <&'value2'&> ...
9929 .endd
9930 .vindex "&$value$&"
9931 where the equals signs and spaces (but not both) are optional. If any of the
9932 values contain white space, they must be enclosed in double quotes, and any
9933 values that are enclosed in double quotes are subject to escape processing as
9934 described in section &<<SECTstrings>>&. The expanded <&'string1'&> is searched
9935 for the value that corresponds to the key. The search is case-insensitive. If
9936 the key is found, <&'string2'&> is expanded, and replaces the whole item;
9937 otherwise <&'string3'&> is used. During the expansion of <&'string2'&> the
9938 variable &$value$& contains the value that has been extracted. Afterwards, it
9939 is restored to any previous value it might have had.
9940
9941 If {<&'string3'&>} is omitted, the item is replaced by an empty string if the
9942 key is not found. If {<&'string2'&>} is also omitted, the value that was
9943 extracted is used. Thus, for example, these two expansions are identical, and
9944 yield &"2001"&:
9945 .code
9946 ${extract{gid}{uid=1984 gid=2001}}
9947 ${extract{gid}{uid=1984 gid=2001}{$value}}
9948 .endd
9949 Instead of {<&'string3'&>} the word &"fail"& (not in curly brackets) can
9950 appear, for example:
9951 .code
9952 ${extract{Z}{A=... B=...}{$value} fail }
9953 .endd
9954 This forces an expansion failure (see section &<<SECTforexpfai>>&);
9955 {<&'string2'&>} must be present for &"fail"& to be recognized.
9956
9957 .vitem "&*${extract json{*&<&'key'&>&*}{*&<&'string1'&>&*}{*&<&'string2'&>&*}&&&
9958        {*&<&'string3'&>&*}}*&" &&&
9959        "&*${extract jsons{*&<&'key'&>&*}{*&<&'string1'&>&*}{*&<&'string2'&>&*}&&&
9960        {*&<&'string3'&>&*}}*&"
9961 .cindex "expansion" "extracting from JSON object"
9962 .cindex JSON expansions
9963 The key and <&'string1'&> are first expanded separately. Leading and trailing
9964 white space is removed from the key (but not from any of the strings). The key
9965 must not be empty and must not consist entirely of digits.
9966 The expanded <&'string1'&> must be of the form:
9967 .display
9968 { <&'"key1"'&> : <&'value1'&> ,  <&'"key2"'&> , <&'value2'&> ... }
9969 .endd
9970 .vindex "&$value$&"
9971 The braces, commas and colons, and the quoting of the member name are required;
9972 the spaces are optional.
9973 Matching of the key against the member names is done case-sensitively.
9974 For the &"json"& variant,
9975 if a returned value is a JSON string, it retains its leading and
9976 trailing quotes.
9977 For the &"jsons"& variant, which is intended for use with JSON strings, the
9978 leading and trailing quotes are removed from the returned value.
9979 . XXX should be a UTF-8 compare
9980
9981 The results of matching are handled as above.
9982
9983
9984 .vitem "&*${extract{*&<&'number'&>&*}{*&<&'separators'&>&*}&&&
9985         {*&<&'string1'&>&*}{*&<&'string2'&>&*}{*&<&'string3'&>&*}}*&"
9986 .cindex "expansion" "extracting substrings by number"
9987 .cindex "&%extract%&" "substrings by number"
9988 The <&'number'&> argument must consist entirely of decimal digits,
9989 apart from leading and trailing white space, which is ignored.
9990 This is what distinguishes this form of &%extract%& from the previous kind. It
9991 behaves in the same way, except that, instead of extracting a named field, it
9992 extracts from <&'string1'&> the field whose number is given as the first
9993 argument. You can use &$value$& in <&'string2'&> or &`fail`& instead of
9994 <&'string3'&> as before.
9995
9996 The fields in the string are separated by any one of the characters in the
9997 separator string. These may include space or tab characters.
9998 The first field is numbered one. If the number is negative, the fields are
9999 counted from the end of the string, with the rightmost one numbered -1. If the
10000 number given is zero, the entire string is returned. If the modulus of the
10001 number is greater than the number of fields in the string, the result is the
10002 expansion of <&'string3'&>, or the empty string if <&'string3'&> is not
10003 provided. For example:
10004 .code
10005 ${extract{2}{:}{x:42:99:& Mailer::/bin/bash}}
10006 .endd
10007 yields &"42"&, and
10008 .code
10009 ${extract{-4}{:}{x:42:99:& Mailer::/bin/bash}}
10010 .endd
10011 yields &"99"&. Two successive separators mean that the field between them is
10012 empty (for example, the fifth field above).
10013
10014
10015 .vitem "&*${extract json {*&<&'number'&>&*}}&&&
10016         {*&<&'string1'&>&*}{*&<&'string2'&>&*}{*&<&'string3'&>&*}}*&" &&&
10017        "&*${extract jsons{*&<&'number'&>&*}}&&&
10018         {*&<&'string1'&>&*}{*&<&'string2'&>&*}{*&<&'string3'&>&*}}*&"
10019 .cindex "expansion" "extracting from JSON array"
10020 .cindex JSON expansions
10021 The <&'number'&> argument must consist entirely of decimal digits,
10022 apart from leading and trailing white space, which is ignored.
10023
10024 Field selection and result handling is as above;
10025 there is no choice of field separator.
10026 For the &"json"& variant,
10027 if a returned value is a JSON string, it retains its leading and
10028 trailing quotes.
10029 For the &"jsons"& variant, which is intended for use with JSON strings, the
10030 leading and trailing quotes are removed from the returned value.
10031
10032
10033 .vitem &*${filter{*&<&'string'&>&*}{*&<&'condition'&>&*}}*&
10034 .cindex "list" "selecting by condition"
10035 .cindex "expansion" "selecting from list by condition"
10036 .vindex "&$item$&"
10037 After expansion, <&'string'&> is interpreted as a list, colon-separated by
10038 default, but the separator can be changed in the usual way (&<<SECTlistsepchange>>&).
10039 For each item
10040 in this list, its value is placed in &$item$&, and then the condition is
10041 evaluated.
10042 Any modification of &$value$& by this evaluation is discarded.
10043 If the condition is true, &$item$& is added to the output as an
10044 item in a new list; if the condition is false, the item is discarded. The
10045 separator used for the output list is the same as the one used for the
10046 input, but a separator setting is not included in the output. For example:
10047 .code
10048 ${filter{a:b:c}{!eq{$item}{b}}}
10049 .endd
10050 yields &`a:c`&. At the end of the expansion, the value of &$item$& is restored
10051 to what it was before.
10052 See also the &%map%& and &%reduce%& expansion items.
10053
10054
10055 .vitem &*${hash{*&<&'string1'&>&*}{*&<&'string2'&>&*}{*&<&'string3'&>&*}}*&
10056 .cindex "hash function" "textual"
10057 .cindex "expansion" "textual hash"
10058 This is a textual hashing function, and was the first to be implemented in
10059 early versions of Exim. In current releases, there are other hashing functions
10060 (numeric, MD5, and SHA-1), which are described below.
10061
10062 The first two strings, after expansion, must be numbers. Call them <&'m'&> and
10063 <&'n'&>. If you are using fixed values for these numbers, that is, if
10064 <&'string1'&> and <&'string2'&> do not change when they are expanded, you can
10065 use the simpler operator notation that avoids some of the braces:
10066 .code
10067 ${hash_<n>_<m>:<string>}
10068 .endd
10069 The second number is optional (in both notations). If <&'n'&> is greater than
10070 or equal to the length of the string, the expansion item returns the string.
10071 Otherwise it computes a new string of length <&'n'&> by applying a hashing
10072 function to the string. The new string consists of characters taken from the
10073 first <&'m'&> characters of the string
10074 .code
10075 abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQWRSTUVWXYZ0123456789
10076 .endd
10077 If <&'m'&> is not present the value 26 is used, so that only lower case
10078 letters appear. For example:
10079 .display
10080 &`$hash{3}{monty}}           `&   yields  &`jmg`&
10081 &`$hash{5}{monty}}           `&   yields  &`monty`&
10082 &`$hash{4}{62}{monty python}}`&   yields  &`fbWx`&
10083 .endd
10084
10085 .vitem "&*$header_*&<&'header&~name'&>&*:*&&~or&~&&&
10086         &*$h_*&<&'header&~name'&>&*:*&" &&&
10087        "&*$bheader_*&<&'header&~name'&>&*:*&&~or&~&&&
10088         &*$bh_*&<&'header&~name'&>&*:*&" &&&
10089        "&*$lheader_*&<&'header&~name'&>&*:*&&~or&~&&&
10090         &*$lh_*&<&'header&~name'&>&*:*&" &&&
10091        "&*$rheader_*&<&'header&~name'&>&*:*&&~or&~&&&
10092         &*$rh_*&<&'header&~name'&>&*:*&"
10093 .cindex "expansion" "header insertion"
10094 .vindex "&$header_$&"
10095 .vindex "&$bheader_$&"
10096 .vindex "&$lheader_$&"
10097 .vindex "&$rheader_$&"
10098 .cindex "header lines" "in expansion strings"
10099 .cindex "header lines" "character sets"
10100 .cindex "header lines" "decoding"
10101 Substitute the contents of the named message header line, for example
10102 .code
10103 $header_reply-to:
10104 .endd
10105 The newline that terminates a header line is not included in the expansion, but
10106 internal newlines (caused by splitting the header line over several physical
10107 lines) may be present.
10108
10109 The difference between the four pairs of expansions is in the way
10110 the data in the header line is interpreted.
10111
10112 .ilist
10113 .cindex "white space" "in header lines"
10114 &%rheader%& gives the original &"raw"& content of the header line, with no
10115 processing at all, and without the removal of leading and trailing white space.
10116
10117 .next
10118 .cindex "list" "of header lines"
10119 &%lheader%& gives a colon-separated list, one element per header when there
10120 are multiple headers with a given name.
10121 Any embedded colon characters within an element are doubled, so normal Exim
10122 list-processing facilities can be used.
10123 The terminating newline of each element is removed; in other respects
10124 the content is &"raw"&.
10125
10126 .next
10127 .cindex "base64 encoding" "in header lines"
10128 &%bheader%& removes leading and trailing white space, and then decodes base64
10129 or quoted-printable MIME &"words"& within the header text, but does no
10130 character set translation. If decoding of what looks superficially like a MIME
10131 &"word"& fails, the raw string is returned. If decoding
10132 .cindex "binary zero" "in header line"
10133 produces a binary zero character, it is replaced by a question mark &-- this is
10134 what Exim does for binary zeros that are actually received in header lines.
10135
10136 .next
10137 &%header%& tries to translate the string as decoded by &%bheader%& to a
10138 standard character set. This is an attempt to produce the same string as would
10139 be displayed on a user's MUA. If translation fails, the &%bheader%& string is
10140 returned. Translation is attempted only on operating systems that support the
10141 &[iconv()]& function. This is indicated by the compile-time macro HAVE_ICONV in
10142 a system Makefile or in &_Local/Makefile_&.
10143 .endlist ilist
10144
10145 In a filter file, the target character set for &%header%& can be specified by a
10146 command of the following form:
10147 .code
10148 headers charset "UTF-8"
10149 .endd
10150 This command affects all references to &$h_$& (or &$header_$&) expansions in
10151 subsequently obeyed filter commands. In the absence of this command, the target
10152 character set in a filter is taken from the setting of the &%headers_charset%&
10153 option in the runtime configuration. The value of this option defaults to the
10154 value of HEADERS_CHARSET in &_Local/Makefile_&. The ultimate default is
10155 ISO-8859-1.
10156
10157 Header names follow the syntax of RFC 2822, which states that they may contain
10158 any printing characters except space and colon. Consequently, curly brackets
10159 &'do not'& terminate header names, and should not be used to enclose them as
10160 if they were variables. Attempting to do so causes a syntax error.
10161
10162 Only header lines that are common to all copies of a message are visible to
10163 this mechanism. These are the original header lines that are received with the
10164 message, and any that are added by an ACL statement or by a system
10165 filter. Header lines that are added to a particular copy of a message by a
10166 router or transport are not accessible.
10167
10168 For incoming SMTP messages, no header lines are visible in
10169 ACLs that are obeyed before the data phase completes,
10170 because the header structure is not set up until the message is received.
10171 They are visible in DKIM, PRDR and DATA ACLs.
10172 Header lines that are added in a RCPT ACL (for example)
10173 are saved until the message's incoming header lines are available, at which
10174 point they are added.
10175 When any of the above ACLs are
10176 running, however, header lines added by earlier ACLs are visible.
10177
10178 Upper case and lower case letters are synonymous in header names. If the
10179 following character is white space, the terminating colon may be omitted, but
10180 this is not recommended, because you may then forget it when it is needed. When
10181 white space terminates the header name, this white space is included in the
10182 expanded string.  If the message does not contain the given header, the
10183 expansion item is replaced by an empty string. (See the &%def%& condition in
10184 section &<<SECTexpcond>>& for a means of testing for the existence of a
10185 header.)
10186
10187 If there is more than one header with the same name, they are all concatenated
10188 to form the substitution string, up to a maximum length of 64K. Unless
10189 &%rheader%& is being used, leading and trailing white space is removed from
10190 each header before concatenation, and a completely empty header is ignored. A
10191 newline character is then inserted between non-empty headers, but there is no
10192 newline at the very end. For the &%header%& and &%bheader%& expansion, for
10193 those headers that contain lists of addresses, a comma is also inserted at the
10194 junctions between headers. This does not happen for the &%rheader%& expansion.
10195
10196 .cindex "tainted data" "message headers"
10197 When the headers are from an incoming message,
10198 the result of expanding any of these variables is tainted.
10199
10200
10201 .vitem &*${hmac{*&<&'hashname'&>&*}{*&<&'secret'&>&*}{*&<&'string'&>&*}}*&
10202 .cindex "expansion" "hmac hashing"
10203 .cindex &%hmac%&
10204 This function uses cryptographic hashing (either MD5 or SHA-1) to convert a
10205 shared secret and some text into a message authentication code, as specified in
10206 RFC 2104. This differs from &`${md5:secret_text...}`& or
10207 &`${sha1:secret_text...}`& in that the hmac step adds a signature to the
10208 cryptographic hash, allowing for authentication that is not possible with MD5
10209 or SHA-1 alone. The hash name must expand to either &`md5`& or &`sha1`& at
10210 present. For example:
10211 .code
10212 ${hmac{md5}{somesecret}{$primary_hostname $tod_log}}
10213 .endd
10214 For the hostname &'mail.example.com'& and time 2002-10-17 11:30:59, this
10215 produces:
10216 .code
10217 dd97e3ba5d1a61b5006108f8c8252953
10218 .endd
10219 As an example of how this might be used, you might put in the main part of
10220 an Exim configuration:
10221 .code
10222 SPAMSCAN_SECRET=cohgheeLei2thahw
10223 .endd
10224 In a router or a transport you could then have:
10225 .code
10226 headers_add = \
10227   X-Spam-Scanned: ${primary_hostname} ${message_exim_id} \
10228   ${hmac{md5}{SPAMSCAN_SECRET}\
10229   {${primary_hostname},${message_exim_id},$h_message-id:}}
10230 .endd
10231 Then given a message, you can check where it was scanned by looking at the
10232 &'X-Spam-Scanned:'& header line. If you know the secret, you can check that
10233 this header line is authentic by recomputing the authentication code from the
10234 host name, message ID and the &'Message-id:'& header line. This can be done
10235 using Exim's &%-be%& option, or by other means, for example, by using the
10236 &'hmac_md5_hex()'& function in Perl.
10237
10238
10239 .vitem &*${if&~*&<&'condition'&>&*&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}}*&
10240 .cindex "expansion" "conditional"
10241 .cindex "&%if%&, expansion item"
10242 If <&'condition'&> is true, <&'string1'&> is expanded and replaces the whole
10243 item; otherwise <&'string2'&> is used. The available conditions are described
10244 in section &<<SECTexpcond>>& below. For example:
10245 .code
10246 ${if eq {$local_part}{postmaster} {yes}{no} }
10247 .endd
10248 The second string need not be present; if it is not and the condition is not
10249 true, the item is replaced with nothing. Alternatively, the word &"fail"& may
10250 be present instead of the second string (without any curly brackets). In this
10251 case, the expansion is forced to fail if the condition is not true (see section
10252 &<<SECTforexpfai>>&).
10253
10254 If both strings are omitted, the result is the string &`true`& if the condition
10255 is true, and the empty string if the condition is false. This makes it less
10256 cumbersome to write custom ACL and router conditions. For example, instead of
10257 .code
10258 condition = ${if >{$acl_m4}{3}{true}{false}}
10259 .endd
10260 you can use
10261 .code
10262 condition = ${if >{$acl_m4}{3}}
10263 .endd
10264
10265
10266
10267 .vitem &*${imapfolder{*&<&'foldername'&>&*}}*&
10268 .cindex expansion "imap folder"
10269 .cindex "&%imapfolder%& expansion item"
10270 This item converts a (possibly multilevel, or with non-ASCII characters)
10271 folder specification to a Maildir name for filesystem use.
10272 For information on internationalisation support see &<<SECTi18nMDA>>&.
10273
10274
10275
10276 .vitem &*${length{*&<&'string1'&>&*}{*&<&'string2'&>&*}}*&
10277 .cindex "expansion" "string truncation"
10278 .cindex "&%length%& expansion item"
10279 The &%length%& item is used to extract the initial portion of a string. Both
10280 strings are expanded, and the first one must yield a number, <&'n'&>, say. If
10281 you are using a fixed value for the number, that is, if <&'string1'&> does not
10282 change when expanded, you can use the simpler operator notation that avoids
10283 some of the braces:
10284 .code
10285 ${length_<n>:<string>}
10286 .endd
10287 The result of this item is either the first <&'n'&> bytes or the whole
10288 of <&'string2'&>, whichever is the shorter. Do not confuse &%length%& with
10289 &%strlen%&, which gives the length of a string.
10290 All measurement is done in bytes and is not UTF-8 aware.
10291
10292
10293 .vitem "&*${listextract{*&<&'number'&>&*}&&&
10294         {*&<&'string1'&>&*}{*&<&'string2'&>&*}{*&<&'string3'&>&*}}*&"
10295 .cindex "expansion" "extracting list elements by number"
10296 .cindex "&%listextract%&" "extract list elements by number"
10297 .cindex "list" "extracting elements by number"
10298 The <&'number'&> argument must consist entirely of decimal digits,
10299 apart from an optional leading minus,
10300 and leading and trailing white space (which is ignored).
10301
10302 After expansion, <&'string1'&> is interpreted as a list, colon-separated by
10303 default, but the separator can be changed in the usual way (&<<SECTlistsepchange>>&).
10304
10305 The first field of the list is numbered one.
10306 If the number is negative, the fields are
10307 counted from the end of the list, with the rightmost one numbered -1.
10308 The numbered element of the list is extracted and placed in &$value$&,
10309 then <&'string2'&> is expanded as the result.
10310
10311 If the modulus of the
10312 number is zero or greater than the number of fields in the string,
10313 the result is the expansion of <&'string3'&>.
10314
10315 For example:
10316 .code
10317 ${listextract{2}{x:42:99}}
10318 .endd
10319 yields &"42"&, and
10320 .code
10321 ${listextract{-3}{<, x,42,99,& Mailer,,/bin/bash}{result: $value}}
10322 .endd
10323 yields &"result: 42"&.
10324
10325 If {<&'string3'&>} is omitted, an empty string is used for string3.
10326 If {<&'string2'&>} is also omitted, the value that was
10327 extracted is used.
10328 You can use &`fail`& instead of {<&'string3'&>} as in a string extract.
10329
10330
10331 .vitem &*${listquote{*&<&'separator'&>&*}{*&<&'string'&>&*}}*&
10332 .cindex quoting "for list"
10333 .cindex list quoting
10334 This item doubles any occurrence of the separator character
10335 in the given string.
10336 An empty string is replaced with a single space.
10337 This converts the string into a safe form for use as a list element,
10338 in a list using the given separator.
10339
10340
10341 .vitem "&*${lookup&~{*&<&'key'&>&*}&~*&<&'search&~type'&>&*&~&&&
10342         {*&<&'file'&>&*}&~{*&<&'string1'&>&*}&~{*&<&'string2'&>&*}}*&" &&&
10343        "&*${lookup&~*&<&'search&~type'&>&*&~{*&<&'query'&>&*}&~&&&
10344         {*&<&'string1'&>&*}&~{*&<&'string2'&>&*}}*&"
10345 .cindex "expansion" "lookup in"
10346 .cindex "file" "lookups"
10347 .cindex "lookup" "in expanded string"
10348 The two forms of lookup item specify data lookups in files and databases, as
10349 discussed in chapter &<<CHAPfdlookup>>&. The first form is used for single-key
10350 lookups, and the second is used for query-style lookups. The <&'key'&>,
10351 <&'file'&>, and <&'query'&> strings are expanded before use.
10352
10353 If there is any white space in a lookup item which is part of a filter command,
10354 a retry or rewrite rule, a routing rule for the &(manualroute)& router, or any
10355 other place where white space is significant, the lookup item must be enclosed
10356 in double quotes. The use of data lookups in users' filter files may be locked
10357 out by the system administrator.
10358
10359 .vindex "&$value$&"
10360 If the lookup succeeds, <&'string1'&> is expanded and replaces the entire item.
10361 During its expansion, the variable &$value$& contains the data returned by the
10362 lookup. Afterwards it reverts to the value it had previously (at the outer
10363 level it is empty). If the lookup fails, <&'string2'&> is expanded and replaces
10364 the entire item. If {<&'string2'&>} is omitted, the replacement is the empty
10365 string on failure. If <&'string2'&> is provided, it can itself be a nested
10366 lookup, thus providing a mechanism for looking up a default value when the
10367 original lookup fails.
10368
10369 If a nested lookup is used as part of <&'string1'&>, &$value$& contains the
10370 data for the outer lookup while the parameters of the second lookup are
10371 expanded, and also while <&'string2'&> of the second lookup is expanded, should
10372 the second lookup fail. Instead of {<&'string2'&>} the word &"fail"& can
10373 appear, and in this case, if the lookup fails, the entire expansion is forced
10374 to fail (see section &<<SECTforexpfai>>&). If both {<&'string1'&>} and
10375 {<&'string2'&>} are omitted, the result is the looked up value in the case of a
10376 successful lookup, and nothing in the case of failure.
10377
10378 For single-key lookups, the string &"partial"& is permitted to precede the
10379 search type in order to do partial matching, and * or *@ may follow a search
10380 type to request default lookups if the key does not match (see sections
10381 &<<SECTdefaultvaluelookups>>& and &<<SECTpartiallookup>>& for details).
10382
10383 .cindex "numerical variables (&$1$& &$2$& etc)" "in lookup expansion"
10384 If a partial search is used, the variables &$1$& and &$2$& contain the wild
10385 and non-wild parts of the key during the expansion of the replacement text.
10386 They return to their previous values at the end of the lookup item.
10387
10388 This example looks up the postmaster alias in the conventional alias file:
10389 .code
10390 ${lookup {postmaster} lsearch {/etc/aliases} {$value}}
10391 .endd
10392 This example uses NIS+ to look up the full name of the user corresponding to
10393 the local part of an address, forcing the expansion to fail if it is not found:
10394 .code
10395 ${lookup nisplus {[name=$local_part],passwd.org_dir:gcos} \
10396   {$value}fail}
10397 .endd
10398
10399
10400 .vitem &*${map{*&<&'string1'&>&*}{*&<&'string2'&>&*}}*&
10401 .cindex "expansion" "list creation"
10402 .vindex "&$item$&"
10403 After expansion, <&'string1'&> is interpreted as a list, colon-separated by
10404 default, but the separator can be changed in the usual way (&<<SECTlistsepchange>>&).
10405 For each item
10406 in this list, its value is place in &$item$&, and then <&'string2'&> is
10407 expanded and added to the output as an item in a new list. The separator used
10408 for the output list is the same as the one used for the input, but a separator
10409 setting is not included in the output. For example:
10410 .code
10411 ${map{a:b:c}{[$item]}} ${map{<- x-y-z}{($item)}}
10412 .endd
10413 expands to &`[a]:[b]:[c] (x)-(y)-(z)`&. At the end of the expansion, the
10414 value of &$item$& is restored to what it was before. See also the &%filter%&
10415 and &%reduce%& expansion items.
10416
10417 .vitem &*${nhash{*&<&'string1'&>&*}{*&<&'string2'&>&*}{*&<&'string3'&>&*}}*&
10418 .cindex "expansion" "numeric hash"
10419 .cindex "hash function" "numeric"
10420 The three strings are expanded; the first two must yield numbers. Call them
10421 <&'n'&> and <&'m'&>. If you are using fixed values for these numbers, that is,
10422 if <&'string1'&> and <&'string2'&> do not change when they are expanded, you
10423 can use the simpler operator notation that avoids some of the braces:
10424 .code
10425 ${nhash_<n>_<m>:<string>}
10426 .endd
10427 The second number is optional (in both notations). If there is only one number,
10428 the result is a number in the range 0&--<&'n'&>-1. Otherwise, the string is
10429 processed by a div/mod hash function that returns two numbers, separated by a
10430 slash, in the ranges 0 to <&'n'&>-1 and 0 to <&'m'&>-1, respectively. For
10431 example,
10432 .code
10433 ${nhash{8}{64}{supercalifragilisticexpialidocious}}
10434 .endd
10435 returns the string &"6/33"&.
10436
10437
10438
10439 .vitem &*${perl{*&<&'subroutine'&>&*}{*&<&'arg'&>&*}{*&<&'arg'&>&*}...}*&
10440 .cindex "Perl" "use in expanded string"
10441 .cindex "expansion" "calling Perl from"
10442 This item is available only if Exim has been built to include an embedded Perl
10443 interpreter. The subroutine name and the arguments are first separately
10444 expanded, and then the Perl subroutine is called with those arguments. No
10445 additional arguments need be given; the maximum number permitted, including the
10446 name of the subroutine, is nine.
10447
10448 The return value of the subroutine is inserted into the expanded string, unless
10449 the return value is &%undef%&. In that case, the entire expansion is
10450 forced to fail, in the same way as an explicit &"fail"& on a lookup item
10451 does (see section &<<SECTforexpfai>>&).  Whatever you return is evaluated
10452 in a scalar context, thus the return value is a scalar.  For example, if you
10453 return a Perl vector, the return value is the size of the vector,
10454 not its contents.
10455
10456 If the subroutine exits by calling Perl's &%die%& function, the expansion fails
10457 with the error message that was passed to &%die%&. More details of the embedded
10458 Perl facility are given in chapter &<<CHAPperl>>&.
10459
10460 The &(redirect)& router has an option called &%forbid_filter_perl%& which locks
10461 out the use of this expansion item in filter files.
10462
10463
10464 .vitem &*${prvs{*&<&'address'&>&*}{*&<&'secret'&>&*}{*&<&'keynumber'&>&*}}*&
10465 .cindex "&%prvs%& expansion item"
10466 The first argument is a complete email address and the second is secret
10467 keystring. The third argument, specifying a key number, is optional. If absent,
10468 it defaults to 0. The result of the expansion is a prvs-signed email address,
10469 to be typically used with the &%return_path%& option on an &(smtp)& transport
10470 as part of a bounce address tag validation (BATV) scheme. For more discussion
10471 and an example, see section &<<SECTverifyPRVS>>&.
10472
10473 .vitem "&*${prvscheck{*&<&'address'&>&*}{*&<&'secret'&>&*}&&&
10474         {*&<&'string'&>&*}}*&"
10475 .cindex "&%prvscheck%& expansion item"
10476 This expansion item is the complement of the &%prvs%& item. It is used for
10477 checking prvs-signed addresses. If the expansion of the first argument does not
10478 yield a syntactically valid prvs-signed address, the whole item expands to the
10479 empty string. When the first argument does expand to a syntactically valid
10480 prvs-signed address, the second argument is expanded, with the prvs-decoded
10481 version of the address and the key number extracted from the address in the
10482 variables &$prvscheck_address$& and &$prvscheck_keynum$&, respectively.
10483
10484 These two variables can be used in the expansion of the second argument to
10485 retrieve the secret. The validity of the prvs-signed address is then checked
10486 against the secret. The result is stored in the variable &$prvscheck_result$&,
10487 which is empty for failure or &"1"& for success.
10488
10489 The third argument is optional; if it is missing, it defaults to an empty
10490 string. This argument is now expanded. If the result is an empty string, the
10491 result of the expansion is the decoded version of the address. This is the case
10492 whether or not the signature was valid. Otherwise, the result of the expansion
10493 is the expansion of the third argument.
10494
10495 All three variables can be used in the expansion of the third argument.
10496 However, once the expansion is complete, only &$prvscheck_result$& remains set.
10497 For more discussion and an example, see section &<<SECTverifyPRVS>>&.
10498
10499 .vitem &*${readfile{*&<&'file&~name'&>&*}{*&<&'eol&~string'&>&*}}*&
10500 .cindex "expansion" "inserting an entire file"
10501 .cindex "file" "inserting into expansion"
10502 .cindex "&%readfile%& expansion item"
10503 The filename and end-of-line (eol) string are first expanded separately. The file is
10504 then read, and its contents replace the entire item. All newline characters in
10505 the file are replaced by the end-of-line string if it is present. Otherwise,
10506 newlines are left in the string.
10507 String expansion is not applied to the contents of the file. If you want this,
10508 you must wrap the item in an &%expand%& operator. If the file cannot be read,
10509 the string expansion fails.
10510
10511 The &(redirect)& router has an option called &%forbid_filter_readfile%& which
10512 locks out the use of this expansion item in filter files.
10513
10514
10515
10516 .vitem "&*${readsocket{*&<&'name'&>&*}{*&<&'request'&>&*}&&&
10517         {*&<&'options'&>&*}{*&<&'eol&~string'&>&*}{*&<&'fail&~string'&>&*}}*&"
10518 .cindex "expansion" "inserting from a socket"
10519 .cindex "socket, use of in expansion"
10520 .cindex "&%readsocket%& expansion item"
10521 This item inserts data from a Unix domain or TCP socket into the expanded
10522 string. The minimal way of using it uses just two arguments, as in these
10523 examples:
10524 .code
10525 ${readsocket{/socket/name}{request string}}
10526 ${readsocket{inet:some.host:1234}{request string}}
10527 .endd
10528 For a Unix domain socket, the first substring must be the path to the socket.
10529 For an Internet socket, the first substring must contain &`inet:`& followed by
10530 a host name or IP address, followed by a colon and a port, which can be a
10531 number or the name of a TCP port in &_/etc/services_&. An IP address may
10532 optionally be enclosed in square brackets. This is best for IPv6 addresses. For
10533 example:
10534 .code
10535 ${readsocket{inet:[::1]:1234}{request string}}
10536 .endd
10537 Only a single host name may be given, but if looking it up yields more than
10538 one IP address, they are each tried in turn until a connection is made. For
10539 both kinds of socket, Exim makes a connection, writes the request string
10540 (unless it is an empty string; no terminating NUL is ever sent)
10541 and reads from the socket until an end-of-file
10542 is read. A timeout of 5 seconds is applied. Additional, optional arguments
10543 extend what can be done. Firstly, you can vary the timeout. For example:
10544 .code
10545 ${readsocket{/socket/name}{request string}{3s}}
10546 .endd
10547
10548 The third argument is a list of options, of which the first element is the timeout
10549 and must be present if any options are given.
10550 Further elements are options of form &'name=value'&.
10551 Example:
10552 .code
10553 ${readsocket{/socket/name}{request string}{3s:shutdown=no}}
10554 .endd
10555
10556 The following option names are recognised:
10557 .ilist
10558 &*cache*&
10559 Defines if the result data can be cached for use by a later identical
10560 request in the same process.
10561 Values are &"yes"& or &"no"& (the default).
10562 If not, all cached results for this connection specification
10563 will be invalidated.
10564
10565 .next
10566 &*shutdown*&
10567 Defines whether or not a write-shutdown is done on the connection after
10568 sending the request. Values are &"yes"& (the default) or &"no"&
10569 (preferred, eg. by some webservers).
10570
10571 .next
10572 &*sni*&
10573 Controls the use of Server Name Identification on the connection.
10574 Any nonempty value will be the SNI sent; TLS will be forced.
10575
10576 .next
10577 &*tls*&
10578 Controls the use of TLS on the connection.
10579 Values are &"yes"& or &"no"& (the default).
10580 If it is enabled, a shutdown as described above is never done.
10581 .endlist
10582
10583
10584 A fourth argument allows you to change any newlines that are in the data
10585 that is read, in the same way as for &%readfile%& (see above). This example
10586 turns them into spaces:
10587 .code
10588 ${readsocket{inet:127.0.0.1:3294}{request string}{3s}{ }}
10589 .endd
10590 As with all expansions, the substrings are expanded before the processing
10591 happens. Errors in these sub-expansions cause the expansion to fail. In
10592 addition, the following errors can occur:
10593
10594 .ilist
10595 Failure to create a socket file descriptor;
10596 .next
10597 Failure to connect the socket;
10598 .next
10599 Failure to write the request string;
10600 .next
10601 Timeout on reading from the socket.
10602 .endlist
10603
10604 By default, any of these errors causes the expansion to fail. However, if
10605 you supply a fifth substring, it is expanded and used when any of the above
10606 errors occurs. For example:
10607 .code
10608 ${readsocket{/socket/name}{request string}{3s}{\n}\
10609   {socket failure}}
10610 .endd
10611 You can test for the existence of a Unix domain socket by wrapping this
10612 expansion in &`${if exists`&, but there is a race condition between that test
10613 and the actual opening of the socket, so it is safer to use the fifth argument
10614 if you want to be absolutely sure of avoiding an expansion error for a
10615 non-existent Unix domain socket, or a failure to connect to an Internet socket.
10616
10617 The &(redirect)& router has an option called &%forbid_filter_readsocket%& which
10618 locks out the use of this expansion item in filter files.
10619
10620
10621 .vitem &*${reduce{*&<&'string1'&>}{<&'string2'&>&*}{*&<&'string3'&>&*}}*&
10622 .cindex "expansion" "reducing a list to a scalar"
10623 .cindex "list" "reducing to a scalar"
10624 .vindex "&$value$&"
10625 .vindex "&$item$&"
10626 This operation reduces a list to a single, scalar string. After expansion,
10627 <&'string1'&> is interpreted as a list, colon-separated by default, but the
10628 separator can be changed in the usual way (&<<SECTlistsepchange>>&).
10629 Then <&'string2'&> is expanded and
10630 assigned to the &$value$& variable. After this, each item in the <&'string1'&>
10631 list is assigned to &$item$&, in turn, and <&'string3'&> is expanded for each of
10632 them. The result of that expansion is assigned to &$value$& before the next
10633 iteration. When the end of the list is reached, the final value of &$value$& is
10634 added to the expansion output. The &%reduce%& expansion item can be used in a
10635 number of ways. For example, to add up a list of numbers:
10636 .code
10637 ${reduce {<, 1,2,3}{0}{${eval:$value+$item}}}
10638 .endd
10639 The result of that expansion would be &`6`&. The maximum of a list of numbers
10640 can be found:
10641 .code
10642 ${reduce {3:0:9:4:6}{0}{${if >{$item}{$value}{$item}{$value}}}}
10643 .endd
10644 At the end of a &*reduce*& expansion, the values of &$item$& and &$value$& are
10645 restored to what they were before. See also the &%filter%& and &%map%&
10646 expansion items.
10647
10648 . A bit of a special-case logic error in writing an expansion;
10649 . probably not worth including in the mainline of documentation.
10650 . If only we had footnotes (the html output variant is the problem).
10651 .
10652 . .new
10653 . &*Note*&: if an &'expansion condition'& is used in <&'string3'&>
10654 . and that condition modifies &$value$&,
10655 . then the string expansions dependent on the condition cannot use
10656 . the &$value$& of the reduce iteration.
10657 . .wen
10658
10659 .vitem &*$rheader_*&<&'header&~name'&>&*:*&&~or&~&*$rh_*&<&'header&~name'&>&*:*&
10660 This item inserts &"raw"& header lines. It is described with the &%header%&
10661 expansion item in section &<<SECTexpansionitems>>& above.
10662
10663 .vitem "&*${run<&'options'&> {*&<&'command&~string'&>&*}{*&<&'string1'&>&*}&&&
10664         {*&<&'string2'&>&*}}*&"
10665 .cindex "expansion" "running a command"
10666 .cindex "&%run%& expansion item"
10667 This item runs an external command, as a subprocess.
10668 One option is supported after the word &'run'&, comma-separated
10669 and without whitespace.
10670
10671 If the option &'preexpand'& is not used,
10672 the command string before expansion is split into individual arguments by spaces
10673 and then each argument is separately expanded.
10674 Then the command is run
10675 in a separate process, but under the same uid and gid.  As in other command
10676 executions from Exim, a shell is not used by default. If the command requires
10677 a shell, you must explicitly code it.
10678 The command name may not be tainted, but the remaining arguments can be.
10679
10680 &*Note*&: if tainted arguments are used, they are supplied by a
10681 potential attacker;
10682 a careful assessment for security vulnerabilities should be done.
10683
10684 If the option &'preexpand'& is used,
10685 the command string is first expanded as a whole.
10686 The expansion result is split apart into individual arguments by spaces,
10687 and then the command is run as above.
10688 Since the arguments are split by spaces, when there is a variable expansion
10689 which has an empty result, it will cause the situation that the argument will
10690 simply be omitted when the program is actually executed by Exim. If the
10691 script/program requires a specific number of arguments and the expanded
10692 variable could possibly result in this empty expansion, the variable must be
10693 quoted. This is more difficult if the expanded variable itself could result
10694 in a string containing quotes, because it would interfere with the quotes
10695 around the command arguments. A possible guard against this is to wrap the
10696 variable in the &%sg%& operator to change any quote marks to some other
10697 character.
10698 Neither the command nor any argument may be tainted.
10699
10700 The standard input for the command exists, but is empty. The standard output
10701 and standard error are set to the same file descriptor.
10702 .cindex "return code" "from &%run%& expansion"
10703 .vindex "&$value$&"
10704 If the command succeeds (gives a zero return code) <&'string1'&> is expanded
10705 and replaces the entire item; during this expansion, the standard output/error
10706 from the command is in the variable &$value$&. If the command fails,
10707 <&'string2'&>, if present, is expanded and used. Once again, during the
10708 expansion, the standard output/error from the command is in the variable
10709 &$value$&.
10710
10711 If <&'string2'&> is absent, the result is empty. Alternatively, <&'string2'&>
10712 can be the word &"fail"& (not in braces) to force expansion failure if the
10713 command does not succeed. If both strings are omitted, the result is contents
10714 of the standard output/error on success, and nothing on failure.
10715
10716 .vindex "&$run_in_acl$&"
10717 The standard output/error of the command is put in the variable &$value$&.
10718 In this ACL example, the output of a command is logged for the admin to
10719 troubleshoot:
10720 .code
10721 warn  condition    = ${run{/usr/bin/id}{yes}{no}}
10722       log_message  = Output of id: $value
10723 .endd
10724 If the command requires shell idioms, such as the > redirect operator, the
10725 shell must be invoked directly, such as with:
10726 .code
10727 ${run{/bin/bash -c "/usr/bin/id >/tmp/id"}{yes}{yes}}
10728 .endd
10729 Note that &$value$& will not persist beyond the reception of a single message.
10730
10731 .vindex "&$runrc$&"
10732 The return code from the command is put in the variable &$runrc$&, and this
10733 remains set afterwards, so in a filter file you can do things like this:
10734 .code
10735 if "${run{x y z}{}}$runrc" is 1 then ...
10736   elif $runrc is 2 then ...
10737   ...
10738 endif
10739 .endd
10740 If execution of the command fails (for example, the command does not exist),
10741 the return code is 127 &-- the same code that shells use for non-existent
10742 commands.
10743
10744 &*Warning*&: In a router or transport, you cannot assume the order in which
10745 option values are expanded, except for those preconditions whose order of
10746 testing is documented. Therefore, you cannot reliably expect to set &$runrc$&
10747 by the expansion of one option, and use it in another.
10748
10749 The &(redirect)& router has an option called &%forbid_filter_run%& which locks
10750 out the use of this expansion item in filter files.
10751
10752
10753 .vitem &*${sg{*&<&'subject'&>&*}{*&<&'regex'&>&*}{*&<&'replacement'&>&*}}*&
10754 .cindex "expansion" "string substitution"
10755 .cindex "&%sg%& expansion item"
10756 This item works like Perl's substitution operator (s) with the global (/g)
10757 option; hence its name. However, unlike the Perl equivalent, Exim does not
10758 modify the subject string; instead it returns the modified string for insertion
10759 into the overall expansion. The item takes three arguments: the subject string,
10760 a regular expression, and a substitution string. For example:
10761 .code
10762 ${sg{abcdefabcdef}{abc}{xyz}}
10763 .endd
10764 yields &"xyzdefxyzdef"&. Because all three arguments are expanded before use,
10765 if any $, } or \ characters are required in the regular expression or in the
10766 substitution string, they have to be escaped. For example:
10767 .code
10768 ${sg{abcdef}{^(...)(...)\$}{\$2\$1}}
10769 .endd
10770 yields &"defabc"&, and
10771 .code
10772 ${sg{1=A 4=D 3=C}{\N(\d+)=\N}{K\$1=}}
10773 .endd
10774 yields &"K1=A K4=D K3=C"&. Note the use of &`\N`& to protect the contents of
10775 the regular expression from string expansion.
10776
10777 The regular expression is compiled in 8-bit mode, working against bytes
10778 rather than any Unicode-aware character handling.
10779
10780
10781 .vitem &*${sort{*&<&'string'&>&*}{*&<&'comparator'&>&*}{*&<&'extractor'&>&*}}*&
10782 .cindex sorting "a list"
10783 .cindex list sorting
10784 .cindex expansion "list sorting"
10785 After expansion, <&'string'&> is interpreted as a list, colon-separated by
10786 default, but the separator can be changed in the usual way (&<<SECTlistsepchange>>&).
10787 The <&'comparator'&> argument is interpreted as the operator
10788 of a two-argument expansion condition.
10789 The numeric operators plus ge, gt, le, lt (and ~i variants) are supported.
10790 The comparison should return true when applied to two values
10791 if the first value should sort before the second value.
10792 The <&'extractor'&> expansion is applied repeatedly to elements of the list,
10793 the element being placed in &$item$&,
10794 to give values for comparison.
10795
10796 The item result is a sorted list,
10797 with the original list separator,
10798 of the list elements (in full) of the original.
10799
10800 Examples:
10801 .code
10802 ${sort{3:2:1:4}{<}{$item}}
10803 .endd
10804 sorts a list of numbers, and
10805 .code
10806 ${sort {${lookup dnsdb{>:,,mx=example.com}}} {<} {${listextract{1}{<,$item}}}}
10807 .endd
10808 will sort an MX lookup into priority order.
10809
10810
10811
10812 .vitem &*${srs_encode&~{*&<&'secret'&>&*}{*&<&'return&~path'&>&*}{*&<&'original&~domain'&>&*}}*&
10813 SRS encoding.  See SECT &<<SECTSRS>>& for details.
10814
10815
10816
10817 .vitem &*${substr{*&<&'start'&>&*}{*&<&'len'&>&*}{*&<&'subject'&>&*}}*&
10818 .cindex "&%substr%& expansion item"
10819 .cindex "substring extraction"
10820 .cindex "expansion" "substring extraction"
10821 The three strings are expanded; the first two must yield numbers. Call them
10822 <&'n'&> and <&'m'&>. If you are using fixed values for these numbers, that is,
10823 if <&'start'&> and <&'len'&> do not change when they are expanded, you
10824 can use the simpler operator notation that avoids some of the braces:
10825 .code
10826 ${substr_<n>_<m>:<subject>}
10827 .endd
10828 The second number is optional (in both notations).
10829 If it is absent in the simpler format, the preceding underscore must also be
10830 omitted.
10831
10832 The &%substr%& item can be used to extract more general substrings than
10833 &%length%&. The first number, <&'n'&>, is a starting offset, and <&'m'&> is the
10834 length required. For example
10835 .code
10836 ${substr{3}{2}{$local_part}}
10837 .endd
10838 If the starting offset is greater than the string length the result is the
10839 null string; if the length plus starting offset is greater than the string
10840 length, the result is the right-hand part of the string, starting from the
10841 given offset. The first byte (character) in the string has offset zero.
10842
10843 The &%substr%& expansion item can take negative offset values to count
10844 from the right-hand end of its operand. The last byte (character) is offset -1,
10845 the second-last is offset -2, and so on. Thus, for example,
10846 .code
10847 ${substr{-5}{2}{1234567}}
10848 .endd
10849 yields &"34"&. If the absolute value of a negative offset is greater than the
10850 length of the string, the substring starts at the beginning of the string, and
10851 the length is reduced by the amount of overshoot. Thus, for example,
10852 .code
10853 ${substr{-5}{2}{12}}
10854 .endd
10855 yields an empty string, but
10856 .code
10857 ${substr{-3}{2}{12}}
10858 .endd
10859 yields &"1"&.
10860
10861 When the second number is omitted from &%substr%&, the remainder of the string
10862 is taken if the offset is positive. If it is negative, all bytes (characters) in the
10863 string preceding the offset point are taken. For example, an offset of -1 and
10864 no length, as in these semantically identical examples:
10865 .code
10866 ${substr_-1:abcde}
10867 ${substr{-1}{abcde}}
10868 .endd
10869 yields all but the last character of the string, that is, &"abcd"&.
10870
10871 All measurement is done in bytes and is not UTF-8 aware.
10872
10873
10874
10875 .vitem "&*${tr{*&<&'subject'&>&*}{*&<&'characters'&>&*}&&&
10876         {*&<&'replacements'&>&*}}*&"
10877 .cindex "expansion" "character translation"
10878 .cindex "&%tr%& expansion item"
10879 This item does single-character (in bytes) translation on its subject string. The second
10880 argument is a list of characters to be translated in the subject string. Each
10881 matching character is replaced by the corresponding character from the
10882 replacement list. For example
10883 .code
10884 ${tr{abcdea}{ac}{13}}
10885 .endd
10886 yields &`1b3de1`&. If there are duplicates in the second character string, the
10887 last occurrence is used. If the third string is shorter than the second, its
10888 last character is replicated. However, if it is empty, no translation takes
10889 place.
10890
10891 All character handling is done in bytes and is not UTF-8 aware.
10892
10893 .endlist
10894
10895
10896
10897 .section "Expansion operators" "SECTexpop"
10898 .cindex "expansion" "operators"
10899 For expansion items that perform transformations on a single argument string,
10900 the &"operator"& notation is used because it is simpler and uses fewer braces.
10901 The substring is first expanded before the operation is applied to it. The
10902 following operations can be performed:
10903
10904 .vlist
10905 .vitem &*${address:*&<&'string'&>&*}*&
10906 .cindex "expansion" "RFC 2822 address handling"
10907 .cindex "&%address%& expansion item"
10908 The string is interpreted as an RFC 2822 address, as it might appear in a
10909 header line, and the effective address is extracted from it. If the string does
10910 not parse successfully, the result is empty.
10911
10912 The parsing correctly handles SMTPUTF8 Unicode in the string.
10913
10914
10915 .vitem &*${addresses:*&<&'string'&>&*}*&
10916 .cindex "expansion" "RFC 2822 address handling"
10917 .cindex "&%addresses%& expansion item"
10918 The string (after expansion) is interpreted as a list of addresses in RFC
10919 2822 format, such as can be found in a &'To:'& or &'Cc:'& header line. The
10920 operative address (&'local-part@domain'&) is extracted from each item, and the
10921 result of the expansion is a colon-separated list, with appropriate
10922 doubling of colons should any happen to be present in the email addresses.
10923 Syntactically invalid RFC2822 address items are omitted from the output.
10924
10925 It is possible to specify a character other than colon for the output
10926 separator by starting the string with > followed by the new separator
10927 character. For example:
10928 .code
10929 ${addresses:>& Chief <ceo@up.stairs>, sec@base.ment (dogsbody)}
10930 .endd
10931 expands to &`ceo@up.stairs&&sec@base.ment`&. The string is expanded
10932 first, so if the expanded string starts with >, it may change the output
10933 separator unintentionally. This can be avoided by setting the output
10934 separator explicitly:
10935 .code
10936 ${addresses:>:$h_from:}
10937 .endd
10938
10939 Compare the &%address%& (singular)
10940 expansion item, which extracts the working address from a single RFC2822
10941 address. See the &%filter%&, &%map%&, and &%reduce%& items for ways of
10942 processing lists.
10943
10944 To clarify "list of addresses in RFC 2822 format" mentioned above, Exim follows
10945 a strict interpretation of header line formatting.  Exim parses the bare,
10946 unquoted portion of an email address and if it finds a comma, treats it as an
10947 email address separator. For the example header line:
10948 .code
10949 From: =?iso-8859-2?Q?Last=2C_First?= <user@example.com>
10950 .endd
10951 The first example below demonstrates that Q-encoded email addresses are parsed
10952 properly if it is given the raw header (in this example, &`$rheader_from:`&).
10953 It does not see the comma because it's still encoded as "=2C".  The second
10954 example below is passed the contents of &`$header_from:`&, meaning it gets
10955 de-mimed. Exim sees the decoded "," so it treats it as &*two*& email addresses.
10956 The third example shows that the presence of a comma is skipped when it is
10957 quoted.  The fourth example shows SMTPUTF8 handling.
10958 .code
10959 # exim -be '${addresses:From: \
10960 =?iso-8859-2?Q?Last=2C_First?= <user@example.com>}'
10961 user@example.com
10962 # exim -be '${addresses:From: Last, First <user@example.com>}'
10963 Last:user@example.com
10964 # exim -be '${addresses:From: "Last, First" <user@example.com>}'
10965 user@example.com
10966 # exim -be '${addresses:フィル <フィリップ@example.jp>}'
10967 フィリップ@example.jp
10968 .endd
10969
10970 .vitem &*${base32:*&<&'digits'&>&*}*&
10971 .cindex "&%base32%& expansion item"
10972 .cindex "expansion" "conversion to base 32"
10973 The string must consist entirely of decimal digits. The number is converted to
10974 base 32 and output as a (empty, for zero) string of characters.
10975 Only lowercase letters are used.
10976
10977 .vitem &*${base32d:*&<&'base-32&~digits'&>&*}*&
10978 .cindex "&%base32d%& expansion item"
10979 .cindex "expansion" "conversion to base 32"
10980 The string must consist entirely of base-32 digits.
10981 The number is converted to decimal and output as a string.
10982
10983 .vitem &*${base62:*&<&'digits'&>&*}*&
10984 .cindex "&%base62%& expansion item"
10985 .cindex "expansion" "conversion to base 62"
10986 The string must consist entirely of decimal digits. The number is converted to
10987 base 62 and output as a string of six characters, including leading zeros. In
10988 the few operating environments where Exim uses base 36 instead of base 62 for
10989 its message identifiers (because those systems do not have case-sensitive
10990 filenames), base 36 is used by this operator, despite its name. &*Note*&: Just
10991 to be absolutely clear: this is &'not'& base64 encoding.
10992
10993 .vitem &*${base62d:*&<&'base-62&~digits'&>&*}*&
10994 .cindex "&%base62d%& expansion item"
10995 .cindex "expansion" "conversion to base 62"
10996 The string must consist entirely of base-62 digits, or, in operating
10997 environments where Exim uses base 36 instead of base 62 for its message
10998 identifiers, base-36 digits. The number is converted to decimal and output as a
10999 string.
11000
11001 .vitem &*${base64:*&<&'string'&>&*}*&
11002 .cindex "expansion" "base64 encoding"
11003 .cindex "base64 encoding" "in string expansion"
11004 .cindex "&%base64%& expansion item"
11005 .cindex certificate "base64 of DER"
11006 This operator converts a string into one that is base64 encoded.
11007
11008 If the string is a single variable of type certificate,
11009 returns the base64 encoding of the DER form of the certificate.
11010
11011
11012 .vitem &*${base64d:*&<&'string'&>&*}*&
11013 .cindex "expansion" "base64 decoding"
11014 .cindex "base64 decoding" "in string expansion"
11015 .cindex "&%base64d%& expansion item"
11016 This operator converts a base64-encoded string into the un-coded form.
11017
11018
11019 .vitem &*${domain:*&<&'string'&>&*}*&
11020 .cindex "domain" "extraction"
11021 .cindex "expansion" "domain extraction"
11022 The string is interpreted as an RFC 2822 address and the domain is extracted
11023 from it. If the string does not parse successfully, the result is empty.
11024
11025
11026 .vitem &*${escape:*&<&'string'&>&*}*&
11027 .cindex "expansion" "escaping non-printing characters"
11028 .cindex "&%escape%& expansion item"
11029 If the string contains any non-printing characters, they are converted to
11030 escape sequences starting with a backslash. Whether characters with the most
11031 significant bit set (so-called &"8-bit characters"&) count as printing or not
11032 is controlled by the &%print_topbitchars%& option.
11033
11034 .vitem &*${escape8bit:*&<&'string'&>&*}*&
11035 .cindex "expansion" "escaping 8-bit characters"
11036 .cindex "&%escape8bit%& expansion item"
11037 If the string contains any characters with the most significant bit set,
11038 they are converted to escape sequences starting with a backslash.
11039 Backslashes and DEL characters are also converted.
11040
11041
11042 .vitem &*${eval:*&<&'string'&>&*}*&&~and&~&*${eval10:*&<&'string'&>&*}*&
11043 .cindex "expansion" "expression evaluation"
11044 .cindex "expansion" "arithmetic expression"
11045 .cindex "&%eval%& expansion item"
11046 These items supports simple arithmetic and bitwise logical operations in
11047 expansion strings. The string (after expansion) must be a conventional
11048 arithmetic expression, but it is limited to basic arithmetic operators, bitwise
11049 logical operators, and parentheses. All operations are carried out using
11050 integer arithmetic. The operator priorities are as follows (the same as in the
11051 C programming language):
11052 .table2 70pt 300pt
11053 .irow &'highest:'& "not (~), negate (-)"
11054 .irow ""   "multiply (*), divide (/), remainder (%)"
11055 .irow ""   "plus (+), minus (-)"
11056 .irow ""   "shift-left (<<), shift-right (>>)"
11057 .irow ""   "and (&&)"
11058 .irow ""   "xor (^)"
11059 .irow &'lowest:'&  "or (|)"
11060 .endtable
11061 Binary operators with the same priority are evaluated from left to right. White
11062 space is permitted before or after operators.
11063
11064 For &%eval%&, numbers may be decimal, octal (starting with &"0"&) or
11065 hexadecimal (starting with &"0x"&). For &%eval10%&, all numbers are taken as
11066 decimal, even if they start with a leading zero; hexadecimal numbers are not
11067 permitted. This can be useful when processing numbers extracted from dates or
11068 times, which often do have leading zeros.
11069
11070 A number may be followed by &"K"&, &"M"& or &"G"& to multiply it by 1024, 1024*1024
11071 or 1024*1024*1024,
11072 respectively. Negative numbers are supported. The result of the computation is
11073 a decimal representation of the answer (without &"K"&, &"M"& or &"G"&). For example:
11074
11075 .display
11076 &`${eval:1+1}            `&  yields 2
11077 &`${eval:1+2*3}          `&  yields 7
11078 &`${eval:(1+2)*3}        `&  yields 9
11079 &`${eval:2+42%5}         `&  yields 4
11080 &`${eval:0xc&amp;5}          `&  yields 4
11081 &`${eval:0xc|5}          `&  yields 13
11082 &`${eval:0xc^5}          `&  yields 9
11083 &`${eval:0xc>>1}         `&  yields 6
11084 &`${eval:0xc<<1}         `&  yields 24
11085 &`${eval:~255&amp;0x1234}    `&  yields 4608
11086 &`${eval:-(~255&amp;0x1234)} `&  yields -4608
11087 .endd
11088
11089 As a more realistic example, in an ACL you might have
11090 .code
11091 deny   condition =                    \
11092          ${if and {                   \
11093            {>{$rcpt_count}{10}}       \
11094            {                          \
11095            <                          \
11096              {$recipients_count}      \
11097              {${eval:$rcpt_count/2}}  \
11098            }                          \
11099          }{yes}{no}}
11100        message = Too many bad recipients
11101 .endd
11102 The condition is true if there have been more than 10 RCPT commands and
11103 fewer than half of them have resulted in a valid recipient.
11104
11105
11106 .vitem &*${expand:*&<&'string'&>&*}*&
11107 .cindex "expansion" "re-expansion of substring"
11108 The &%expand%& operator causes a string to be expanded for a second time. For
11109 example,
11110 .code
11111 ${expand:${lookup{$domain}dbm{/some/file}{$value}}}
11112 .endd
11113 first looks up a string in a file while expanding the operand for &%expand%&,
11114 and then re-expands what it has found.
11115
11116
11117 .vitem &*${from_utf8:*&<&'string'&>&*}*&
11118 .cindex "Unicode"
11119 .cindex "UTF-8" "conversion from"
11120 .cindex "expansion" "UTF-8 conversion"
11121 .cindex "&%from_utf8%& expansion item"
11122 The world is slowly moving towards Unicode, although there are no standards for
11123 email yet. However, other applications (including some databases) are starting
11124 to store data in Unicode, using UTF-8 encoding. This operator converts from a
11125 UTF-8 string to an ISO-8859-1 string. UTF-8 code values greater than 255 are
11126 converted to underscores. The input must be a valid UTF-8 string. If it is not,
11127 the result is an undefined sequence of bytes.
11128
11129 Unicode code points with values less than 256 are compatible with ASCII and
11130 ISO-8859-1 (also known as Latin-1).
11131 For example, character 169 is the copyright symbol in both cases, though the
11132 way it is encoded is different. In UTF-8, more than one byte is needed for
11133 characters with code values greater than 127, whereas ISO-8859-1 is a
11134 single-byte encoding (but thereby limited to 256 characters). This makes
11135 translation from UTF-8 to ISO-8859-1 straightforward.
11136
11137
11138 .vitem &*${hash_*&<&'n'&>&*_*&<&'m'&>&*:*&<&'string'&>&*}*&
11139 .cindex "hash function" "textual"
11140 .cindex "expansion" "textual hash"
11141 The &%hash%& operator is a simpler interface to the hashing function that can
11142 be used when the two parameters are fixed numbers (as opposed to strings that
11143 change when expanded). The effect is the same as
11144 .code
11145 ${hash{<n>}{<m>}{<string>}}
11146 .endd
11147 See the description of the general &%hash%& item above for details. The
11148 abbreviation &%h%& can be used when &%hash%& is used as an operator.
11149
11150
11151
11152 .vitem &*${headerwrap_*&<&'cols'&>&*_*&<&'limit'&>&*:*&<&'string'&>&*}*&
11153 .cindex header "wrapping operator"
11154 .cindex expansion "header wrapping"
11155 This operator line-wraps its argument in a way useful for headers.
11156 The &'cols'& value gives the column number to wrap after,
11157 the &'limit'& gives a limit number of result characters to truncate at.
11158 Either just the &'limit'& and the preceding underbar, or both, can be omitted;
11159 the defaults are 80 and 998.
11160 Wrapping will be inserted at a space if possible before the
11161 column number is reached.
11162 Whitespace at a chosen wrap point is removed.
11163 A line-wrap consists of a newline followed by a tab,
11164 and the tab is counted as 8 columns.
11165
11166
11167
11168 .vitem &*${hex2b64:*&<&'hexstring'&>&*}*&
11169 .cindex "base64 encoding" "conversion from hex"
11170 .cindex "expansion" "hex to base64"
11171 .cindex "&%hex2b64%& expansion item"
11172 This operator converts a hex string into one that is base64 encoded. This can
11173 be useful for processing the output of the various hashing functions.
11174
11175
11176
11177 .vitem &*${hexquote:*&<&'string'&>&*}*&
11178 .cindex "quoting" "hex-encoded unprintable characters"
11179 .cindex "&%hexquote%& expansion item"
11180 This operator converts non-printable characters in a string into a hex
11181 escape form. Byte values between 33 (!) and 126 (~) inclusive are left
11182 as is, and other byte values are converted to &`\xNN`&, for example, a
11183 byte value 127 is converted to &`\x7f`&.
11184
11185
11186 .vitem &*${ipv6denorm:*&<&'string'&>&*}*&
11187 .cindex "&%ipv6denorm%& expansion item"
11188 .cindex "IP address" normalisation
11189 This expands an IPv6 address to a full eight-element colon-separated set
11190 of hex digits including leading zeroes.
11191 A trailing ipv4-style dotted-decimal set is converted to hex.
11192 Pure IPv4 addresses are converted to IPv4-mapped IPv6.
11193
11194 .vitem &*${ipv6norm:*&<&'string'&>&*}*&
11195 .cindex "&%ipv6norm%& expansion item"
11196 .cindex "IP address" normalisation
11197 .cindex "IP address" "canonical form"
11198 This converts an IPv6 address to canonical form.
11199 Leading zeroes of groups are omitted, and the longest
11200 set of zero-valued groups is replaced with a double colon.
11201 A trailing ipv4-style dotted-decimal set is converted to hex.
11202 Pure IPv4 addresses are converted to IPv4-mapped IPv6.
11203
11204
11205 .vitem &*${lc:*&<&'string'&>&*}*&
11206 .cindex "case forcing in strings"
11207 .cindex "string" "case forcing"
11208 .cindex "lower casing"
11209 .cindex "expansion" "case forcing"
11210 .cindex "&%lc%& expansion item"
11211 This forces the letters in the string into lower-case, for example:
11212 .code
11213 ${lc:$local_part}
11214 .endd
11215 Case is defined per the system C locale.
11216
11217 .vitem &*${length_*&<&'number'&>&*:*&<&'string'&>&*}*&
11218 .cindex "expansion" "string truncation"
11219 .cindex "&%length%& expansion item"
11220 The &%length%& operator is a simpler interface to the &%length%& function that
11221 can be used when the parameter is a fixed number (as opposed to a string that
11222 changes when expanded). The effect is the same as
11223 .code
11224 ${length{<number>}{<string>}}
11225 .endd
11226 See the description of the general &%length%& item above for details. Note that
11227 &%length%& is not the same as &%strlen%&. The abbreviation &%l%& can be used
11228 when &%length%& is used as an operator.
11229 All measurement is done in bytes and is not UTF-8 aware.
11230
11231
11232 .vitem &*${listcount:*&<&'string'&>&*}*&
11233 .cindex "expansion" "list item count"
11234 .cindex "list" "item count"
11235 .cindex "list" "count of items"
11236 .cindex "&%listcount%& expansion item"
11237 The string is interpreted as a list and the number of items is returned.
11238
11239
11240 .vitem &*${listnamed:*&<&'name'&>&*}*&&~and&~&*${listnamed_*&<&'type'&>&*:*&<&'name'&>&*}*&
11241 .cindex "expansion" "named list"
11242 .cindex "&%listnamed%& expansion item"
11243 The name is interpreted as a named list and the content of the list is returned,
11244 expanding any referenced lists, re-quoting as needed for colon-separation.
11245 If the optional type is given it must be one of "a", "d", "h" or "l"
11246 and selects address-, domain-, host- or localpart- lists to search among respectively.
11247 Otherwise all types are searched in an undefined order and the first
11248 matching list is returned.
11249 &*Note*&: Neither string-expansion of lists referenced by named-list syntax elements,
11250 nor expansion of lookup elements, is done by the &%listnamed%& operator.
11251
11252
11253 .vitem &*${local_part:*&<&'string'&>&*}*&
11254 .cindex "expansion" "local part extraction"
11255 .cindex "&%local_part%& expansion item"
11256 The string is interpreted as an RFC 2822 address and the local part is
11257 extracted from it. If the string does not parse successfully, the result is
11258 empty.
11259 The parsing correctly handles SMTPUTF8 Unicode in the string.
11260
11261
11262 .vitem &*${mask:*&<&'IP&~address'&>&*/*&<&'bit&~count'&>&*}*& &&&
11263        &*${mask_n:*&<&'IP&~address'&>&*/*&<&'bit&~count'&>&*}*&
11264 .cindex "masked IP address"
11265 .cindex "IP address" "masking"
11266 .cindex "CIDR notation"
11267 .cindex "expansion" "IP address masking"
11268 .cindex "&%mask%& expansion item"
11269 If the form of the string to be operated on is not an IP address followed by a
11270 slash and an integer (that is, a network address in CIDR notation), the
11271 expansion fails. Otherwise, this operator converts the IP address to binary,
11272 masks off the least significant bits according to the bit count, and converts
11273 the result back to text, with mask appended. For example,
11274 .code
11275 ${mask:10.111.131.206/28}
11276 .endd
11277 returns the string &"10.111.131.192/28"&.
11278
11279 Since this operation is expected to
11280 be mostly used for looking up masked addresses in files, the
11281 normal
11282 result for an IPv6
11283 address uses dots to separate components instead of colons, because colon
11284 terminates a key string in lsearch files. So, for example,
11285 .code
11286 ${mask:3ffe:ffff:836f:0a00:000a:0800:200a:c031/99}
11287 .endd
11288 returns the string
11289 .code
11290 3ffe.ffff.836f.0a00.000a.0800.2000.0000/99
11291 .endd
11292 If the optional form &*mask_n*& is used, IPv6 address result are instead
11293 returned in normailsed form, using colons and with zero-compression.
11294 Letters in IPv6 addresses are always output in lower case.
11295
11296
11297 .vitem &*${md5:*&<&'string'&>&*}*&
11298 .cindex "MD5 hash"
11299 .cindex "expansion" "MD5 hash"
11300 .cindex certificate fingerprint
11301 .cindex "&%md5%& expansion item"
11302 The &%md5%& operator computes the MD5 hash value of the string, and returns it
11303 as a 32-digit hexadecimal number, in which any letters are in lower case.
11304
11305 If the string is a single variable of type certificate,
11306 returns the MD5 hash fingerprint of the certificate.
11307
11308
11309 .vitem &*${nhash_*&<&'n'&>&*_*&<&'m'&>&*:*&<&'string'&>&*}*&
11310 .cindex "expansion" "numeric hash"
11311 .cindex "hash function" "numeric"
11312 The &%nhash%& operator is a simpler interface to the numeric hashing function
11313 that can be used when the two parameters are fixed numbers (as opposed to
11314 strings that change when expanded). The effect is the same as
11315 .code
11316 ${nhash{<n>}{<m>}{<string>}}
11317 .endd
11318 See the description of the general &%nhash%& item above for details.
11319
11320
11321 .vitem &*${quote:*&<&'string'&>&*}*&
11322 .cindex "quoting" "in string expansions"
11323 .cindex "expansion" "quoting"
11324 .cindex "&%quote%& expansion item"
11325 The &%quote%& operator puts its argument into double quotes if it
11326 is an empty string or
11327 contains anything other than letters, digits, underscores, dots, and hyphens.
11328 Any occurrences of double quotes and backslashes are escaped with a backslash.
11329 Newlines and carriage returns are converted to &`\n`& and &`\r`&,
11330 respectively For example,
11331 .code
11332 ${quote:ab"*"cd}
11333 .endd
11334 becomes
11335 .code
11336 "ab\"*\"cd"
11337 .endd
11338 The place where this is useful is when the argument is a substitution from a
11339 variable or a message header.
11340
11341 .vitem &*${quote_local_part:*&<&'string'&>&*}*&
11342 .cindex "&%quote_local_part%& expansion item"
11343 This operator is like &%quote%&, except that it quotes the string only if
11344 required to do so by the rules of RFC 2822 for quoting local parts. For
11345 example, a plus sign would not cause quoting (but it would for &%quote%&).
11346 If you are creating a new email address from the contents of &$local_part$&
11347 (or any other unknown data), you should always use this operator.
11348
11349 This quoting determination is not SMTPUTF8-aware, thus quoting non-ASCII data
11350 will likely use the quoting form.
11351 Thus &'${quote_local_part:フィル}'& will always become &'"フィル"'&.
11352
11353
11354 .vitem &*${quote_*&<&'lookup-type'&>&*:*&<&'string'&>&*}*&
11355 .cindex "quoting" "lookup-specific"
11356 This operator applies lookup-specific quoting rules to the string. Each
11357 query-style lookup type has its own quoting rules which are described with
11358 the lookups in chapter &<<CHAPfdlookup>>&. For example,
11359 .code
11360 ${quote_ldap:two * two}
11361 .endd
11362 returns
11363 .code
11364 two%20%5C2A%20two
11365 .endd
11366 For single-key lookup types, no quoting is ever necessary and this operator
11367 yields an unchanged string.
11368
11369
11370 .vitem &*${randint:*&<&'n'&>&*}*&
11371 .cindex "random number"
11372 This operator returns a somewhat random number which is less than the
11373 supplied number and is at least 0.  The quality of this randomness depends
11374 on how Exim was built; the values are not suitable for keying material.
11375 If Exim is linked against OpenSSL then RAND_pseudo_bytes() is used.
11376 If Exim is linked against GnuTLS then gnutls_rnd(GNUTLS_RND_NONCE) is used,
11377 for versions of GnuTLS with that function.
11378 Otherwise, the implementation may be arc4random(), random() seeded by
11379 srandomdev() or srandom(), or a custom implementation even weaker than
11380 random().
11381
11382
11383 .vitem &*${reverse_ip:*&<&'ipaddr'&>&*}*&
11384 .cindex "expansion" "IP address"
11385 This operator reverses an IP address; for IPv4 addresses, the result is in
11386 dotted-quad decimal form, while for IPv6 addresses the result is in
11387 dotted-nibble hexadecimal form.  In both cases, this is the "natural" form
11388 for DNS.  For example,
11389 .code
11390 ${reverse_ip:192.0.2.4}
11391 ${reverse_ip:2001:0db8:c42:9:1:abcd:192.0.2.127}
11392 .endd
11393 returns
11394 .code
11395 4.2.0.192
11396 f.7.2.0.0.0.0.c.d.c.b.a.1.0.0.0.9.0.0.0.2.4.c.0.8.b.d.0.1.0.0.2
11397 .endd
11398
11399
11400 .vitem &*${rfc2047:*&<&'string'&>&*}*&
11401 .cindex "expansion" "RFC 2047"
11402 .cindex "RFC 2047" "expansion operator"
11403 .cindex "&%rfc2047%& expansion item"
11404 This operator encodes text according to the rules of RFC 2047. This is an
11405 encoding that is used in header lines to encode non-ASCII characters. It is
11406 assumed that the input string is in the encoding specified by the
11407 &%headers_charset%& option, which gets its default at build time. If the string
11408 contains only characters in the range 33&--126, and no instances of the
11409 characters
11410 .code
11411 ? = ( ) < > @ , ; : \ " . [ ] _
11412 .endd
11413 it is not modified. Otherwise, the result is the RFC 2047 encoding of the
11414 string, using as many &"encoded words"& as necessary to encode all the
11415 characters.
11416
11417
11418 .vitem &*${rfc2047d:*&<&'string'&>&*}*&
11419 .cindex "expansion" "RFC 2047"
11420 .cindex "RFC 2047" "decoding"
11421 .cindex "&%rfc2047d%& expansion item"
11422 This operator decodes strings that are encoded as per RFC 2047. Binary zero
11423 bytes are replaced by question marks. Characters are converted into the
11424 character set defined by &%headers_charset%&. Overlong RFC 2047 &"words"& are
11425 not recognized unless &%check_rfc2047_length%& is set false.
11426
11427 &*Note*&: If you use &%$header%&_&'xxx'&&*:*& (or &%$h%&_&'xxx'&&*:*&) to
11428 access a header line, RFC 2047 decoding is done automatically. You do not need
11429 to use this operator as well.
11430
11431
11432
11433 .vitem &*${rxquote:*&<&'string'&>&*}*&
11434 .cindex "quoting" "in regular expressions"
11435 .cindex "regular expressions" "quoting"
11436 .cindex "&%rxquote%& expansion item"
11437 The &%rxquote%& operator inserts a backslash before any non-alphanumeric
11438 characters in its argument. This is useful when substituting the values of
11439 variables or headers inside regular expressions.
11440
11441
11442 .vitem &*${sha1:*&<&'string'&>&*}*&
11443 .cindex "SHA-1 hash"
11444 .cindex "expansion" "SHA-1 hashing"
11445 .cindex certificate fingerprint
11446 .cindex "&%sha1%& expansion item"
11447 The &%sha1%& operator computes the SHA-1 hash value of the string, and returns
11448 it as a 40-digit hexadecimal number, in which any letters are in upper case.
11449
11450 If the string is a single variable of type certificate,
11451 returns the SHA-1 hash fingerprint of the certificate.
11452
11453
11454 .vitem &*${sha256:*&<&'string'&>&*}*& &&&
11455        &*${sha2:*&<&'string'&>&*}*& &&&
11456        &*${sha2_<n>:*&<&'string'&>&*}*&
11457 .cindex "SHA-256 hash"
11458 .cindex "SHA-2 hash"
11459 .cindex certificate fingerprint
11460 .cindex "expansion" "SHA-256 hashing"
11461 .cindex "&%sha256%& expansion item"
11462 .cindex "&%sha2%& expansion item"
11463 The &%sha256%& operator computes the SHA-256 hash value of the string
11464 and returns
11465 it as a 64-digit hexadecimal number, in which any letters are in upper case.
11466
11467 If the string is a single variable of type certificate,
11468 returns the SHA-256 hash fingerprint of the certificate.
11469
11470 The operator can also be spelled &%sha2%& and does the same as &%sha256%&
11471 (except for certificates, which are not supported).
11472 Finally, if an underbar
11473 and a number is appended it specifies the output length, selecting a
11474 member of the SHA-2 family of hash functions.
11475 Values of 256, 384 and 512 are accepted, with 256 being the default.
11476
11477
11478 .vitem &*${sha3:*&<&'string'&>&*}*& &&&
11479        &*${sha3_<n>:*&<&'string'&>&*}*&
11480 .cindex "SHA3 hash"
11481 .cindex "expansion" "SHA3 hashing"
11482 .cindex "&%sha3%& expansion item"
11483 The &%sha3%& operator computes the SHA3-256 hash value of the string
11484 and returns
11485 it as a 64-digit hexadecimal number, in which any letters are in upper case.
11486
11487 If a number is appended, separated by an underbar, it specifies
11488 the output length.  Values of 224, 256, 384 and 512 are accepted;
11489 with 256 being the default.
11490
11491 The &%sha3%& expansion item is only supported if Exim has been
11492 compiled with GnuTLS 3.5.0 or later,
11493 or OpenSSL 1.1.1 or later.
11494 The macro "_CRYPTO_HASH_SHA3" will be defined if it is supported.
11495
11496
11497 .vitem &*${stat:*&<&'string'&>&*}*&
11498 .cindex "expansion" "statting a file"
11499 .cindex "file" "extracting characteristics"
11500 .cindex "&%stat%& expansion item"
11501 The string, after expansion, must be a file path. A call to the &[stat()]&
11502 function is made for this path. If &[stat()]& fails, an error occurs and the
11503 expansion fails. If it succeeds, the data from the stat replaces the item, as a
11504 series of <&'name'&>=<&'value'&> pairs, where the values are all numerical,
11505 except for the value of &"smode"&. The names are: &"mode"& (giving the mode as
11506 a 4-digit octal number), &"smode"& (giving the mode in symbolic format as a
11507 10-character string, as for the &'ls'& command), &"inode"&, &"device"&,
11508 &"links"&, &"uid"&, &"gid"&, &"size"&, &"atime"&, &"mtime"&, and &"ctime"&. You
11509 can extract individual fields using the &%extract%& expansion item.
11510
11511 The use of the &%stat%& expansion in users' filter files can be locked out by
11512 the system administrator. &*Warning*&: The file size may be incorrect on 32-bit
11513 systems for files larger than 2GB.
11514
11515 .vitem &*${str2b64:*&<&'string'&>&*}*&
11516 .cindex "&%str2b64%& expansion item"
11517 Now deprecated, a synonym for the &%base64%& expansion operator.
11518
11519
11520
11521 .vitem &*${strlen:*&<&'string'&>&*}*&
11522 .cindex "expansion" "string length"
11523 .cindex "string" "length in expansion"
11524 .cindex "&%strlen%& expansion item"
11525 The item is replaced by the length of the expanded string, expressed as a
11526 decimal number. &*Note*&: Do not confuse &%strlen%& with &%length%&.
11527 All measurement is done in bytes and is not UTF-8 aware.
11528
11529
11530 .vitem &*${substr_*&<&'start'&>&*_*&<&'length'&>&*:*&<&'string'&>&*}*&
11531 .cindex "&%substr%& expansion item"
11532 .cindex "substring extraction"
11533 .cindex "expansion" "substring expansion"
11534 The &%substr%& operator is a simpler interface to the &%substr%& function that
11535 can be used when the two parameters are fixed numbers (as opposed to strings
11536 that change when expanded). The effect is the same as
11537 .code
11538 ${substr{<start>}{<length>}{<string>}}
11539 .endd
11540 See the description of the general &%substr%& item above for details. The
11541 abbreviation &%s%& can be used when &%substr%& is used as an operator.
11542 All measurement is done in bytes and is not UTF-8 aware.
11543
11544 .vitem &*${time_eval:*&<&'string'&>&*}*&
11545 .cindex "&%time_eval%& expansion item"
11546 .cindex "time interval" "decoding"
11547 This item converts an Exim time interval such as &`2d4h5m`& into a number of
11548 seconds.
11549
11550 .vitem &*${time_interval:*&<&'string'&>&*}*&
11551 .cindex "&%time_interval%& expansion item"
11552 .cindex "time interval" "formatting"
11553 The argument (after sub-expansion) must be a sequence of decimal digits that
11554 represents an interval of time as a number of seconds. It is converted into a
11555 number of larger units and output in Exim's normal time format, for example,
11556 &`1w3d4h2m6s`&.
11557
11558 .vitem &*${uc:*&<&'string'&>&*}*&
11559 .cindex "case forcing in strings"
11560 .cindex "string" "case forcing"
11561 .cindex "upper casing"
11562 .cindex "expansion" "case forcing"
11563 .cindex "&%uc%& expansion item"
11564 This forces the letters in the string into upper-case.
11565 Case is defined per the system C locale.
11566
11567 .vitem &*${utf8clean:*&<&'string'&>&*}*&
11568 .cindex "correction of invalid utf-8 sequences in strings"
11569 .cindex "utf-8" "utf-8 sequences"
11570 .cindex "incorrect utf-8"
11571 .cindex "expansion" "utf-8 forcing"
11572 .cindex "&%utf8clean%& expansion item"
11573 This replaces any invalid utf-8 sequence in the string by the character &`?`&.
11574 In versions of Exim before 4.92, this did not correctly do so for a truncated
11575 final codepoint's encoding, and the character would be silently dropped.
11576 If you must handle detection of this scenario across both sets of Exim behavior,
11577 the complexity will depend upon the task.
11578 For instance, to detect if the first character is multibyte and a 1-byte
11579 extraction can be successfully used as a path component (as is common for
11580 dividing up delivery folders), you might use:
11581 .code
11582 condition = ${if inlist{${utf8clean:${length_1:$local_part}}}{:?}{yes}{no}}
11583 .endd
11584 (which will false-positive if the first character of the local part is a
11585 literal question mark).
11586
11587 .vitem "&*${utf8_domain_to_alabel:*&<&'string'&>&*}*&" &&&
11588        "&*${utf8_domain_from_alabel:*&<&'string'&>&*}*&" &&&
11589        "&*${utf8_localpart_to_alabel:*&<&'string'&>&*}*&" &&&
11590        "&*${utf8_localpart_from_alabel:*&<&'string'&>&*}*&"
11591 .cindex expansion UTF-8
11592 .cindex UTF-8 expansion
11593 .cindex EAI
11594 .cindex internationalisation
11595 .cindex "&%utf8_domain_to_alabel%& expansion item"
11596 .cindex "&%utf8_domain_from_alabel%& expansion item"
11597 .cindex "&%utf8_localpart_to_alabel%& expansion item"
11598 .cindex "&%utf8_localpart_from_alabel%& expansion item"
11599 These convert EAI mail name components between UTF-8 and a-label forms.
11600 For information on internationalisation support see &<<SECTi18nMTA>>&.
11601
11602
11603 .vitem &*${xtextd:*&<&'string'&>&*}*&
11604 .cindex "text forcing in strings"
11605 .cindex "string" "xtext decoding"
11606 .cindex "xtext"
11607 .cindex "&%xtextd%& expansion item"
11608 This performs xtext decoding of the string (per RFC 3461 section 4).
11609
11610
11611
11612 .endlist
11613
11614
11615
11616
11617
11618
11619 .section "Expansion conditions" "SECTexpcond"
11620 .scindex IIDexpcond "expansion" "conditions"
11621 The following conditions are available for testing by the &%${if%& construct
11622 while expanding strings:
11623
11624 .vlist
11625 .vitem &*!*&<&'condition'&>
11626 .cindex "expansion" "negating a condition"
11627 .cindex "negation" "in expansion condition"
11628 Preceding any condition with an exclamation mark negates the result of the
11629 condition.
11630
11631 .vitem <&'symbolic&~operator'&>&~&*{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
11632 .cindex "numeric comparison"
11633 .cindex "expansion" "numeric comparison"
11634 There are a number of symbolic operators for doing numeric comparisons. They
11635 are:
11636 .itable none 0 0 2 10* left 90* left
11637 .irow "=   " "equal"
11638 .irow "==  " "equal"
11639 .irow ">   " "greater"
11640 .irow ">=  " "greater or equal"
11641 .irow "<   " "less"
11642 .irow "<=  " "less or equal"
11643 .endtable
11644 For example:
11645 .code
11646 ${if >{$message_size}{10M} ...
11647 .endd
11648 Note that the general negation operator provides for inequality testing. The
11649 two strings must take the form of optionally signed decimal integers,
11650 optionally followed by one of the letters &"K"&, &"M"& or &"G"& (in either upper or
11651 lower case), signifying multiplication by 1024, 1024*1024 or 1024*1024*1024, respectively.
11652 As a special case, the numerical value of an empty string is taken as
11653 zero.
11654
11655 In all cases, a relative comparator OP is testing if <&'string1'&> OP
11656 <&'string2'&>; the above example is checking if &$message_size$& is larger than
11657 10M, not if 10M is larger than &$message_size$&.
11658
11659
11660 .vitem &*acl&~{{*&<&'name'&>&*}{*&<&'arg1'&>&*}&&&
11661         {*&<&'arg2'&>&*}...}*&
11662 .cindex "expansion" "calling an acl"
11663 .cindex "&%acl%&" "expansion condition"
11664 The name and zero to nine argument strings are first expanded separately.  The expanded
11665 arguments are assigned to the variables &$acl_arg1$& to &$acl_arg9$& in order.
11666 Any unused are made empty.  The variable &$acl_narg$& is set to the number of
11667 arguments.  The named ACL (see chapter &<<CHAPACL>>&) is called
11668 and may use the variables; if another acl expansion is used the values
11669 are restored after it returns.  If the ACL sets
11670 a value using a "message =" modifier the variable $value becomes
11671 the result of the expansion, otherwise it is empty.
11672 If the ACL returns accept the condition is true; if deny, false.
11673 If the ACL returns defer the result is a forced-fail.
11674
11675 .vitem &*bool&~{*&<&'string'&>&*}*&
11676 .cindex "expansion" "boolean parsing"
11677 .cindex "&%bool%& expansion condition"
11678 This condition turns a string holding a true or false representation into
11679 a boolean state.  It parses &"true"&, &"false"&, &"yes"& and &"no"&
11680 (case-insensitively); also integer numbers map to true if non-zero,
11681 false if zero.
11682 An empty string is treated as false.
11683 Leading and trailing whitespace is ignored;
11684 thus a string consisting only of whitespace is false.
11685 All other string values will result in expansion failure.
11686
11687 When combined with ACL variables, this expansion condition will let you
11688 make decisions in one place and act on those decisions in another place.
11689 For example:
11690 .code
11691 ${if bool{$acl_m_privileged_sender} ...
11692 .endd
11693
11694
11695 .vitem &*bool_lax&~{*&<&'string'&>&*}*&
11696 .cindex "expansion" "boolean parsing"
11697 .cindex "&%bool_lax%& expansion condition"
11698 Like &%bool%&, this condition turns a string into a boolean state.  But
11699 where &%bool%& accepts a strict set of strings, &%bool_lax%& uses the same
11700 loose definition that the Router &%condition%& option uses.  The empty string
11701 and the values &"false"&, &"no"& and &"0"& map to false, all others map to
11702 true.  Leading and trailing whitespace is ignored.
11703
11704 Note that where &"bool{00}"& is false, &"bool_lax{00}"& is true.
11705
11706 .vitem &*crypteq&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
11707 .cindex "expansion" "encrypted comparison"
11708 .cindex "encrypted strings, comparing"
11709 .cindex "&%crypteq%& expansion condition"
11710 This condition is included in the Exim binary if it is built to support any
11711 authentication mechanisms (see chapter &<<CHAPSMTPAUTH>>&). Otherwise, it is
11712 necessary to define SUPPORT_CRYPTEQ in &_Local/Makefile_& to get &%crypteq%&
11713 included in the binary.
11714
11715 The &%crypteq%& condition has two arguments. The first is encrypted and
11716 compared against the second, which is already encrypted. The second string may
11717 be in the LDAP form for storing encrypted strings, which starts with the
11718 encryption type in curly brackets, followed by the data. If the second string
11719 does not begin with &"{"& it is assumed to be encrypted with &[crypt()]& or
11720 &[crypt16()]& (see below), since such strings cannot begin with &"{"&.
11721 Typically this will be a field from a password file. An example of an encrypted
11722 string in LDAP form is:
11723 .code
11724 {md5}CY9rzUYh03PK3k6DJie09g==
11725 .endd
11726 If such a string appears directly in an expansion, the curly brackets have to
11727 be quoted, because they are part of the expansion syntax. For example:
11728 .code
11729 ${if crypteq {test}{\{md5\}CY9rzUYh03PK3k6DJie09g==}{yes}{no}}
11730 .endd
11731 The following encryption types (whose names are matched case-independently) are
11732 supported:
11733
11734 .ilist
11735 .cindex "MD5 hash"
11736 .cindex "base64 encoding" "in encrypted password"
11737 &%{md5}%& computes the MD5 digest of the first string, and expresses this as
11738 printable characters to compare with the remainder of the second string. If the
11739 length of the comparison string is 24, Exim assumes that it is base64 encoded
11740 (as in the above example). If the length is 32, Exim assumes that it is a
11741 hexadecimal encoding of the MD5 digest. If the length not 24 or 32, the
11742 comparison fails.
11743
11744 .next
11745 .cindex "SHA-1 hash"
11746 &%{sha1}%& computes the SHA-1 digest of the first string, and expresses this as
11747 printable characters to compare with the remainder of the second string. If the
11748 length of the comparison string is 28, Exim assumes that it is base64 encoded.
11749 If the length is 40, Exim assumes that it is a hexadecimal encoding of the
11750 SHA-1 digest. If the length is not 28 or 40, the comparison fails.
11751
11752 .next
11753 .cindex "&[crypt()]&"
11754 &%{crypt}%& calls the &[crypt()]& function, which traditionally used to use
11755 only the first eight characters of the password. However, in modern operating
11756 systems this is no longer true, and in many cases the entire password is used,
11757 whatever its length.
11758
11759 .next
11760 .cindex "&[crypt16()]&"
11761 &%{crypt16}%& calls the &[crypt16()]& function, which was originally created to
11762 use up to 16 characters of the password in some operating systems. Again, in
11763 modern operating systems, more characters may be used.
11764 .endlist
11765 Exim has its own version of &[crypt16()]&, which is just a double call to
11766 &[crypt()]&. For operating systems that have their own version, setting
11767 HAVE_CRYPT16 in &_Local/Makefile_& when building Exim causes it to use the
11768 operating system version instead of its own. This option is set by default in
11769 the OS-dependent &_Makefile_& for those operating systems that are known to
11770 support &[crypt16()]&.
11771
11772 Some years after Exim's &[crypt16()]& was implemented, a user discovered that
11773 it was not using the same algorithm as some operating systems' versions. It
11774 turns out that as well as &[crypt16()]& there is a function called
11775 &[bigcrypt()]& in some operating systems. This may or may not use the same
11776 algorithm, and both of them may be different to Exim's built-in &[crypt16()]&.
11777
11778 However, since there is now a move away from the traditional &[crypt()]&
11779 functions towards using SHA1 and other algorithms, tidying up this area of
11780 Exim is seen as very low priority.
11781
11782 If you do not put a encryption type (in curly brackets) in a &%crypteq%&
11783 comparison, the default is usually either &`{crypt}`& or &`{crypt16}`&, as
11784 determined by the setting of DEFAULT_CRYPT in &_Local/Makefile_&. The default
11785 default is &`{crypt}`&. Whatever the default, you can always use either
11786 function by specifying it explicitly in curly brackets.
11787
11788 .vitem &*def:*&<&'variable&~name'&>
11789 .cindex "expansion" "checking for empty variable"
11790 .cindex "&%def%& expansion condition"
11791 The &%def%& condition must be followed by the name of one of the expansion
11792 variables defined in section &<<SECTexpvar>>&. The condition is true if the
11793 variable does not contain the empty string. For example:
11794 .code
11795 ${if def:sender_ident {from $sender_ident}}
11796 .endd
11797 Note that the variable name is given without a leading &%$%& character. If the
11798 variable does not exist, the expansion fails.
11799
11800 .vitem "&*def:header_*&<&'header&~name'&>&*:*&&~&~or&~&&&
11801         &~&*def:h_*&<&'header&~name'&>&*:*&"
11802 .cindex "expansion" "checking header line existence"
11803 This condition is true if a message is being processed and the named header
11804 exists in the message. For example,
11805 .code
11806 ${if def:header_reply-to:{$h_reply-to:}{$h_from:}}
11807 .endd
11808 &*Note*&: No &%$%& appears before &%header_%& or &%h_%& in the condition, and
11809 the header name must be terminated by a colon if white space does not follow.
11810
11811 .vitem &*eq&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*& &&&
11812        &*eqi&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
11813 .cindex "string" "comparison"
11814 .cindex "expansion" "string comparison"
11815 .cindex "&%eq%& expansion condition"
11816 .cindex "&%eqi%& expansion condition"
11817 The two substrings are first expanded. The condition is true if the two
11818 resulting strings are identical. For &%eq%& the comparison includes the case of
11819 letters, whereas for &%eqi%& the comparison is case-independent, where
11820 case is defined per the system C locale.
11821
11822 .vitem &*exists&~{*&<&'file&~name'&>&*}*&
11823 .cindex "expansion" "file existence test"
11824 .cindex "file" "existence test"
11825 .cindex "&%exists%&, expansion condition"
11826 The substring is first expanded and then interpreted as an absolute path. The
11827 condition is true if the named file (or directory) exists. The existence test
11828 is done by calling the &[stat()]& function. The use of the &%exists%& test in
11829 users' filter files may be locked out by the system administrator.
11830
11831 &*Note:*& Testing a path using this condition is not a sufficient way of
11832 de-tainting it.
11833 Consider using a dsearch lookup.
11834
11835 .vitem &*first_delivery*&
11836 .cindex "delivery" "first"
11837 .cindex "first delivery"
11838 .cindex "expansion" "first delivery test"
11839 .cindex "&%first_delivery%& expansion condition"
11840 .cindex retry condition
11841 This condition, which has no data, is true during a message's first delivery
11842 attempt. It is false during any subsequent delivery attempts.
11843
11844
11845 .vitem "&*forall{*&<&'a list'&>&*}{*&<&'a condition'&>&*}*&" &&&
11846        "&*forany{*&<&'a list'&>&*}{*&<&'a condition'&>&*}*&"
11847 .cindex "list" "iterative conditions"
11848 .cindex "expansion" "&*forall*& condition"
11849 .cindex "expansion" "&*forany*& condition"
11850 .vindex "&$item$&"
11851 These conditions iterate over a list. The first argument is expanded to form
11852 the list. By default, the list separator is a colon, but it can be changed by
11853 the normal method (&<<SECTlistsepchange>>&).
11854 The second argument is interpreted as a condition that is to
11855 be applied to each item in the list in turn. During the interpretation of the
11856 condition, the current list item is placed in a variable called &$item$&.
11857 .ilist
11858 For &*forany*&, interpretation stops if the condition is true for any item, and
11859 the result of the whole condition is true. If the condition is false for all
11860 items in the list, the overall condition is false.
11861 .next
11862 For &*forall*&, interpretation stops if the condition is false for any item,
11863 and the result of the whole condition is false. If the condition is true for
11864 all items in the list, the overall condition is true.
11865 .endlist
11866 Note that negation of &*forany*& means that the condition must be false for all
11867 items for the overall condition to succeed, and negation of &*forall*& means
11868 that the condition must be false for at least one item.
11869
11870 Example:
11871 .code
11872 ${if forany{$recipients_list}{match{$item}{^user3@}}{yes}{no}}
11873 .endd
11874 The value of &$item$& is saved and restored while &%forany%& or &%forall%& is
11875 being processed, to enable these expansion items to be nested.
11876
11877 To scan a named list, expand it with the &*listnamed*& operator.
11878
11879 .vitem "&*forall_json{*&<&'a JSON array'&>&*}{*&<&'a condition'&>&*}*&" &&&
11880        "&*forany_json{*&<&'a JSON array'&>&*}{*&<&'a condition'&>&*}*&" &&&
11881        "&*forall_jsons{*&<&'a JSON array'&>&*}{*&<&'a condition'&>&*}*&" &&&
11882        "&*forany_jsons{*&<&'a JSON array'&>&*}{*&<&'a condition'&>&*}*&"
11883 .cindex JSON "iterative conditions"
11884 .cindex JSON expansions
11885 .cindex expansion "&*forall_json*& condition"
11886 .cindex expansion "&*forany_json*& condition"
11887 .cindex expansion "&*forall_jsons*& condition"
11888 .cindex expansion "&*forany_jsons*& condition"
11889 As for the above, except that the first argument must, after expansion,
11890 be a JSON array.
11891 The array separator is not changeable.
11892 For the &"jsons"& variants the elements are expected to be JSON strings
11893 and have their quotes removed before the evaluation of the condition.
11894
11895
11896
11897 .vitem &*ge&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*& &&&
11898        &*gei&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
11899 .cindex "string" "comparison"
11900 .cindex "expansion" "string comparison"
11901 .cindex "&%ge%& expansion condition"
11902 .cindex "&%gei%& expansion condition"
11903 The two substrings are first expanded. The condition is true if the first
11904 string is lexically greater than or equal to the second string. For &%ge%& the
11905 comparison includes the case of letters, whereas for &%gei%& the comparison is
11906 case-independent.
11907 Case and collation order are defined per the system C locale.
11908
11909 .vitem &*gt&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*& &&&
11910        &*gti&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
11911 .cindex "string" "comparison"
11912 .cindex "expansion" "string comparison"
11913 .cindex "&%gt%& expansion condition"
11914 .cindex "&%gti%& expansion condition"
11915 The two substrings are first expanded. The condition is true if the first
11916 string is lexically greater than the second string. For &%gt%& the comparison
11917 includes the case of letters, whereas for &%gti%& the comparison is
11918 case-independent.
11919 Case and collation order are defined per the system C locale.
11920
11921
11922 .vitem &*inbound_srs&~{*&<&'local&~part'&>&*}{*&<&'secret'&>&*}*&
11923 SRS decode.  See SECT &<<SECTSRS>>& for details.
11924
11925
11926 .vitem &*inlist&~{*&<&'subject'&>&*}{*&<&'list'&>&*}*& &&&
11927        &*inlisti&~{*&<&'subject'&>&*}{*&<&'list'&>&*}*&
11928 .cindex "string" "comparison"
11929 .cindex "list" "iterative conditions"
11930 Both strings are expanded; the second string is treated as a list of simple
11931 strings; if the first string is a member of the second, then the condition
11932 is true.
11933 For the case-independent &%inlisti%& condition, case is defined per the system C locale.
11934
11935 These are simpler to use versions of the more powerful &*forany*& condition.
11936 Examples, and the &*forany*& equivalents:
11937 .code
11938 ${if inlist{needle}{foo:needle:bar}}
11939   ${if forany{foo:needle:bar}{eq{$item}{needle}}}
11940 ${if inlisti{Needle}{fOo:NeeDLE:bAr}}
11941   ${if forany{fOo:NeeDLE:bAr}{eqi{$item}{Needle}}}
11942 .endd
11943
11944 The variable &$value$& will be set for a successful match and can be
11945 used in the success clause of an &%if%& expansion item using the condition.
11946 .cindex "tainted data" "de-tainting"
11947 .cindex "de-tainting" "using an inlist expansion condition"
11948 It will have the same taint status as the list; expansions such as
11949 .code
11950 ${if inlist {$h_mycode:} {0 : 1 : 42} {$value}}
11951 .endd
11952 can be used for de-tainting.
11953 Any previous &$value$& is restored after the if.
11954
11955
11956 .vitem &*isip&~{*&<&'string'&>&*}*&  &&&
11957        &*isip4&~{*&<&'string'&>&*}*& &&&
11958        &*isip6&~{*&<&'string'&>&*}*&
11959 .cindex "IP address" "testing string format"
11960 .cindex "string" "testing for IP address"
11961 .cindex "&%isip%& expansion condition"
11962 .cindex "&%isip4%& expansion condition"
11963 .cindex "&%isip6%& expansion condition"
11964 The substring is first expanded, and then tested to see if it has the form of
11965 an IP address. Both IPv4 and IPv6 addresses are valid for &%isip%&, whereas
11966 &%isip4%& and &%isip6%& test specifically for IPv4 or IPv6 addresses.
11967
11968 For an IPv4 address, the test is for four dot-separated components, each of
11969 which consists of from one to three digits. For an IPv6 address, up to eight
11970 colon-separated components are permitted, each containing from one to four
11971 hexadecimal digits. There may be fewer than eight components if an empty
11972 component (adjacent colons) is present. Only one empty component is permitted.
11973
11974 &*Note*&: The checks used to be just on the form of the address; actual numerical
11975 values were not considered. Thus, for example, 999.999.999.999 passed the IPv4
11976 check.
11977 This is no longer the case.
11978
11979 The main use of these tests is to distinguish between IP addresses and
11980 host names, or between IPv4 and IPv6 addresses. For example, you could use
11981 .code
11982 ${if isip4{$sender_host_address}...
11983 .endd
11984 to test which IP version an incoming SMTP connection is using.
11985
11986 .vitem &*ldapauth&~{*&<&'ldap&~query'&>&*}*&
11987 .cindex "LDAP" "use for authentication"
11988 .cindex "expansion" "LDAP authentication test"
11989 .cindex "&%ldapauth%& expansion condition"
11990 This condition supports user authentication using LDAP. See section
11991 &<<SECTldap>>& for details of how to use LDAP in lookups and the syntax of
11992 queries. For this use, the query must contain a user name and password. The
11993 query itself is not used, and can be empty. The condition is true if the
11994 password is not empty, and the user name and password are accepted by the LDAP
11995 server. An empty password is rejected without calling LDAP because LDAP binds
11996 with an empty password are considered anonymous regardless of the username, and
11997 will succeed in most configurations. See chapter &<<CHAPSMTPAUTH>>& for details
11998 of SMTP authentication, and chapter &<<CHAPplaintext>>& for an example of how
11999 this can be used.
12000
12001
12002 .vitem &*le&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*& &&&
12003        &*lei&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
12004 .cindex "string" "comparison"
12005 .cindex "expansion" "string comparison"
12006 .cindex "&%le%& expansion condition"
12007 .cindex "&%lei%& expansion condition"
12008 The two substrings are first expanded. The condition is true if the first
12009 string is lexically less than or equal to the second string. For &%le%& the
12010 comparison includes the case of letters, whereas for &%lei%& the comparison is
12011 case-independent.
12012 Case and collation order are defined per the system C locale.
12013
12014 .vitem &*lt&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*& &&&
12015        &*lti&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
12016 .cindex "string" "comparison"
12017 .cindex "expansion" "string comparison"
12018 .cindex "&%lt%& expansion condition"
12019 .cindex "&%lti%& expansion condition"
12020 The two substrings are first expanded. The condition is true if the first
12021 string is lexically less than the second string. For &%lt%& the comparison
12022 includes the case of letters, whereas for &%lti%& the comparison is
12023 case-independent.
12024 Case and collation order are defined per the system C locale.
12025
12026
12027 .vitem &*match&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
12028 .cindex "expansion" "regular expression comparison"
12029 .cindex "regular expressions" "match in expanded string"
12030 .cindex "&%match%& expansion condition"
12031 The two substrings are first expanded. The second is then treated as a regular
12032 expression and applied to the first. Because of the pre-expansion, if the
12033 regular expression contains dollar, or backslash characters, they must be
12034 escaped. Care must also be taken if the regular expression contains braces
12035 (curly brackets). A closing brace must be escaped so that it is not taken as a
12036 premature termination of <&'string2'&>. The easiest approach is to use the
12037 &`\N`& feature to disable expansion of the regular expression.
12038 For example,
12039 .code
12040 ${if match {$local_part}{\N^\d{3}\N} ...
12041 .endd
12042 If the whole expansion string is in double quotes, further escaping of
12043 backslashes is also required.
12044
12045 The condition is true if the regular expression match succeeds.
12046 The regular expression is not required to begin with a circumflex
12047 metacharacter, but if there is no circumflex, the expression is not anchored,
12048 and it may match anywhere in the subject, not just at the start. If you want
12049 the pattern to match at the end of the subject, you must include the &`$`&
12050 metacharacter at an appropriate point.
12051 All character handling is done in bytes and is not UTF-8 aware,
12052 but we might change this in a future Exim release.
12053
12054 .cindex "numerical variables (&$1$& &$2$& etc)" "in &%if%& expansion"
12055 At the start of an &%if%& expansion the values of the numeric variable
12056 substitutions &$1$& etc. are remembered. Obeying a &%match%& condition that
12057 succeeds causes them to be reset to the substrings of that condition and they
12058 will have these values during the expansion of the success string. At the end
12059 of the &%if%& expansion, the previous values are restored. After testing a
12060 combination of conditions using &%or%&, the subsequent values of the numeric
12061 variables are those of the condition that succeeded.
12062
12063 .vitem &*match_address&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
12064 .cindex "&%match_address%& expansion condition"
12065 See &*match_local_part*&.
12066
12067 .vitem &*match_domain&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
12068 .cindex "&%match_domain%& expansion condition"
12069 See &*match_local_part*&.
12070
12071 .vitem &*match_ip&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
12072 .cindex "&%match_ip%& expansion condition"
12073 This condition matches an IP address to a list of IP address patterns. It must
12074 be followed by two argument strings. The first (after expansion) must be an IP
12075 address or an empty string. The second (not expanded) is a restricted host
12076 list that can match only an IP address, not a host name. For example:
12077 .code
12078 ${if match_ip{$sender_host_address}{1.2.3.4:5.6.7.8}{...}{...}}
12079 .endd
12080 The specific types of host list item that are permitted in the list are:
12081
12082 .ilist
12083 An IP address, optionally with a CIDR mask.
12084 .next
12085 A single asterisk, which matches any IP address.
12086 .next
12087 An empty item, which matches only if the IP address is empty. This could be
12088 useful for testing for a locally submitted message or one from specific hosts
12089 in a single test such as
12090 . ==== As this is a nested list, any displays it contains must be indented
12091 . ==== as otherwise they are too far to the left. This comment applies to
12092 . ==== the use of xmlto plus fop. There's no problem when formatting with
12093 . ==== sdop, with or without the extra indent.
12094 .code
12095   ${if match_ip{$sender_host_address}{:4.3.2.1:...}{...}{...}}
12096 .endd
12097 where the first item in the list is the empty string.
12098 .next
12099 The item @[] matches any of the local host's interface addresses.
12100 .next
12101 Single-key lookups are assumed to be like &"net-"& style lookups in host lists
12102 (see section &<<SECThoslispatsikey>>&),
12103 even if &`net-`& is not specified. There is never any attempt to turn the IP
12104 address into a host name. The most common type of linear search for
12105 &*match_ip*& is likely to be &*iplsearch*&, in which the file can contain CIDR
12106 masks. For example:
12107 .code
12108   ${if match_ip{$sender_host_address}{iplsearch;/some/file}...
12109 .endd
12110 It is of course possible to use other kinds of lookup, and in such a case, you
12111 do need to specify the &`net-`& prefix if you want to specify a specific
12112 address mask, for example:
12113 .code
12114   ${if match_ip{$sender_host_address}{net24-dbm;/some/file}...
12115 .endd
12116 However, unless you are combining a &%match_ip%& condition with others, it is
12117 just as easy to use the fact that a lookup is itself a condition, and write:
12118 .code
12119   ${lookup{${mask:$sender_host_address/24}}dbm{/a/file}...
12120 .endd
12121 .endlist ilist
12122
12123 Note that <&'string2'&> is not itself subject to string expansion, unless
12124 Exim was built with the EXPAND_LISTMATCH_RHS option.
12125
12126 Consult section &<<SECThoslispatip>>& for further details of these patterns.
12127
12128 The variable &$value$& will be set for a successful match and can be
12129 used in the success clause of an &%if%& expansion item using the condition.
12130 Any previous &$value$& is restored after the if.
12131
12132 .vitem &*match_local_part&~{*&<&'string1'&>&*}{*&<&'string2'&>&*}*&
12133 .cindex "domain list" "in expansion condition"
12134 .cindex "address list" "in expansion condition"
12135 .cindex "local part" "list, in expansion condition"
12136 .cindex "&%match_local_part%& expansion condition"
12137 This condition, together with &%match_address%& and &%match_domain%&, make it
12138 possible to test domain, address, and local part lists within expansions. Each
12139 condition requires two arguments: an item and a list to match. A trivial
12140 example is:
12141 .code
12142 ${if match_domain{a.b.c}{x.y.z:a.b.c:p.q.r}{yes}{no}}
12143 .endd
12144 In each case, the second argument may contain any of the allowable items for a
12145 list of the appropriate type. Also, because the second argument
12146 is a standard form of list, it is possible to refer to a named list.
12147 Thus, you can use conditions like this:
12148 .code
12149 ${if match_domain{$domain}{+local_domains}{...
12150 .endd
12151 .cindex "&`+caseful`&"
12152 For address lists, the matching starts off caselessly, but the &`+caseful`&
12153 item can be used, as in all address lists, to cause subsequent items to
12154 have their local parts matched casefully. Domains are always matched
12155 caselessly.
12156
12157 The variable &$value$& will be set for a successful match and can be
12158 used in the success clause of an &%if%& expansion item using the condition.
12159 .cindex "tainted data" "de-tainting"
12160 .cindex "de-tainting" "using a match_local_part expansion condition"
12161 It will have the same taint status as the list; expansions such as
12162 .code
12163 ${if match_local_part {$local_part} {alice : bill : charlotte : dave} {$value}}
12164 .endd
12165 can be used for de-tainting.
12166 Any previous &$value$& is restored after the if.
12167
12168 Note that <&'string2'&> is not itself subject to string expansion, unless
12169 Exim was built with the EXPAND_LISTMATCH_RHS option.
12170
12171 &*Note*&: Host lists are &'not'& supported in this way. This is because
12172 hosts have two identities: a name and an IP address, and it is not clear
12173 how to specify cleanly how such a test would work. However, IP addresses can be
12174 matched using &%match_ip%&.
12175
12176 .vitem &*pam&~{*&<&'string1'&>&*:*&<&'string2'&>&*:...}*&
12177 .cindex "PAM authentication"
12178 .cindex "AUTH" "with PAM"
12179 .cindex "Solaris" "PAM support"
12180 .cindex "expansion" "PAM authentication test"
12181 .cindex "&%pam%& expansion condition"
12182 &'Pluggable Authentication Modules'&
12183 (&url(https://mirrors.edge.kernel.org/pub/linux/libs/pam/)) are a facility that is
12184 available in Solaris
12185 and in some GNU/Linux distributions.
12186 The Exim support, which is intended for use in conjunction with
12187 the SMTP AUTH command, is available only if Exim is compiled with
12188 .code
12189 SUPPORT_PAM=yes
12190 .endd
12191 in &_Local/Makefile_&. You probably need to add &%-lpam%& to EXTRALIBS, and
12192 in some releases of GNU/Linux &%-ldl%& is also needed.
12193
12194 The argument string is first expanded, and the result must be a
12195 colon-separated list of strings. Leading and trailing white space is ignored.
12196 The PAM module is initialized with the service name &"exim"& and the user name
12197 taken from the first item in the colon-separated data string (<&'string1'&>).
12198 The remaining items in the data string are passed over in response to requests
12199 from the authentication function. In the simple case there will only be one
12200 request, for a password, so the data consists of just two strings.
12201
12202 There can be problems if any of the strings are permitted to contain colon
12203 characters. In the usual way, these have to be doubled to avoid being taken as
12204 separators.
12205 The &%listquote%& expansion item can be used for this.
12206 For example, the configuration
12207 of a LOGIN authenticator might contain this setting:
12208 .code
12209 server_condition = ${if pam{$auth1:${listquote{:}{$auth2}}}}
12210 .endd
12211 In some operating systems, PAM authentication can be done only from a process
12212 running as root. Since Exim is running as the Exim user when receiving
12213 messages, this means that PAM cannot be used directly in those systems.
12214 . --- 2018-09-07: the pam_exim modified variant has gone, removed claims re using Exim via that
12215
12216
12217 .vitem &*pwcheck&~{*&<&'string1'&>&*:*&<&'string2'&>&*}*&
12218 .cindex "&'pwcheck'& daemon"
12219 .cindex "Cyrus"
12220 .cindex "expansion" "&'pwcheck'& authentication test"
12221 .cindex "&%pwcheck%& expansion condition"
12222 This condition supports user authentication using the Cyrus &'pwcheck'& daemon.
12223 This is one way of making it possible for passwords to be checked by a process
12224 that is not running as root. &*Note*&: The use of &'pwcheck'& is now
12225 deprecated. Its replacement is &'saslauthd'& (see below).
12226
12227 The pwcheck support is not included in Exim by default. You need to specify
12228 the location of the pwcheck daemon's socket in &_Local/Makefile_& before
12229 building Exim. For example:
12230 .code
12231 CYRUS_PWCHECK_SOCKET=/var/pwcheck/pwcheck
12232 .endd
12233 You do not need to install the full Cyrus software suite in order to use
12234 the pwcheck daemon. You can compile and install just the daemon alone
12235 from the Cyrus SASL library. Ensure that &'exim'& is the only user that has
12236 access to the &_/var/pwcheck_& directory.
12237
12238 The &%pwcheck%& condition takes one argument, which must be the user name and
12239 password, separated by a colon. For example, in a LOGIN authenticator
12240 configuration, you might have this:
12241 .code
12242 server_condition = ${if pwcheck{$auth1:$auth2}}
12243 .endd
12244 Again, for a PLAIN authenticator configuration, this would be:
12245 .code
12246 server_condition = ${if pwcheck{$auth2:$auth3}}
12247 .endd
12248 .vitem &*queue_running*&
12249 .cindex "queue runner" "detecting when delivering from"
12250 .cindex "expansion" "queue runner test"
12251 .cindex "&%queue_running%& expansion condition"
12252 This condition, which has no data, is true during delivery attempts that are
12253 initiated by queue runner processes, and false otherwise.
12254
12255
12256 .vitem &*radius&~{*&<&'authentication&~string'&>&*}*&
12257 .cindex "Radius"
12258 .cindex "expansion" "Radius authentication"
12259 .cindex "&%radius%& expansion condition"
12260 Radius authentication (RFC 2865) is supported in a similar way to PAM. You must
12261 set RADIUS_CONFIG_FILE in &_Local/Makefile_& to specify the location of
12262 the Radius client configuration file in order to build Exim with Radius
12263 support.
12264
12265 With just that one setting, Exim expects to be linked with the &%radiusclient%&
12266 library, using the original API. If you are using release 0.4.0 or later of
12267 this library, you need to set
12268 .code
12269 RADIUS_LIB_TYPE=RADIUSCLIENTNEW
12270 .endd
12271 in &_Local/Makefile_& when building Exim. You can also link Exim with the
12272 &%libradius%& library that comes with FreeBSD. To do this, set
12273 .code
12274 RADIUS_LIB_TYPE=RADLIB
12275 .endd
12276 in &_Local/Makefile_&, in addition to setting RADIUS_CONFIGURE_FILE.
12277 You may also have to supply a suitable setting in EXTRALIBS so that the
12278 Radius library can be found when Exim is linked.
12279
12280 The string specified by RADIUS_CONFIG_FILE is expanded and passed to the
12281 Radius client library, which calls the Radius server. The condition is true if
12282 the authentication is successful. For example:
12283 .code
12284 server_condition = ${if radius{<arguments>}}
12285 .endd
12286
12287
12288 .vitem "&*saslauthd&~{{*&<&'user'&>&*}{*&<&'password'&>&*}&&&
12289         {*&<&'service'&>&*}{*&<&'realm'&>&*}}*&"
12290 .cindex "&'saslauthd'& daemon"
12291 .cindex "Cyrus"
12292 .cindex "expansion" "&'saslauthd'& authentication test"
12293 .cindex "&%saslauthd%& expansion condition"
12294 This condition supports user authentication using the Cyrus &'saslauthd'&
12295 daemon. This replaces the older &'pwcheck'& daemon, which is now deprecated.
12296 Using this daemon is one way of making it possible for passwords to be checked
12297 by a process that is not running as root.
12298
12299 The saslauthd support is not included in Exim by default. You need to specify
12300 the location of the saslauthd daemon's socket in &_Local/Makefile_& before
12301 building Exim. For example:
12302 .code
12303 CYRUS_SASLAUTHD_SOCKET=/var/state/saslauthd/mux
12304 .endd
12305 You do not need to install the full Cyrus software suite in order to use
12306 the saslauthd daemon. You can compile and install just the daemon alone
12307 from the Cyrus SASL library.
12308
12309 Up to four arguments can be supplied to the &%saslauthd%& condition, but only
12310 two are mandatory. For example:
12311 .code
12312 server_condition = ${if saslauthd{{$auth1}{$auth2}}}
12313 .endd
12314 The service and the realm are optional (which is why the arguments are enclosed
12315 in their own set of braces). For details of the meaning of the service and
12316 realm, and how to run the daemon, consult the Cyrus documentation.
12317 .endlist vlist
12318
12319
12320
12321 .section "Combining expansion conditions" "SECID84"
12322 .cindex "expansion" "combining conditions"
12323 Several conditions can be tested at once by combining them using the &%and%&
12324 and &%or%& combination conditions. Note that &%and%& and &%or%& are complete
12325 conditions on their own, and precede their lists of sub-conditions. Each
12326 sub-condition must be enclosed in braces within the overall braces that contain
12327 the list. No repetition of &%if%& is used.
12328
12329
12330 .vlist
12331 .vitem &*or&~{{*&<&'cond1'&>&*}{*&<&'cond2'&>&*}...}*&
12332 .cindex "&""or""& expansion condition"
12333 .cindex "expansion" "&""or""& of conditions"
12334 The sub-conditions are evaluated from left to right. The condition is true if
12335 any one of the sub-conditions is true.
12336 For example,
12337 .code
12338 ${if or {{eq{$local_part}{spqr}}{eq{$domain}{testing.com}}}...
12339 .endd
12340 When a true sub-condition is found, the following ones are parsed but not
12341 evaluated. If there are several &"match"& sub-conditions the values of the
12342 numeric variables afterwards are taken from the first one that succeeds.
12343
12344 .vitem &*and&~{{*&<&'cond1'&>&*}{*&<&'cond2'&>&*}...}*&
12345 .cindex "&""and""& expansion condition"
12346 .cindex "expansion" "&""and""& of conditions"
12347 The sub-conditions are evaluated from left to right. The condition is true if
12348 all of the sub-conditions are true. If there are several &"match"&
12349 sub-conditions, the values of the numeric variables afterwards are taken from
12350 the last one. When a false sub-condition is found, the following ones are
12351 parsed but not evaluated.
12352 .endlist
12353 .ecindex IIDexpcond
12354
12355
12356
12357
12358 .section "Expansion variables" "SECTexpvar"
12359 .cindex "expansion" "variables, list of"
12360 This section contains an alphabetical list of all the expansion variables. Some
12361 of them are available only when Exim is compiled with specific options such as
12362 support for TLS or the content scanning extension.
12363 .cindex "tainted data"
12364 Variables marked as &'tainted'& are likely to carry data supplied by
12365 a potential attacker.
12366 Variables without such marking may also, depending on how their
12367 values are created.
12368 Such variables should not be further expanded,
12369 used as filenames
12370 or used as command-line arguments for external commands.
12371
12372 .vlist
12373 .vitem "&$0$&, &$1$&, etc"
12374 .cindex "numerical variables (&$1$& &$2$& etc)"
12375 When a &%match%& expansion condition succeeds, these variables contain the
12376 captured substrings identified by the regular expression during subsequent
12377 processing of the success string of the containing &%if%& expansion item.
12378 In the expansion condition case
12379 they do not retain their values afterwards; in fact, their previous
12380 values are restored at the end of processing an &%if%& item. The numerical
12381 variables may also be set externally by some other matching process which
12382 precedes the expansion of the string. For example, the commands available in
12383 Exim filter files include an &%if%& command with its own regular expression
12384 matching condition.
12385 If the subject string was tainted then any captured substring will also be.
12386
12387 .vitem "&$acl_arg1$&, &$acl_arg2$&, etc"
12388 Within an acl condition, expansion condition or expansion item
12389 any arguments are copied to these variables,
12390 any unused variables being made empty.
12391
12392 .vitem "&$acl_c...$&"
12393 Values can be placed in these variables by the &%set%& modifier in an ACL. They
12394 can be given any name that starts with &$acl_c$& and is at least six characters
12395 long, but the sixth character must be either a digit or an underscore. For
12396 example: &$acl_c5$&, &$acl_c_mycount$&. The values of the &$acl_c...$&
12397 variables persist throughout the lifetime of an SMTP connection. They can be
12398 used to pass information between ACLs and between different invocations of the
12399 same ACL. When a message is received, the values of these variables are saved
12400 with the message, and can be accessed by filters, routers, and transports
12401 during subsequent delivery.
12402
12403 .vitem "&$acl_m...$&"
12404 These variables are like the &$acl_c...$& variables, except that their values
12405 are reset after a message has been received. Thus, if several messages are
12406 received in one SMTP connection, &$acl_m...$& values are not passed on from one
12407 message to the next, as &$acl_c...$& values are. The &$acl_m...$& variables are
12408 also reset by MAIL, RSET, EHLO, HELO, and after starting a TLS session. When a
12409 message is received, the values of these variables are saved with the message,
12410 and can be accessed by filters, routers, and transports during subsequent
12411 delivery.
12412
12413 .vitem &$acl_narg$&
12414 Within an acl condition, expansion condition or expansion item
12415 this variable has the number of arguments.
12416
12417 .vitem &$acl_verify_message$&
12418 .vindex "&$acl_verify_message$&"
12419 After an address verification has failed, this variable contains the failure
12420 message. It retains its value for use in subsequent modifiers of the verb.
12421 The message can be preserved by coding like this:
12422 .code
12423 warn !verify = sender
12424      set acl_m0 = $acl_verify_message
12425 .endd
12426 You can use &$acl_verify_message$& during the expansion of the &%message%& or
12427 &%log_message%& modifiers, to include information about the verification
12428 failure.
12429 &*Note*&: The variable is cleared at the end of processing the ACL verb.
12430
12431 .vitem &$address_data$&
12432 .vindex "&$address_data$&"
12433 This variable is set by means of the &%address_data%& option in routers. The
12434 value then remains with the address while it is processed by subsequent routers
12435 and eventually a transport. If the transport is handling multiple addresses,
12436 the value from the first address is used. See chapter &<<CHAProutergeneric>>&
12437 for more details. &*Note*&: The contents of &$address_data$& are visible in
12438 user filter files.
12439
12440 If &$address_data$& is set when the routers are called from an ACL to verify
12441 a recipient address, the final value is still in the variable for subsequent
12442 conditions and modifiers of the ACL statement. If routing the address caused it
12443 to be redirected to just one address, the child address is also routed as part
12444 of the verification, and in this case the final value of &$address_data$& is
12445 from the child's routing.
12446
12447 If &$address_data$& is set when the routers are called from an ACL to verify a
12448 sender address, the final value is also preserved, but this time in
12449 &$sender_address_data$&, to distinguish it from data from a recipient
12450 address.
12451
12452 In both cases (recipient and sender verification), the value does not persist
12453 after the end of the current ACL statement. If you want to preserve
12454 these values for longer, you can save them in ACL variables.
12455
12456 .vitem &$address_file$&
12457 .vindex "&$address_file$&"
12458 When, as a result of aliasing, forwarding, or filtering, a message is directed
12459 to a specific file, this variable holds the name of the file when the transport
12460 is running. At other times, the variable is empty. For example, using the
12461 default configuration, if user &%r2d2%& has a &_.forward_& file containing
12462 .code
12463 /home/r2d2/savemail
12464 .endd
12465 then when the &(address_file)& transport is running, &$address_file$&
12466 contains the text string &`/home/r2d2/savemail`&.
12467 .cindex "Sieve filter" "value of &$address_file$&"
12468 For Sieve filters, the value may be &"inbox"& or a relative folder name. It is
12469 then up to the transport configuration to generate an appropriate absolute path
12470 to the relevant file.
12471
12472 .vitem &$address_pipe$&
12473 .vindex "&$address_pipe$&"
12474 When, as a result of aliasing or forwarding, a message is directed to a pipe,
12475 this variable holds the pipe command when the transport is running.
12476
12477 .vitem "&$auth1$& &-- &$auth4$&"
12478 .vindex "&$auth1$&, &$auth2$&, etc"
12479 These variables are used in SMTP authenticators (see chapters
12480 &<<CHAPplaintext>>&&--&<<CHAPtlsauth>>&). Elsewhere, they are empty.
12481
12482 .vitem &$authenticated_id$&
12483 .cindex "authentication" "id"
12484 .vindex "&$authenticated_id$&"
12485 When a server successfully authenticates a client it may be configured to
12486 preserve some of the authentication information in the variable
12487 &$authenticated_id$& (see chapter &<<CHAPSMTPAUTH>>&). For example, a
12488 user/password authenticator configuration might preserve the user name for use
12489 in the routers. Note that this is not the same information that is saved in
12490 &$sender_host_authenticated$&.
12491
12492 When a message is submitted locally (that is, not over a TCP connection)
12493 the value of &$authenticated_id$& is normally the login name of the calling
12494 process. However, a trusted user can override this by means of the &%-oMai%&
12495 command line option.
12496 This second case also sets up information used by the
12497 &$authresults$& expansion item.
12498
12499 .vitem &$authenticated_fail_id$&
12500 .cindex "authentication" "fail" "id"
12501 .vindex "&$authenticated_fail_id$&"
12502 When an authentication attempt fails, the variable &$authenticated_fail_id$&
12503 will contain the failed authentication id. If more than one authentication
12504 id is attempted, it will contain only the last one. The variable is
12505 available for processing in the ACL's, generally the quit or notquit ACL.
12506 A message to a local recipient could still be accepted without requiring
12507 authentication, which means this variable could also be visible in all of
12508 the ACL's as well.
12509
12510
12511 .tvar &$authenticated_sender$&
12512 .cindex "sender" "authenticated"
12513 .cindex "authentication" "sender"
12514 .cindex "AUTH" "on MAIL command"
12515 When acting as a server, Exim takes note of the AUTH= parameter on an incoming
12516 SMTP MAIL command if it believes the sender is sufficiently trusted, as
12517 described in section &<<SECTauthparamail>>&. Unless the data is the string
12518 &"<>"&, it is set as the authenticated sender of the message, and the value is
12519 available during delivery in the &$authenticated_sender$& variable. If the
12520 sender is not trusted, Exim accepts the syntax of AUTH=, but ignores the data.
12521
12522 .vindex "&$qualify_domain$&"
12523 When a message is submitted locally (that is, not over a TCP connection), the
12524 value of &$authenticated_sender$& is an address constructed from the login
12525 name of the calling process and &$qualify_domain$&, except that a trusted user
12526 can override this by means of the &%-oMas%& command line option.
12527
12528
12529 .vitem &$authentication_failed$&
12530 .cindex "authentication" "failure"
12531 .vindex "&$authentication_failed$&"
12532 This variable is set to &"1"& in an Exim server if a client issues an AUTH
12533 command that does not succeed. Otherwise it is set to &"0"&. This makes it
12534 possible to distinguish between &"did not try to authenticate"&
12535 (&$sender_host_authenticated$& is empty and &$authentication_failed$& is set to
12536 &"0"&) and &"tried to authenticate but failed"& (&$sender_host_authenticated$&
12537 is empty and &$authentication_failed$& is set to &"1"&).
12538 Failure includes cancellation of a authentication attempt,
12539 and any negative response to an AUTH command,
12540 (including, for example, an attempt to use an undefined mechanism).
12541
12542 .vitem &$av_failed$&
12543 .cindex "content scanning" "AV scanner failure"
12544 This variable is available when Exim is compiled with the content-scanning
12545 extension. It is set to &"0"& by default, but will be set to &"1"& if any
12546 problem occurs with the virus scanner (specified by &%av_scanner%&) during
12547 the ACL malware condition.
12548
12549 .vitem &$body_linecount$&
12550 .cindex "message body" "line count"
12551 .cindex "body of message" "line count"
12552 .vindex "&$body_linecount$&"
12553 When a message is being received or delivered, this variable contains the
12554 number of lines in the message's body. See also &$message_linecount$&.
12555
12556 .vitem &$body_zerocount$&
12557 .cindex "message body" "binary zero count"
12558 .cindex "body of message" "binary zero count"
12559 .cindex "binary zero" "in message body"
12560 .vindex "&$body_zerocount$&"
12561 When a message is being received or delivered, this variable contains the
12562 number of binary zero bytes (ASCII NULs) in the message's body.
12563
12564 .vitem &$bounce_recipient$&
12565 .vindex "&$bounce_recipient$&"
12566 This is set to the recipient address of a bounce message while Exim is creating
12567 it. It is useful if a customized bounce message text file is in use (see
12568 chapter &<<CHAPemsgcust>>&).
12569
12570 .vitem &$bounce_return_size_limit$&
12571 .vindex "&$bounce_return_size_limit$&"
12572 This contains the value set in the &%bounce_return_size_limit%& option, rounded
12573 up to a multiple of 1000. It is useful when a customized error message text
12574 file is in use (see chapter &<<CHAPemsgcust>>&).
12575
12576 .vitem &$caller_gid$&
12577 .cindex "gid (group id)" "caller"
12578 .vindex "&$caller_gid$&"
12579 The real group id under which the process that called Exim was running. This is
12580 not the same as the group id of the originator of a message (see
12581 &$originator_gid$&). If Exim re-execs itself, this variable in the new
12582 incarnation normally contains the Exim gid.
12583
12584 .vitem &$caller_uid$&
12585 .cindex "uid (user id)" "caller"
12586 .vindex "&$caller_uid$&"
12587 The real user id under which the process that called Exim was running. This is
12588 not the same as the user id of the originator of a message (see
12589 &$originator_uid$&). If Exim re-execs itself, this variable in the new
12590 incarnation normally contains the Exim uid.
12591
12592 .vitem &$callout_address$&
12593 .vindex "&$callout_address$&"
12594 After a callout for verification, spamd or malware daemon service, the
12595 address that was connected to.
12596
12597 .vitem &$compile_number$&
12598 .vindex "&$compile_number$&"
12599 The building process for Exim keeps a count of the number
12600 of times it has been compiled. This serves to distinguish different
12601 compilations of the same version of Exim.
12602
12603 .vitem &$config_dir$&
12604 .vindex "&$config_dir$&"
12605 The directory name of the main configuration file. That is, the content of
12606 &$config_file$& with the last component stripped. The value does not
12607 contain the trailing slash. If &$config_file$& does not contain a slash,
12608 &$config_dir$& is ".".
12609
12610 .vitem &$config_file$&
12611 .vindex "&$config_file$&"
12612 The name of the main configuration file Exim is using.
12613
12614 .vitem &$dkim_verify_status$&
12615 Results of DKIM verification.
12616 For details see section &<<SECDKIMVFY>>&.
12617
12618 .vitem &$dkim_cur_signer$& &&&
12619        &$dkim_verify_reason$& &&&
12620        &$dkim_domain$& &&&
12621        &$dkim_identity$& &&&
12622        &$dkim_selector$& &&&
12623        &$dkim_algo$& &&&
12624        &$dkim_canon_body$& &&&
12625        &$dkim_canon_headers$& &&&
12626        &$dkim_copiedheaders$& &&&
12627        &$dkim_bodylength$& &&&
12628        &$dkim_created$& &&&
12629        &$dkim_expires$& &&&
12630        &$dkim_headernames$& &&&
12631        &$dkim_key_testing$& &&&
12632        &$dkim_key_nosubdomains$& &&&
12633        &$dkim_key_srvtype$& &&&
12634        &$dkim_key_granularity$& &&&
12635        &$dkim_key_notes$& &&&
12636        &$dkim_key_length$&
12637 These variables are only available within the DKIM ACL.
12638 For details see section &<<SECDKIMVFY>>&.
12639
12640 .vitem &$dkim_signers$&
12641 .vindex &$dkim_signers$&
12642 When a message has been received this variable contains
12643 a colon-separated list of signer domains and identities for the message.
12644 For details see section &<<SECDKIMVFY>>&.
12645
12646 .vitem &$dmarc_domain_policy$& &&&
12647        &$dmarc_status$& &&&
12648        &$dmarc_status_text$& &&&
12649        &$dmarc_used_domains$&
12650 Results of DMARC verification.
12651 For details see section &<<SECDMARC>>&.
12652
12653 .vitem &$dnslist_domain$& &&&
12654        &$dnslist_matched$& &&&
12655        &$dnslist_text$& &&&
12656        &$dnslist_value$&
12657 .vindex "&$dnslist_domain$&"
12658 .vindex "&$dnslist_matched$&"
12659 .vindex "&$dnslist_text$&"
12660 .vindex "&$dnslist_value$&"
12661 .cindex "black list (DNS)"
12662 When a DNS (black) list lookup succeeds, these variables are set to contain
12663 the following data from the lookup: the list's domain name, the key that was
12664 looked up, the contents of any associated TXT record, and the value from the
12665 main A record. See section &<<SECID204>>& for more details.
12666
12667 .tvar &$domain$&
12668 When an address is being routed, or delivered on its own, this variable
12669 contains the domain. Uppercase letters in the domain are converted into lower
12670 case for &$domain$&.
12671
12672 Global address rewriting happens when a message is received, so the value of
12673 &$domain$& during routing and delivery is the value after rewriting. &$domain$&
12674 is set during user filtering, but not during system filtering, because a
12675 message may have many recipients and the system filter is called just once.
12676
12677 When more than one address is being delivered at once (for example, several
12678 RCPT commands in one SMTP delivery), &$domain$& is set only if they all
12679 have the same domain. Transports can be restricted to handling only one domain
12680 at a time if the value of &$domain$& is required at transport time &-- this is
12681 the default for local transports. For further details of the environment in
12682 which local transports are run, see chapter &<<CHAPenvironment>>&.
12683
12684 .oindex "&%delay_warning_condition%&"
12685 At the end of a delivery, if all deferred addresses have the same domain, it is
12686 set in &$domain$& during the expansion of &%delay_warning_condition%&.
12687
12688 The &$domain$& variable is also used in some other circumstances:
12689
12690 .ilist
12691 When an ACL is running for a RCPT command, &$domain$& contains the domain of
12692 the recipient address. The domain of the &'sender'& address is in
12693 &$sender_address_domain$& at both MAIL time and at RCPT time. &$domain$& is not
12694 normally set during the running of the MAIL ACL. However, if the sender address
12695 is verified with a callout during the MAIL ACL, the sender domain is placed in
12696 &$domain$& during the expansions of &%hosts%&, &%interface%&, and &%port%& in
12697 the &(smtp)& transport.
12698
12699 .next
12700 When a rewrite item is being processed (see chapter &<<CHAPrewrite>>&),
12701 &$domain$& contains the domain portion of the address that is being rewritten;
12702 it can be used in the expansion of the replacement address, for example, to
12703 rewrite domains by file lookup.
12704
12705 .next
12706 With one important exception, whenever a domain list is being scanned,
12707 &$domain$& contains the subject domain. &*Exception*&: When a domain list in
12708 a &%sender_domains%& condition in an ACL is being processed, the subject domain
12709 is in &$sender_address_domain$& and not in &$domain$&. It works this way so
12710 that, in a RCPT ACL, the sender domain list can be dependent on the
12711 recipient domain (which is what is in &$domain$& at this time).
12712
12713 .next
12714 .cindex "ETRN" "value of &$domain$&"
12715 .oindex "&%smtp_etrn_command%&"
12716 When the &%smtp_etrn_command%& option is being expanded, &$domain$& contains
12717 the complete argument of the ETRN command (see section &<<SECTETRN>>&).
12718 .endlist
12719
12720 .cindex "tainted data"
12721 If the origin of the data is an incoming message,
12722 the result of expanding this variable is tainted and may not
12723 be further expanded or used as a filename.
12724 When an untainted version is needed, one should be obtained from
12725 looking up the value in a local (therefore trusted) database.
12726 Often &$domain_data$& is usable in this role.
12727
12728
12729 .vitem &$domain_data$&
12730 .vindex "&$domain_data$&"
12731 When the &%domains%& condition on a router
12732 or an ACL
12733 matches a domain
12734 against a list, the match value is copied to &$domain_data$&.
12735 This is an enhancement over previous versions of Exim, when it only
12736 applied to the data read by a lookup.
12737 For details on match values see section &<<SECTlistresults>>& et. al.
12738
12739 If the router routes the
12740 address to a transport, the value is available in that transport. If the
12741 transport is handling multiple addresses, the value from the first address is
12742 used.
12743
12744 &$domain_data$& set in an ACL is available during
12745 the rest of the ACL statement.
12746
12747 .vitem &$exim_gid$&
12748 .vindex "&$exim_gid$&"
12749 This variable contains the numerical value of the Exim group id.
12750
12751 .vitem &$exim_path$&
12752 .vindex "&$exim_path$&"
12753 This variable contains the path to the Exim binary.
12754
12755 .vitem &$exim_uid$&
12756 .vindex "&$exim_uid$&"
12757 This variable contains the numerical value of the Exim user id.
12758
12759 .vitem &$exim_version$&
12760 .vindex "&$exim_version$&"
12761 This variable contains the version string of the Exim build.
12762 The first character is a major version number, currently 4.
12763 Then after a dot, the next group of digits is a minor version number.
12764 There may be other characters following the minor version.
12765 This value may be overridden by the &%exim_version%& main config option.
12766
12767 .vitem &$header_$&<&'name'&>
12768 .tmark
12769 This is not strictly an expansion variable. It is expansion syntax for
12770 inserting the message header line with the given name. Note that the name must
12771 be terminated by colon or white space, because it may contain a wide variety of
12772 characters. Note also that braces must &'not'& be used.
12773 See the full description in section &<<SECTexpansionitems>>& above.
12774
12775 .vitem &$headers_added$&
12776 .vindex "&$headers_added$&"
12777 Within an ACL this variable contains the headers added so far by
12778 the ACL modifier add_header (section &<<SECTaddheadacl>>&).
12779 The headers are a newline-separated list.
12780
12781 .vitem &$home$&
12782 .vindex "&$home$&"
12783 When the &%check_local_user%& option is set for a router, the user's home
12784 directory is placed in &$home$& when the check succeeds. In particular, this
12785 means it is set during the running of users' filter files. A router may also
12786 explicitly set a home directory for use by a transport; this can be overridden
12787 by a setting on the transport itself.
12788
12789 When running a filter test via the &%-bf%& option, &$home$& is set to the value
12790 of the environment variable HOME, which is subject to the
12791 &%keep_environment%& and &%add_environment%& main config options.
12792
12793 .vitem &$host$&
12794 .vindex "&$host$&"
12795 If a router assigns an address to a transport (any transport), and passes a
12796 list of hosts with the address, the value of &$host$& when the transport starts
12797 to run is the name of the first host on the list. Note that this applies both
12798 to local and remote transports.
12799
12800 .cindex "transport" "filter"
12801 .cindex "filter" "transport filter"
12802 For the &(smtp)& transport, if there is more than one host, the value of
12803 &$host$& changes as the transport works its way through the list. In
12804 particular, when the &(smtp)& transport is expanding its options for encryption
12805 using TLS, or for specifying a transport filter (see chapter
12806 &<<CHAPtransportgeneric>>&), &$host$& contains the name of the host to which it
12807 is connected.
12808
12809 When used in the client part of an authenticator configuration (see chapter
12810 &<<CHAPSMTPAUTH>>&), &$host$& contains the name of the server to which the
12811 client is connected.
12812
12813
12814 .vitem &$host_address$&
12815 .vindex "&$host_address$&"
12816 This variable is set to the remote host's IP address whenever &$host$& is set
12817 for a remote connection. It is also set to the IP address that is being checked
12818 when the &%ignore_target_hosts%& option is being processed.
12819
12820 .vitem &$host_data$&
12821 .vindex "&$host_data$&"
12822 If a &%hosts%& condition in an ACL is satisfied by means of a lookup, the
12823 result of the lookup is made available in the &$host_data$& variable. This
12824 allows you, for example, to do things like this:
12825 .code
12826 deny  hosts = net-lsearch;/some/file
12827       message = $host_data
12828 .endd
12829
12830 .vitem &$host_lookup_deferred$&
12831 .cindex "host name" "lookup, failure of"
12832 .vindex "&$host_lookup_deferred$&"
12833 This variable normally contains &"0"&, as does &$host_lookup_failed$&. When a
12834 message comes from a remote host and there is an attempt to look up the host's
12835 name from its IP address, and the attempt is not successful, one of these
12836 variables is set to &"1"&.
12837
12838 .ilist
12839 If the lookup receives a definite negative response (for example, a DNS lookup
12840 succeeded, but no records were found), &$host_lookup_failed$& is set to &"1"&.
12841
12842 .next
12843 If there is any kind of problem during the lookup, such that Exim cannot
12844 tell whether or not the host name is defined (for example, a timeout for a DNS
12845 lookup), &$host_lookup_deferred$& is set to &"1"&.
12846 .endlist ilist
12847
12848 Looking up a host's name from its IP address consists of more than just a
12849 single reverse lookup. Exim checks that a forward lookup of at least one of the
12850 names it receives from a reverse lookup yields the original IP address. If this
12851 is not the case, Exim does not accept the looked up name(s), and
12852 &$host_lookup_failed$& is set to &"1"&. Thus, being able to find a name from an
12853 IP address (for example, the existence of a PTR record in the DNS) is not
12854 sufficient on its own for the success of a host name lookup. If the reverse
12855 lookup succeeds, but there is a lookup problem such as a timeout when checking
12856 the result, the name is not accepted, and &$host_lookup_deferred$& is set to
12857 &"1"&. See also &$sender_host_name$&.
12858
12859 .cindex authentication "expansion item"
12860 Performing these checks sets up information used by the
12861 &%authresults%& expansion item.
12862
12863
12864 .vitem &$host_lookup_failed$&
12865 .vindex "&$host_lookup_failed$&"
12866 See &$host_lookup_deferred$&.
12867
12868 .vitem &$host_port$&
12869 .vindex "&$host_port$&"
12870 This variable is set to the remote host's TCP port whenever &$host$& is set
12871 for an outbound connection.
12872
12873 .vitem &$initial_cwd$&
12874 .vindex "&$initial_cwd$&
12875 This variable contains the full path name of the initial working
12876 directory of the current Exim process. This may differ from the current
12877 working directory, as Exim changes this to "/" during early startup, and
12878 to &$spool_directory$& later.
12879
12880 .vitem &$inode$&
12881 .vindex "&$inode$&"
12882 The only time this variable is set is while expanding the &%directory_file%&
12883 option in the &(appendfile)& transport. The variable contains the inode number
12884 of the temporary file which is about to be renamed. It can be used to construct
12885 a unique name for the file.
12886
12887 .vitem &$interface_address$& &&&
12888        &$interface_port$&
12889 .vindex "&$interface_address$&"
12890 .vindex "&$interface_port$&"
12891 These are obsolete names for &$received_ip_address$& and &$received_port$&.
12892
12893 .vitem &$item$&
12894 .vindex "&$item$&"
12895 This variable is used during the expansion of &*forall*& and &*forany*&
12896 conditions (see section &<<SECTexpcond>>&), and &*filter*&, &*map*&, and
12897 &*reduce*& items (see section &<<SECTexpcond>>&). In other circumstances, it is
12898 empty.
12899
12900 .vitem &$ldap_dn$&
12901 .vindex "&$ldap_dn$&"
12902 This variable, which is available only when Exim is compiled with LDAP support,
12903 contains the DN from the last entry in the most recently successful LDAP
12904 lookup.
12905
12906 .vitem &$load_average$&
12907 .vindex "&$load_average$&"
12908 This variable contains the system load average, multiplied by 1000 so that it
12909 is an integer. For example, if the load average is 0.21, the value of the
12910 variable is 210. The value is recomputed every time the variable is referenced.
12911
12912 .tvar &$local_part$&
12913 When an address is being routed, or delivered on its own, this
12914 variable contains the local part. When a number of addresses are being
12915 delivered together (for example, multiple RCPT commands in an SMTP
12916 session), &$local_part$& is not set.
12917
12918 Global address rewriting happens when a message is received, so the value of
12919 &$local_part$& during routing and delivery is the value after rewriting.
12920 &$local_part$& is set during user filtering, but not during system filtering,
12921 because a message may have many recipients and the system filter is called just
12922 once.
12923
12924 .cindex "tainted data"
12925 If the origin of the data is an incoming message,
12926 the result of expanding this variable is tainted and
12927 may not be further expanded or used as a filename.
12928
12929 &*Warning*&: the content of this variable is usually provided by a potential
12930 attacker.
12931 Consider carefully the implications of using it unvalidated as a name
12932 for file access.
12933 This presents issues for users' &_.forward_& and filter files.
12934 For traditional full user accounts, use &%check_local_users%& and the
12935 &$local_part_data$& variable rather than this one.
12936 For virtual users, store a suitable pathname component in the database
12937 which is used for account name validation, and use that retrieved value
12938 rather than this variable.
12939 Often &$local_part_data$& is usable in this role.
12940 If needed, use a router &%address_data%& or &%set%& option for
12941 the retrieved data.
12942
12943 When a message is being delivered to a file, pipe, or autoreply transport as a
12944 result of aliasing or forwarding, &$local_part$& is set to the local part of
12945 the parent address, not to the filename or command (see &$address_file$& and
12946 &$address_pipe$&).
12947
12948 When an ACL is running for a RCPT command, &$local_part$& contains the
12949 local part of the recipient address.
12950
12951 When a rewrite item is being processed (see chapter &<<CHAPrewrite>>&),
12952 &$local_part$& contains the local part of the address that is being rewritten;
12953 it can be used in the expansion of the replacement address, for example.
12954
12955 In all cases, all quoting is removed from the local part. For example, for both
12956 the addresses
12957 .code
12958 "abc:xyz"@test.example
12959 abc\:xyz@test.example
12960 .endd
12961 the value of &$local_part$& is
12962 .code
12963 abc:xyz
12964 .endd
12965 If you use &$local_part$& to create another address, you should always wrap it
12966 inside a quoting operator. For example, in a &(redirect)& router you could
12967 have:
12968 .code
12969 data = ${quote_local_part:$local_part}@new.domain.example
12970 .endd
12971 &*Note*&: The value of &$local_part$& is normally lower cased. If you want
12972 to process local parts in a case-dependent manner in a router, you can set the
12973 &%caseful_local_part%& option (see chapter &<<CHAProutergeneric>>&).
12974
12975 .vitem &$local_part_data$&
12976 .vindex "&$local_part_data$&"
12977 When the &%local_parts%& condition on a router or ACL
12978 matches a local part list
12979 the match value is copied to &$local_part_data$&.
12980 This is an enhancement over previous versions of Exim, when it only
12981 applied to the data read by a lookup.
12982 For details on match values see section &<<SECTlistresults>>& et. al.
12983
12984 The &%check_local_user%& router option also sets this variable.
12985
12986 .vindex &$local_part_prefix$& &&&
12987         &$local_part_prefix_v$& &&&
12988         &$local_part_suffix$& &&&
12989         &$local_part_suffix_v$&
12990 .cindex affix variables
12991 If a local part prefix or suffix has been recognized, it is not included in the
12992 value of &$local_part$& during routing and subsequent delivery. The values of
12993 any prefix or suffix are in &$local_part_prefix$& and
12994 &$local_part_suffix$&, respectively.
12995 .cindex "tainted data"
12996 If the specification did not include a wildcard then
12997 the affix variable value is not tainted.
12998
12999 If the affix specification included a wildcard then the portion of
13000 the affix matched by the wildcard is in
13001 &$local_part_prefix_v$& or &$local_part_suffix_v$& as appropriate,
13002 and both the whole and varying values are tainted.
13003
13004 .vitem &$local_scan_data$&
13005 .vindex "&$local_scan_data$&"
13006 This variable contains the text returned by the &[local_scan()]& function when
13007 a message is received. See chapter &<<CHAPlocalscan>>& for more details.
13008
13009 .vitem &$local_user_gid$&
13010 .vindex "&$local_user_gid$&"
13011 See &$local_user_uid$&.
13012
13013 .vitem &$local_user_uid$&
13014 .vindex "&$local_user_uid$&"
13015 This variable and &$local_user_gid$& are set to the uid and gid after the
13016 &%check_local_user%& router precondition succeeds. This means that their values
13017 are available for the remaining preconditions (&%senders%&, &%require_files%&,
13018 and &%condition%&), for the &%address_data%& expansion, and for any
13019 router-specific expansions. At all other times, the values in these variables
13020 are &`(uid_t)(-1)`& and &`(gid_t)(-1)`&, respectively.
13021
13022 .vitem &$localhost_number$&
13023 .vindex "&$localhost_number$&"
13024 This contains the expanded value of the
13025 &%localhost_number%& option. The expansion happens after the main options have
13026 been read.
13027
13028 .vitem &$log_inodes$&
13029 .vindex "&$log_inodes$&"
13030 The number of free inodes in the disk partition where Exim's
13031 log files are being written. The value is recalculated whenever the variable is
13032 referenced. If the relevant file system does not have the concept of inodes,
13033 the value of is -1. See also the &%check_log_inodes%& option.
13034
13035 .vitem &$log_space$&
13036 .vindex "&$log_space$&"
13037 The amount of free space (as a number of kilobytes) in the disk
13038 partition where Exim's log files are being written. The value is recalculated
13039 whenever the variable is referenced. If the operating system does not have the
13040 ability to find the amount of free space (only true for experimental systems),
13041 the space value is -1. See also the &%check_log_space%& option.
13042
13043
13044 .vitem &$lookup_dnssec_authenticated$&
13045 .vindex "&$lookup_dnssec_authenticated$&"
13046 This variable is set after a DNS lookup done by
13047 a dnsdb lookup expansion, dnslookup router or smtp transport.
13048 .cindex "DNS" "DNSSEC"
13049 It will be empty if &(DNSSEC)& was not requested,
13050 &"no"& if the result was not labelled as authenticated data
13051 and &"yes"& if it was.
13052 Results that are labelled as authoritative answer that match
13053 the &%dns_trust_aa%& configuration variable count also
13054 as authenticated data.
13055
13056 .vitem &$mailstore_basename$&
13057 .vindex "&$mailstore_basename$&"
13058 This variable is set only when doing deliveries in &"mailstore"& format in the
13059 &(appendfile)& transport. During the expansion of the &%mailstore_prefix%&,
13060 &%mailstore_suffix%&, &%message_prefix%&, and &%message_suffix%& options, it
13061 contains the basename of the files that are being written, that is, the name
13062 without the &".tmp"&, &".env"&, or &".msg"& suffix. At all other times, this
13063 variable is empty.
13064
13065 .vitem &$malware_name$&
13066 .vindex "&$malware_name$&"
13067 This variable is available when Exim is compiled with the
13068 content-scanning extension. It is set to the name of the virus that was found
13069 when the ACL &%malware%& condition is true (see section &<<SECTscanvirus>>&).
13070
13071 .vitem &$max_received_linelength$&
13072 .vindex "&$max_received_linelength$&"
13073 .cindex "maximum" "line length"
13074 .cindex "line length" "maximum"
13075 This variable contains the number of bytes in the longest line that was
13076 received as part of the message, not counting the line termination
13077 character(s).
13078 It is not valid if the &%spool_wireformat%& option is used.
13079
13080 .vitem &$message_age$&
13081 .cindex "message" "age of"
13082 .vindex "&$message_age$&"
13083 This variable is set at the start of a delivery attempt to contain the number
13084 of seconds since the message was received. It does not change during a single
13085 delivery attempt.
13086
13087 .tvar &$message_body$&
13088 .cindex "body of message" "expansion variable"
13089 .cindex "message body" "in expansion"
13090 .cindex "binary zero" "in message body"
13091 .oindex "&%message_body_visible%&"
13092 This variable contains the initial portion of a message's body while it is
13093 being delivered, and is intended mainly for use in filter files. The maximum
13094 number of characters of the body that are put into the variable is set by the
13095 &%message_body_visible%& configuration option; the default is 500.
13096
13097 .oindex "&%message_body_newlines%&"
13098 By default, newlines are converted into spaces in &$message_body$&, to make it
13099 easier to search for phrases that might be split over a line break. However,
13100 this can be disabled by setting &%message_body_newlines%& to be true. Binary
13101 zeros are always converted into spaces.
13102
13103 .tvar &$message_body_end$&
13104 .cindex "body of message" "expansion variable"
13105 .cindex "message body" "in expansion"
13106 This variable contains the final portion of a message's
13107 body while it is being delivered. The format and maximum size are as for
13108 &$message_body$&.
13109
13110 .vitem &$message_body_size$&
13111 .cindex "body of message" "size"
13112 .cindex "message body" "size"
13113 .vindex "&$message_body_size$&"
13114 When a message is being delivered, this variable contains the size of the body
13115 in bytes. The count starts from the character after the blank line that
13116 separates the body from the header. Newlines are included in the count. See
13117 also &$message_size$&, &$body_linecount$&, and &$body_zerocount$&.
13118
13119 If the spool file is wireformat
13120 (see the &%spool_wireformat%& main option)
13121 the CRLF line-terminators are included in the count.
13122
13123 .vitem &$message_exim_id$&
13124 .vindex "&$message_exim_id$&"
13125 When a message is being received or delivered, this variable contains the
13126 unique message id that is generated and used by Exim to identify the message.
13127 An id is not created for a message until after its header has been successfully
13128 received. &*Note*&: This is &'not'& the contents of the &'Message-ID:'& header
13129 line; it is the local id that Exim assigns to the message, for example:
13130 &`1BXTIK-0001yO-VA`&.
13131
13132 .tvar &$message_headers$&
13133 This variable contains a concatenation of all the header lines when a message
13134 is being processed, except for lines added by routers or transports. The header
13135 lines are separated by newline characters. Their contents are decoded in the
13136 same way as a header line that is inserted by &%bheader%&.
13137
13138 .tvar &$message_headers_raw$&
13139 This variable is like &$message_headers$& except that no processing of the
13140 contents of header lines is done.
13141
13142 .vitem &$message_id$&
13143 This is an old name for &$message_exim_id$&. It is now deprecated.
13144
13145 .vitem &$message_linecount$&
13146 .vindex "&$message_linecount$&"
13147 This variable contains the total number of lines in the header and body of the
13148 message. Compare &$body_linecount$&, which is the count for the body only.
13149 During the DATA and content-scanning ACLs, &$message_linecount$& contains the
13150 number of lines received. Before delivery happens (that is, before filters,
13151 routers, and transports run) the count is increased to include the
13152 &'Received:'& header line that Exim standardly adds, and also any other header
13153 lines that are added by ACLs. The blank line that separates the message header
13154 from the body is not counted.
13155
13156 As with the special case of &$message_size$&, during the expansion of the
13157 appendfile transport's maildir_tag option in maildir format, the value of
13158 &$message_linecount$& is the precise size of the number of newlines in the
13159 file that has been written (minus one for the blank line between the
13160 header and the body).
13161
13162 Here is an example of the use of this variable in a DATA ACL:
13163 .code
13164 deny condition = \
13165       ${if <{250}{${eval:$message_linecount - $body_linecount}}}
13166      message   = Too many lines in message header
13167 .endd
13168 In the MAIL and RCPT ACLs, the value is zero because at that stage the
13169 message has not yet been received.
13170
13171 This variable is not valid if the &%spool_wireformat%& option is used.
13172
13173 .vitem &$message_size$&
13174 .cindex "size" "of message"
13175 .cindex "message" "size"
13176 .vindex "&$message_size$&"
13177 When a message is being processed, this variable contains its size in bytes. In
13178 most cases, the size includes those headers that were received with the
13179 message, but not those (such as &'Envelope-to:'&) that are added to individual
13180 deliveries as they are written. However, there is one special case: during the
13181 expansion of the &%maildir_tag%& option in the &(appendfile)& transport while
13182 doing a delivery in maildir format, the value of &$message_size$& is the
13183 precise size of the file that has been written. See also
13184 &$message_body_size$&, &$body_linecount$&, and &$body_zerocount$&.
13185
13186 .cindex "RCPT" "value of &$message_size$&"
13187 While running a per message ACL (mail/rcpt/predata), &$message_size$&
13188 contains the size supplied on the MAIL command, or -1 if no size was given. The
13189 value may not, of course, be truthful.
13190
13191 .vitem &$mime_anomaly_level$& &&&
13192        &$mime_anomaly_text$& &&&
13193        &$mime_boundary$& &&&
13194        &$mime_charset$& &&&
13195        &$mime_content_description$& &&&
13196        &$mime_content_disposition$& &&&
13197        &$mime_content_id$& &&&
13198        &$mime_content_size$& &&&
13199        &$mime_content_transfer_encoding$& &&&
13200        &$mime_content_type$& &&&
13201        &$mime_decoded_filename$& &&&
13202        &$mime_filename$& &&&
13203        &$mime_is_coverletter$& &&&
13204        &$mime_is_multipart$& &&&
13205        &$mime_is_rfc822$& &&&
13206        &$mime_part_count$&
13207 A number of variables whose names start with &$mime$& are
13208 available when Exim is compiled with the content-scanning extension. For
13209 details, see section &<<SECTscanmimepart>>&.
13210
13211 .vitem "&$n0$& &-- &$n9$&"
13212 These variables are counters that can be incremented by means
13213 of the &%add%& command in filter files.
13214
13215 .tvar &$original_domain$&
13216 .vindex "&$domain$&"
13217 When a top-level address is being processed for delivery, this contains the
13218 same value as &$domain$&. However, if a &"child"& address (for example,
13219 generated by an alias, forward, or filter file) is being processed, this
13220 variable contains the domain of the original address (lower cased). This
13221 differs from &$parent_domain$& only when there is more than one level of
13222 aliasing or forwarding. When more than one address is being delivered in a
13223 single transport run, &$original_domain$& is not set.
13224
13225 If a new address is created by means of a &%deliver%& command in a system
13226 filter, it is set up with an artificial &"parent"& address. This has the local
13227 part &'system-filter'& and the default qualify domain.
13228
13229 .tvar &$original_local_part$&
13230 .vindex "&$local_part$&"
13231 When a top-level address is being processed for delivery, this contains the
13232 same value as &$local_part$&, unless a prefix or suffix was removed from the
13233 local part, because &$original_local_part$& always contains the full local
13234 part. When a &"child"& address (for example, generated by an alias, forward, or
13235 filter file) is being processed, this variable contains the full local part of
13236 the original address.
13237
13238 If the router that did the redirection processed the local part
13239 case-insensitively, the value in &$original_local_part$& is in lower case.
13240 This variable differs from &$parent_local_part$& only when there is more than
13241 one level of aliasing or forwarding. When more than one address is being
13242 delivered in a single transport run, &$original_local_part$& is not set.
13243
13244 If a new address is created by means of a &%deliver%& command in a system
13245 filter, it is set up with an artificial &"parent"& address. This has the local
13246 part &'system-filter'& and the default qualify domain.
13247
13248 .vitem &$originator_gid$&
13249 .cindex "gid (group id)" "of originating user"
13250 .cindex "sender" "gid"
13251 .vindex "&$caller_gid$&"
13252 .vindex "&$originator_gid$&"
13253 This variable contains the value of &$caller_gid$& that was set when the
13254 message was received. For messages received via the command line, this is the
13255 gid of the sending user. For messages received by SMTP over TCP/IP, this is
13256 normally the gid of the Exim user.
13257
13258 .vitem &$originator_uid$&
13259 .cindex "uid (user id)" "of originating user"
13260 .cindex "sender" "uid"
13261 .vindex "&$caller_uid$&"
13262 .vindex "&$originator_uid$&"
13263 The value of &$caller_uid$& that was set when the message was received. For
13264 messages received via the command line, this is the uid of the sending user.
13265 For messages received by SMTP over TCP/IP, this is normally the uid of the Exim
13266 user.
13267
13268 .tvar &$parent_domain$&
13269 This variable is similar to &$original_domain$& (see
13270 above), except that it refers to the immediately preceding parent address.
13271
13272 .tvar &$parent_local_part$&
13273 This variable is similar to &$original_local_part$&
13274 (see above), except that it refers to the immediately preceding parent address.
13275
13276 .vitem &$pid$&
13277 .cindex "pid (process id)" "of current process"
13278 .vindex "&$pid$&"
13279 This variable contains the current process id.
13280
13281 .vitem &$pipe_addresses$&
13282 .cindex "filter" "transport filter"
13283 .cindex "transport" "filter"
13284 .vindex "&$pipe_addresses$&"
13285 This is not an expansion variable, but is mentioned here because the string
13286 &`$pipe_addresses`& is handled specially in the command specification for the
13287 &(pipe)& transport (chapter &<<CHAPpipetransport>>&) and in transport filters
13288 (described under &%transport_filter%& in chapter &<<CHAPtransportgeneric>>&).
13289 It cannot be used in general expansion strings, and provokes an &"unknown
13290 variable"& error if encountered.
13291 &*Note*&: This value permits data supplied by a potential attacker to
13292 be used in the command for a &(pipe)& transport.
13293 Such configurations should be carefully assessed for security vulnerbilities.
13294
13295 .vitem &$primary_hostname$&
13296 .vindex "&$primary_hostname$&"
13297 This variable contains the value set by &%primary_hostname%& in the
13298 configuration file, or read by the &[uname()]& function. If &[uname()]& returns
13299 a single-component name, Exim calls &[gethostbyname()]& (or
13300 &[getipnodebyname()]& where available) in an attempt to acquire a fully
13301 qualified host name. See also &$smtp_active_hostname$&.
13302
13303
13304 .vitem &$proxy_external_address$& &&&
13305        &$proxy_external_port$& &&&
13306        &$proxy_local_address$& &&&
13307        &$proxy_local_port$& &&&
13308        &$proxy_session$&
13309 These variables are only available when built with Proxy Protocol
13310 or SOCKS5 support.
13311 For details see chapter &<<SECTproxyInbound>>&.
13312
13313 .vitem &$prdr_requested$&
13314 .cindex "PRDR" "variable for"
13315 This variable is set to &"yes"& if PRDR was requested by the client for the
13316 current message, otherwise &"no"&.
13317
13318 .vitem &$prvscheck_address$& &&&
13319        &$prvscheck_keynum$& &&&
13320        &$prvscheck_result$&
13321 These variables are used in conjunction with the &%prvscheck%& expansion item,
13322 which is described in sections &<<SECTexpansionitems>>& and
13323 &<<SECTverifyPRVS>>&.
13324
13325 .vitem &$qualify_domain$&
13326 .vindex "&$qualify_domain$&"
13327 The value set for the &%qualify_domain%& option in the configuration file.
13328
13329 .vitem &$qualify_recipient$&
13330 .vindex "&$qualify_recipient$&"
13331 The value set for the &%qualify_recipient%& option in the configuration file,
13332 or if not set, the value of &$qualify_domain$&.
13333
13334 .vitem &$queue_name$&
13335 .vindex &$queue_name$&
13336 .cindex "named queues" variable
13337 .cindex queues named
13338 The name of the spool queue in use; empty for the default queue.
13339
13340 .vitem &$queue_size$&
13341 .vindex "&$queue_size$&"
13342 .cindex "queue" "size of"
13343 .cindex "spool" "number of messages"
13344 This variable contains the number of messages queued.
13345 It is evaluated on demand, but no more often than once every minute.
13346 If there is no daemon notifier socket open, the value will be
13347 an empty string.
13348
13349 .vitem &$r_...$&
13350 .vindex &$r_...$&
13351 .cindex router variables
13352 Values can be placed in these variables by the &%set%& option of a router.
13353 They can be given any name that starts with &$r_$&.
13354 The values persist for the address being handled through subsequent routers
13355 and the eventual transport.
13356
13357 .vitem &$rcpt_count$&
13358 .vindex "&$rcpt_count$&"
13359 When a message is being received by SMTP, this variable contains the number of
13360 RCPT commands received for the current message. If this variable is used in a
13361 RCPT ACL, its value includes the current command.
13362
13363 .vitem &$rcpt_defer_count$&
13364 .vindex "&$rcpt_defer_count$&"
13365 .cindex "4&'xx'& responses" "count of"
13366 When a message is being received by SMTP, this variable contains the number of
13367 RCPT commands in the current message that have previously been rejected with a
13368 temporary (4&'xx'&) response.
13369
13370 .vitem &$rcpt_fail_count$&
13371 .vindex "&$rcpt_fail_count$&"
13372 When a message is being received by SMTP, this variable contains the number of
13373 RCPT commands in the current message that have previously been rejected with a
13374 permanent (5&'xx'&) response.
13375
13376 .vitem &$received_count$&
13377 .vindex "&$received_count$&"
13378 This variable contains the number of &'Received:'& header lines in the message,
13379 including the one added by Exim (so its value is always greater than zero). It
13380 is available in the DATA ACL, the non-SMTP ACL, and while routing and
13381 delivering.
13382
13383 .tvar &$received_for$&
13384 If there is only a single recipient address in an incoming message, this
13385 variable contains that address when the &'Received:'& header line is being
13386 built. The value is copied after recipient rewriting has happened, but before
13387 the &[local_scan()]& function is run.
13388
13389 .vitem &$received_ip_address$& &&&
13390        &$received_port$&
13391 .vindex "&$received_ip_address$&"
13392 .vindex "&$received_port$&"
13393 As soon as an Exim server starts processing an incoming TCP/IP connection, these
13394 variables are set to the address and port on the local IP interface.
13395 (The remote IP address and port are in
13396 &$sender_host_address$& and &$sender_host_port$&.) When testing with &%-bh%&,
13397 the port value is -1 unless it has been set using the &%-oMi%& command line
13398 option.
13399
13400 As well as being useful in ACLs (including the &"connect"& ACL), these variable
13401 could be used, for example, to make the filename for a TLS certificate depend
13402 on which interface and/or port is being used for the incoming connection. The
13403 values of &$received_ip_address$& and &$received_port$& are saved with any
13404 messages that are received, thus making these variables available at delivery
13405 time.
13406 For outbound connections see &$sending_ip_address$&.
13407
13408 .vitem &$received_protocol$&
13409 .vindex "&$received_protocol$&"
13410 When a message is being processed, this variable contains the name of the
13411 protocol by which it was received. Most of the names used by Exim are defined
13412 by RFCs 821, 2821, and 3848. They start with &"smtp"& (the client used HELO) or
13413 &"esmtp"& (the client used EHLO). This can be followed by &"s"& for secure
13414 (encrypted) and/or &"a"& for authenticated. Thus, for example, if the protocol
13415 is set to &"esmtpsa"&, the message was received over an encrypted SMTP
13416 connection and the client was successfully authenticated.
13417
13418 Exim uses the protocol name &"smtps"& for the case when encryption is
13419 automatically set up on connection without the use of STARTTLS (see
13420 &%tls_on_connect_ports%&), and the client uses HELO to initiate the
13421 encrypted SMTP session. The name &"smtps"& is also used for the rare situation
13422 where the client initially uses EHLO, sets up an encrypted connection using
13423 STARTTLS, and then uses HELO afterwards.
13424
13425 The &%-oMr%& option provides a way of specifying a custom protocol name for
13426 messages that are injected locally by trusted callers. This is commonly used to
13427 identify messages that are being re-injected after some kind of scanning.
13428
13429 .vitem &$received_time$&
13430 .vindex "&$received_time$&"
13431 This variable contains the date and time when the current message was received,
13432 as a number of seconds since the start of the Unix epoch.
13433
13434 .vitem &$recipient_data$&
13435 .vindex "&$recipient_data$&"
13436 This variable is set after an indexing lookup success in an ACL &%recipients%&
13437 condition. It contains the data from the lookup, and the value remains set
13438 until the next &%recipients%& test. Thus, you can do things like this:
13439 .display
13440 &`require recipients  = cdb*@;/some/file`&
13441 &`deny    `&&'some further test involving'& &`$recipient_data`&
13442 .endd
13443 &*Warning*&: This variable is set only when a lookup is used as an indexing
13444 method in the address list, using the semicolon syntax as in the example above.
13445 The variable is not set for a lookup that is used as part of the string
13446 expansion that all such lists undergo before being interpreted.
13447
13448 .vitem &$recipient_verify_failure$&
13449 .vindex "&$recipient_verify_failure$&"
13450 In an ACL, when a recipient verification fails, this variable contains
13451 information about the failure. It is set to one of the following words:
13452
13453 .ilist
13454 &"qualify"&: The address was unqualified (no domain), and the message
13455 was neither local nor came from an exempted host.
13456
13457 .next
13458 &"route"&: Routing failed.
13459
13460 .next
13461 &"mail"&: Routing succeeded, and a callout was attempted; rejection occurred at
13462 or before the MAIL command (that is, on initial connection, HELO, or
13463 MAIL).
13464
13465 .next
13466 &"recipient"&: The RCPT command in a callout was rejected.
13467 .next
13468
13469 &"postmaster"&: The postmaster check in a callout was rejected.
13470 .endlist
13471
13472 The main use of this variable is expected to be to distinguish between
13473 rejections of MAIL and rejections of RCPT.
13474
13475 .tvar &$recipients$&
13476 .tvar &$recipients_list$&
13477 These variables both contain the envelope recipients for a message.
13478
13479 The first uses a comma and a space separate the addresses in the replacement text.
13480 &*Note*&: an address can legitimately contain a comma;
13481 this variable is not intended for further processing.
13482
13483 The second is a proper Exim list; colon-separated.
13484
13485 However, the variables
13486 are not generally available, to prevent exposure of Bcc recipients in
13487 unprivileged users' filter files. You can use either of them  only in these
13488 cases:
13489
13490 .olist
13491 In a system filter file.
13492 .next
13493 In the ACLs associated with the DATA command and with non-SMTP messages, that
13494 is, the ACLs defined by &%acl_smtp_predata%&, &%acl_smtp_data%&,
13495 &%acl_smtp_mime%&, &%acl_not_smtp_start%&, &%acl_not_smtp%&, and
13496 &%acl_not_smtp_mime%&.
13497 .next
13498 From within a &[local_scan()]& function.
13499 .endlist
13500
13501
13502 .vitem &$recipients_count$&
13503 .vindex "&$recipients_count$&"
13504 When a message is being processed, this variable contains the number of
13505 envelope recipients that came with the message. Duplicates are not excluded
13506 from the count. While a message is being received over SMTP, the number
13507 increases for each accepted recipient. It can be referenced in an ACL.
13508
13509
13510 .vitem &$regex_match_string$&
13511 .vindex "&$regex_match_string$&"
13512 This variable is set to contain the matching regular expression after a
13513 &%regex%& ACL condition has matched (see section &<<SECTscanregex>>&).
13514
13515 .vitem "&$regex1$&, &$regex2$&, etc"
13516 .cindex "regex submatch variables (&$1regex$& &$2regex$& etc)"
13517 When a &%regex%& or &%mime_regex%& ACL condition succeeds,
13518 these variables contain the
13519 captured substrings identified by the regular expression.
13520 If the subject string was tainted then so will any captured substring.
13521
13522
13523 .tvar &$reply_address$&
13524 When a message is being processed, this variable contains the contents of the
13525 &'Reply-To:'& header line if one exists and it is not empty, or otherwise the
13526 contents of the &'From:'& header line. Apart from the removal of leading
13527 white space, the value is not processed in any way. In particular, no RFC 2047
13528 decoding or character code translation takes place.
13529
13530 .vitem &$return_path$&
13531 .vindex "&$return_path$&"
13532 When a message is being delivered, this variable contains the return path &--
13533 the sender field that will be sent as part of the envelope. It is not enclosed
13534 in <> characters. At the start of routing an address, &$return_path$& has the
13535 same value as &$sender_address$&, but if, for example, an incoming message to a
13536 mailing list has been expanded by a router which specifies a different address
13537 for bounce messages, &$return_path$& subsequently contains the new bounce
13538 address, whereas &$sender_address$& always contains the original sender address
13539 that was received with the message. In other words, &$sender_address$& contains
13540 the incoming envelope sender, and &$return_path$& contains the outgoing
13541 envelope sender.
13542
13543 .vitem &$return_size_limit$&
13544 .vindex "&$return_size_limit$&"
13545 This is an obsolete name for &$bounce_return_size_limit$&.
13546
13547 .vitem &$router_name$&
13548 .cindex "router" "name"
13549 .cindex "name" "of router"
13550 .vindex "&$router_name$&"
13551 During the running of a router, or a transport called,
13552 this variable contains the router name.
13553
13554 .vitem &$runrc$&
13555 .cindex "return code" "from &%run%& expansion"
13556 .vindex "&$runrc$&"
13557 This variable contains the return code from a command that is run by the
13558 &%${run...}%& expansion item. &*Warning*&: In a router or transport, you cannot
13559 assume the order in which option values are expanded, except for those
13560 preconditions whose order of testing is documented. Therefore, you cannot
13561 reliably expect to set &$runrc$& by the expansion of one option, and use it in
13562 another.
13563
13564 .vitem &$self_hostname$&
13565 .oindex "&%self%&" "value of host name"
13566 .vindex "&$self_hostname$&"
13567 When an address is routed to a supposedly remote host that turns out to be the
13568 local host, what happens is controlled by the &%self%& generic router option.
13569 One of its values causes the address to be passed to another router. When this
13570 happens, &$self_hostname$& is set to the name of the local host that the
13571 original router encountered. In other circumstances its contents are null.
13572
13573 .tvar &$sender_address$&
13574 When a message is being processed, this variable contains the sender's address
13575 that was received in the message's envelope. The case of letters in the address
13576 is retained, in both the local part and the domain. For bounce messages, the
13577 value of this variable is the empty string. See also &$return_path$&.
13578
13579 .vitem &$sender_address_data$&
13580 .vindex "&$address_data$&"
13581 .vindex "&$sender_address_data$&"
13582 If &$address_data$& is set when the routers are called from an ACL to verify a
13583 sender address, the final value is preserved in &$sender_address_data$&, to
13584 distinguish it from data from a recipient address. The value does not persist
13585 after the end of the current ACL statement. If you want to preserve it for
13586 longer, you can save it in an ACL variable.
13587
13588 .tvar &$sender_address_domain$&
13589 The domain portion of &$sender_address$&.
13590
13591 .tvar &$sender_address_local_part$&
13592 The local part portion of &$sender_address$&.
13593
13594 .vitem &$sender_data$&
13595 .vindex "&$sender_data$&"
13596 This variable is set after a lookup success in an ACL &%senders%& condition or
13597 in a router &%senders%& option. It contains the data from the lookup, and the
13598 value remains set until the next &%senders%& test. Thus, you can do things like
13599 this:
13600 .display
13601 &`require senders      = cdb*@;/some/file`&
13602 &`deny    `&&'some further test involving'& &`$sender_data`&
13603 .endd
13604 &*Warning*&: This variable is set only when a lookup is used as an indexing
13605 method in the address list, using the semicolon syntax as in the example above.
13606 The variable is not set for a lookup that is used as part of the string
13607 expansion that all such lists undergo before being interpreted.
13608
13609 .vitem &$sender_fullhost$&
13610 .vindex "&$sender_fullhost$&"
13611 When a message is received from a remote host, this variable contains the host
13612 name and IP address in a single string. It ends with the IP address in square
13613 brackets, followed by a colon and a port number if the logging of ports is
13614 enabled. The format of the rest of the string depends on whether the host
13615 issued a HELO or EHLO SMTP command, and whether the host name was verified by
13616 looking up its IP address. (Looking up the IP address can be forced by the
13617 &%host_lookup%& option, independent of verification.) A plain host name at the
13618 start of the string is a verified host name; if this is not present,
13619 verification either failed or was not requested. A host name in parentheses is
13620 the argument of a HELO or EHLO command. This is omitted if it is identical to
13621 the verified host name or to the host's IP address in square brackets.
13622
13623 .vitem &$sender_helo_dnssec$&
13624 .vindex "&$sender_helo_dnssec$&"
13625 This boolean variable is true if a successful HELO verification was
13626 .cindex "DNS" "DNSSEC"
13627 done using DNS information the resolver library stated was authenticated data.
13628
13629 .tvar &$sender_helo_name$&
13630 When a message is received from a remote host that has issued a HELO or EHLO
13631 command, the argument of that command is placed in this variable. It is also
13632 set if HELO or EHLO is used when a message is received using SMTP locally via
13633 the &%-bs%& or &%-bS%& options.
13634
13635 .vitem &$sender_host_address$&
13636 .vindex "&$sender_host_address$&"
13637 When a message is received from a remote host using SMTP,
13638 this variable contains that
13639 host's IP address. For locally non-SMTP submitted messages, it is empty.
13640
13641 .vitem &$sender_host_authenticated$&
13642 .vindex "&$sender_host_authenticated$&"
13643 This variable contains the name (not the public name) of the authenticator
13644 driver that successfully authenticated the client from which the message was
13645 received. It is empty if there was no successful authentication. See also
13646 &$authenticated_id$&.
13647
13648 .vitem &$sender_host_dnssec$&
13649 .vindex "&$sender_host_dnssec$&"
13650 If an attempt to populate &$sender_host_name$& has been made
13651 (by reference, &%hosts_lookup%& or
13652 otherwise) then this boolean will have been set true if, and only if, the
13653 resolver library states that both
13654 the reverse and forward DNS were authenticated data.  At all
13655 other times, this variable is false.
13656
13657 .cindex "DNS" "DNSSEC"
13658 It is likely that you will need to coerce DNSSEC support on in the resolver
13659 library, by setting:
13660 .code
13661 dns_dnssec_ok = 1
13662 .endd
13663
13664 In addition, on Linux with glibc 2.31 or newer the resolver library will
13665 default to stripping out a successful validation status.
13666 This will break a previously working Exim installation.
13667 Provided that you do trust the resolver (ie, is on localhost) you can tell
13668 glibc to pass through any successful validation with a new option in
13669 &_/etc/resolv.conf_&:
13670 .code
13671 options trust-ad
13672 .endd
13673
13674 Exim does not perform DNSSEC validation itself, instead leaving that to a
13675 validating resolver (e.g. unbound, or bind with suitable configuration).
13676
13677 If you have changed &%host_lookup_order%& so that &`bydns`& is not the first
13678 mechanism in the list, then this variable will be false.
13679
13680 This requires that your system resolver library support EDNS0 (and that
13681 DNSSEC flags exist in the system headers).  If the resolver silently drops
13682 all EDNS0 options, then this will have no effect.  OpenBSD's asr resolver
13683 is known to currently ignore EDNS0, documented in CAVEATS of asr_run(3).
13684
13685
13686 .tvar &$sender_host_name$&
13687 When a message is received from a remote host, this variable contains the
13688 host's name as obtained by looking up its IP address. For messages received by
13689 other means, this variable is empty.
13690
13691 .vindex "&$host_lookup_failed$&"
13692 If the host name has not previously been looked up, a reference to
13693 &$sender_host_name$& triggers a lookup (for messages from remote hosts).
13694 A looked up name is accepted only if it leads back to the original IP address
13695 via a forward lookup. If either the reverse or the forward lookup fails to find
13696 any data, or if the forward lookup does not yield the original IP address,
13697 &$sender_host_name$& remains empty, and &$host_lookup_failed$& is set to &"1"&.
13698
13699 .vindex "&$host_lookup_deferred$&"
13700 However, if either of the lookups cannot be completed (for example, there is a
13701 DNS timeout), &$host_lookup_deferred$& is set to &"1"&, and
13702 &$host_lookup_failed$& remains set to &"0"&.
13703
13704 Once &$host_lookup_failed$& is set to &"1"&, Exim does not try to look up the
13705 host name again if there is a subsequent reference to &$sender_host_name$&
13706 in the same Exim process, but it does try again if &$host_lookup_deferred$&
13707 is set to &"1"&.
13708
13709 Exim does not automatically look up every calling host's name. If you want
13710 maximum efficiency, you should arrange your configuration so that it avoids
13711 these lookups altogether. The lookup happens only if one or more of the
13712 following are true:
13713
13714 .ilist
13715 A string containing &$sender_host_name$& is expanded.
13716 .next
13717 The calling host matches the list in &%host_lookup%&. In the default
13718 configuration, this option is set to *, so it must be changed if lookups are
13719 to be avoided. (In the code, the default for &%host_lookup%& is unset.)
13720 .next
13721 Exim needs the host name in order to test an item in a host list. The items
13722 that require this are described in sections &<<SECThoslispatnam>>& and
13723 &<<SECThoslispatnamsk>>&.
13724 .next
13725 The calling host matches &%helo_try_verify_hosts%& or &%helo_verify_hosts%&.
13726 In this case, the host name is required to compare with the name quoted in any
13727 EHLO or HELO commands that the client issues.
13728 .next
13729 The remote host issues a EHLO or HELO command that quotes one of the
13730 domains in &%helo_lookup_domains%&. The default value of this option is
13731 . ==== As this is a nested list, any displays it contains must be indented
13732 . ==== as otherwise they are too far to the left.
13733 .code
13734   helo_lookup_domains = @ : @[]
13735 .endd
13736 which causes a lookup if a remote host (incorrectly) gives the server's name or
13737 IP address in an EHLO or HELO command.
13738 .endlist
13739
13740
13741 .vitem &$sender_host_port$&
13742 .vindex "&$sender_host_port$&"
13743 When a message is received from a remote host, this variable contains the port
13744 number that was used on the remote host.
13745
13746 .vitem &$sender_ident$&
13747 .vindex "&$sender_ident$&"
13748 When a message is received from a remote host, this variable contains the
13749 identification received in response to an RFC 1413 request. When a message has
13750 been received locally, this variable contains the login name of the user that
13751 called Exim.
13752
13753 .vitem &$sender_rate_$&&'xxx'&
13754 A number of variables whose names begin &$sender_rate_$& are set as part of the
13755 &%ratelimit%& ACL condition. Details are given in section
13756 &<<SECTratelimiting>>&.
13757
13758 .vitem &$sender_rcvhost$&
13759 .cindex "DNS" "reverse lookup"
13760 .cindex "reverse DNS lookup"
13761 .vindex "&$sender_rcvhost$&"
13762 This is provided specifically for use in &'Received:'& headers. It starts with
13763 either the verified host name (as obtained from a reverse DNS lookup) or, if
13764 there is no verified host name, the IP address in square brackets. After that
13765 there may be text in parentheses. When the first item is a verified host name,
13766 the first thing in the parentheses is the IP address in square brackets,
13767 followed by a colon and a port number if port logging is enabled. When the
13768 first item is an IP address, the port is recorded as &"port=&'xxxx'&"& inside
13769 the parentheses.
13770
13771 There may also be items of the form &"helo=&'xxxx'&"& if HELO or EHLO
13772 was used and its argument was not identical to the real host name or IP
13773 address, and &"ident=&'xxxx'&"& if an RFC 1413 ident string is available. If
13774 all three items are present in the parentheses, a newline and tab are inserted
13775 into the string, to improve the formatting of the &'Received:'& header.
13776
13777 .vitem &$sender_verify_failure$&
13778 .vindex "&$sender_verify_failure$&"
13779 In an ACL, when a sender verification fails, this variable contains information
13780 about the failure. The details are the same as for
13781 &$recipient_verify_failure$&.
13782
13783 .vitem &$sending_ip_address$&
13784 .vindex "&$sending_ip_address$&"
13785 This variable is set whenever an outgoing SMTP connection to another host has
13786 been set up. It contains the IP address of the local interface that is being
13787 used. This is useful if a host that has more than one IP address wants to take
13788 on different personalities depending on which one is being used. For incoming
13789 connections, see &$received_ip_address$&.
13790
13791 .vitem &$sending_port$&
13792 .vindex "&$sending_port$&"
13793 This variable is set whenever an outgoing SMTP connection to another host has
13794 been set up. It contains the local port that is being used. For incoming
13795 connections, see &$received_port$&.
13796
13797 .vitem &$smtp_active_hostname$&
13798 .vindex "&$smtp_active_hostname$&"
13799 During an incoming SMTP session, this variable contains the value of the active
13800 host name, as specified by the &%smtp_active_hostname%& option. The value of
13801 &$smtp_active_hostname$& is saved with any message that is received, so its
13802 value can be consulted during routing and delivery.
13803
13804 .tvar &$smtp_command$&
13805 During the processing of an incoming SMTP command, this variable contains the
13806 entire command. This makes it possible to distinguish between HELO and EHLO in
13807 the HELO ACL, and also to distinguish between commands such as these:
13808 .code
13809 MAIL FROM:<>
13810 MAIL FROM: <>
13811 .endd
13812 For a MAIL command, extra parameters such as SIZE can be inspected. For a RCPT
13813 command, the address in &$smtp_command$& is the original address before any
13814 rewriting, whereas the values in &$local_part$& and &$domain$& are taken from
13815 the address after SMTP-time rewriting.
13816
13817 .tvar &$smtp_command_argument$&
13818 .cindex "SMTP" "command, argument for"
13819 While an ACL is running to check an SMTP command, this variable contains the
13820 argument, that is, the text that follows the command name, with leading white
13821 space removed. Following the introduction of &$smtp_command$&, this variable is
13822 somewhat redundant, but is retained for backwards compatibility.
13823
13824 .vitem &$smtp_command_history$&
13825 .cindex SMTP "command history"
13826 .vindex "&$smtp_command_history$&"
13827 A comma-separated list (with no whitespace) of the most-recent SMTP commands
13828 received, in time-order left to right.  Only a limited number of commands
13829 are remembered.
13830
13831 .vitem &$smtp_count_at_connection_start$&
13832 .vindex "&$smtp_count_at_connection_start$&"
13833 This variable is set greater than zero only in processes spawned by the Exim
13834 daemon for handling incoming SMTP connections. The name is deliberately long,
13835 in order to emphasize what the contents are. When the daemon accepts a new
13836 connection, it increments this variable. A copy of the variable is passed to
13837 the child process that handles the connection, but its value is fixed, and
13838 never changes. It is only an approximation of how many incoming connections
13839 there actually are, because many other connections may come and go while a
13840 single connection is being processed. When a child process terminates, the
13841 daemon decrements its copy of the variable.
13842
13843 .vitem &$smtp_notquit_reason$&
13844 .vindex "&$smtp_notquit_reason$&"
13845 When the not-QUIT ACL is running, this variable is set to a string
13846 that indicates the reason for the termination of the SMTP connection.
13847
13848 .vitem "&$sn0$& &-- &$sn9$&"
13849 These variables are copies of the values of the &$n0$& &-- &$n9$& accumulators
13850 that were current at the end of the system filter file. This allows a system
13851 filter file to set values that can be tested in users' filter files. For
13852 example, a system filter could set a value indicating how likely it is that a
13853 message is junk mail.
13854
13855 .vitem &$spam_score$& &&&
13856        &$spam_score_int$& &&&
13857        &$spam_bar$& &&&
13858        &$spam_report$& &&&
13859        &$spam_action$&
13860 A number of variables whose names start with &$spam$& are available when Exim
13861 is compiled with the content-scanning extension. For details, see section
13862 &<<SECTscanspamass>>&.
13863
13864 .vitem &$spf_header_comment$& &&&
13865        &$spf_received$& &&&
13866        &$spf_result$& &&&
13867        &$spf_result_guessed$& &&&
13868        &$spf_smtp_comment$&
13869 These variables are only available if Exim is built with SPF support.
13870 For details see section &<<SECSPF>>&.
13871
13872 .vitem &$spool_directory$&
13873 .vindex "&$spool_directory$&"
13874 The name of Exim's spool directory.
13875
13876 .vitem &$spool_inodes$&
13877 .vindex "&$spool_inodes$&"
13878 The number of free inodes in the disk partition where Exim's spool files are
13879 being written. The value is recalculated whenever the variable is referenced.
13880 If the relevant file system does not have the concept of inodes, the value of
13881 is -1. See also the &%check_spool_inodes%& option.
13882
13883 .vitem &$spool_space$&
13884 .vindex "&$spool_space$&"
13885 The amount of free space (as a number of kilobytes) in the disk partition where
13886 Exim's spool files are being written. The value is recalculated whenever the
13887 variable is referenced. If the operating system does not have the ability to
13888 find the amount of free space (only true for experimental systems), the space
13889 value is -1. For example, to check in an ACL that there is at least 50
13890 megabytes free on the spool, you could write:
13891 .code
13892 condition = ${if > {$spool_space}{50000}}
13893 .endd
13894 See also the &%check_spool_space%& option.
13895
13896
13897 .vitem &$thisaddress$&
13898 .vindex "&$thisaddress$&"
13899 This variable is set only during the processing of the &%foranyaddress%&
13900 command in a filter file. Its use is explained in the description of that
13901 command, which can be found in the separate document entitled &'Exim's
13902 interfaces to mail filtering'&.
13903
13904 .vitem &$tls_in_bits$&
13905 .vindex "&$tls_in_bits$&"
13906 Contains an approximation of the TLS cipher's bit-strength
13907 on the inbound connection; the meaning of
13908 this depends upon the TLS implementation used.
13909 If TLS has not been negotiated, the value will be 0.
13910 The value of this is automatically fed into the Cyrus SASL authenticator
13911 when acting as a server, to specify the "external SSF" (a SASL term).
13912
13913 The deprecated &$tls_bits$& variable refers to the inbound side
13914 except when used in the context of an outbound SMTP delivery, when it refers to
13915 the outbound.
13916
13917 .vitem &$tls_out_bits$&
13918 .vindex "&$tls_out_bits$&"
13919 Contains an approximation of the TLS cipher's bit-strength
13920 on an outbound SMTP connection; the meaning of
13921 this depends upon the TLS implementation used.
13922 If TLS has not been negotiated, the value will be 0.
13923
13924 .vitem &$tls_in_ourcert$&
13925 .vindex "&$tls_in_ourcert$&"
13926 .cindex certificate variables
13927 This variable refers to the certificate presented to the peer of an
13928 inbound connection when the message was received.
13929 It is only useful as the argument of a
13930 &%certextract%& expansion item, &%md5%&, &%sha1%& or &%sha256%& operator,
13931 or a &%def%& condition.
13932
13933 &*Note*&: Under versions of OpenSSL preceding 1.1.1,
13934 when a list of more than one
13935 file is used for &%tls_certificate%&, this variable is not reliable.
13936 The macro "_TLS_BAD_MULTICERT_IN_OURCERT" will be defined for those versions.
13937
13938 .vitem &$tls_in_peercert$&
13939 .vindex "&$tls_in_peercert$&"
13940 This variable refers to the certificate presented by the peer of an
13941 inbound connection when the message was received.
13942 It is only useful as the argument of a
13943 &%certextract%& expansion item, &%md5%&, &%sha1%& or &%sha256%& operator,
13944 or a &%def%& condition.
13945 If certificate verification fails it may refer to a failing chain element
13946 which is not the leaf.
13947
13948 .vitem &$tls_out_ourcert$&
13949 .vindex "&$tls_out_ourcert$&"
13950 This variable refers to the certificate presented to the peer of an
13951 outbound connection.  It is only useful as the argument of a
13952 &%certextract%& expansion item, &%md5%&, &%sha1%& or &%sha256%& operator,
13953 or a &%def%& condition.
13954
13955 .vitem &$tls_out_peercert$&
13956 .vindex "&$tls_out_peercert$&"
13957 This variable refers to the certificate presented by the peer of an
13958 outbound connection.  It is only useful as the argument of a
13959 &%certextract%& expansion item, &%md5%&, &%sha1%& or &%sha256%& operator,
13960 or a &%def%& condition.
13961 If certificate verification fails it may refer to a failing chain element
13962 which is not the leaf.
13963
13964 .vitem &$tls_in_certificate_verified$&
13965 .vindex "&$tls_in_certificate_verified$&"
13966 This variable is set to &"1"& if a TLS certificate was verified when the
13967 message was received, and &"0"& otherwise.
13968
13969 The deprecated &$tls_certificate_verified$& variable refers to the inbound side
13970 except when used in the context of an outbound SMTP delivery, when it refers to
13971 the outbound.
13972
13973 .vitem &$tls_out_certificate_verified$&
13974 .vindex "&$tls_out_certificate_verified$&"
13975 This variable is set to &"1"& if a TLS certificate was verified when an
13976 outbound SMTP connection was made,
13977 and &"0"& otherwise.
13978
13979 .vitem &$tls_in_cipher$&
13980 .vindex "&$tls_in_cipher$&"
13981 .vindex "&$tls_cipher$&"
13982 When a message is received from a remote host over an encrypted SMTP
13983 connection, this variable is set to the cipher suite that was negotiated, for
13984 example DES-CBC3-SHA. In other circumstances, in particular, for message
13985 received over unencrypted connections, the variable is empty. Testing
13986 &$tls_in_cipher$& for emptiness is one way of distinguishing between encrypted and
13987 non-encrypted connections during ACL processing.
13988
13989 The deprecated &$tls_cipher$& variable is the same as &$tls_in_cipher$& during message reception,
13990 but in the context of an outward SMTP delivery taking place via the &(smtp)& transport
13991 becomes the same as &$tls_out_cipher$&.
13992
13993 .vitem &$tls_in_cipher_std$&
13994 .vindex "&$tls_in_cipher_std$&"
13995 As above, but returning the RFC standard name for the cipher suite.
13996
13997 .vitem &$tls_out_cipher$&
13998 .vindex "&$tls_out_cipher$&"
13999 This variable is
14000 cleared before any outgoing SMTP connection is made,
14001 and then set to the outgoing cipher suite if one is negotiated. See chapter
14002 &<<CHAPTLS>>& for details of TLS support and chapter &<<CHAPsmtptrans>>& for
14003 details of the &(smtp)& transport.
14004
14005 .vitem &$tls_out_cipher_std$&
14006 .vindex "&$tls_out_cipher_std$&"
14007 As above, but returning the RFC standard name for the cipher suite.
14008
14009 .vitem &$tls_out_dane$&
14010 .vindex &$tls_out_dane$&
14011 DANE active status.  See section &<<SECDANE>>&.
14012
14013 .vitem &$tls_in_ocsp$&
14014 .vindex "&$tls_in_ocsp$&"
14015 When a message is received from a remote client connection
14016 the result of any OCSP request from the client is encoded in this variable:
14017 .code
14018 0 OCSP proof was not requested (default value)
14019 1 No response to request
14020 2 Response not verified
14021 3 Verification failed
14022 4 Verification succeeded
14023 .endd
14024
14025 .vitem &$tls_out_ocsp$&
14026 .vindex "&$tls_out_ocsp$&"
14027 When a message is sent to a remote host connection
14028 the result of any OCSP request made is encoded in this variable.
14029 See &$tls_in_ocsp$& for values.
14030
14031 .vitem &$tls_in_peerdn$&
14032 .vindex "&$tls_in_peerdn$&"
14033 .vindex "&$tls_peerdn$&"
14034 .cindex certificate "extracting fields"
14035 When a message is received from a remote host over an encrypted SMTP
14036 connection, and Exim is configured to request a certificate from the client,
14037 the value of the Distinguished Name of the certificate is made available in the
14038 &$tls_in_peerdn$& during subsequent processing.
14039 If certificate verification fails it may refer to a failing chain element
14040 which is not the leaf.
14041
14042 The deprecated &$tls_peerdn$& variable refers to the inbound side
14043 except when used in the context of an outbound SMTP delivery, when it refers to
14044 the outbound.
14045
14046 .vitem &$tls_out_peerdn$&
14047 .vindex "&$tls_out_peerdn$&"
14048 When a message is being delivered to a remote host over an encrypted SMTP
14049 connection, and Exim is configured to request a certificate from the server,
14050 the value of the Distinguished Name of the certificate is made available in the
14051 &$tls_out_peerdn$& during subsequent processing.
14052 If certificate verification fails it may refer to a failing chain element
14053 which is not the leaf.
14054
14055
14056 .vitem &$tls_in_resumption$& &&&
14057        &$tls_out_resumption$&
14058 .vindex &$tls_in_resumption$&
14059 .vindex &$tls_out_resumption$&
14060 .cindex TLS resumption
14061 Observability for TLS session resumption.  See &<<SECTresumption>>& for details.
14062
14063
14064 .tvar &$tls_in_sni$&
14065 .vindex "&$tls_sni$&"
14066 .cindex "TLS" "Server Name Indication"
14067 .cindex "TLS" SNI
14068 .cindex SNI "observability on server"
14069 When a TLS session is being established, if the client sends the Server
14070 Name Indication extension, the value will be placed in this variable.
14071 If the variable appears in &%tls_certificate%& then this option and
14072 some others, described in &<<SECTtlssni>>&,
14073 will be re-expanded early in the TLS session, to permit
14074 a different certificate to be presented (and optionally a different key to be
14075 used) to the client, based upon the value of the SNI extension.
14076
14077 The deprecated &$tls_sni$& variable refers to the inbound side
14078 except when used in the context of an outbound SMTP delivery, when it refers to
14079 the outbound.
14080
14081 .vitem &$tls_out_sni$&
14082 .vindex "&$tls_out_sni$&"
14083 .cindex "TLS" "Server Name Indication"
14084 .cindex "TLS" SNI
14085 .cindex SNI "observability in client"
14086 During outbound
14087 SMTP deliveries, this variable reflects the value of the &%tls_sni%& option on
14088 the transport.
14089
14090 .vitem &$tls_out_tlsa_usage$&
14091 .vindex &$tls_out_tlsa_usage$&
14092 Bitfield of TLSA record types found.  See section &<<SECDANE>>&.
14093
14094 .vitem &$tls_in_ver$&
14095 .vindex "&$tls_in_ver$&"
14096 When a message is received from a remote host over an encrypted SMTP connection
14097 this variable is set to the protocol version, eg &'TLS1.2'&.
14098
14099 .vitem &$tls_out_ver$&
14100 .vindex "&$tls_out_ver$&"
14101 When a message is being delivered to a remote host over an encrypted SMTP connection
14102 this variable is set to the protocol version.
14103
14104
14105 .vitem &$tod_bsdinbox$&
14106 .vindex "&$tod_bsdinbox$&"
14107 The time of day and the date, in the format required for BSD-style mailbox
14108 files, for example: Thu Oct 17 17:14:09 1995.
14109
14110 .vitem &$tod_epoch$&
14111 .vindex "&$tod_epoch$&"
14112 The time and date as a number of seconds since the start of the Unix epoch.
14113
14114 .vitem &$tod_epoch_l$&
14115 .vindex "&$tod_epoch_l$&"
14116 The time and date as a number of microseconds since the start of the Unix epoch.
14117
14118 .vitem &$tod_full$&
14119 .vindex "&$tod_full$&"
14120 A full version of the time and date, for example: Wed, 16 Oct 1995 09:51:40
14121 +0100. The timezone is always given as a numerical offset from UTC, with
14122 positive values used for timezones that are ahead (east) of UTC, and negative
14123 values for those that are behind (west).
14124
14125 .vitem &$tod_log$&
14126 .vindex "&$tod_log$&"
14127 The time and date in the format used for writing Exim's log files, for example:
14128 1995-10-12 15:32:29, but without a timezone.
14129
14130 .vitem &$tod_logfile$&
14131 .vindex "&$tod_logfile$&"
14132 This variable contains the date in the format yyyymmdd. This is the format that
14133 is used for datestamping log files when &%log_file_path%& contains the &`%D`&
14134 flag.
14135
14136 .vitem &$tod_zone$&
14137 .vindex "&$tod_zone$&"
14138 This variable contains the numerical value of the local timezone, for example:
14139 -0500.
14140
14141 .vitem &$tod_zulu$&
14142 .vindex "&$tod_zulu$&"
14143 This variable contains the UTC date and time in &"Zulu"& format, as specified
14144 by ISO 8601, for example: 20030221154023Z.
14145
14146 .vitem &$transport_name$&
14147 .cindex "transport" "name"
14148 .cindex "name" "of transport"
14149 .vindex "&$transport_name$&"
14150 During the running of a transport, this variable contains its name.
14151
14152 .vitem &$value$&
14153 .vindex "&$value$&"
14154 This variable contains the result of an expansion lookup, extraction operation,
14155 or external command, as described above. It is also used during a
14156 &*reduce*& expansion.
14157
14158 .vitem &$verify_mode$&
14159 .vindex "&$verify_mode$&"
14160 While a router or transport is being run in verify mode or for cutthrough delivery,
14161 contains "S" for sender-verification or "R" for recipient-verification.
14162 Otherwise, empty.
14163
14164 .vitem &$version_number$&
14165 .vindex "&$version_number$&"
14166 The version number of Exim. Same as &$exim_version$&, may be overridden
14167 by the &%exim_version%& main config option.
14168
14169 .vitem &$warn_message_delay$&
14170 .vindex "&$warn_message_delay$&"
14171 This variable is set only during the creation of a message warning about a
14172 delivery delay. Details of its use are explained in section &<<SECTcustwarn>>&.
14173
14174 .vitem &$warn_message_recipients$&
14175 .vindex "&$warn_message_recipients$&"
14176 This variable is set only during the creation of a message warning about a
14177 delivery delay. Details of its use are explained in section &<<SECTcustwarn>>&.
14178 .endlist
14179 .ecindex IIDstrexp
14180
14181
14182
14183 . ////////////////////////////////////////////////////////////////////////////
14184 . ////////////////////////////////////////////////////////////////////////////
14185
14186 .chapter "Embedded Perl" "CHAPperl"
14187 .scindex IIDperl "Perl" "calling from Exim"
14188 Exim can be built to include an embedded Perl interpreter. When this is done,
14189 Perl subroutines can be called as part of the string expansion process. To make
14190 use of the Perl support, you need version 5.004 or later of Perl installed on
14191 your system. To include the embedded interpreter in the Exim binary, include
14192 the line
14193 .code
14194 EXIM_PERL = perl.o
14195 .endd
14196 in your &_Local/Makefile_& and then build Exim in the normal way.
14197
14198
14199 .section "Setting up so Perl can be used" "SECID85"
14200 .oindex "&%perl_startup%&"
14201 Access to Perl subroutines is via a global configuration option called
14202 &%perl_startup%& and an expansion string operator &%${perl ...}%&. If there is
14203 no &%perl_startup%& option in the Exim configuration file then no Perl
14204 interpreter is started and there is almost no overhead for Exim (since none of
14205 the Perl library will be paged in unless used). If there is a &%perl_startup%&
14206 option then the associated value is taken to be Perl code which is executed in
14207 a newly created Perl interpreter.
14208
14209 The value of &%perl_startup%& is not expanded in the Exim sense, so you do not
14210 need backslashes before any characters to escape special meanings. The option
14211 should usually be something like
14212 .code
14213 perl_startup = do '/etc/exim.pl'
14214 .endd
14215 where &_/etc/exim.pl_& is Perl code which defines any subroutines you want to
14216 use from Exim. Exim can be configured either to start up a Perl interpreter as
14217 soon as it is entered, or to wait until the first time it is needed. Starting
14218 the interpreter at the beginning ensures that it is done while Exim still has
14219 its setuid privilege, but can impose an unnecessary overhead if Perl is not in
14220 fact used in a particular run. Also, note that this does not mean that Exim is
14221 necessarily running as root when Perl is called at a later time. By default,
14222 the interpreter is started only when it is needed, but this can be changed in
14223 two ways:
14224
14225 .ilist
14226 .oindex "&%perl_at_start%&"
14227 Setting &%perl_at_start%& (a boolean option) in the configuration requests
14228 a startup when Exim is entered.
14229 .next
14230 The command line option &%-ps%& also requests a startup when Exim is entered,
14231 overriding the setting of &%perl_at_start%&.
14232 .endlist
14233
14234 There is also a command line option &%-pd%& (for delay) which suppresses the
14235 initial startup, even if &%perl_at_start%& is set.
14236
14237 .ilist
14238 .oindex "&%perl_taintmode%&"
14239 .cindex "Perl" "taintmode"
14240 To provide more security executing Perl code via the embedded Perl
14241 interpreter, the &%perl_taintmode%& option can be set. This enables the
14242 taint mode of the Perl interpreter. You are encouraged to set this
14243 option to a true value. To avoid breaking existing installations, it
14244 defaults to false.
14245
14246 &*Note*&: This is entirely separate from Exim's tainted-data tracking.
14247
14248
14249 .section "Calling Perl subroutines" "SECID86"
14250 When the configuration file includes a &%perl_startup%& option you can make use
14251 of the string expansion item to call the Perl subroutines that are defined
14252 by the &%perl_startup%& code. The operator is used in any of the following
14253 forms:
14254 .code
14255 ${perl{foo}}
14256 ${perl{foo}{argument}}
14257 ${perl{foo}{argument1}{argument2} ... }
14258 .endd
14259 which calls the subroutine &%foo%& with the given arguments. A maximum of eight
14260 arguments may be passed. Passing more than this results in an expansion failure
14261 with an error message of the form
14262 .code
14263 Too many arguments passed to Perl subroutine "foo" (max is 8)
14264 .endd
14265 The return value of the Perl subroutine is evaluated in a scalar context before
14266 it is passed back to Exim to be inserted into the expanded string. If the
14267 return value is &'undef'&, the expansion is forced to fail in the same way as
14268 an explicit &"fail"& on an &%if%& or &%lookup%& item. If the subroutine aborts
14269 by obeying Perl's &%die%& function, the expansion fails with the error message
14270 that was passed to &%die%&.
14271
14272
14273 .section "Calling Exim functions from Perl" "SECID87"
14274 Within any Perl code called from Exim, the function &'Exim::expand_string()'&
14275 is available to call back into Exim's string expansion function. For example,
14276 the Perl code
14277 .code
14278 my $lp = Exim::expand_string('$local_part');
14279 .endd
14280 makes the current Exim &$local_part$& available in the Perl variable &$lp$&.
14281 Note those are single quotes and not double quotes to protect against
14282 &$local_part$& being interpolated as a Perl variable.
14283
14284 If the string expansion is forced to fail by a &"fail"& item, the result of
14285 &'Exim::expand_string()'& is &%undef%&. If there is a syntax error in the
14286 expansion string, the Perl call from the original expansion string fails with
14287 an appropriate error message, in the same way as if &%die%& were used.
14288
14289 .cindex "debugging" "from embedded Perl"
14290 .cindex "log" "writing from embedded Perl"
14291 Two other Exim functions are available for use from within Perl code.
14292 &'Exim::debug_write()'& writes a string to the standard error stream if Exim's
14293 debugging is enabled. If you want a newline at the end, you must supply it.
14294 &'Exim::log_write()'& writes a string to Exim's main log, adding a leading
14295 timestamp. In this case, you should not supply a terminating newline.
14296
14297
14298 .section "Use of standard output and error by Perl" "SECID88"
14299 .cindex "Perl" "standard output and error"
14300 You should not write to the standard error or output streams from within your
14301 Perl code, as it is not defined how these are set up. In versions of Exim
14302 before 4.50, it is possible for the standard output or error to refer to the
14303 SMTP connection during message reception via the daemon. Writing to this stream
14304 is certain to cause chaos. From Exim 4.50 onwards, the standard output and
14305 error streams are connected to &_/dev/null_& in the daemon. The chaos is
14306 avoided, but the output is lost.
14307
14308 .cindex "Perl" "use of &%warn%&"
14309 The Perl &%warn%& statement writes to the standard error stream by default.
14310 Calls to &%warn%& may be embedded in Perl modules that you use, but over which
14311 you have no control. When Exim starts up the Perl interpreter, it arranges for
14312 output from the &%warn%& statement to be written to the Exim main log. You can
14313 change this by including appropriate Perl magic somewhere in your Perl code.
14314 For example, to discard &%warn%& output completely, you need this:
14315 .code
14316 $SIG{__WARN__} = sub { };
14317 .endd
14318 Whenever a &%warn%& is obeyed, the anonymous subroutine is called. In this
14319 example, the code for the subroutine is empty, so it does nothing, but you can
14320 include any Perl code that you like. The text of the &%warn%& message is passed
14321 as the first subroutine argument.
14322 .ecindex IIDperl
14323
14324
14325 . ////////////////////////////////////////////////////////////////////////////
14326 . ////////////////////////////////////////////////////////////////////////////
14327
14328 .chapter "Starting the daemon and the use of network interfaces" &&&
14329          "CHAPinterfaces" &&&
14330          "Starting the daemon"
14331 .cindex "daemon" "starting"
14332 .cindex "interface" "listening"
14333 .cindex "network interface"
14334 .cindex "interface" "network"
14335 .cindex "IP address" "for listening"
14336 .cindex "daemon" "listening IP addresses"
14337 .cindex "TCP/IP" "setting listening interfaces"
14338 .cindex "TCP/IP" "setting listening ports"
14339 A host that is connected to a TCP/IP network may have one or more physical
14340 hardware network interfaces. Each of these interfaces may be configured as one
14341 or more &"logical"& interfaces, which are the entities that a program actually
14342 works with. Each of these logical interfaces is associated with an IP address.
14343 In addition, TCP/IP software supports &"loopback"& interfaces (127.0.0.1 in
14344 IPv4 and ::1 in IPv6), which do not use any physical hardware. Exim requires
14345 knowledge about the host's interfaces for use in three different circumstances:
14346
14347 .olist
14348 When a listening daemon is started, Exim needs to know which interfaces
14349 and ports to listen on.
14350 .next
14351 When Exim is routing an address, it needs to know which IP addresses
14352 are associated with local interfaces. This is required for the correct
14353 processing of MX lists by removing the local host and others with the
14354 same or higher priority values. Also, Exim needs to detect cases
14355 when an address is routed to an IP address that in fact belongs to the
14356 local host. Unless the &%self%& router option or the &%allow_localhost%&
14357 option of the smtp transport is set (as appropriate), this is treated
14358 as an error situation.
14359 .next
14360 When Exim connects to a remote host, it may need to know which interface to use
14361 for the outgoing connection.
14362 .endlist
14363
14364
14365 Exim's default behaviour is likely to be appropriate in the vast majority
14366 of cases. If your host has only one interface, and you want all its IP
14367 addresses to be treated in the same way, and you are using only the
14368 standard SMTP port, you should not need to take any special action. The
14369 rest of this chapter does not apply to you.
14370
14371 In a more complicated situation you may want to listen only on certain
14372 interfaces, or on different ports, and for this reason there are a number of
14373 options that can be used to influence Exim's behaviour. The rest of this
14374 chapter describes how they operate.
14375
14376 When a message is received over TCP/IP, the interface and port that were
14377 actually used are set in &$received_ip_address$& and &$received_port$&.
14378
14379
14380
14381 .section "Starting a listening daemon" "SECID89"
14382 When a listening daemon is started (by means of the &%-bd%& command line
14383 option), the interfaces and ports on which it listens are controlled by the
14384 following options:
14385
14386 .ilist
14387 &%daemon_smtp_ports%& contains a list of default ports
14388 or service names.
14389 (For backward compatibility, this option can also be specified in the singular.)
14390 .next
14391 &%local_interfaces%& contains list of interface IP addresses on which to
14392 listen. Each item may optionally also specify a port.
14393 .endlist
14394
14395 The default list separator in both cases is a colon, but this can be changed as
14396 described in section &<<SECTlistsepchange>>&. When IPv6 addresses are involved,
14397 it is usually best to change the separator to avoid having to double all the
14398 colons. For example:
14399 .code
14400 local_interfaces = <; 127.0.0.1 ; \
14401                       192.168.23.65 ; \
14402                       ::1 ; \
14403                       3ffe:ffff:836f::fe86:a061
14404 .endd
14405 There are two different formats for specifying a port along with an IP address
14406 in &%local_interfaces%&:
14407
14408 .olist
14409 The port is added onto the address with a dot separator. For example, to listen
14410 on port 1234 on two different IP addresses:
14411 .code
14412 local_interfaces = <; 192.168.23.65.1234 ; \
14413                       3ffe:ffff:836f::fe86:a061.1234
14414 .endd
14415 .next
14416 The IP address is enclosed in square brackets, and the port is added
14417 with a colon separator, for example:
14418 .code
14419 local_interfaces = <; [192.168.23.65]:1234 ; \
14420                       [3ffe:ffff:836f::fe86:a061]:1234
14421 .endd
14422 .endlist
14423
14424 When a port is not specified, the value of &%daemon_smtp_ports%& is used. The
14425 default setting contains just one port:
14426 .code
14427 daemon_smtp_ports = smtp
14428 .endd
14429 If more than one port is listed, each interface that does not have its own port
14430 specified listens on all of them. Ports that are listed in
14431 &%daemon_smtp_ports%& can be identified either by name (defined in
14432 &_/etc/services_&) or by number. However, when ports are given with individual
14433 IP addresses in &%local_interfaces%&, only numbers (not names) can be used.
14434
14435
14436
14437 .section "Special IP listening addresses" "SECID90"
14438 The addresses 0.0.0.0 and ::0 are treated specially. They are interpreted
14439 as &"all IPv4 interfaces"& and &"all IPv6 interfaces"&, respectively. In each
14440 case, Exim tells the TCP/IP stack to &"listen on all IPv&'x'& interfaces"&
14441 instead of setting up separate listening sockets for each interface. The
14442 default value of &%local_interfaces%& is
14443 .code
14444 local_interfaces = 0.0.0.0
14445 .endd
14446 when Exim is built without IPv6 support; otherwise it is:
14447 .code
14448 local_interfaces = <; ::0 ; 0.0.0.0
14449 .endd
14450 Thus, by default, Exim listens on all available interfaces, on the SMTP port.
14451
14452
14453
14454 .section "Overriding local_interfaces and daemon_smtp_ports" "SECID91"
14455 The &%-oX%& command line option can be used to override the values of
14456 &%daemon_smtp_ports%& and/or &%local_interfaces%& for a particular daemon
14457 instance. Another way of doing this would be to use macros and the &%-D%&
14458 option. However, &%-oX%& can be used by any admin user, whereas modification of
14459 the runtime configuration by &%-D%& is allowed only when the caller is root or
14460 exim.
14461
14462 The value of &%-oX%& is a list of items. The default colon separator can be
14463 changed in the usual way (&<<SECTlistsepchange>>&) if required.
14464 If there are any items that do not
14465 contain dots or colons (that is, are not IP addresses), the value of
14466 &%daemon_smtp_ports%& is replaced by the list of those items. If there are any
14467 items that do contain dots or colons, the value of &%local_interfaces%& is
14468 replaced by those items. Thus, for example,
14469 .code
14470 -oX 1225
14471 .endd
14472 overrides &%daemon_smtp_ports%&, but leaves &%local_interfaces%& unchanged,
14473 whereas
14474 .code
14475 -oX 192.168.34.5.1125
14476 .endd
14477 overrides &%local_interfaces%&, leaving &%daemon_smtp_ports%& unchanged.
14478 (However, since &%local_interfaces%& now contains no items without ports, the
14479 value of &%daemon_smtp_ports%& is no longer relevant in this example.)
14480
14481
14482
14483 .section "Support for the submissions (aka SSMTP or SMTPS) protocol" "SECTsupobssmt"
14484 .cindex "submissions protocol"
14485 .cindex "ssmtp protocol"
14486 .cindex "smtps protocol"
14487 .cindex "SMTP" "ssmtp protocol"
14488 .cindex "SMTP" "smtps protocol"
14489 Exim supports the use of TLS-on-connect, used by mail clients in the
14490 &"submissions"& protocol, historically also known as SMTPS or SSMTP.
14491 For some years, IETF Standards Track documents only blessed the
14492 STARTTLS-based Submission service (port 587) while common practice was to support
14493 the same feature set on port 465, but using TLS-on-connect.
14494 If your installation needs to provide service to mail clients
14495 (Mail User Agents, MUAs) then you should provide service on both the 587 and
14496 the 465 TCP ports.
14497
14498 If the &%tls_on_connect_ports%& option is set to a list of port numbers or
14499 service names, connections to those ports must first establish TLS, before
14500 proceeding to the application layer use of the SMTP protocol.
14501
14502 The common use of this option is expected to be
14503 .code
14504 tls_on_connect_ports = 465
14505 .endd
14506 per RFC 8314.
14507 There is also a command line option &%-tls-on-connect%&, which forces all ports
14508 to behave in this way when a daemon is started.
14509
14510 &*Warning*&: Setting &%tls_on_connect_ports%& does not of itself cause the
14511 daemon to listen on those ports. You must still specify them in
14512 &%daemon_smtp_ports%&, &%local_interfaces%&, or the &%-oX%& option. (This is
14513 because &%tls_on_connect_ports%& applies to &%inetd%& connections as well as to
14514 connections via the daemon.)
14515
14516
14517
14518
14519 .section "IPv6 address scopes" "SECID92"
14520 .cindex "IPv6" "address scopes"
14521 IPv6 addresses have &"scopes"&, and a host with multiple hardware interfaces
14522 can, in principle, have the same link-local IPv6 address on different
14523 interfaces. Thus, additional information is needed, over and above the IP
14524 address, to distinguish individual interfaces. A convention of using a
14525 percent sign followed by something (often the interface name) has been
14526 adopted in some cases, leading to addresses like this:
14527 .code
14528 fe80::202:b3ff:fe03:45c1%eth0
14529 .endd
14530 To accommodate this usage, a percent sign followed by an arbitrary string is
14531 allowed at the end of an IPv6 address. By default, Exim calls &[getaddrinfo()]&
14532 to convert a textual IPv6 address for actual use. This function recognizes the
14533 percent convention in operating systems that support it, and it processes the
14534 address appropriately. Unfortunately, some older libraries have problems with
14535 &[getaddrinfo()]&. If
14536 .code
14537 IPV6_USE_INET_PTON=yes
14538 .endd
14539 is set in &_Local/Makefile_& (or an OS-dependent Makefile) when Exim is built,
14540 Exim uses &'inet_pton()'& to convert a textual IPv6 address for actual use,
14541 instead of &[getaddrinfo()]&. (Before version 4.14, it always used this
14542 function.) Of course, this means that the additional functionality of
14543 &[getaddrinfo()]& &-- recognizing scoped addresses &-- is lost.
14544
14545 .section "Disabling IPv6" "SECID93"
14546 .cindex "IPv6" "disabling"
14547 Sometimes it happens that an Exim binary that was compiled with IPv6 support is
14548 run on a host whose kernel does not support IPv6. The binary will fall back to
14549 using IPv4, but it may waste resources looking up AAAA records, and trying to
14550 connect to IPv6 addresses, causing delays to mail delivery. If you set the
14551 .oindex "&%disable_ipv6%&"
14552 &%disable_ipv6%& option true, even if the Exim binary has IPv6 support, no IPv6
14553 activities take place. AAAA records are never looked up, and any IPv6 addresses
14554 that are listed in &%local_interfaces%&, data for the &(manualroute)& router,
14555 etc. are ignored. If IP literals are enabled, the &(ipliteral)& router declines
14556 to handle IPv6 literal addresses.
14557
14558 On the other hand, when IPv6 is in use, there may be times when you want to
14559 disable it for certain hosts or domains. You can use the &%dns_ipv4_lookup%&
14560 option to globally suppress the lookup of AAAA records for specified domains,
14561 and you can use the &%ignore_target_hosts%& generic router option to ignore
14562 IPv6 addresses in an individual router.
14563
14564
14565
14566 .section "Examples of starting a listening daemon" "SECID94"
14567 The default case in an IPv6 environment is
14568 .code
14569 daemon_smtp_ports = smtp
14570 local_interfaces = <; ::0 ; 0.0.0.0
14571 .endd
14572 This specifies listening on the smtp port on all IPv6 and IPv4 interfaces.
14573 Either one or two sockets may be used, depending on the characteristics of
14574 the TCP/IP stack. (This is complicated and messy; for more information,
14575 read the comments in the &_daemon.c_& source file.)
14576
14577 To specify listening on ports 25 and 26 on all interfaces:
14578 .code
14579 daemon_smtp_ports = 25 : 26
14580 .endd
14581 (leaving &%local_interfaces%& at the default setting) or, more explicitly:
14582 .code
14583 local_interfaces = <; ::0.25     ; ::0.26 \
14584                       0.0.0.0.25 ; 0.0.0.0.26
14585 .endd
14586 To listen on the default port on all IPv4 interfaces, and on port 26 on the
14587 IPv4 loopback address only:
14588 .code
14589 local_interfaces = 0.0.0.0 : 127.0.0.1.26
14590 .endd
14591 To specify listening on the default port on specific interfaces only:
14592 .code
14593 local_interfaces = 10.0.0.67 : 192.168.34.67
14594 .endd
14595 &*Warning*&: Such a setting excludes listening on the loopback interfaces.
14596
14597
14598
14599 .section "Recognizing the local host" "SECTreclocipadd"
14600 The &%local_interfaces%& option is also used when Exim needs to determine
14601 whether or not an IP address refers to the local host. That is, the IP
14602 addresses of all the interfaces on which a daemon is listening are always
14603 treated as local.
14604
14605 For this usage, port numbers in &%local_interfaces%& are ignored. If either of
14606 the items 0.0.0.0 or ::0 are encountered, Exim gets a complete list of
14607 available interfaces from the operating system, and extracts the relevant
14608 (that is, IPv4 or IPv6) addresses to use for checking.
14609
14610 Some systems set up large numbers of virtual interfaces in order to provide
14611 many virtual web servers. In this situation, you may want to listen for
14612 email on only a few of the available interfaces, but nevertheless treat all
14613 interfaces as local when routing. You can do this by setting
14614 &%extra_local_interfaces%& to a list of IP addresses, possibly including the
14615 &"all"& wildcard values. These addresses are recognized as local, but are not
14616 used for listening. Consider this example:
14617 .code
14618 local_interfaces = <; 127.0.0.1 ; ::1 ; \
14619                       192.168.53.235 ; \
14620                       3ffe:2101:12:1:a00:20ff:fe86:a061
14621
14622 extra_local_interfaces = <; ::0 ; 0.0.0.0
14623 .endd
14624 The daemon listens on the loopback interfaces and just one IPv4 and one IPv6
14625 address, but all available interface addresses are treated as local when
14626 Exim is routing.
14627
14628 In some environments the local host name may be in an MX list, but with an IP
14629 address that is not assigned to any local interface. In other cases it may be
14630 desirable to treat other host names as if they referred to the local host. Both
14631 these cases can be handled by setting the &%hosts_treat_as_local%& option.
14632 This contains host names rather than IP addresses. When a host is referenced
14633 during routing, either via an MX record or directly, it is treated as the local
14634 host if its name matches &%hosts_treat_as_local%&, or if any of its IP
14635 addresses match &%local_interfaces%& or &%extra_local_interfaces%&.
14636
14637
14638
14639 .section "Delivering to a remote host" "SECID95"
14640 Delivery to a remote host is handled by the smtp transport. By default, it
14641 allows the system's TCP/IP functions to choose which interface to use (if
14642 there is more than one) when connecting to a remote host. However, the
14643 &%interface%& option can be set to specify which interface is used. See the
14644 description of the smtp transport in chapter &<<CHAPsmtptrans>>& for more
14645 details.
14646
14647
14648
14649
14650 . ////////////////////////////////////////////////////////////////////////////
14651 . ////////////////////////////////////////////////////////////////////////////
14652
14653 .chapter "Main configuration" "CHAPmainconfig"
14654 .scindex IIDconfima "configuration file" "main section"
14655 .scindex IIDmaiconf "main configuration"
14656 The first part of the runtime configuration file contains three types of item:
14657
14658 .ilist
14659 Macro definitions: These lines start with an upper case letter. See section
14660 &<<SECTmacrodefs>>& for details of macro processing.
14661 .next
14662 Named list definitions: These lines start with one of the words &"domainlist"&,
14663 &"hostlist"&, &"addresslist"&, or &"localpartlist"&. Their use is described in
14664 section &<<SECTnamedlists>>&.
14665 .next
14666 Main configuration settings: Each setting occupies one line of the file
14667 (with possible continuations). If any setting is preceded by the word
14668 &"hide"&, the &%-bP%& command line option displays its value to admin users
14669 only. See section &<<SECTcos>>& for a description of the syntax of these option
14670 settings.
14671 .endlist
14672
14673 This chapter specifies all the main configuration options, along with their
14674 types and default values. For ease of finding a particular option, they appear
14675 in alphabetical order in section &<<SECTalomo>>& below. However, because there
14676 are now so many options, they are first listed briefly in functional groups, as
14677 an aid to finding the name of the option you are looking for. Some options are
14678 listed in more than one group.
14679
14680 .section "Miscellaneous" "SECID96"
14681 .table2
14682 .row &%add_environment%&             "environment variables"
14683 .row &%bi_command%&                  "to run for &%-bi%& command line option"
14684 .row &%debug_store%&                 "do extra internal checks"
14685 .row &%disable_ipv6%&                "do no IPv6 processing"
14686 .row &%keep_environment%&            "environment variables"
14687 .row &%keep_malformed%&              "for broken files &-- should not happen"
14688 .row &%localhost_number%&            "for unique message ids in clusters"
14689 .row &%message_body_newlines%&       "retain newlines in &$message_body$&"
14690 .row &%message_body_visible%&        "how much to show in &$message_body$&"
14691 .row &%mua_wrapper%&                 "run in &""MUA wrapper""& mode"
14692 .row &%print_topbitchars%&           "top-bit characters are printing"
14693 .row &%spool_wireformat%&            "use wire-format spool data files when possible"
14694 .row &%timezone%&                    "force time zone"
14695 .endtable
14696
14697
14698 .section "Exim parameters" "SECID97"
14699 .table2
14700 .row &%exim_group%&                  "override compiled-in value"
14701 .row &%exim_path%&                   "override compiled-in value"
14702 .row &%exim_user%&                   "override compiled-in value"
14703 .row &%primary_hostname%&            "default from &[uname()]&"
14704 .row &%split_spool_directory%&       "use multiple directories"
14705 .row &%spool_directory%&             "override compiled-in value"
14706 .endtable
14707
14708
14709
14710 .section "Privilege controls" "SECID98"
14711 .table2
14712 .row &%admin_groups%&                "groups that are Exim admin users"
14713 .row &%commandline_checks_require_admin%& "require admin for various checks"
14714 .row &%deliver_drop_privilege%&      "drop root for delivery processes"
14715 .row &%local_from_check%&            "insert &'Sender:'& if necessary"
14716 .row &%local_from_prefix%&           "for testing &'From:'& for local sender"
14717 .row &%local_from_suffix%&           "for testing &'From:'& for local sender"
14718 .row &%local_sender_retain%&         "keep &'Sender:'& from untrusted user"
14719 .row &%never_users%&                 "do not run deliveries as these"
14720 .row &%prod_requires_admin%&         "forced delivery requires admin user"
14721 .row &%queue_list_requires_admin%&   "queue listing requires admin user"
14722 .row &%trusted_groups%&              "groups that are trusted"
14723 .row &%trusted_users%&               "users that are trusted"
14724 .endtable
14725
14726
14727
14728 .section "Logging" "SECID99"
14729 .table2
14730 .row &%event_action%&                "custom logging"
14731 .row &%hosts_connection_nolog%&      "exemption from connect logging"
14732 .row &%log_file_path%&               "override compiled-in value"
14733 .row &%log_selector%&                "set/unset optional logging"
14734 .row &%log_timezone%&                "add timezone to log lines"
14735 .row &%message_logs%&                "create per-message logs"
14736 .row &%preserve_message_logs%&       "after message completion"
14737 .row &%panic_coredump%&              "request coredump on fatal errors"
14738 .row &%process_log_path%&            "for SIGUSR1 and &'exiwhat'&"
14739 .row &%slow_lookup_log%&             "control logging of slow DNS lookups"
14740 .row &%syslog_duplication%&          "controls duplicate log lines on syslog"
14741 .row &%syslog_facility%&             "set syslog &""facility""& field"
14742 .row &%syslog_pid%&                  "pid in syslog lines"
14743 .row &%syslog_processname%&          "set syslog &""ident""& field"
14744 .row &%syslog_timestamp%&            "timestamp syslog lines"
14745 .row &%write_rejectlog%&             "control use of message log"
14746 .endtable
14747
14748
14749
14750 .section "Frozen messages" "SECID100"
14751 .table2
14752 .row &%auto_thaw%&                   "sets time for retrying frozen messages"
14753 .row &%freeze_tell%&                 "send message when freezing"
14754 .row &%move_frozen_messages%&        "to another directory"
14755 .row &%timeout_frozen_after%&        "keep frozen messages only so long"
14756 .endtable
14757
14758
14759
14760 .section "Data lookups" "SECID101"
14761 .table2
14762 .row &%ibase_servers%&               "InterBase servers"
14763 .row &%ldap_ca_cert_dir%&            "dir of CA certs to verify LDAP server's"
14764 .row &%ldap_ca_cert_file%&           "file of CA certs to verify LDAP server's"
14765 .row &%ldap_cert_file%&              "client cert file for LDAP"
14766 .row &%ldap_cert_key%&               "client key file for LDAP"
14767 .row &%ldap_cipher_suite%&           "TLS negotiation preference control"
14768 .row &%ldap_default_servers%&        "used if no server in query"
14769 .row &%ldap_require_cert%&           "action to take without LDAP server cert"
14770 .row &%ldap_start_tls%&              "require TLS within LDAP"
14771 .row &%ldap_version%&                "set protocol version"
14772 .row &%lookup_open_max%&             "lookup files held open"
14773 .row &%mysql_servers%&               "default MySQL servers"
14774 .row &%oracle_servers%&              "Oracle servers"
14775 .row &%pgsql_servers%&               "default PostgreSQL servers"
14776 .row &%sqlite_lock_timeout%&         "as it says"
14777 .endtable
14778
14779
14780
14781 .section "Message ids" "SECID102"
14782 .table2
14783 .row &%message_id_header_domain%&    "used to build &'Message-ID:'& header"
14784 .row &%message_id_header_text%&      "ditto"
14785 .endtable
14786
14787
14788
14789 .section "Embedded Perl Startup" "SECID103"
14790 .table2
14791 .row &%perl_at_start%&               "always start the interpreter"
14792 .row &%perl_startup%&                "code to obey when starting Perl"
14793 .row &%perl_taintmode%&              "enable taint mode in Perl"
14794 .endtable
14795
14796
14797
14798 .section "Daemon" "SECID104"
14799 .table2
14800 .row &%daemon_smtp_ports%&           "default ports"
14801 .row &%daemon_startup_retries%&      "number of times to retry"
14802 .row &%daemon_startup_sleep%&        "time to sleep between tries"
14803 .row &%extra_local_interfaces%&      "not necessarily listened on"
14804 .row &%local_interfaces%&            "on which to listen, with optional ports"
14805 .row &%notifier_socket%&             "override compiled-in value"
14806 .row &%pid_file_path%&               "override compiled-in value"
14807 .row &%queue_run_max%&               "maximum simultaneous queue runners"
14808 .row &%smtp_backlog_monitor%&        "level to log listen backlog"
14809 .endtable
14810
14811
14812
14813 .section "Resource control" "SECID105"
14814 .table2
14815 .row &%check_log_inodes%&            "before accepting a message"
14816 .row &%check_log_space%&             "before accepting a message"
14817 .row &%check_spool_inodes%&          "before accepting a message"
14818 .row &%check_spool_space%&           "before accepting a message"
14819 .row &%deliver_queue_load_max%&      "no queue deliveries if load high"
14820 .row &%queue_only_load%&             "queue incoming if load high"
14821 .row &%queue_only_load_latch%&       "don't re-evaluate load for each message"
14822 .row &%queue_run_max%&               "maximum simultaneous queue runners"
14823 .row &%remote_max_parallel%&         "parallel SMTP delivery per message"
14824 .row &%smtp_accept_max%&             "simultaneous incoming connections"
14825 .row &%smtp_accept_max_nonmail%&     "non-mail commands"
14826 .row &%smtp_accept_max_nonmail_hosts%& "hosts to which the limit applies"
14827 .row &%smtp_accept_max_per_connection%& "messages per connection"
14828 .row &%smtp_accept_max_per_host%&    "connections from one host"
14829 .row &%smtp_accept_queue%&           "queue mail if more connections"
14830 .row &%smtp_accept_queue_per_connection%& "queue if more messages per &&&
14831                                            connection"
14832 .row &%smtp_accept_reserve%&         "only reserve hosts if more connections"
14833 .row &%smtp_check_spool_space%&      "from SIZE on MAIL command"
14834 .row &%smtp_connect_backlog%&        "passed to TCP/IP stack"
14835 .row &%smtp_load_reserve%&           "SMTP from reserved hosts if load high"
14836 .row &%smtp_reserve_hosts%&          "these are the reserve hosts"
14837 .endtable
14838
14839
14840
14841 .section "Policy controls" "SECID106"
14842 .table2
14843 .row &%acl_not_smtp%&                "ACL for non-SMTP messages"
14844 .row &%acl_not_smtp_mime%&           "ACL for non-SMTP MIME parts"
14845 .row &%acl_not_smtp_start%&          "ACL for start of non-SMTP message"
14846 .row &%acl_smtp_auth%&               "ACL for AUTH"
14847 .row &%acl_smtp_connect%&            "ACL for connection"
14848 .row &%acl_smtp_data%&               "ACL for DATA"
14849 .row &%acl_smtp_data_prdr%&          "ACL for DATA, per-recipient"
14850 .row &%acl_smtp_dkim%&               "ACL for DKIM verification"
14851 .row &%acl_smtp_etrn%&               "ACL for ETRN"
14852 .row &%acl_smtp_expn%&               "ACL for EXPN"
14853 .row &%acl_smtp_helo%&               "ACL for EHLO or HELO"
14854 .row &%acl_smtp_mail%&               "ACL for MAIL"
14855 .row &%acl_smtp_mailauth%&           "ACL for AUTH on MAIL command"
14856 .row &%acl_smtp_mime%&               "ACL for MIME parts"
14857 .row &%acl_smtp_notquit%&            "ACL for non-QUIT terminations"
14858 .row &%acl_smtp_predata%&            "ACL for start of data"
14859 .row &%acl_smtp_quit%&               "ACL for QUIT"
14860 .row &%acl_smtp_rcpt%&               "ACL for RCPT"
14861 .row &%acl_smtp_starttls%&           "ACL for STARTTLS"
14862 .row &%acl_smtp_vrfy%&               "ACL for VRFY"
14863 .row &%acl_smtp_wellknown%&          "ACL for WELLKNOWN"
14864 .row &%av_scanner%&                  "specify virus scanner"
14865 .row &%check_rfc2047_length%&        "check length of RFC 2047 &""encoded &&&
14866                                       words""&"
14867 .row &%dns_cname_loops%&             "follow CNAMEs returned by resolver"
14868 .row &%dns_csa_search_limit%&        "control CSA parent search depth"
14869 .row &%dns_csa_use_reverse%&         "en/disable CSA IP reverse search"
14870 .row &%header_maxsize%&              "total size of message header"
14871 .row &%header_line_maxsize%&         "individual header line limit"
14872 .row &%helo_accept_junk_hosts%&      "allow syntactic junk from these hosts"
14873 .row &%helo_allow_chars%&            "allow illegal chars in HELO names"
14874 .row &%helo_lookup_domains%&         "lookup hostname for these HELO names"
14875 .row &%helo_try_verify_hosts%&       "HELO soft-checked for these hosts"
14876 .row &%helo_verify_hosts%&           "HELO hard-checked for these hosts"
14877 .row &%host_lookup%&                 "host name looked up for these hosts"
14878 .row &%host_lookup_order%&           "order of DNS and local name lookups"
14879 .row &%hosts_proxy%&                 "use proxy protocol for these hosts"
14880 .row &%host_reject_connection%&      "reject connection from these hosts"
14881 .row &%hosts_treat_as_local%&        "useful in some cluster configurations"
14882 .row &%local_scan_timeout%&          "timeout for &[local_scan()]&"
14883 .row &%message_size_limit%&          "for all messages"
14884 .row &%percent_hack_domains%&        "recognize %-hack for these domains"
14885 .row &%proxy_protocol_timeout%&      "timeout for proxy protocol negotiation"
14886 .row &%spamd_address%&               "set interface to SpamAssassin"
14887 .row &%strict_acl_vars%&             "object to unset ACL variables"
14888 .row &%spf_smtp_comment_template%&   "template for &$spf_smtp_comment$&"
14889 .endtable
14890
14891
14892
14893 .section "Callout cache" "SECID107"
14894 .table2
14895 .row &%callout_domain_negative_expire%& "timeout for negative domain cache &&&
14896                                          item"
14897 .row &%callout_domain_positive_expire%& "timeout for positive domain cache &&&
14898                                          item"
14899 .row &%callout_negative_expire%&     "timeout for negative address cache item"
14900 .row &%callout_positive_expire%&     "timeout for positive address cache item"
14901 .row &%callout_random_local_part%&   "string to use for &""random""& testing"
14902 .endtable
14903
14904
14905
14906 .section "TLS" "SECID108"
14907 .table2
14908 .row &%gnutls_compat_mode%&          "use GnuTLS compatibility mode"
14909 .row &%gnutls_allow_auto_pkcs11%&    "allow GnuTLS to autoload PKCS11 modules"
14910 .row &%hosts_require_alpn%&          "mandatory ALPN"
14911 .row &%hosts_require_helo%&          "mandatory HELO/EHLO"
14912 .row &%openssl_options%&             "adjust OpenSSL compatibility options"
14913 .row &%tls_advertise_hosts%&         "advertise TLS to these hosts"
14914 .row &%tls_alpn%&                    "acceptable protocol names"
14915 .row &%tls_certificate%&             "location of server certificate"
14916 .row &%tls_crl%&                     "certificate revocation list"
14917 .row &%tls_dh_max_bits%&             "clamp D-H bit count suggestion"
14918 .row &%tls_dhparam%&                 "DH parameters for server"
14919 .row &%tls_eccurve%&                 "EC curve selection for server"
14920 .row &%tls_ocsp_file%&               "location of server certificate status proof"
14921 .row &%tls_on_connect_ports%&        "specify SSMTP (SMTPS) ports"
14922 .row &%tls_privatekey%&              "location of server private key"
14923 .row &%tls_remember_esmtp%&          "don't reset after starting TLS"
14924 .row &%tls_require_ciphers%&         "specify acceptable ciphers"
14925 .row &%tls_try_verify_hosts%&        "try to verify client certificate"
14926 .row &%tls_verify_certificates%&     "expected client certificates"
14927 .row &%tls_verify_hosts%&            "insist on client certificate verify"
14928 .endtable
14929
14930
14931
14932 .section "Local user handling" "SECID109"
14933 .table2
14934 .row &%finduser_retries%&            "useful in NIS environments"
14935 .row &%gecos_name%&                  "used when creating &'Sender:'&"
14936 .row &%gecos_pattern%&               "ditto"
14937 .row &%max_username_length%&         "for systems that truncate"
14938 .row &%unknown_login%&               "used when no login name found"
14939 .row &%unknown_username%&            "ditto"
14940 .row &%uucp_from_pattern%&           "for recognizing &""From ""& lines"
14941 .row &%uucp_from_sender%&            "ditto"
14942 .endtable
14943
14944
14945
14946 .section "All incoming messages (SMTP and non-SMTP)" "SECID110"
14947 .table2
14948 .row &%header_maxsize%&              "total size of message header"
14949 .row &%header_line_maxsize%&         "individual header line limit"
14950 .row &%message_size_limit%&          "applies to all messages"
14951 .row &%percent_hack_domains%&        "recognize %-hack for these domains"
14952 .row &%received_header_text%&        "expanded to make &'Received:'&"
14953 .row &%received_headers_max%&        "for mail loop detection"
14954 .row &%recipients_max%&              "limit per message"
14955 .row &%recipients_max_reject%&       "permanently reject excess recipients"
14956 .endtable
14957
14958
14959
14960
14961 .section "Non-SMTP incoming messages" "SECID111"
14962 .table2
14963 .row &%receive_timeout%&             "for non-SMTP messages"
14964 .endtable
14965
14966
14967
14968
14969
14970 .section "Incoming SMTP messages" "SECID112"
14971 See also the &'Policy controls'& section above.
14972
14973 .table2
14974 .row &%dkim_verify_hashes%&          "DKIM hash methods accepted for signatures"
14975 .row &%dkim_verify_keytypes%&        "DKIM key types accepted for signatures"
14976 .row &%dkim_verify_min_keysizes%&    "DKIM key sizes accepted for signatures"
14977 .row &%dkim_verify_signers%&         "DKIM domains for which DKIM ACL is run"
14978 .row &%dmarc_forensic_sender%&       "DMARC sender for report messages"
14979 .row &%dmarc_history_file%&          "DMARC results log"
14980 .row &%dmarc_tld_file%&              "DMARC toplevel domains file"
14981 .row &%host_lookup%&                 "host name looked up for these hosts"
14982 .row &%host_lookup_order%&           "order of DNS and local name lookups"
14983 .row &%recipient_unqualified_hosts%& "may send unqualified recipients"
14984 .row &%rfc1413_hosts%&               "make ident calls to these hosts"
14985 .row &%rfc1413_query_timeout%&       "zero disables ident calls"
14986 .row &%sender_unqualified_hosts%&    "may send unqualified senders"
14987 .row &%smtp_accept_keepalive%&       "some TCP/IP magic"
14988 .row &%smtp_accept_max%&             "simultaneous incoming connections"
14989 .row &%smtp_accept_max_nonmail%&     "non-mail commands"
14990 .row &%smtp_accept_max_nonmail_hosts%& "hosts to which the limit applies"
14991 .row &%smtp_accept_max_per_connection%& "messages per connection"
14992 .row &%smtp_accept_max_per_host%&    "connections from one host"
14993 .row &%smtp_accept_queue%&           "queue mail if more connections"
14994 .row &%smtp_accept_queue_per_connection%& "queue if more messages per &&&
14995                                            connection"
14996 .row &%smtp_accept_reserve%&         "only reserve hosts if more connections"
14997 .row &%smtp_active_hostname%&        "host name to use in messages"
14998 .row &%smtp_banner%&                 "text for welcome banner"
14999 .row &%smtp_check_spool_space%&      "from SIZE on MAIL command"
15000 .row &%smtp_connect_backlog%&        "passed to TCP/IP stack"
15001 .row &%smtp_enforce_sync%&           "of SMTP command/responses"
15002 .row &%smtp_etrn_command%&           "what to run for ETRN"
15003 .row &%smtp_etrn_serialize%&         "only one at once"
15004 .row &%smtp_load_reserve%&           "only reserve hosts if this load"
15005 .row &%smtp_max_unknown_commands%&   "before dropping connection"
15006 .row &%smtp_ratelimit_hosts%&        "apply ratelimiting to these hosts"
15007 .row &%smtp_ratelimit_mail%&         "ratelimit for MAIL commands"
15008 .row &%smtp_ratelimit_rcpt%&         "ratelimit for RCPT commands"
15009 .row &%smtp_receive_timeout%&        "per command or data line"
15010 .row &%smtp_reserve_hosts%&          "these are the reserve hosts"
15011 .row &%smtp_return_error_details%&   "give detail on rejections"
15012 .endtable
15013
15014
15015
15016 .section "SMTP extensions" "SECID113"
15017 .table2
15018 .row &%accept_8bitmime%&             "advertise 8BITMIME"
15019 .row &%auth_advertise_hosts%&        "advertise AUTH to these hosts"
15020 .row &%chunking_advertise_hosts%&    "advertise CHUNKING to these hosts"
15021 .row &%dsn_advertise_hosts%&         "advertise DSN extensions to these hosts"
15022 .row &%ignore_fromline_hosts%&       "allow &""From ""& from these hosts"
15023 .row &%ignore_fromline_local%&       "allow &""From ""& from local SMTP"
15024 .row &%limits_advertise_hosts%&      "advertise LIMITS to these hosts"
15025 .row &%pipelining_advertise_hosts%&  "advertise pipelining to these hosts"
15026 .row &%pipelining_connect_advertise_hosts%& "advertise pipelining to these hosts"
15027 .row &%prdr_enable%&                 "advertise PRDR to all hosts"
15028 .row &%smtputf8_advertise_hosts%&    "advertise SMTPUTF8 to these hosts"
15029 .row &%tls_advertise_hosts%&         "advertise TLS to these hosts"
15030 .row &%wellknown_advertise_hosts%&   "advertise WELLKNOWN to these hosts"
15031 .endtable
15032
15033
15034
15035 .section "Processing messages" "SECID114"
15036 .table2
15037 .row &%allow_domain_literals%&       "recognize domain literal syntax"
15038 .row &%allow_mx_to_ip%&              "allow MX to point to IP address"
15039 .row &%allow_utf8_domains%&          "in addresses"
15040 .row &%check_rfc2047_length%&        "check length of RFC 2047 &""encoded &&&
15041                                       words""&"
15042 .row &%delivery_date_remove%&        "from incoming messages"
15043 .row &%envelope_to_remove%&          "from incoming messages"
15044 .row &%extract_addresses_remove_arguments%& "affects &%-t%& processing"
15045 .row &%headers_charset%&             "default for translations"
15046 .row &%qualify_domain%&              "default for senders"
15047 .row &%qualify_recipient%&           "default for recipients"
15048 .row &%return_path_remove%&          "from incoming messages"
15049 .row &%strip_excess_angle_brackets%& "in addresses"
15050 .row &%strip_trailing_dot%&          "at end of addresses"
15051 .row &%untrusted_set_sender%&        "untrusted can set envelope sender"
15052 .endtable
15053
15054
15055
15056 .section "System filter" "SECID115"
15057 .table2
15058 .row &%system_filter%&               "locate system filter"
15059 .row &%system_filter_directory_transport%& "transport for delivery to a &&&
15060                                             directory"
15061 .row &%system_filter_file_transport%& "transport for delivery to a file"
15062 .row &%system_filter_group%&         "group for filter running"
15063 .row &%system_filter_pipe_transport%& "transport for delivery to a pipe"
15064 .row &%system_filter_reply_transport%& "transport for autoreply delivery"
15065 .row &%system_filter_user%&          "user for filter running"
15066 .endtable
15067
15068
15069
15070 .section "Routing and delivery" "SECID116"
15071 .table2
15072 .row &%disable_ipv6%&                "do no IPv6 processing"
15073 .row &%dns_again_means_nonexist%&    "for broken domains"
15074 .row &%dns_check_names_pattern%&     "pre-DNS syntax check"
15075 .row &%dns_dnssec_ok%&               "parameter for resolver"
15076 .row &%dns_ipv4_lookup%&             "only v4 lookup for these domains"
15077 .row &%dns_retrans%&                 "parameter for resolver"
15078 .row &%dns_retry%&                   "parameter for resolver"
15079 .row &%dns_trust_aa%&                "DNS zones trusted as authentic"
15080 .row &%dns_use_edns0%&               "parameter for resolver"
15081 .row &%hold_domains%&                "hold delivery for these domains"
15082 .row &%local_interfaces%&            "for routing checks"
15083 .row &%queue_domains%&               "no immediate delivery for these"
15084 .row &%queue_fast_ramp%&             "parallel delivery with 2-phase queue run"
15085 .row &%queue_only%&                  "no immediate delivery at all"
15086 .row &%queue_only_file%&             "no immediate delivery if file exists"
15087 .row &%queue_only_load%&             "no immediate delivery if load is high"
15088 .row &%queue_only_load_latch%&       "don't re-evaluate load for each message"
15089 .row &%queue_only_override%&         "allow command line to override"
15090 .row &%queue_run_in_order%&          "order of arrival"
15091 .row &%queue_run_max%&               "of simultaneous queue runners"
15092 .row &%queue_smtp_domains%&          "no immediate SMTP delivery for these"
15093 .row &%remote_max_parallel%&         "parallel SMTP delivery per message"
15094 .row &%remote_sort_domains%&         "order of remote deliveries"
15095 .row &%retry_data_expire%&           "timeout for retry data"
15096 .row &%retry_interval_max%&          "safety net for retry rules"
15097 .endtable
15098
15099
15100
15101 .section "Bounce and warning messages" "SECID117"
15102 .table2
15103 .row &%bounce_message_file%&         "content of bounce"
15104 .row &%bounce_message_text%&         "content of bounce"
15105 .row &%bounce_return_body%&          "include body if returning message"
15106 .row &%bounce_return_linesize_limit%& "limit on returned message line length"
15107 .row &%bounce_return_message%&       "include original message in bounce"
15108 .row &%bounce_return_size_limit%&    "limit on returned message"
15109 .row &%bounce_sender_authentication%& "send authenticated sender with bounce"
15110 .row &%dsn_from%&                    "set &'From:'& contents in bounces"
15111 .row &%errors_copy%&                 "copy bounce messages"
15112 .row &%errors_reply_to%&             "&'Reply-to:'& in bounces"
15113 .row &%delay_warning%&               "time schedule"
15114 .row &%delay_warning_condition%&     "condition for warning messages"
15115 .row &%ignore_bounce_errors_after%&  "discard undeliverable bounces"
15116 .row &%smtp_return_error_details%&   "give detail on rejections"
15117 .row &%warn_message_file%&           "content of warning message"
15118 .endtable
15119
15120
15121
15122 .section "Alphabetical list of main options" "SECTalomo"
15123 Those options that undergo string expansion before use are marked with
15124 &dagger;.
15125
15126 .option accept_8bitmime main boolean true
15127 .cindex "8BITMIME"
15128 .cindex "8-bit characters"
15129 .cindex "log" "selectors"
15130 .cindex "log" "8BITMIME"
15131 .cindex "ESMTP extensions" 8BITMIME
15132 This option causes Exim to send 8BITMIME in its response to an SMTP
15133 EHLO command, and to accept the BODY= parameter on MAIL commands.
15134 However, though Exim is 8-bit clean, it is not a protocol converter, and it
15135 takes no steps to do anything special with messages received by this route.
15136
15137 Historically Exim kept this option off by default, but the maintainers
15138 feel that in today's Internet, this causes more problems than it solves.
15139 It now defaults to true.
15140 A more detailed analysis of the issues is provided by Dan Bernstein:
15141 .display
15142 &url(https://cr.yp.to/smtp/8bitmime.html)
15143 .endd
15144
15145 To log received 8BITMIME status use
15146 .code
15147 log_selector = +8bitmime
15148 .endd
15149
15150 .option acl_not_smtp main string&!! unset
15151 .cindex "&ACL;" "for non-SMTP messages"
15152 .cindex "non-SMTP messages" "ACLs for"
15153 This option defines the ACL that is run when a non-SMTP message has been
15154 read and is on the point of being accepted. See section &<<SECnonSMTP>>& for
15155 further details.
15156
15157 .option acl_not_smtp_mime main string&!! unset
15158 This option defines the ACL that is run for individual MIME parts of non-SMTP
15159 messages. It operates in exactly the same way as &%acl_smtp_mime%& operates for
15160 SMTP messages.
15161
15162 .option acl_not_smtp_start main string&!! unset
15163 .cindex "&ACL;" "at start of non-SMTP message"
15164 .cindex "non-SMTP messages" "ACLs for"
15165 This option defines the ACL that is run before Exim starts reading a
15166 non-SMTP message. See section &<<SECnonSMTP>>& for further details.
15167
15168 .option acl_smtp_auth main string&!! unset
15169 .cindex "&ACL;" "setting up for SMTP commands"
15170 .cindex "AUTH" "ACL for"
15171 This option defines the ACL that is run when an SMTP AUTH command is
15172 received.
15173 See chapter &<<CHAPACL>>& for general information on ACLs, and chapter
15174 &<<CHAPSMTPAUTH>>& for details of authentication.
15175
15176 .option acl_smtp_connect main string&!! unset
15177 .cindex "&ACL;" "on SMTP connection"
15178 This option defines the ACL that is run when an SMTP connection is received.
15179 See section &<<SECconnectACL>>& for further details.
15180
15181 .option acl_smtp_data main string&!! unset
15182 .cindex "DATA" "ACL for"
15183 This option defines the ACL that is run after an SMTP DATA command has been
15184 processed and the message itself has been received, but before the final
15185 acknowledgment is sent. See section &<<SECdataACLS>>& for further details.
15186
15187 .option acl_smtp_data_prdr main string&!! accept
15188 .cindex "PRDR" "ACL for"
15189 .cindex "DATA" "PRDR ACL for"
15190 .cindex "&ACL;" "PRDR-related"
15191 .cindex "&ACL;" "per-user data processing"
15192 This option defines the ACL that,
15193 if the PRDR feature has been negotiated,
15194 is run for each recipient after an SMTP DATA command has been
15195 processed and the message itself has been received, but before the
15196 acknowledgment is sent. See section &<<SECTPRDRACL>>& for further details.
15197
15198 .option acl_smtp_dkim main string&!! unset
15199 .cindex DKIM "ACL for"
15200 This option defines the ACL that is run for each DKIM signature
15201 (by default, or as specified in the dkim_verify_signers option)
15202 of a received message.
15203 See section &<<SECDKIMVFY>>& for further details.
15204
15205 .option acl_smtp_etrn main string&!! unset
15206 .cindex "ETRN" "ACL for"
15207 This option defines the ACL that is run when an SMTP ETRN command is
15208 received. See chapter &<<CHAPACL>>& for further details.
15209
15210 .option acl_smtp_expn main string&!! unset
15211 .cindex "EXPN" "ACL for"
15212 This option defines the ACL that is run when an SMTP EXPN command is
15213 received. See chapter &<<CHAPACL>>& for further details.
15214
15215 .option acl_smtp_helo main string&!! unset
15216 .cindex "EHLO" "ACL for"
15217 .cindex "HELO" "ACL for"
15218 This option defines the ACL that is run when an SMTP EHLO or HELO
15219 command is received. See section &<<SECheloACL>>& for further details.
15220
15221
15222 .option acl_smtp_mail main string&!! unset
15223 .cindex "MAIL" "ACL for"
15224 This option defines the ACL that is run when an SMTP MAIL command is
15225 received. See chapter &<<CHAPACL>>& for further details.
15226
15227 .option acl_smtp_mailauth main string&!! unset
15228 .cindex "AUTH" "on MAIL command"
15229 This option defines the ACL that is run when there is an AUTH parameter on
15230 a MAIL command.
15231 See chapter &<<CHAPACL>>& for general information on ACLs, and chapter
15232 &<<CHAPSMTPAUTH>>& for details of authentication.
15233
15234 .option acl_smtp_mime main string&!! unset
15235 .cindex "MIME content scanning" "ACL for"
15236 This option is available when Exim is built with the content-scanning
15237 extension. It defines the ACL that is run for each MIME part in a message. See
15238 section &<<SECTscanmimepart>>& for details.
15239
15240 .option acl_smtp_notquit main string&!! unset
15241 .cindex "not-QUIT, ACL for"
15242 This option defines the ACL that is run when an SMTP session
15243 ends without a QUIT command being received.
15244 See section &<<SECTNOTQUITACL>>& for further details.
15245
15246 .option acl_smtp_predata main string&!! unset
15247 This option defines the ACL that is run when an SMTP DATA command is
15248 received, before the message itself is received. See chapter &<<CHAPACL>>& for
15249 further details.
15250
15251 .option acl_smtp_quit main string&!! unset
15252 .cindex "QUIT, ACL for"
15253 This option defines the ACL that is run when an SMTP QUIT command is
15254 received. See chapter &<<CHAPACL>>& for further details.
15255
15256 .option acl_smtp_rcpt main string&!! unset
15257 .cindex "RCPT" "ACL for"
15258 This option defines the ACL that is run when an SMTP RCPT command is
15259 received. See section &<<SECTQUITACL>>& for further details.
15260
15261 .option acl_smtp_starttls main string&!! unset
15262 .cindex "STARTTLS, ACL for"
15263 This option defines the ACL that is run when an SMTP STARTTLS command is
15264 received. See chapter &<<CHAPACL>>& for further details.
15265
15266 .option acl_smtp_vrfy main string&!! unset
15267 .cindex "VRFY" "ACL for"
15268 This option defines the ACL that is run when an SMTP VRFY command is
15269 received. See chapter &<<CHAPACL>>& for further details.
15270
15271 .option acl_smtp_wellknown main string&!! unset
15272 .cindex "WELLKNOWN, ACL for"
15273 This option defines the ACL that is run when an SMTP WELLKNOWN command is
15274 received. See section &<<SECTWELLKNOWNACL>>& for further details.
15275
15276 .option add_environment main "string list" empty
15277 .cindex "environment" "set values"
15278 This option adds individual environment variables that the
15279 currently linked libraries and programs in child processes may use.
15280 Each list element should be of the form &"name=value"&.
15281
15282 See &<<SECTpipeenv>>& for the environment of &(pipe)& transports.
15283
15284 .option admin_groups main "string list&!!" unset
15285 .cindex "admin user"
15286 This option is expanded just once, at the start of Exim's processing. If the
15287 current group or any of the supplementary groups of an Exim caller is in this
15288 colon-separated list, the caller has admin privileges. If all your system
15289 programmers are in a specific group, for example, you can give them all Exim
15290 admin privileges by putting that group in &%admin_groups%&. However, this does
15291 not permit them to read Exim's spool files (whose group owner is the Exim gid).
15292 To permit this, you have to add individuals to the Exim group.
15293
15294 .option allow_domain_literals main boolean false
15295 .cindex "domain literal"
15296 If this option is set, the RFC 2822 domain literal format is permitted in
15297 email addresses. The option is not set by default, because the domain literal
15298 format is not normally required these days, and few people know about it. It
15299 has, however, been exploited by mail abusers.
15300
15301 Unfortunately, it seems that some DNS black list maintainers are using this
15302 format to report black listing to postmasters. If you want to accept messages
15303 addressed to your hosts by IP address, you need to set
15304 &%allow_domain_literals%& true, and also to add &`@[]`& to the list of local
15305 domains (defined in the named domain list &%local_domains%& in the default
15306 configuration). This &"magic string"& matches the domain literal form of all
15307 the local host's IP addresses.
15308
15309 .option allow_mx_to_ip main boolean false
15310 .cindex "MX record" "pointing to IP address"
15311 It appears that more and more DNS zone administrators are breaking the rules
15312 and putting domain names that look like IP addresses on the right hand side of
15313 MX records. Exim follows the rules and rejects this, giving an error message
15314 that explains the misconfiguration. However, some other MTAs support this
15315 practice, so to avoid &"Why can't Exim do this?"& complaints,
15316 &%allow_mx_to_ip%& exists, in order to enable this heinous activity. It is not
15317 recommended, except when you have no other choice.
15318
15319 .option allow_utf8_domains main boolean false
15320 .cindex "domain" "UTF-8 characters in"
15321 .cindex "UTF-8" "in domain name"
15322 Lots of discussion is going on about internationalized domain names. One
15323 camp is strongly in favour of just using UTF-8 characters, and it seems
15324 that at least two other MTAs permit this.
15325 This option allows Exim users to experiment if they wish.
15326
15327 If it is set true, Exim's domain parsing function allows valid
15328 UTF-8 multicharacters to appear in domain name components, in addition to
15329 letters, digits, and hyphens.
15330
15331 If Exim is built with internationalization support
15332 and the SMTPUTF8 ESMTP option is in use (see chapter &<<CHAPi18n>>&)
15333 this option can be left as default.
15334 Without that,
15335 if you want to look up such domain names in the DNS, you must also
15336 adjust the value of &%dns_check_names_pattern%& to match the extended form. A
15337 suitable setting is:
15338 .code
15339 dns_check_names_pattern = (?i)^(?>(?(1)\.|())[a-z0-9\xc0-\xff]\
15340   (?>[-a-z0-9\x80-\xff]*[a-z0-9\x80-\xbf])?)+$
15341 .endd
15342 Alternatively, you can just disable this feature by setting
15343 .code
15344 dns_check_names_pattern =
15345 .endd
15346 That is, set the option to an empty string so that no check is done.
15347
15348
15349 .option auth_advertise_hosts main "host list&!!" *
15350 .cindex "authentication" "advertising"
15351 .cindex "AUTH" "advertising"
15352 .cindex "ESMTP extensions" AUTH
15353 If any server authentication mechanisms are configured, Exim advertises them in
15354 response to an EHLO command only if the calling host matches this list.
15355 Otherwise, Exim does not advertise AUTH.
15356 Exim does not accept AUTH commands from clients to which it has not
15357 advertised the availability of AUTH. The advertising of individual
15358 authentication mechanisms can be controlled by the use of the
15359 &%server_advertise_condition%& generic authenticator option on the individual
15360 authenticators. See chapter &<<CHAPSMTPAUTH>>& for further details.
15361
15362 Certain mail clients (for example, Netscape) require the user to provide a name
15363 and password for authentication if AUTH is advertised, even though it may
15364 not be needed (the host may accept messages from hosts on its local LAN without
15365 authentication, for example). The &%auth_advertise_hosts%& option can be used
15366 to make these clients more friendly by excluding them from the set of hosts to
15367 which Exim advertises AUTH.
15368
15369 .cindex "AUTH" "advertising when encrypted"
15370 If you want to advertise the availability of AUTH only when the connection
15371 is encrypted using TLS, you can make use of the fact that the value of this
15372 option is expanded, with a setting like this:
15373 .code
15374 auth_advertise_hosts = ${if eq{$tls_in_cipher}{}{}{*}}
15375 .endd
15376 .vindex "&$tls_in_cipher$&"
15377 If &$tls_in_cipher$& is empty, the session is not encrypted, and the result of
15378 the expansion is empty, thus matching no hosts. Otherwise, the result of the
15379 expansion is *, which matches all hosts.
15380
15381
15382 .option auto_thaw main time 0s
15383 .cindex "thawing messages"
15384 .cindex "unfreezing messages"
15385 If this option is set to a time greater than zero, a queue runner will try a
15386 new delivery attempt on any frozen message, other than a bounce message, if
15387 this much time has passed since it was frozen. This may result in the message
15388 being re-frozen if nothing has changed since the last attempt. It is a way of
15389 saying &"keep on trying, even though there are big problems"&.
15390
15391 &*Note*&: This is an old option, which predates &%timeout_frozen_after%& and
15392 &%ignore_bounce_errors_after%&. It is retained for compatibility, but it is not
15393 thought to be very useful any more, and its use should probably be avoided.
15394
15395
15396 .option av_scanner main string "see below"
15397 This option is available if Exim is built with the content-scanning extension.
15398 It specifies which anti-virus scanner to use. The default value is:
15399 .code
15400 sophie:/var/run/sophie
15401 .endd
15402 If the value of &%av_scanner%& starts with a dollar character, it is expanded
15403 before use. See section &<<SECTscanvirus>>& for further details.
15404
15405
15406 .option bi_command main string unset
15407 .oindex "&%-bi%&"
15408 This option supplies the name of a command that is run when Exim is called with
15409 the &%-bi%& option (see chapter &<<CHAPcommandline>>&). The string value is
15410 just the command name, it is not a complete command line. If an argument is
15411 required, it must come from the &%-oA%& command line option.
15412
15413
15414 .option bounce_message_file main string&!! unset
15415 .cindex "bounce message" "customizing"
15416 .cindex "customizing" "bounce message"
15417 This option defines a template file containing paragraphs of text to be used
15418 for constructing bounce messages.  Details of the file's contents are given in
15419 chapter &<<CHAPemsgcust>>&.
15420 .cindex bounce_message_file "tainted data"
15421 The option is expanded to give the file path, which must be
15422 absolute and untainted.
15423 See also &%warn_message_file%&.
15424
15425
15426 .option bounce_message_text main string unset
15427 When this option is set, its contents are included in the default bounce
15428 message immediately after &"This message was created automatically by mail
15429 delivery software."& It is not used if &%bounce_message_file%& is set.
15430
15431 .option bounce_return_body main boolean true
15432 .cindex "bounce message" "including body"
15433 This option controls whether the body of an incoming message is included in a
15434 bounce message when &%bounce_return_message%& is true. The default setting
15435 causes the entire message, both header and body, to be returned (subject to the
15436 value of &%bounce_return_size_limit%&). If this option is false, only the
15437 message header is included. In the case of a non-SMTP message containing an
15438 error that is detected during reception, only those header lines preceding the
15439 point at which the error was detected are returned.
15440 .cindex "bounce message" "including original"
15441
15442 .option bounce_return_linesize_limit main integer 998
15443 .cindex "size" "of bounce lines, limit"
15444 .cindex "bounce message" "line length limit"
15445 .cindex "limit" "bounce message line length"
15446 This option sets a limit in bytes on the line length of messages
15447 that are returned to senders due to delivery problems,
15448 when &%bounce_return_message%& is true.
15449 The default value corresponds to RFC limits.
15450 If the message being returned has lines longer than this value it is
15451 treated as if the &%bounce_return_size_limit%& (below) restriction was exceeded.
15452
15453 The option also applies to bounces returned when an error is detected
15454 during reception of a message.
15455 In this case lines from the original are truncated.
15456
15457 The option does not apply to messages generated by an &(autoreply)& transport.
15458
15459
15460 .option bounce_return_message main boolean true
15461 If this option is set false, none of the original message is included in
15462 bounce messages generated by Exim. See also &%bounce_return_size_limit%& and
15463 &%bounce_return_body%&.
15464
15465
15466 .option bounce_return_size_limit main integer 100K
15467 .cindex "size" "of bounce, limit"
15468 .cindex "bounce message" "size limit"
15469 .cindex "limit" "bounce message size"
15470 This option sets a limit in bytes on the size of messages that are returned to
15471 senders as part of bounce messages when &%bounce_return_message%& is true. The
15472 limit should be less than the value of the global &%message_size_limit%& and of
15473 any &%message_size_limit%& settings on transports, to allow for the bounce text
15474 that Exim generates. If this option is set to zero there is no limit.
15475
15476 When the body of any message that is to be included in a bounce message is
15477 greater than the limit, it is truncated, and a comment pointing this out is
15478 added at the top. The actual cutoff may be greater than the value given, owing
15479 to the use of buffering for transferring the message in chunks (typically 8K in
15480 size). The idea is to save bandwidth on those undeliverable 15-megabyte
15481 messages.
15482
15483 .option bounce_sender_authentication main string unset
15484 .cindex "bounce message" "sender authentication"
15485 .cindex "authentication" "bounce message"
15486 .cindex "AUTH" "on bounce message"
15487 This option provides an authenticated sender address that is sent with any
15488 bounce messages generated by Exim that are sent over an authenticated SMTP
15489 connection. A typical setting might be:
15490 .code
15491 bounce_sender_authentication = mailer-daemon@my.domain.example
15492 .endd
15493 which would cause bounce messages to be sent using the SMTP command:
15494 .code
15495 MAIL FROM:<> AUTH=mailer-daemon@my.domain.example
15496 .endd
15497 The value of &%bounce_sender_authentication%& must always be a complete email
15498 address.
15499
15500 .option callout_domain_negative_expire main time 3h
15501 .cindex "caching" "callout timeouts"
15502 .cindex "callout" "caching timeouts"
15503 This option specifies the expiry time for negative callout cache data for a
15504 domain. See section &<<SECTcallver>>& for details of callout verification, and
15505 section &<<SECTcallvercache>>& for details of the caching.
15506
15507
15508 .option callout_domain_positive_expire main time 7d
15509 This option specifies the expiry time for positive callout cache data for a
15510 domain. See section &<<SECTcallver>>& for details of callout verification, and
15511 section &<<SECTcallvercache>>& for details of the caching.
15512
15513
15514 .option callout_negative_expire main time 2h
15515 This option specifies the expiry time for negative callout cache data for an
15516 address. See section &<<SECTcallver>>& for details of callout verification, and
15517 section &<<SECTcallvercache>>& for details of the caching.
15518
15519
15520 .option callout_positive_expire main time 24h
15521 This option specifies the expiry time for positive callout cache data for an
15522 address. See section &<<SECTcallver>>& for details of callout verification, and
15523 section &<<SECTcallvercache>>& for details of the caching.
15524
15525
15526 .option callout_random_local_part main string&!! "see below"
15527 This option defines the &"random"& local part that can be used as part of
15528 callout verification. The default value is
15529 .code
15530 $primary_hostname-$tod_epoch-testing
15531 .endd
15532 See section &<<CALLaddparcall>>& for details of how this value is used.
15533
15534
15535 .options check_log_inodes main integer 100 &&&
15536          check_log_space main integer 10M
15537 See &%check_spool_space%& below.
15538
15539 .oindex "&%check_rfc2047_length%&"
15540 .cindex "RFC 2047" "disabling length check"
15541 .option check_rfc2047_length main boolean true
15542 RFC 2047 defines a way of encoding non-ASCII characters in headers using a
15543 system of &"encoded words"&. The RFC specifies a maximum length for an encoded
15544 word; strings to be encoded that exceed this length are supposed to use
15545 multiple encoded words. By default, Exim does not recognize encoded words that
15546 exceed the maximum length. However, it seems that some software, in violation
15547 of the RFC, generates overlong encoded words. If &%check_rfc2047_length%& is
15548 set false, Exim recognizes encoded words of any length.
15549
15550
15551 .options check_spool_inodes main integer 100 &&&
15552          check_spool_space main integer 10M
15553 .cindex "checking disk space"
15554 .cindex "disk space, checking"
15555 .cindex "spool directory" "checking space"
15556 The four &%check_...%& options allow for checking of disk resources before a
15557 message is accepted.
15558
15559 .vindex "&$log_inodes$&"
15560 .vindex "&$log_space$&"
15561 .vindex "&$spool_inodes$&"
15562 .vindex "&$spool_space$&"
15563 When any of these options are nonzero, they apply to all incoming messages. If you
15564 want to apply different checks to different kinds of message, you can do so by
15565 testing the variables &$log_inodes$&, &$log_space$&, &$spool_inodes$&, and
15566 &$spool_space$& in an ACL with appropriate additional conditions.
15567
15568
15569 &%check_spool_space%& and &%check_spool_inodes%& check the spool partition if
15570 either value is greater than zero, for example:
15571 .code
15572 check_spool_space = 100M
15573 check_spool_inodes = 100
15574 .endd
15575 The spool partition is the one that contains the directory defined by
15576 SPOOL_DIRECTORY in &_Local/Makefile_&. It is used for holding messages in
15577 transit.
15578
15579 &%check_log_space%& and &%check_log_inodes%&  check the partition in which log
15580 files are written if either is greater than zero. These should be set only if
15581 &%log_file_path%& and &%spool_directory%& refer to different partitions.
15582
15583 If there is less space or fewer inodes than requested, Exim refuses to accept
15584 incoming mail. In the case of SMTP input this is done by giving a 452 temporary
15585 error response to the MAIL command. If ESMTP is in use and there was a
15586 SIZE parameter on the MAIL command, its value is added to the
15587 &%check_spool_space%& value, and the check is performed even if
15588 &%check_spool_space%& is zero, unless &%no_smtp_check_spool_space%& is set.
15589
15590 The values for &%check_spool_space%& and &%check_log_space%& are held as a
15591 number of kilobytes (though specified in bytes).
15592 If a non-multiple of 1024 is specified, it is rounded up.
15593
15594 For non-SMTP input and for batched SMTP input, the test is done at start-up; on
15595 failure a message is written to stderr and Exim exits with a non-zero code, as
15596 it obviously cannot send an error message of any kind.
15597
15598 There is a slight performance penalty for these checks.
15599 Versions of Exim preceding 4.88 had these disabled by default;
15600 high-rate installations confident they will never run out of resources
15601 may wish to deliberately disable them.
15602
15603 .option chunking_advertise_hosts main "host list&!!" *
15604 .cindex CHUNKING advertisement
15605 .cindex "RFC 3030" "CHUNKING"
15606 .cindex "ESMTP extensions" CHUNKING
15607 The CHUNKING extension (RFC3030) will be advertised in the EHLO message to
15608 these hosts.
15609 Hosts may use the BDAT command as an alternate to DATA.
15610
15611 .option commandline_checks_require_admin main boolean &`false`&
15612 .cindex "restricting access to features"
15613 This option restricts various basic checking features to require an
15614 administrative user.
15615 This affects most of the &%-b*%& options, such as &%-be%&.
15616
15617 .option debug_store main boolean &`false`&
15618 .cindex debugging "memory corruption"
15619 .cindex memory debugging
15620 This option, when true, enables extra checking in Exim's internal memory
15621 management.  For use when a memory corruption issue is being investigated,
15622 it should normally be left as default.
15623
15624 .option daemon_smtp_ports main string &`smtp`&
15625 .cindex "port" "for daemon"
15626 .cindex "TCP/IP" "setting listening ports"
15627 This option specifies one or more default SMTP ports on which the Exim daemon
15628 listens. See chapter &<<CHAPinterfaces>>& for details of how it is used. For
15629 backward compatibility, &%daemon_smtp_port%& (singular) is a synonym.
15630
15631 .options daemon_startup_retries main integer 9 &&&
15632          daemon_startup_sleep main time 30s
15633 .cindex "daemon startup, retrying"
15634 These options control the retrying done by
15635 the daemon at startup when it cannot immediately bind a listening socket
15636 (typically because the socket is already in use): &%daemon_startup_retries%&
15637 defines the number of retries after the first failure, and
15638 &%daemon_startup_sleep%& defines the length of time to wait between retries.
15639
15640 .option delay_warning main "time list" 24h
15641 .cindex "warning of delay"
15642 .cindex "delay warning, specifying"
15643 .cindex "queue" "delay warning"
15644 When a message is delayed, Exim sends a warning message to the sender at
15645 intervals specified by this option. The data is a colon-separated list of times
15646 after which to send warning messages. If the value of the option is an empty
15647 string or a zero time, no warnings are sent. Up to 10 times may be given. If a
15648 message has been in the queue for longer than the last time, the last interval
15649 between the times is used to compute subsequent warning times. For example,
15650 with
15651 .code
15652 delay_warning = 4h:8h:24h
15653 .endd
15654 the first message is sent after 4 hours, the second after 8 hours, and
15655 the third one after 24 hours. After that, messages are sent every 16 hours,
15656 because that is the interval between the last two times on the list. If you set
15657 just one time, it specifies the repeat interval. For example, with:
15658 .code
15659 delay_warning = 6h
15660 .endd
15661 messages are repeated every six hours. To stop warnings after a given time, set
15662 a very large time at the end of the list. For example:
15663 .code
15664 delay_warning = 2h:12h:99d
15665 .endd
15666 Note that the option is only evaluated at the time a delivery attempt fails,
15667 which depends on retry and queue-runner configuration.
15668 Typically retries will be configured more frequently than warning messages.
15669
15670 .option delay_warning_condition main string&!! "see below"
15671 .vindex "&$domain$&"
15672 The string is expanded at the time a warning message might be sent. If all the
15673 deferred addresses have the same domain, it is set in &$domain$& during the
15674 expansion. Otherwise &$domain$& is empty. If the result of the expansion is a
15675 forced failure, an empty string, or a string matching any of &"0"&, &"no"& or
15676 &"false"& (the comparison being done caselessly) then the warning message is
15677 not sent. The default is:
15678 .code
15679 delay_warning_condition = ${if or {\
15680   { !eq{$h_list-id:$h_list-post:$h_list-subscribe:}{} }\
15681   { match{$h_precedence:}{(?i)bulk|list|junk} }\
15682   { match{$h_auto-submitted:}{(?i)auto-generated|auto-replied} }\
15683   } {no}{yes}}
15684 .endd
15685 This suppresses the sending of warnings for messages that contain &'List-ID:'&,
15686 &'List-Post:'&, or &'List-Subscribe:'& headers, or have &"bulk"&, &"list"& or
15687 &"junk"& in a &'Precedence:'& header, or have &"auto-generated"& or
15688 &"auto-replied"& in an &'Auto-Submitted:'& header.
15689
15690 .option deliver_drop_privilege main boolean false
15691 .cindex "unprivileged delivery"
15692 .cindex "delivery" "unprivileged"
15693 If this option is set true, Exim drops its root privilege at the start of a
15694 delivery process, and runs as the Exim user throughout. This severely restricts
15695 the kinds of local delivery that are possible, but is viable in certain types
15696 of configuration. There is a discussion about the use of root privilege in
15697 chapter &<<CHAPsecurity>>&.
15698
15699 .option deliver_queue_load_max main fixed-point unset
15700 .cindex "load average"
15701 .cindex "queue runner" "abandoning"
15702 When this option is set, a queue run is abandoned if the system load average
15703 becomes greater than the value of the option. The option has no effect on
15704 ancient operating systems on which Exim cannot determine the load average.
15705 See also &%queue_only_load%& and &%smtp_load_reserve%&.
15706
15707
15708 .option delivery_date_remove main boolean true
15709 .cindex "&'Delivery-date:'& header line"
15710 Exim's transports have an option for adding a &'Delivery-date:'& header to a
15711 message when it is delivered, in exactly the same way as &'Return-path:'& is
15712 handled. &'Delivery-date:'& records the actual time of delivery. Such headers
15713 should not be present in incoming messages, and this option causes them to be
15714 removed at the time the message is received, to avoid any problems that might
15715 occur when a delivered message is subsequently sent on to some other recipient.
15716
15717 .option disable_fsync main boolean false
15718 .cindex "&[fsync()]&, disabling"
15719 This option is available only if Exim was built with the compile-time option
15720 ENABLE_DISABLE_FSYNC. When this is not set, a reference to &%disable_fsync%& in
15721 a runtime configuration generates an &"unknown option"& error. You should not
15722 build Exim with ENABLE_DISABLE_FSYNC or set &%disable_fsync%& unless you
15723 really, really, really understand what you are doing. &'No pre-compiled
15724 distributions of Exim should ever make this option available.'&
15725
15726 When &%disable_fsync%& is set true, Exim no longer calls &[fsync()]& to force
15727 updated files' data to be written to disc before continuing. Unexpected events
15728 such as crashes and power outages may cause data to be lost or scrambled.
15729 Here be Dragons. &*Beware.*&
15730
15731
15732 .option disable_ipv6 main boolean false
15733 .cindex "IPv6" "disabling"
15734 If this option is set true, even if the Exim binary has IPv6 support, no IPv6
15735 activities take place. AAAA records are never looked up, and any IPv6 addresses
15736 that are listed in &%local_interfaces%&, data for the &%manualroute%& router,
15737 etc. are ignored. If IP literals are enabled, the &(ipliteral)& router declines
15738 to handle IPv6 literal addresses.
15739
15740
15741 .option dkim_verify_hashes main "string list" "sha256 : sha512"
15742 .cindex DKIM "selecting signature algorithms"
15743 This option gives a list of hash types which are acceptable in signatures,
15744 and an order of processing.
15745 Signatures with algorithms not in the list will be ignored.
15746
15747 Acceptable values include:
15748 .code
15749 sha1
15750 sha256
15751 sha512
15752 .endd
15753
15754 Note that the acceptance of sha1 violates RFC 8301.
15755
15756 .option dkim_verify_keytypes main "string list" "ed25519 : rsa"
15757 This option gives a list of key types which are acceptable in signatures,
15758 and an order of processing.
15759 Signatures with algorithms not in the list will be ignored.
15760
15761
15762 .option dkim_verify_min_keysizes main "string list" "rsa=1024 ed25519=250"
15763 This option gives a list of key sizes which are acceptable in signatures.
15764 The list is keyed by the algorithm type for the key; the values are in bits.
15765 Signatures with keys smaller than given by this option will fail verification.
15766
15767 The default enforces the RFC 8301 minimum key size for RSA signatures.
15768
15769 .option dkim_verify_minimal main boolean false
15770 If set to true, verification of signatures will terminate after the
15771 first success.
15772
15773 .option dkim_verify_signers main "domain list&!!" $dkim_signers
15774 .cindex DKIM "controlling calls to the ACL"
15775 This option gives a list of DKIM domains for which the DKIM ACL is run.
15776 It is expanded after the message is received; by default it runs
15777 the ACL once for each signature in the message.
15778 See section &<<SECDKIMVFY>>&.
15779
15780
15781 .option dmarc_forensic_sender main string&!! unset &&&
15782         dmarc_history_file main string unset &&&
15783         dmarc_tld_file main string unset
15784 .cindex DMARC "main section options"
15785 These options control DMARC processing.
15786 See section &<<SECDMARC>>& for details.
15787
15788
15789 .option dns_again_means_nonexist main "domain list&!!" unset
15790 .cindex "DNS" "&""try again""& response; overriding"
15791 DNS lookups give a &"try again"& response for the DNS errors
15792 &"non-authoritative host not found"& and &"SERVERFAIL"&. This can cause Exim to
15793 keep trying to deliver a message, or to give repeated temporary errors to
15794 incoming mail. Sometimes the effect is caused by a badly set up name server and
15795 may persist for a long time. If a domain which exhibits this problem matches
15796 anything in &%dns_again_means_nonexist%&, it is treated as if it did not exist.
15797 This option should be used with care. You can make it apply to reverse lookups
15798 by a setting such as this:
15799 .code
15800 dns_again_means_nonexist = *.in-addr.arpa
15801 .endd
15802 This option applies to all DNS lookups that Exim does,
15803 except for TLSA lookups (where knowing about such failures
15804 is security-relevant).
15805 It also applies when the
15806 &[gethostbyname()]& or &[getipnodebyname()]& functions give temporary errors,
15807 since these are most likely to be caused by DNS lookup problems. The
15808 &(dnslookup)& router has some options of its own for controlling what happens
15809 when lookups for MX or SRV records give temporary errors. These more specific
15810 options are applied after this global option.
15811
15812 .option dns_check_names_pattern main string "see below"
15813 .cindex "DNS" "pre-check of name syntax"
15814 When this option is set to a non-empty string, it causes Exim to check domain
15815 names for characters that are not allowed in host names before handing them to
15816 the DNS resolver, because some resolvers give temporary errors for names that
15817 contain unusual characters. If a domain name contains any unwanted characters,
15818 a &"not found"& result is forced, and the resolver is not called. The check is
15819 done by matching the domain name against a regular expression, which is the
15820 value of this option. The default pattern is
15821 .code
15822 dns_check_names_pattern = \
15823   (?i)^(?>(?(1)\.|())[^\W_](?>[a-z0-9/-]*[^\W_])?)+$
15824 .endd
15825 which permits only letters, digits, slashes, and hyphens in components, but
15826 they must start and end with a letter or digit. Slashes are not, in fact,
15827 permitted in host names, but they are found in certain NS records (which can be
15828 accessed in Exim by using a &%dnsdb%& lookup). If you set
15829 &%allow_utf8_domains%&, you must modify this pattern, or set the option to an
15830 empty string.
15831
15832 .option dns_csa_search_limit main integer 5
15833 This option controls the depth of parental searching for CSA SRV records in the
15834 DNS, as described in more detail in section &<<SECTverifyCSA>>&.
15835
15836 .option dns_csa_use_reverse main boolean true
15837 This option controls whether or not an IP address, given as a CSA domain, is
15838 reversed and looked up in the reverse DNS, as described in more detail in
15839 section &<<SECTverifyCSA>>&.
15840
15841 .option dns_cname_loops main integer 1
15842 .cindex DNS "CNAME following"
15843 This option controls the following of CNAME chains, needed if the resolver does
15844 not do it internally.
15845 As of 2018 most should, and the default can be left.
15846 If you have an ancient one, a value of 10 is likely needed.
15847
15848 The default value of one CNAME-follow is needed
15849 thanks to the observed return for an MX request,
15850 given no MX presence but a CNAME to an A, of the CNAME.
15851
15852
15853 .option dns_dnssec_ok main integer -1
15854 .cindex "DNS" "resolver options"
15855 .cindex "DNS" "DNSSEC"
15856 If this option is set to a non-negative number then Exim will initialise the
15857 DNS resolver library to either use or not use DNSSEC, overriding the system
15858 default. A value of 0 coerces DNSSEC off, a value of 1 coerces DNSSEC on.
15859
15860 If the resolver library does not support DNSSEC then this option has no effect.
15861
15862 On Linux with glibc 2.31 or newer this is insufficient, the resolver library
15863 will default to stripping out a successful validation status.
15864 This will break a previously working Exim installation.
15865 Provided that you do trust the resolver (ie, is on localhost) you can tell
15866 glibc to pass through any successful validation with a new option in
15867 &_/etc/resolv.conf_&:
15868 .code
15869 options trust-ad
15870 .endd
15871
15872
15873 .option dns_ipv4_lookup main "domain list&!!" unset
15874 .cindex "IPv6" "DNS lookup for AAAA records"
15875 .cindex "DNS" "IPv6 lookup for AAAA records"
15876 .cindex DNS "IPv6 disabling"
15877 When Exim is compiled with IPv6 support and &%disable_ipv6%& is not set, it
15878 looks for IPv6 address records (AAAA records) as well as IPv4 address records
15879 (A records) when trying to find IP addresses for hosts, unless the host's
15880 domain matches this list.
15881
15882 This is a fudge to help with name servers that give big delays or otherwise do
15883 not work for the AAAA record type. In due course, when the world's name
15884 servers have all been upgraded, there should be no need for this option.
15885 Note that all lookups, including those done for verification, are affected;
15886 this will result in verify failure for IPv6 connections or ones using names
15887 only valid for IPv6 addresses.
15888
15889
15890 .option dns_retrans main time 0s
15891 .cindex "DNS" "resolver options"
15892 .cindex timeout "dns lookup"
15893 .cindex "DNS" timeout
15894 The options &%dns_retrans%& and &%dns_retry%& can be used to set the
15895 retransmission and retry parameters for DNS lookups. Values of zero (the
15896 defaults) leave the system default settings unchanged. The first value is the
15897 time between retries, and the second is the number of retries. It isn't
15898 totally clear exactly how these settings affect the total time a DNS lookup may
15899 take. I haven't found any documentation about timeouts on DNS lookups; these
15900 parameter values are available in the external resolver interface structure,
15901 but nowhere does it seem to describe how they are used or what you might want
15902 to set in them.
15903 See also the &%slow_lookup_log%& option.
15904
15905
15906 .option dns_retry main integer 0
15907 See &%dns_retrans%& above.
15908
15909
15910 .option dns_trust_aa main "domain list&!!" unset
15911 .cindex "DNS" "resolver options"
15912 .cindex "DNS" "DNSSEC"
15913 If this option is set then lookup results marked with the AA bit
15914 (Authoritative Answer) are trusted the same way as if they were
15915 DNSSEC-verified. The authority section's name of the answer must
15916 match with this expanded domain list.
15917
15918 Use this option only if you talk directly to a resolver that is
15919 authoritative for some zones and does not set the AD (Authentic Data)
15920 bit in the answer. Some DNS servers may have an configuration option to
15921 mark the answers from their own zones as verified (they set the AD bit).
15922 Others do not have this option. It is considered as poor practice using
15923 a resolver that is an authoritative server for some zones.
15924
15925 Use this option only if you really have to (e.g. if you want
15926 to use DANE for remote delivery to a server that is listed in the DNS
15927 zones that your resolver is authoritative for).
15928
15929 If the DNS answer packet has the AA bit set and contains resource record
15930 in the answer section, the name of the first NS record appearing in the
15931 authority section is compared against the list. If the answer packet is
15932 authoritative but the answer section is empty, the name of the first SOA
15933 record in the authoritative section is used instead.
15934
15935 .cindex "DNS" "resolver options"
15936 .option dns_use_edns0 main integer -1
15937 .cindex "DNS" "resolver options"
15938 .cindex "DNS" "EDNS0"
15939 .cindex "DNS" "OpenBSD
15940 If this option is set to a non-negative number then Exim will initialise the
15941 DNS resolver library to either use or not use EDNS0 extensions, overriding
15942 the system default. A value of 0 coerces EDNS0 off, a value of 1 coerces EDNS0
15943 on.
15944
15945 If the resolver library does not support EDNS0 then this option has no effect.
15946
15947 OpenBSD's asr resolver routines are known to ignore the EDNS0 option; this
15948 means that DNSSEC will not work with Exim on that platform either, unless Exim
15949 is linked against an alternative DNS client library.
15950
15951
15952 .option drop_cr main boolean false
15953 This is an obsolete option that is now a no-op. It used to affect the way Exim
15954 handled CR and LF characters in incoming messages. What happens now is
15955 described in section &<<SECTlineendings>>&.
15956
15957 .option dsn_advertise_hosts main "host list&!!" unset
15958 .cindex "bounce messages" "success"
15959 .cindex "DSN" "success"
15960 .cindex "Delivery Status Notification" "success"
15961 .cindex "ESMTP extensions" DSN
15962 DSN extensions (RFC3461) will be advertised in the EHLO message to,
15963 and accepted from, these hosts.
15964 Hosts may use the NOTIFY and ORCPT options on RCPT TO commands,
15965 and RET and ENVID options on MAIL FROM commands.
15966 A NOTIFY=SUCCESS option requests success-DSN messages.
15967 A NOTIFY= option with no argument requests that no delay or failure DSNs
15968 are sent.
15969 &*Note*&: Supplying success-DSN messages has been criticised
15970 on privacy grounds; it can leak details of internal forwarding.
15971
15972 .option dsn_from main "string&!!" "see below"
15973 .cindex "&'From:'& header line" "in bounces"
15974 .cindex "bounce messages" "&'From:'& line, specifying"
15975 This option can be used to vary the contents of &'From:'& header lines in
15976 bounces and other automatically generated messages (&"Delivery Status
15977 Notifications"& &-- hence the name of the option). The default setting is:
15978 .code
15979 dsn_from = Mail Delivery System <Mailer-Daemon@$qualify_domain>
15980 .endd
15981 The value is expanded every time it is needed. If the expansion fails, a
15982 panic is logged, and the default value is used.
15983
15984 .option envelope_to_remove main boolean true
15985 .cindex "&'Envelope-to:'& header line"
15986 Exim's transports have an option for adding an &'Envelope-to:'& header to a
15987 message when it is delivered, in exactly the same way as &'Return-path:'& is
15988 handled. &'Envelope-to:'& records the original recipient address from the
15989 message's envelope that caused the delivery to happen. Such headers should not
15990 be present in incoming messages, and this option causes them to be removed at
15991 the time the message is received, to avoid any problems that might occur when a
15992 delivered message is subsequently sent on to some other recipient.
15993
15994
15995 .option errors_copy main "string list&!!" unset
15996 .cindex "bounce message" "copy to other address"
15997 .cindex "copy of bounce message"
15998 Setting this option causes Exim to send bcc copies of bounce messages that it
15999 generates to other addresses. &*Note*&: This does not apply to bounce messages
16000 coming from elsewhere. The value of the option is a colon-separated list of
16001 items. Each item consists of a pattern, terminated by white space, followed by
16002 a comma-separated list of email addresses. If a pattern contains spaces, it
16003 must be enclosed in double quotes.
16004
16005 Each pattern is processed in the same way as a single item in an address list
16006 (see section &<<SECTaddresslist>>&). When a pattern matches the recipient of
16007 the bounce message, the message is copied to the addresses on the list. The
16008 items are scanned in order, and once a matching one is found, no further items
16009 are examined. For example:
16010 .code
16011 errors_copy = spqr@mydomain   postmaster@mydomain.example :\
16012               rqps@mydomain   hostmaster@mydomain.example,\
16013                               postmaster@mydomain.example
16014 .endd
16015 .vindex "&$domain$&"
16016 .vindex "&$local_part$&"
16017 The address list is expanded before use. The expansion variables &$local_part$&
16018 and &$domain$& are set from the original recipient of the error message, and if
16019 there was any wildcard matching in the pattern, the expansion
16020 .cindex "numerical variables (&$1$& &$2$& etc)" "in &%errors_copy%&"
16021 variables &$0$&, &$1$&, etc. are set in the normal way.
16022
16023
16024 .option errors_reply_to main string unset
16025 .cindex "bounce message" "&'Reply-to:'& in"
16026 By default, Exim's bounce and delivery warning messages contain the header line
16027 .display
16028 &`From: Mail Delivery System <Mailer-Daemon@`&&'qualify-domain'&&`>`&
16029 .endd
16030 .oindex &%quota_warn_message%&
16031 where &'qualify-domain'& is the value of the &%qualify_domain%& option.
16032 A warning message that is generated by the &%quota_warn_message%& option in an
16033 &(appendfile)& transport may contain its own &'From:'& header line that
16034 overrides the default.
16035
16036 Experience shows that people reply to bounce messages. If the
16037 &%errors_reply_to%& option is set, a &'Reply-To:'& header is added to bounce
16038 and warning messages. For example:
16039 .code
16040 errors_reply_to = postmaster@my.domain.example
16041 .endd
16042 The value of the option is not expanded. It must specify a valid RFC 2822
16043 address. However, if a warning message that is generated by the
16044 &%quota_warn_message%& option in an &(appendfile)& transport contain its
16045 own &'Reply-To:'& header line, the value of the &%errors_reply_to%& option is
16046 not used.
16047
16048
16049 .option event_action main string&!! unset
16050 .cindex events
16051 This option declares a string to be expanded for Exim's events mechanism.
16052 For details see chapter &<<CHAPevents>>&.
16053
16054
16055 .option exim_group main string "compile-time configured"
16056 .cindex "gid (group id)" "Exim's own"
16057 .cindex "Exim group"
16058 This option changes the gid under which Exim runs when it gives up root
16059 privilege. The default value is compiled into the binary. The value of this
16060 option is used only when &%exim_user%& is also set. Unless it consists entirely
16061 of digits, the string is looked up using &[getgrnam()]&, and failure causes a
16062 configuration error. See chapter &<<CHAPsecurity>>& for a discussion of
16063 security issues.
16064
16065
16066 .option exim_path main string "see below"
16067 .cindex "Exim binary, path name"
16068 This option specifies the path name of the Exim binary, which is used when Exim
16069 needs to re-exec itself. The default is set up to point to the file &'exim'& in
16070 the directory configured at compile time by the BIN_DIRECTORY setting. It
16071 is necessary to change &%exim_path%& if, exceptionally, Exim is run from some
16072 other place.
16073 &*Warning*&: Do not use a macro to define the value of this option, because
16074 you will break those Exim utilities that scan the configuration file to find
16075 where the binary is. (They then use the &%-bP%& option to extract option
16076 settings such as the value of &%spool_directory%&.)
16077
16078
16079 .option exim_user main string "compile-time configured"
16080 .cindex "uid (user id)" "Exim's own"
16081 .cindex "Exim user"
16082 This option changes the uid under which Exim runs when it gives up root
16083 privilege. The default value is compiled into the binary. Ownership of the run
16084 time configuration file and the use of the &%-C%& and &%-D%& command line
16085 options is checked against the values in the binary, not what is set here.
16086
16087 Unless it consists entirely of digits, the string is looked up using
16088 &[getpwnam()]&, and failure causes a configuration error. If &%exim_group%& is
16089 not also supplied, the gid is taken from the result of &[getpwnam()]& if it is
16090 used. See chapter &<<CHAPsecurity>>& for a discussion of security issues.
16091
16092
16093 .option exim_version main string "current version"
16094 .cindex "Exim version"
16095 .cindex customizing "version number"
16096 .cindex "version number of Exim" override
16097 This option overrides the &$version_number$&/&$exim_version$& that Exim reports in
16098 various places.  Use with care; this may fool stupid security scanners.
16099
16100
16101 .option extra_local_interfaces main "string list" unset
16102 This option defines network interfaces that are to be considered local when
16103 routing, but which are not used for listening by the daemon. See section
16104 &<<SECTreclocipadd>>& for details.
16105
16106
16107 . Allow this long option name to split; give it unsplit as a fifth argument
16108 . for the automatic .oindex that is generated by .option.
16109
16110 .option "extract_addresses_remove_arguments" main boolean true &&&
16111          extract_addresses_remove_arguments
16112 .oindex "&%-t%&"
16113 .cindex "command line" "addresses with &%-t%&"
16114 .cindex "Sendmail compatibility" "&%-t%& option"
16115 According to some Sendmail documentation (Sun, IRIX, HP-UX), if any addresses
16116 are present on the command line when the &%-t%& option is used to build an
16117 envelope from a message's &'To:'&, &'Cc:'& and &'Bcc:'& headers, the command
16118 line addresses are removed from the recipients list. This is also how Smail
16119 behaves. However, other Sendmail documentation (the O'Reilly book) states that
16120 command line addresses are added to those obtained from the header lines. When
16121 &%extract_addresses_remove_arguments%& is true (the default), Exim subtracts
16122 argument headers. If it is set false, Exim adds rather than removes argument
16123 addresses.
16124
16125
16126 .option finduser_retries main integer 0
16127 .cindex "NIS, retrying user lookups"
16128 On systems running NIS or other schemes in which user and group information is
16129 distributed from a remote system, there can be times when &[getpwnam()]& and
16130 related functions fail, even when given valid data, because things time out.
16131 Unfortunately these failures cannot be distinguished from genuine &"not found"&
16132 errors. If &%finduser_retries%& is set greater than zero, Exim will try that
16133 many extra times to find a user or a group, waiting for one second between
16134 retries.
16135
16136 .cindex "&_/etc/passwd_&" "multiple reading of"
16137 You should not set this option greater than zero if your user information is in
16138 a traditional &_/etc/passwd_& file, because it will cause Exim needlessly to
16139 search the file multiple times for non-existent users, and also cause delay.
16140
16141
16142
16143 .option freeze_tell main "string list, comma separated" unset
16144 .cindex "freezing messages" "sending a message when freezing"
16145 .cindex "frozen messages" "sending a message when freezing"
16146 On encountering certain errors, or when configured to do so in a system filter,
16147 ACL, or special router, Exim freezes a message. This means that no further
16148 delivery attempts take place until an administrator thaws the message, or the
16149 &%auto_thaw%&, &%ignore_bounce_errors_after%&, or &%timeout_frozen_after%&
16150 feature cause it to be processed. If &%freeze_tell%& is set, Exim generates a
16151 warning message whenever it freezes something, unless the message it is
16152 freezing is a locally-generated bounce message. (Without this exception there
16153 is the possibility of looping.) The warning message is sent to the addresses
16154 supplied as the comma-separated value of this option. If several of the
16155 message's addresses cause freezing, only a single message is sent. If the
16156 freezing was automatic, the reason(s) for freezing can be found in the message
16157 log. If you configure freezing in a filter or ACL, you must arrange for any
16158 logging that you require.
16159
16160
16161 .options gecos_name main string&!! unset &&&
16162          gecos_pattern main string unset
16163 .cindex "HP-UX"
16164 .cindex "&""gecos""& field, parsing"
16165 Some operating systems, notably HP-UX, use the &"gecos"& field in the system
16166 password file to hold other information in addition to users' real names. Exim
16167 looks up this field for use when it is creating &'Sender:'& or &'From:'&
16168 headers. If either &%gecos_pattern%& or &%gecos_name%& are unset, the contents
16169 of the field are used unchanged, except that, if an ampersand is encountered,
16170 it is replaced by the user's login name with the first character forced to
16171 upper case, since this is a convention that is observed on many systems.
16172
16173 When these options are set, &%gecos_pattern%& is treated as a regular
16174 expression that is to be applied to the field (again with && replaced by the
16175 login name), and if it matches, &%gecos_name%& is expanded and used as the
16176 user's name.
16177
16178 .cindex "numerical variables (&$1$& &$2$& etc)" "in &%gecos_name%&"
16179 Numeric variables such as &$1$&, &$2$&, etc. can be used in the expansion to
16180 pick up sub-fields that were matched by the pattern. In HP-UX, where the user's
16181 name terminates at the first comma, the following can be used:
16182 .code
16183 gecos_pattern = ([^,]*)
16184 gecos_name = $1
16185 .endd
16186
16187
16188 .option gnutls_compat_mode main boolean unset
16189 This option controls whether GnuTLS is used in compatibility mode in an Exim
16190 server. This reduces security slightly, but improves interworking with older
16191 implementations of TLS.
16192
16193
16194 .option gnutls_allow_auto_pkcs11 main boolean unset
16195 This option will let GnuTLS (2.12.0 or later) autoload PKCS11 modules with
16196 the p11-kit configuration files in &_/etc/pkcs11/modules/_&.
16197
16198 See
16199 &url(https://www.gnutls.org/manual/gnutls.html#Smart-cards-and-HSMs)
16200 for documentation.
16201
16202
16203
16204 .option headers_charset main string "see below"
16205 This option sets a default character set for translating from encoded MIME
16206 &"words"& in header lines, when referenced by an &$h_xxx$& expansion item. The
16207 default is the value of HEADERS_CHARSET in &_Local/Makefile_&. The
16208 ultimate default is ISO-8859-1. For more details see the description of header
16209 insertions in section &<<SECTexpansionitems>>&.
16210
16211
16212
16213 .option header_maxsize main integer "see below"
16214 .cindex "header section" "maximum size of"
16215 .cindex "limit" "size of message header section"
16216 This option controls the overall maximum size of a message's header
16217 section. The default is the value of HEADER_MAXSIZE in
16218 &_Local/Makefile_&; the default for that is 1M. Messages with larger header
16219 sections are rejected.
16220
16221
16222 .option header_line_maxsize main integer 0
16223 .cindex "header lines" "maximum size of"
16224 .cindex "limit" "size of one header line"
16225 This option limits the length of any individual header line in a message, after
16226 all the continuations have been joined together. Messages with individual
16227 header lines that are longer than the limit are rejected. The default value of
16228 zero means &"no limit"&.
16229
16230
16231
16232
16233 .option helo_accept_junk_hosts main "host list&!!" unset
16234 .cindex "HELO" "accepting junk data"
16235 .cindex "EHLO" "accepting junk data"
16236 Exim checks the syntax of HELO and EHLO commands for incoming SMTP
16237 mail, and gives an error response for invalid data. Unfortunately, there are
16238 some SMTP clients that send syntactic junk. They can be accommodated by setting
16239 this option. Note that this is a syntax check only. See &%helo_verify_hosts%&
16240 if you want to do semantic checking.
16241 See also &%helo_allow_chars%& for a way of extending the permitted character
16242 set.
16243
16244
16245 .option helo_allow_chars main string unset
16246 .cindex "HELO" "underscores in"
16247 .cindex "EHLO" "underscores in"
16248 .cindex "underscore in EHLO/HELO"
16249 This option can be set to a string of rogue characters that are permitted in
16250 non-ip-literal EHLO and HELO names in addition to the standard letters, digits,
16251 hyphens, and dots. For examplem if you really must allow underscores,
16252 you can set
16253 .code
16254 helo_allow_chars = _
16255 .endd
16256 This option does not apply to names that look like ip-literals.
16257 Note that the value is one string, not a list.
16258
16259
16260 .option helo_lookup_domains main "domain list&!!" &`@:@[]`&
16261 .cindex "HELO" "forcing reverse lookup"
16262 .cindex "EHLO" "forcing reverse lookup"
16263 If the domain given by a client in a HELO or EHLO command matches this
16264 list, a reverse lookup is done in order to establish the host's true name. The
16265 default forces a lookup if the client host gives the server's name or any of
16266 its IP addresses (in brackets), something that broken clients have been seen to
16267 do.
16268
16269
16270 .option helo_try_verify_hosts main "host list&!!" unset
16271 .cindex "HELO verifying" "optional"
16272 .cindex "EHLO" "verifying, optional"
16273 By default, Exim just checks the syntax of HELO and EHLO commands (see
16274 &%helo_accept_junk_hosts%& and &%helo_allow_chars%&). However, some sites like
16275 to do more extensive checking of the data supplied by these commands. The ACL
16276 condition &`verify = helo`& is provided to make this possible.
16277 Formerly, it was necessary also to set this option (&%helo_try_verify_hosts%&)
16278 to force the check to occur. From release 4.53 onwards, this is no longer
16279 necessary. If the check has not been done before &`verify = helo`& is
16280 encountered, it is done at that time. Consequently, this option is obsolete.
16281 Its specification is retained here for backwards compatibility.
16282
16283 When an EHLO or HELO command is received, if the calling host matches
16284 &%helo_try_verify_hosts%&, Exim checks that the host name given in the HELO or
16285 EHLO command either:
16286
16287 .ilist
16288 is an IP literal matching the calling address of the host, or
16289 .next
16290 .cindex "DNS" "reverse lookup"
16291 .cindex "reverse DNS lookup"
16292 matches the host name that Exim obtains by doing a reverse lookup of the
16293 calling host address, or
16294 .next
16295 when looked up in DNS yields the calling host address.
16296 .endlist
16297
16298 However, the EHLO or HELO command is not rejected if any of the checks
16299 fail. Processing continues, but the result of the check is remembered, and can
16300 be detected later in an ACL by the &`verify = helo`& condition.
16301
16302 If DNS was used for successful verification, the variable
16303 .cindex "DNS" "DNSSEC"
16304 &$helo_verify_dnssec$& records the DNSSEC status of the lookups.
16305
16306 .option helo_verify_hosts main "host list&!!" unset
16307 .cindex "HELO verifying" "mandatory"
16308 .cindex "EHLO" "verifying, mandatory"
16309 Like &%helo_try_verify_hosts%&, this option is obsolete, and retained only for
16310 backwards compatibility. For hosts that match this option, Exim checks the host
16311 name given in the HELO or EHLO in the same way as for
16312 &%helo_try_verify_hosts%&. If the check fails, the HELO or EHLO command is
16313 rejected with a 550 error, and entries are written to the main and reject logs.
16314 If a MAIL command is received before EHLO or HELO, it is rejected with a 503
16315 error.
16316
16317 .option hold_domains main "domain list&!!" unset
16318 .cindex "domain" "delaying delivery"
16319 .cindex "delivery" "delaying certain domains"
16320 This option allows mail for particular domains to be held in the queue
16321 manually. The option is overridden if a message delivery is forced with the
16322 &%-M%&, &%-qf%&, &%-Rf%& or &%-Sf%& options, and also while testing or
16323 verifying addresses using &%-bt%& or &%-bv%&. Otherwise, if a domain matches an
16324 item in &%hold_domains%&, no routing or delivery for that address is done, and
16325 it is deferred every time the message is looked at.
16326
16327 This option is intended as a temporary operational measure for delaying the
16328 delivery of mail while some problem is being sorted out, or some new
16329 configuration tested. If you just want to delay the processing of some
16330 domains until a queue run occurs, you should use &%queue_domains%& or
16331 &%queue_smtp_domains%&, not &%hold_domains%&.
16332
16333 A setting of &%hold_domains%& does not override Exim's code for removing
16334 messages from the queue if they have been there longer than the longest retry
16335 time in any retry rule. If you want to hold messages for longer than the normal
16336 retry times, insert a dummy retry rule with a long retry time.
16337
16338
16339 .option host_lookup main "host list&!!" unset
16340 .cindex "host name" "lookup, forcing"
16341 Exim does not look up the name of a calling host from its IP address unless it
16342 is required to compare against some host list, or the host matches
16343 &%helo_try_verify_hosts%& or &%helo_verify_hosts%&, or the host matches this
16344 option (which normally contains IP addresses rather than host names). The
16345 default configuration file contains
16346 .code
16347 host_lookup = *
16348 .endd
16349 which causes a lookup to happen for all hosts. If the expense of these lookups
16350 is felt to be too great, the setting can be changed or removed.
16351
16352 After a successful reverse lookup, Exim does a forward lookup on the name it
16353 has obtained, to verify that it yields the IP address that it started with. If
16354 this check fails, Exim behaves as if the name lookup failed.
16355
16356 .vindex "&$host_lookup_failed$&"
16357 .vindex "&$sender_host_name$&"
16358 After any kind of failure, the host name (in &$sender_host_name$&) remains
16359 unset, and &$host_lookup_failed$& is set to the string &"1"&. See also
16360 &%dns_again_means_nonexist%&, &%helo_lookup_domains%&, and
16361 &`verify = reverse_host_lookup`& in ACLs.
16362
16363
16364 .option host_lookup_order main "string list" &`bydns:byaddr`&
16365 This option specifies the order of different lookup methods when Exim is trying
16366 to find a host name from an IP address. The default is to do a DNS lookup
16367 first, and then to try a local lookup (using &[gethostbyaddr()]& or equivalent)
16368 if that fails. You can change the order of these lookups, or omit one entirely,
16369 if you want.
16370
16371 &*Warning*&: The &"byaddr"& method does not always yield aliases when there are
16372 multiple PTR records in the DNS and the IP address is not listed in
16373 &_/etc/hosts_&. Different operating systems give different results in this
16374 case. That is why the default tries a DNS lookup first.
16375
16376
16377
16378 .option host_reject_connection main "host list&!!" unset
16379 .cindex "host" "rejecting connections from"
16380 If this option is set, incoming SMTP calls from the hosts listed are rejected
16381 as soon as the connection is made.
16382 This option is obsolete, and retained only for backward compatibility, because
16383 nowadays the ACL specified by &%acl_smtp_connect%& can also reject incoming
16384 connections immediately.
16385
16386 If the connection is on a TLS-on-connect port then the TCP connection is
16387 just dropped.  Otherwise, an SMTP error is sent first.
16388
16389 The ability to give an immediate rejection (either by this option or using an
16390 ACL) is provided for use in unusual cases. Many hosts will just try again,
16391 sometimes without much delay. Normally, it is better to use an ACL to reject
16392 incoming messages at a later stage, such as after RCPT commands. See
16393 chapter &<<CHAPACL>>&.
16394
16395
16396 .option hosts_connection_nolog main "host list&!!" unset
16397 .cindex "host" "not logging connections from"
16398 This option defines a list of hosts for which connection logging does not
16399 happen, even though the &%smtp_connection%& log selector is set. For example,
16400 you might want not to log SMTP connections from local processes, or from
16401 127.0.0.1, or from your local LAN. This option is consulted in the main loop of
16402 the daemon; you should therefore strive to restrict its value to a short inline
16403 list of IP addresses and networks. To disable logging SMTP connections from
16404 local processes, you must create a host list with an empty item. For example:
16405 .code
16406 hosts_connection_nolog = :
16407 .endd
16408 The hosts affected by this option also do not log "no MAIL in SMTP connection"
16409 lines, as may commonly be produced by a monitoring system.
16410
16411
16412 .option hosts_require_alpn main "host list&!!" unset
16413 .cindex ALPN "require negotiation in server"
16414 .cindex TLS ALPN
16415 .cindex TLS "Application Layer Protocol Names"
16416 If the TLS library supports ALPN
16417 then a successful negotiation of ALPN will be required for any client
16418 matching the list, for TLS to be used.
16419 See also the &%tls_alpn%& option.
16420
16421 &*Note*&: prevention of fallback to in-clear connection is not
16422 managed by this option, and should be done separately.
16423
16424
16425 .option hosts_require_helo main "host list&!!" *
16426 .cindex "HELO/EHLO" requiring
16427 Exim will require an accepted HELO or EHLO command from a host matching
16428 this list, before accepting a MAIL command.
16429
16430
16431 .option hosts_proxy main "host list&!!" unset
16432 .cindex proxy "proxy protocol"
16433 This option enables use of Proxy Protocol proxies for incoming
16434 connections.  For details see section &<<SECTproxyInbound>>&.
16435
16436
16437 .option hosts_treat_as_local main "domain list&!!" unset
16438 .cindex "local host" "domains treated as"
16439 .cindex "host" "treated as local"
16440 If this option is set, any host names that match the domain list are treated as
16441 if they were the local host when Exim is scanning host lists obtained from MX
16442 records
16443 or other sources. Note that the value of this option is a domain list, not a
16444 host list, because it is always used to check host names, not IP addresses.
16445
16446 This option also applies when Exim is matching the special items
16447 &`@mx_any`&, &`@mx_primary`&, and &`@mx_secondary`& in a domain list (see
16448 section &<<SECTdomainlist>>&), and when checking the &%hosts%& option in the
16449 &(smtp)& transport for the local host (see the &%allow_localhost%& option in
16450 that transport). See also &%local_interfaces%&, &%extra_local_interfaces%&, and
16451 chapter &<<CHAPinterfaces>>&, which contains a discussion about local network
16452 interfaces and recognizing the local host.
16453
16454
16455 .option ibase_servers main "string list" unset
16456 .cindex "InterBase" "server list"
16457 This option provides a list of InterBase servers and associated connection data,
16458 to be used in conjunction with &(ibase)& lookups (see section &<<SECID72>>&).
16459 The option is available only if Exim has been built with InterBase support.
16460
16461
16462
16463 .option ignore_bounce_errors_after main time 10w
16464 .cindex "bounce message" "discarding"
16465 .cindex "discarding bounce message"
16466 This option affects the processing of bounce messages that cannot be delivered,
16467 that is, those that suffer a permanent delivery failure. (Bounce messages that
16468 suffer temporary delivery failures are of course retried in the usual way.)
16469
16470 After a permanent delivery failure, bounce messages are frozen,
16471 because there is no sender to whom they can be returned. When a frozen bounce
16472 message has been in the queue for more than the given time, it is unfrozen at
16473 the next queue run, and a further delivery is attempted. If delivery fails
16474 again, the bounce message is discarded. This makes it possible to keep failed
16475 bounce messages around for a shorter time than the normal maximum retry time
16476 for frozen messages. For example,
16477 .code
16478 ignore_bounce_errors_after = 12h
16479 .endd
16480 retries failed bounce message deliveries after 12 hours, discarding any further
16481 failures. If the value of this option is set to a zero time period, bounce
16482 failures are discarded immediately. Setting a very long time (as in the default
16483 value) has the effect of disabling this option. For ways of automatically
16484 dealing with other kinds of frozen message, see &%auto_thaw%& and
16485 &%timeout_frozen_after%&.
16486
16487
16488 .options ignore_fromline_hosts main "host list&!!" unset &&&
16489          ignore_fromline_local main boolean false
16490 .cindex "&""From""& line"
16491 .cindex "UUCP" "&""From""& line"
16492 Some broken SMTP clients insist on sending a UUCP-like &"From&~"& line before
16493 the headers of a message. By default this is treated as the start of the
16494 message's body, which means that any following headers are not recognized as
16495 such. Exim can be made to ignore it by setting &%ignore_fromline_hosts%& to
16496 match those hosts that insist on sending it. If the sender is actually a local
16497 process rather than a remote host, and is using &%-bs%& to inject the messages,
16498 &%ignore_fromline_local%& must be set to achieve this effect.
16499
16500
16501
16502 .option keep_environment main "string list" unset
16503 .cindex "environment" "values from"
16504 This option contains a string list of environment variables to keep.
16505 You have to trust these variables or you have to be sure that
16506 these variables do not impose any security risk. Keep in mind that
16507 during the startup phase Exim is running with an effective UID 0 in most
16508 installations. As the default value is an empty list, the default
16509 environment for using libraries, running embedded Perl code, or running
16510 external binaries is empty, and does not not even contain PATH or HOME.
16511
16512 Actually the list is interpreted as a list of patterns
16513 (&<<SECTlistexpand>>&), except that it is not expanded first.
16514
16515 WARNING: Macro substitution is still done first, so having a macro
16516 FOO and having FOO_HOME in your &%keep_environment%& option may have
16517 unexpected results. You may work around this using a regular expression
16518 that does not match the macro name: ^[F]OO_HOME$.
16519
16520 Current versions of Exim issue a warning during startup if you do not mention
16521 &%keep_environment%& in your runtime configuration file and if your
16522 current environment is not empty. Future versions may not issue that warning
16523 anymore.
16524
16525 See the &%add_environment%& main config option for a way to set
16526 environment variables to a fixed value.  The environment for &(pipe)&
16527 transports is handled separately, see section &<<SECTpipeenv>>& for
16528 details.
16529
16530
16531 .option keep_malformed main time 4d
16532 This option specifies the length of time to keep messages whose spool files
16533 have been corrupted in some way. This should, of course, never happen. At the
16534 next attempt to deliver such a message, it gets removed. The incident is
16535 logged.
16536
16537
16538 .option ldap_ca_cert_dir main string unset
16539 .cindex "LDAP", "TLS CA certificate directory"
16540 .cindex certificate "directory for LDAP"
16541 This option indicates which directory contains CA certificates for verifying
16542 a TLS certificate presented by an LDAP server.
16543 While Exim does not provide a default value, your SSL library may.
16544 Analogous to &%tls_verify_certificates%& but as a client-side option for LDAP
16545 and constrained to be a directory.
16546
16547
16548 .option ldap_ca_cert_file main string unset
16549 .cindex "LDAP", "TLS CA certificate file"
16550 .cindex certificate "file for LDAP"
16551 This option indicates which file contains CA certificates for verifying
16552 a TLS certificate presented by an LDAP server.
16553 While Exim does not provide a default value, your SSL library may.
16554 Analogous to &%tls_verify_certificates%& but as a client-side option for LDAP
16555 and constrained to be a file.
16556
16557
16558 .option ldap_cert_file main string unset
16559 .cindex "LDAP" "TLS client certificate file"
16560 .cindex certificate "file for LDAP"
16561 This option indicates which file contains an TLS client certificate which
16562 Exim should present to the LDAP server during TLS negotiation.
16563 Should be used together with &%ldap_cert_key%&.
16564
16565
16566 .option ldap_cert_key main string unset
16567 .cindex "LDAP" "TLS client key file"
16568 .cindex certificate "key for LDAP"
16569 This option indicates which file contains the secret/private key to use
16570 to prove identity to the LDAP server during TLS negotiation.
16571 Should be used together with &%ldap_cert_file%&, which contains the
16572 identity to be proven.
16573
16574
16575 .option ldap_cipher_suite main string unset
16576 .cindex "LDAP" "TLS cipher suite"
16577 This controls the TLS cipher-suite negotiation during TLS negotiation with
16578 the LDAP server.  See &<<SECTreqciphssl>>& for more details of the format of
16579 cipher-suite options with OpenSSL (as used by LDAP client libraries).
16580
16581
16582 .option ldap_default_servers main "string list" unset
16583 .cindex "LDAP" "default servers"
16584 This option provides a list of LDAP servers which are tried in turn when an
16585 LDAP query does not contain a server. See section &<<SECTforldaque>>& for
16586 details of LDAP queries. This option is available only when Exim has been built
16587 with LDAP support.
16588
16589
16590 .option ldap_require_cert main string unset.
16591 .cindex "LDAP" "policy for LDAP server TLS cert presentation"
16592 This should be one of the values "hard", "demand", "allow", "try" or "never".
16593 A value other than one of these is interpreted as "never".
16594 See the entry "TLS_REQCERT" in your system man page for ldap.conf(5).
16595 Although Exim does not set a default, the LDAP library probably defaults
16596 to hard/demand.
16597
16598
16599 .option ldap_start_tls main boolean false
16600 .cindex "LDAP" "whether or not to negotiate TLS"
16601 If set, Exim will attempt to negotiate TLS with the LDAP server when
16602 connecting on a regular LDAP port.  This is the LDAP equivalent of SMTP's
16603 "STARTTLS".  This is distinct from using "ldaps", which is the LDAP form
16604 of SSL-on-connect.
16605 In the event of failure to negotiate TLS, the action taken is controlled
16606 by &%ldap_require_cert%&.
16607 This option is ignored for &`ldapi`& connections.
16608
16609
16610 .option ldap_version main integer unset
16611 .cindex "LDAP" "protocol version, forcing"
16612 This option can be used to force Exim to set a specific protocol version for
16613 LDAP. If it option is unset, it is shown by the &%-bP%& command line option as
16614 -1. When this is the case, the default is 3 if LDAP_VERSION3 is defined in
16615 the LDAP headers; otherwise it is 2. This option is available only when Exim
16616 has been built with LDAP support.
16617
16618
16619
16620 .option limits_advertise_hosts main "host list&!!" *
16621 .cindex LIMITS "suppressing advertising"
16622 .cindex "ESMTP extensions" LIMITS
16623 This option can be used to suppress the advertisement of the SMTP
16624 LIMITS extension (RFC 9422) to specific hosts.
16625 If permitted, Exim as a servier will advertise in the EHLO response
16626 the limit for RCPT commands set by the &%recipients_max%& option (if it is set)
16627 and the limit for MAIL commands set by the &%smtp_accept_max_per_connection%&
16628 option.
16629
16630 .option local_from_check main boolean true
16631 .cindex "&'Sender:'& header line" "disabling addition of"
16632 .cindex "&'From:'& header line" "disabling checking of"
16633 When a message is submitted locally (that is, not over a TCP/IP connection) by
16634 an untrusted user, Exim removes any existing &'Sender:'& header line, and
16635 checks that the &'From:'& header line matches the login of the calling user and
16636 the domain specified by &%qualify_domain%&.
16637
16638 &*Note*&: An unqualified address (no domain) in the &'From:'& header in a
16639 locally submitted message is automatically qualified by Exim, unless the
16640 &%-bnq%& command line option is used.
16641
16642 You can use &%local_from_prefix%& and &%local_from_suffix%& to permit affixes
16643 on the local part. If the &'From:'& header line does not match, Exim adds a
16644 &'Sender:'& header with an address constructed from the calling user's login
16645 and the default qualify domain.
16646
16647 If &%local_from_check%& is set false, the &'From:'& header check is disabled,
16648 and no &'Sender:'& header is ever added. If, in addition, you want to retain
16649 &'Sender:'& header lines supplied by untrusted users, you must also set
16650 &%local_sender_retain%& to be true.
16651
16652 .cindex "envelope from"
16653 .cindex "envelope sender"
16654 These options affect only the header lines in the message. The envelope sender
16655 is still forced to be the login id at the qualify domain unless
16656 &%untrusted_set_sender%& permits the user to supply an envelope sender.
16657
16658 For messages received over TCP/IP, an ACL can specify &"submission mode"& to
16659 request similar header line checking. See section &<<SECTthesenhea>>&, which
16660 has more details about &'Sender:'& processing.
16661
16662
16663
16664
16665 .options local_from_prefix main string unset &&&
16666          local_from_suffix main string unset
16667 When Exim checks the &'From:'& header line of locally submitted messages for
16668 matching the login id (see &%local_from_check%& above), it can be configured to
16669 ignore certain prefixes and suffixes in the local part of the address. This is
16670 done by setting &%local_from_prefix%& and/or &%local_from_suffix%& to
16671 appropriate lists, in the same form as the &%local_part_prefix%& and
16672 &%local_part_suffix%& router options (see chapter &<<CHAProutergeneric>>&). For
16673 example, if
16674 .code
16675 local_from_prefix = *-
16676 .endd
16677 is set, a &'From:'& line containing
16678 .code
16679 From: anything-user@your.domain.example
16680 .endd
16681 will not cause a &'Sender:'& header to be added if &'user@your.domain.example'&
16682 matches the actual sender address that is constructed from the login name and
16683 qualify domain.
16684
16685
16686 .option local_interfaces main "string list" "see below"
16687 This option controls which network interfaces are used by the daemon for
16688 listening; they are also used to identify the local host when routing. Chapter
16689 &<<CHAPinterfaces>>& contains a full description of this option and the related
16690 options &%daemon_smtp_ports%&, &%extra_local_interfaces%&,
16691 &%hosts_treat_as_local%&, and &%tls_on_connect_ports%&. The default value for
16692 &%local_interfaces%& is
16693 .code
16694 local_interfaces = 0.0.0.0
16695 .endd
16696 when Exim is built without IPv6 support; otherwise it is
16697 .code
16698 local_interfaces = <; ::0 ; 0.0.0.0
16699 .endd
16700
16701 .option local_scan_timeout main time 5m
16702 .cindex "timeout" "for &[local_scan()]& function"
16703 .cindex "&[local_scan()]& function" "timeout"
16704 This timeout applies to the &[local_scan()]& function (see chapter
16705 &<<CHAPlocalscan>>&). Zero means &"no timeout"&. If the timeout is exceeded,
16706 the incoming message is rejected with a temporary error if it is an SMTP
16707 message. For a non-SMTP message, the message is dropped and Exim ends with a
16708 non-zero code. The incident is logged on the main and reject logs.
16709
16710
16711
16712 .option local_sender_retain main boolean false
16713 .cindex "&'Sender:'& header line" "retaining from local submission"
16714 When a message is submitted locally (that is, not over a TCP/IP connection) by
16715 an untrusted user, Exim removes any existing &'Sender:'& header line. If you
16716 do not want this to happen, you must set &%local_sender_retain%&, and you must
16717 also set &%local_from_check%& to be false (Exim will complain if you do not).
16718 See also the ACL modifier &`control = suppress_local_fixups`&. Section
16719 &<<SECTthesenhea>>& has more details about &'Sender:'& processing.
16720
16721
16722
16723
16724 .option localhost_number main string&!! unset
16725 .cindex "host" "locally unique number for"
16726 .cindex "message ids" "with multiple hosts"
16727 .cindex multiple "systems sharing a spool"
16728 .cindex "multiple hosts" "sharing a spool"
16729 .cindex "shared spool directory"
16730 .cindex "spool directory" sharing
16731 .vindex "&$localhost_number$&"
16732 Exim's message ids are normally unique only within the local host. If
16733 uniqueness among a set of hosts is required
16734 (eg. because they share a spool directory),
16735 each host must set a different
16736 value for the &%localhost_number%& option. The string is expanded immediately
16737 after reading the configuration file (so that a number can be computed from the
16738 host name, for example) and the result of the expansion must be a number in the
16739 range 0&--16 (or 0&--10 on operating systems with case-insensitive file
16740 systems). This is available in subsequent string expansions via the variable
16741 &$localhost_number$&. When &%localhost_number%& is set, the final four
16742 characters of the message id, instead of just being a fractional part of the
16743 time, are computed from the time and the local host number as described in
16744 section &<<SECTmessiden>>&.
16745
16746
16747
16748 .option log_file_path main "string list&!!" "set at compile time"
16749 .cindex "log" "file path for"
16750 This option sets the path which is used to determine the names of Exim's log
16751 files, or indicates that logging is to be to syslog, or both. It is expanded
16752 when Exim is entered, so it can, for example, contain a reference to the host
16753 name. If no specific path is set for the log files at compile or runtime,
16754 or if the option is unset at runtime (i.e.  &`log_file_path = `&)
16755 they are written in a sub-directory called &_log_& in Exim's spool directory.
16756 A path must start with a slash.
16757 To send to syslog, use the word &"syslog"&.
16758 Chapter &<<CHAPlog>>& contains further details about Exim's logging, and
16759 section &<<SECTwhelogwri>>& describes how the contents of &%log_file_path%& are
16760 used. If this string is fixed at your installation (contains no expansion
16761 variables) it is recommended that you do not set this option in the
16762 configuration file, but instead supply the path using LOG_FILE_PATH in
16763 &_Local/Makefile_& so that it is available to Exim for logging errors detected
16764 early on &-- in particular, failure to read the configuration file.
16765
16766
16767 .option log_selector main string unset
16768 .cindex "log" "selectors"
16769 This option can be used to reduce or increase the number of things that Exim
16770 writes to its log files. Its argument is made up of names preceded by plus or
16771 minus characters. For example:
16772 .code
16773 log_selector = +arguments -retry_defer
16774 .endd
16775 A list of possible names and what they control is given in the chapter on
16776 logging, in section &<<SECTlogselector>>&.
16777
16778
16779 .option log_timezone main boolean false
16780 .cindex "log" "timezone for entries"
16781 .vindex "&$tod_log$&"
16782 .vindex "&$tod_zone$&"
16783 By default, the timestamps on log lines are in local time without the
16784 timezone. This means that if your timezone changes twice a year, the timestamps
16785 in log lines are ambiguous for an hour when the clocks go back. One way of
16786 avoiding this problem is to set the timezone to UTC. An alternative is to set
16787 &%log_timezone%& true. This turns on the addition of the timezone offset to
16788 timestamps in log lines. Turning on this option can add quite a lot to the size
16789 of log files because each line is extended by 6 characters. Note that the
16790 &$tod_log$& variable contains the log timestamp without the zone, but there is
16791 another variable called &$tod_zone$& that contains just the timezone offset.
16792
16793
16794 .option lookup_open_max main integer 25
16795 .cindex "too many open files"
16796 .cindex "open files, too many"
16797 .cindex "file" "too many open"
16798 .cindex "lookup" "maximum open files"
16799 .cindex "limit" "open files for lookups"
16800 This option limits the number of simultaneously open files for single-key
16801 lookups that use regular files (that is, &(lsearch)&, &(dbm)&, and &(cdb)&).
16802 Exim normally keeps these files open during routing, because often the same
16803 file is required several times. If the limit is reached, Exim closes the least
16804 recently used file. Note that if you are using the &'ndbm'& library, it
16805 actually opens two files for each logical DBM database, though it still counts
16806 as one for the purposes of &%lookup_open_max%&. If you are getting &"too many
16807 open files"& errors with NDBM, you need to reduce the value of
16808 &%lookup_open_max%&.
16809
16810
16811 .option max_username_length main integer 0
16812 .cindex "length of login name"
16813 .cindex "user name" "maximum length"
16814 .cindex "limit" "user name length"
16815 Some operating systems are broken in that they truncate long arguments to
16816 &[getpwnam()]& to eight characters, instead of returning &"no such user"&. If
16817 this option is set greater than zero, any attempt to call &[getpwnam()]& with
16818 an argument that is longer behaves as if &[getpwnam()]& failed.
16819
16820
16821 .option message_body_newlines main bool false
16822 .cindex "message body" "newlines in variables"
16823 .cindex "newline" "in message body variables"
16824 .vindex "&$message_body$&"
16825 .vindex "&$message_body_end$&"
16826 By default, newlines in the message body are replaced by spaces when setting
16827 the &$message_body$& and &$message_body_end$& expansion variables. If this
16828 option is set true, this no longer happens.
16829
16830
16831 .option message_body_visible main integer 500
16832 .cindex "body of message" "visible size"
16833 .cindex "message body" "visible size"
16834 .vindex "&$message_body$&"
16835 .vindex "&$message_body_end$&"
16836 This option specifies how much of a message's body is to be included in the
16837 &$message_body$& and &$message_body_end$& expansion variables.
16838
16839
16840 .option message_id_header_domain main string&!! unset
16841 .cindex "&'Message-ID:'& header line"
16842 If this option is set, the string is expanded and used as the right hand side
16843 (domain) of the &'Message-ID:'& header that Exim creates if a
16844 locally-originated incoming message does not have one. &"Locally-originated"&
16845 means &"not received over TCP/IP."&
16846 Otherwise, the primary host name is used.
16847 Only letters, digits, dot and hyphen are accepted; any other characters are
16848 replaced by hyphens. If the expansion is forced to fail, or if the result is an
16849 empty string, the option is ignored.
16850
16851
16852 .option message_id_header_text main string&!! unset
16853 If this variable is set, the string is expanded and used to augment the text of
16854 the &'Message-id:'& header that Exim creates if a locally-originated incoming
16855 message does not have one. The text of this header is required by RFC 2822 to
16856 take the form of an address. By default, Exim uses its internal message id as
16857 the local part, and the primary host name as the domain. If this option is set,
16858 it is expanded, and provided the expansion is not forced to fail, and does not
16859 yield an empty string, the result is inserted into the header immediately
16860 before the @, separated from the internal message id by a dot. Any characters
16861 that are illegal in an address are automatically converted into hyphens. This
16862 means that variables such as &$tod_log$& can be used, because the spaces and
16863 colons will become hyphens.
16864
16865
16866 .option message_logs main boolean true
16867 .cindex "message logs" "disabling"
16868 .cindex "log" "message log; disabling"
16869 If this option is turned off, per-message log files are not created in the
16870 &_msglog_& spool sub-directory. This reduces the amount of disk I/O required by
16871 Exim, by reducing the number of files involved in handling a message from a
16872 minimum of four (header spool file, body spool file, delivery journal, and
16873 per-message log) to three. The other major I/O activity is Exim's main log,
16874 which is not affected by this option.
16875
16876
16877 .option message_size_limit main string&!! 50M
16878 .cindex "message" "size limit"
16879 .cindex "limit" "message size"
16880 .cindex "size" "of message, limit"
16881 This option limits the maximum size of message that Exim will process. The
16882 value is expanded for each incoming connection so, for example, it can be made
16883 to depend on the IP address of the remote host for messages arriving via
16884 TCP/IP. After expansion, the value must be a sequence of decimal digits,
16885 optionally followed by K or M.
16886
16887 .cindex "SIZE" "ESMTP extension, advertising"
16888 .cindex "ESMTP extensions" SIZE
16889 If nonzero the value will be advertised as a parameter to the ESMTP SIZE
16890 service extension keyword.
16891
16892 &*Note*&: This limit cannot be made to depend on a message's sender or any
16893 other properties of an individual message, because it has to be advertised in
16894 the server's response to EHLO. String expansion failure causes a temporary
16895 error. A value of zero means no limit, but its use is not recommended. See also
16896 &%bounce_return_size_limit%&.
16897
16898 Incoming SMTP messages are failed with a 552 error if the limit is
16899 exceeded; locally-generated messages either get a stderr message or a delivery
16900 failure message to the sender, depending on the &%-oe%& setting. Rejection of
16901 an oversized message is logged in both the main and the reject logs. See also
16902 the generic transport option &%message_size_limit%&, which limits the size of
16903 message that an individual transport can process.
16904
16905 If you use a virus-scanner and set this option to to a value larger than the
16906 maximum size that your virus-scanner is configured to support, you may get
16907 failures triggered by large mails.  The right size to configure for the
16908 virus-scanner depends upon what data is passed and the options in use but it's
16909 probably safest to just set it to a little larger than this value.  E.g., with a
16910 default Exim message size of 50M and a default ClamAV StreamMaxLength of 10M,
16911 some problems may result.
16912
16913 A value of 0 will disable size limit checking; Exim will still advertise the
16914 SIZE extension in an EHLO response, but without a limit, so as to permit
16915 SMTP clients to still indicate the message size along with the MAIL verb.
16916
16917
16918 .option move_frozen_messages main boolean false
16919 .cindex "frozen messages" "moving"
16920 This option, which is available only if Exim has been built with the setting
16921 .code
16922 SUPPORT_MOVE_FROZEN_MESSAGES=yes
16923 .endd
16924 in &_Local/Makefile_&, causes frozen messages and their message logs to be
16925 moved from the &_input_& and &_msglog_& directories on the spool to &_Finput_&
16926 and &_Fmsglog_&, respectively. There is currently no support in Exim or the
16927 standard utilities for handling such moved messages, and they do not show up in
16928 lists generated by &%-bp%& or by the Exim monitor.
16929
16930
16931 .option mua_wrapper main boolean false
16932 Setting this option true causes Exim to run in a very restrictive mode in which
16933 it passes messages synchronously to a smart host. Chapter &<<CHAPnonqueueing>>&
16934 contains a full description of this facility.
16935
16936
16937
16938 .option mysql_servers main "string list" unset
16939 .cindex "MySQL" "server list"
16940 This option provides a list of MySQL servers and associated connection data, to
16941 be used in conjunction with &(mysql)& lookups (see section &<<SECID72>>&). The
16942 option is available only if Exim has been built with MySQL support.
16943
16944
16945 .option never_users main "string list&!!" unset
16946 This option is expanded just once, at the start of Exim's processing. Local
16947 message deliveries are normally run in processes that are setuid to the
16948 recipient, and remote deliveries are normally run under Exim's own uid and gid.
16949 It is usually desirable to prevent any deliveries from running as root, as a
16950 safety precaution.
16951
16952 When Exim is built, an option called FIXED_NEVER_USERS can be set to a
16953 list of users that must not be used for local deliveries. This list is fixed in
16954 the binary and cannot be overridden by the configuration file. By default, it
16955 contains just the single user name &"root"&. The &%never_users%& runtime option
16956 can be used to add more users to the fixed list.
16957
16958 If a message is to be delivered as one of the users on the fixed list or the
16959 &%never_users%& list, an error occurs, and delivery is deferred. A common
16960 example is
16961 .code
16962 never_users = root:daemon:bin
16963 .endd
16964 Including root is redundant if it is also on the fixed list, but it does no
16965 harm. This option overrides the &%pipe_as_creator%& option of the &(pipe)&
16966 transport driver.
16967
16968
16969 .option notifier_socket main string "$spool_directory/exim_daemon_notify"
16970 This option gives the name for a unix-domain socket on which the daemon
16971 listens for work and information-requests.
16972 Only installations running multiple daemons sharing a spool directory
16973 should need to modify the default.
16974
16975 The option is expanded before use.
16976 If the platform supports Linux-style abstract socket names, the result
16977 is used with a nul byte prefixed.
16978 Otherwise,
16979 it should be a full path name and use a directory accessible
16980 to Exim.
16981
16982 If this option is set as empty,
16983 or the command line &%-oY%& option is used, or
16984 the command line uses a &%-oX%& option and does not use &%-oP%&,
16985 then a notifier socket is not created.
16986
16987
16988 .option openssl_options main "string list" "+no_sslv2 +no_sslv3 +single_dh_use +no_ticket +no_renegotiation"
16989 .cindex "OpenSSL "compatibility options"
16990 This option allows an administrator to adjust the SSL options applied
16991 by OpenSSL to connections.  It is given as a space-separated list of items,
16992 each one to be +added or -subtracted from the current value.
16993
16994 This option is only available if Exim is built against OpenSSL.  The values
16995 available for this option vary according to the age of your OpenSSL install.
16996 The &"all"& value controls a subset of flags which are available, typically
16997 the bug workaround options.  The &'SSL_CTX_set_options'& man page will
16998 list the values known on your system and Exim should support all the
16999 &"bug workaround"& options and many of the &"modifying"& options.  The Exim
17000 names lose the leading &"SSL_OP_"& and are lower-cased.
17001
17002 Note that adjusting the options can have severe impact upon the security of
17003 SSL as used by Exim.  It is possible to disable safety checks and shoot
17004 yourself in the foot in various unpleasant ways.  This option should not be
17005 adjusted lightly.  An unrecognised item will be detected at startup, by
17006 invoking Exim with the &%-bV%& flag.
17007
17008 The option affects Exim operating both as a server and as a client.
17009
17010 Historical note: prior to release 4.80, Exim defaulted this value to
17011 "+dont_insert_empty_fragments", which may still be needed for compatibility
17012 with some clients, but which lowers security by increasing exposure to
17013 some now infamous attacks.
17014
17015 Examples:
17016 .code
17017 # Make both old MS and old Eudora happy:
17018 openssl_options = -all +microsoft_big_sslv3_buffer \
17019                        +dont_insert_empty_fragments
17020
17021 # Disable older protocol versions:
17022 openssl_options = +no_sslv2 +no_sslv3
17023 .endd
17024
17025 Possible options may include:
17026 .ilist
17027 &`all`&
17028 .next
17029 &`allow_unsafe_legacy_renegotiation`&
17030 .next
17031 &`cipher_server_preference`&
17032 .next
17033 &`dont_insert_empty_fragments`&
17034 .next
17035 &`ephemeral_rsa`&
17036 .next
17037 &`legacy_server_connect`&
17038 .next
17039 &`microsoft_big_sslv3_buffer`&
17040 .next
17041 &`microsoft_sess_id_bug`&
17042 .next
17043 &`msie_sslv2_rsa_padding`&
17044 .next
17045 &`netscape_challenge_bug`&
17046 .next
17047 &`netscape_reuse_cipher_change_bug`&
17048 .next
17049 &`no_compression`&
17050 .next
17051 &`no_session_resumption_on_renegotiation`&
17052 .next
17053 &`no_sslv2`&
17054 .next
17055 &`no_sslv3`&
17056 .next
17057 &`no_ticket`&
17058 .next
17059 &`no_tlsv1`&
17060 .next
17061 &`no_tlsv1_1`&
17062 .next
17063 &`no_tlsv1_2`&
17064 .next
17065 &`safari_ecdhe_ecdsa_bug`&
17066 .next
17067 &`single_dh_use`&
17068 .next
17069 &`single_ecdh_use`&
17070 .next
17071 &`ssleay_080_client_dh_bug`&
17072 .next
17073 &`sslref2_reuse_cert_type_bug`&
17074 .next
17075 &`tls_block_padding_bug`&
17076 .next
17077 &`tls_d5_bug`&
17078 .next
17079 &`tls_rollback_bug`&
17080 .endlist
17081
17082 As an aside, the &`safari_ecdhe_ecdsa_bug`& item is a misnomer and affects
17083 all clients connecting using the MacOS SecureTransport TLS facility prior
17084 to MacOS 10.8.4, including email clients.  If you see old MacOS clients failing
17085 to negotiate TLS then this option value might help, provided that your OpenSSL
17086 release is new enough to contain this work-around.  This may be a situation
17087 where you have to upgrade OpenSSL to get buggy clients working.
17088
17089
17090 .option oracle_servers main "string list" unset
17091 .cindex "Oracle" "server list"
17092 This option provides a list of Oracle servers and associated connection data,
17093 to be used in conjunction with &(oracle)& lookups (see section &<<SECID72>>&).
17094 The option is available only if Exim has been built with Oracle support.
17095
17096
17097 .option panic_coredump main boolean false
17098 This option is rarely needed but can help for some debugging investigations.
17099 If set, when an internal error is detected by Exim which is sufficient
17100 to terminate the process
17101 (all such are logged in the paniclog)
17102 then a coredump is requested.
17103
17104 Note that most systems require additional administrative configuration
17105 to permit write a core file for a setuid program, which is Exim's
17106 common installed configuration.
17107
17108 .option percent_hack_domains main "domain list&!!" unset
17109 .cindex "&""percent hack""&"
17110 .cindex "source routing" "in email address"
17111 .cindex "address" "source-routed"
17112 The &"percent hack"& is the convention whereby a local part containing a
17113 percent sign is re-interpreted as a new email address, with the percent
17114 replaced by @. This is sometimes called &"source routing"&, though that term is
17115 also applied to RFC 2822 addresses that begin with an @ character. If this
17116 option is set, Exim implements the percent facility for those domains listed,
17117 but no others. This happens before an incoming SMTP address is tested against
17118 an ACL.
17119
17120 &*Warning*&: The &"percent hack"& has often been abused by people who are
17121 trying to get round relaying restrictions. For this reason, it is best avoided
17122 if at all possible. Unfortunately, a number of less security-conscious MTAs
17123 implement it unconditionally. If you are running Exim on a gateway host, and
17124 routing mail through to internal MTAs without processing the local parts, it is
17125 a good idea to reject recipient addresses with percent characters in their
17126 local parts. Exim's default configuration does this.
17127
17128
17129 .options perl_at_start main boolean false &&&
17130          perl_startup main string unset
17131 .cindex "Perl"
17132 These options are available only when Exim is built with an embedded Perl
17133 interpreter. See chapter &<<CHAPperl>>& for details of their use.
17134
17135 .option perl_taintmode main boolean false
17136 .cindex "Perl"
17137 This option enables the taint mode of the embedded Perl interpreter.
17138
17139
17140 .option pgsql_servers main "string list" unset
17141 .cindex "PostgreSQL lookup type" "server list"
17142 This option provides a list of PostgreSQL servers and associated connection
17143 data, to be used in conjunction with &(pgsql)& lookups (see section
17144 &<<SECID72>>&). The option is available only if Exim has been built with
17145 PostgreSQL support.
17146
17147
17148 .option pid_file_path main string&!! "set at compile time"
17149 .cindex "daemon" "pid file path"
17150 .cindex "pid file, path for"
17151 This option sets the name of the file to which the Exim daemon writes its
17152 process id. The string is expanded, so it can contain, for example, references
17153 to the host name:
17154 .code
17155 pid_file_path = /var/log/$primary_hostname/exim.pid
17156 .endd
17157 If no path is set, the pid is written to the file &_exim-daemon.pid_& in Exim's
17158 spool directory.
17159 The value set by the option can be overridden by the &%-oP%& command line
17160 option. A pid file is not written if a &"non-standard"& daemon is run by means
17161 of the &%-oX%& option, unless a path is explicitly supplied by &%-oP%&.
17162
17163
17164 .option pipelining_advertise_hosts main "host list&!!" *
17165 .cindex "PIPELINING" "suppressing advertising"
17166 .cindex "ESMTP extensions" PIPELINING
17167 This option can be used to suppress the advertisement of the SMTP
17168 PIPELINING extension to specific hosts. See also the &*no_pipelining*&
17169 control in section &<<SECTcontrols>>&. When PIPELINING is not advertised and
17170 &%smtp_enforce_sync%& is true, an Exim server enforces strict synchronization
17171 for each SMTP command and response. When PIPELINING is advertised, Exim assumes
17172 that clients will use it; &"out of order"& commands that are &"expected"& do
17173 not count as protocol errors (see &%smtp_max_synprot_errors%&).
17174
17175 .option pipelining_connect_advertise_hosts main "host list&!!" *
17176 .cindex "pipelining" "early connection"
17177 .cindex "pipelining" PIPECONNECT
17178 .cindex "ESMTP extensions" PIPECONNECT
17179 If Exim is built without the DISABLE_PIPE_CONNECT build option
17180 this option controls which hosts the facility is advertised to
17181 and from which pipeline early-connection (before MAIL) SMTP
17182 commands are acceptable.
17183 When used, the pipelining saves on roundtrip times.
17184
17185 See also the &%hosts_pipe_connect%& smtp transport option.
17186
17187 The SMTP service extension keyword advertised is &"PIPECONNECT"&;
17188 it permits the client to pipeline
17189 TCP connection and hello command (inclear phase),
17190 or TLS-establishment and hello command (encrypted phase),
17191 on later connections to the same host.
17192
17193
17194 .option prdr_enable main boolean false
17195 .cindex "PRDR" "enabling on server"
17196 .cindex "ESMTP extensions" PRDR
17197 This option can be used to enable the Per-Recipient Data Response extension
17198 to SMTP, defined by Eric Hall.
17199 If the option is set, PRDR is advertised by Exim when operating as a server.
17200 If the client requests PRDR, and more than one recipient, for a message
17201 an additional ACL is called for each recipient after the message content
17202 is received.  See section &<<SECTPRDRACL>>&.
17203
17204 .option preserve_message_logs main boolean false
17205 .cindex "message logs" "preserving"
17206 If this option is set, message log files are not deleted when messages are
17207 completed. Instead, they are moved to a sub-directory of the spool directory
17208 called &_msglog.OLD_&, where they remain available for statistical or debugging
17209 purposes. This is a dangerous option to set on systems with any appreciable
17210 volume of mail. Use with care!
17211
17212
17213 .option primary_hostname main string "see below"
17214 .cindex "name" "of local host"
17215 .cindex "host" "name of local"
17216 .cindex "local host" "name of"
17217 .vindex "&$primary_hostname$&"
17218 This specifies the name of the current host. It is used in the default EHLO or
17219 HELO command for outgoing SMTP messages (changeable via the &%helo_data%&
17220 option in the &(smtp)& transport), and as the default for &%qualify_domain%&.
17221 The value is also used by default in some SMTP response messages from an Exim
17222 server. This can be changed dynamically by setting &%smtp_active_hostname%&.
17223
17224 If &%primary_hostname%& is not set, Exim calls &[uname()]& to find the host
17225 name. If this fails, Exim panics and dies. If the name returned by &[uname()]&
17226 contains only one component, Exim passes it to &[gethostbyname()]& (or
17227 &[getipnodebyname()]& when available) in order to obtain the fully qualified
17228 version. The variable &$primary_hostname$& contains the host name, whether set
17229 explicitly by this option, or defaulted.
17230
17231
17232 .option print_topbitchars main boolean false
17233 .cindex "printing characters"
17234 .cindex "8-bit characters"
17235 By default, Exim considers only those characters whose codes lie in the range
17236 32&--126 to be printing characters. In a number of circumstances (for example,
17237 when writing log entries) non-printing characters are converted into escape
17238 sequences, primarily to avoid messing up the layout. If &%print_topbitchars%&
17239 is set, code values of 128 and above are also considered to be printing
17240 characters.
17241
17242 This option also affects the header syntax checks performed by the
17243 &(autoreply)& transport, and whether Exim uses RFC 2047 encoding of
17244 the user's full name when constructing From: and Sender: addresses (as
17245 described in section &<<SECTconstr>>&). Setting this option can cause
17246 Exim to generate eight bit message headers that do not conform to the
17247 standards.
17248
17249
17250 .option process_log_path main string unset
17251 .cindex "process log path"
17252 .cindex "log" "process log"
17253 .cindex "&'exiwhat'&"
17254 This option sets the name of the file to which an Exim process writes its
17255 &"process log"& when sent a USR1 signal. This is used by the &'exiwhat'&
17256 utility script. If this option is unset, the file called &_exim-process.info_&
17257 in Exim's spool directory is used. The ability to specify the name explicitly
17258 can be useful in environments where two different Exims are running, using
17259 different spool directories.
17260
17261
17262 .option prod_requires_admin main boolean true
17263 .cindex "restricting access to features"
17264 .oindex "&%-M%&"
17265 .oindex "&%-R%&"
17266 .oindex "&%-q%&"
17267 The &%-M%&, &%-R%&, and &%-q%& command-line options require the caller to be an
17268 admin user unless &%prod_requires_admin%& is set false. See also
17269 &%queue_list_requires_admin%& and &%commandline_checks_require_admin%&.
17270
17271
17272 .option proxy_protocol_timeout main time 3s
17273 .cindex proxy "proxy protocol"
17274 This option sets the timeout for proxy protocol negotiation.
17275 For details see section &<<SECTproxyInbound>>&.
17276
17277
17278 .option qualify_domain main string "see below"
17279 .cindex "domain" "for qualifying addresses"
17280 .cindex "address" "qualification"
17281 This option specifies the domain name that is added to any envelope sender
17282 addresses that do not have a domain qualification. It also applies to
17283 recipient addresses if &%qualify_recipient%& is not set. Unqualified addresses
17284 are accepted by default only for locally-generated messages. Qualification is
17285 also applied to addresses in header lines such as &'From:'& and &'To:'& for
17286 locally-generated messages, unless the &%-bnq%& command line option is used.
17287
17288 Messages from external sources must always contain fully qualified addresses,
17289 unless the sending host matches &%sender_unqualified_hosts%& or
17290 &%recipient_unqualified_hosts%& (as appropriate), in which case incoming
17291 addresses are qualified with &%qualify_domain%& or &%qualify_recipient%& as
17292 necessary. Internally, Exim always works with fully qualified envelope
17293 addresses. If &%qualify_domain%& is not set, it defaults to the
17294 &%primary_hostname%& value.
17295
17296
17297 .option qualify_recipient main string "see below"
17298 This option allows you to specify a different domain for qualifying recipient
17299 addresses to the one that is used for senders. See &%qualify_domain%& above.
17300
17301
17302
17303 .option queue_domains main "domain list&!!" unset
17304 .cindex "domain" "specifying non-immediate delivery"
17305 .cindex "queueing incoming messages"
17306 .cindex "message" "queueing certain domains"
17307 This option lists domains for which immediate delivery is not required.
17308 A delivery process is started whenever a message is received, but only those
17309 domains that do not match are processed. All other deliveries wait until the
17310 next queue run. See also &%hold_domains%& and &%queue_smtp_domains%&.
17311
17312
17313 .option queue_fast_ramp main boolean true
17314 .cindex "queue runner" "two phase"
17315 .cindex "queue" "double scanning"
17316 If set to true, two-phase queue runs, initiated using &%-qq%& on the
17317 command line, may start parallel delivery processes during their first
17318 phase.  This will be done when a threshold number of messages have been
17319 routed for a single host.
17320
17321
17322 .option queue_list_requires_admin main boolean true
17323 .cindex "restricting access to features"
17324 .oindex "&%-bp%&"
17325 The &%-bp%& command-line option, which lists the messages that are on the
17326 queue, requires the caller to be an admin user unless
17327 &%queue_list_requires_admin%& is set false.
17328 See also &%prod_requires_admin%& and &%commandline_checks_require_admin%&.
17329
17330
17331 .option queue_only main boolean false
17332 .cindex "queueing incoming messages"
17333 .cindex "message" "queueing unconditionally"
17334 If &%queue_only%& is set, a delivery process is not automatically started
17335 whenever a message is received. Instead, the message waits in the queue for the
17336 next queue run. Even if &%queue_only%& is false, incoming messages may not get
17337 delivered immediately when certain conditions (such as heavy load) occur.
17338
17339 The &%-odq%& command line has the same effect as &%queue_only%&. The &%-odb%&
17340 and &%-odi%& command line options override &%queue_only%& unless
17341 &%queue_only_override%& is set false. See also &%queue_only_file%&,
17342 &%queue_only_load%&, and &%smtp_accept_queue%&.
17343
17344
17345 .option queue_only_file main "string list" unset
17346 .cindex "queueing incoming messages"
17347 .cindex "message" "queueing by file existence"
17348 This option can be set to a colon-separated list of absolute path names, each
17349 one optionally preceded by &"smtp"&. When Exim is receiving a message,
17350 it tests for the existence of each listed path using a call to &[stat()]&. For
17351 each path that exists, the corresponding queueing option is set.
17352 For paths with no prefix, &%queue_only%& is set; for paths prefixed by
17353 &"smtp"&, &%queue_smtp_domains%& is set to match all domains. So, for example,
17354 .code
17355 queue_only_file = smtp/some/file
17356 .endd
17357 causes Exim to behave as if &%queue_smtp_domains%& were set to &"*"& whenever
17358 &_/some/file_& exists.
17359
17360
17361 .option queue_only_load main fixed-point unset
17362 .cindex "load average"
17363 .cindex "queueing incoming messages"
17364 .cindex "message" "queueing by load"
17365 If the system load average is higher than this value, incoming messages from
17366 all sources are queued, and no automatic deliveries are started. If this
17367 happens during local or remote SMTP input, all subsequent messages received on
17368 the same SMTP connection are queued by default, whatever happens to the load in
17369 the meantime, but this can be changed by setting &%queue_only_load_latch%&
17370 false.
17371
17372 Deliveries will subsequently be performed by queue runner processes. This
17373 option has no effect on ancient operating systems on which Exim cannot
17374 determine the load average. See also &%deliver_queue_load_max%& and
17375 &%smtp_load_reserve%&.
17376
17377
17378 .option queue_only_load_latch main boolean true
17379 .cindex "load average" "re-evaluating per message"
17380 When this option is true (the default), once one message has been queued
17381 because the load average is higher than the value set by &%queue_only_load%&,
17382 all subsequent messages received on the same SMTP connection are also queued.
17383 This is a deliberate choice; even though the load average may fall below the
17384 threshold, it doesn't seem right to deliver later messages on the same
17385 connection when not delivering earlier ones. However, there are special
17386 circumstances such as very long-lived connections from scanning appliances
17387 where this is not the best strategy. In such cases, &%queue_only_load_latch%&
17388 should be set false. This causes the value of the load average to be
17389 re-evaluated for each message.
17390
17391
17392 .option queue_only_override main boolean true
17393 .cindex "queueing incoming messages"
17394 When this option is true, the &%-od%&&'x'& command line options override the
17395 setting of &%queue_only%& or &%queue_only_file%& in the configuration file. If
17396 &%queue_only_override%& is set false, the &%-od%&&'x'& options cannot be used
17397 to override; they are accepted, but ignored.
17398
17399
17400 .option queue_run_in_order main boolean false
17401 .cindex "queue runner" "processing messages in order"
17402 If this option is set, queue runs happen in order of message arrival instead of
17403 in an arbitrary order. For this to happen, a complete list of the entire queue
17404 must be set up before the deliveries start. When the queue is all held in a
17405 single directory (the default), a single list is created for both the ordered
17406 and the non-ordered cases. However, if &%split_spool_directory%& is set, a
17407 single list is not created when &%queue_run_in_order%& is false. In this case,
17408 the sub-directories are processed one at a time (in a random order), and this
17409 avoids setting up one huge list for the whole queue. Thus, setting
17410 &%queue_run_in_order%& with &%split_spool_directory%& may degrade performance
17411 when the queue is large, because of the extra work in setting up the single,
17412 large list. In most situations, &%queue_run_in_order%& should not be set.
17413
17414
17415
17416 .option queue_run_max main integer&!! 5
17417 .cindex "queue runner" "maximum number of"
17418 This controls the maximum number of queue runner processes that an Exim daemon
17419 can run simultaneously. This does not mean that it starts them all at once,
17420 but rather that if the maximum number are still running when the time comes to
17421 start another one, it refrains from starting another one. This can happen with
17422 very large queues and/or very sluggish deliveries. This option does not,
17423 however, interlock with other processes, so additional queue runners can be
17424 started by other means, or by killing and restarting the daemon.
17425
17426 Setting this option to zero does not suppress queue runs; rather, it disables
17427 the limit, allowing any number of simultaneous queue runner processes to be
17428 run. If you do not want queue runs to occur, omit the &%-q%&&'xx'& setting on
17429 the daemon's command line.
17430
17431 .cindex queues named
17432 .cindex "named queues" "resource limit"
17433 To set limits for different named queues use
17434 an expansion depending on the &$queue_name$& variable.
17435
17436 .option queue_smtp_domains main "domain list&!!" unset
17437 .cindex "queueing incoming messages"
17438 .cindex "message" "queueing remote deliveries"
17439 .cindex "first pass routing"
17440 When this option is set, a delivery process is started whenever a message is
17441 received, routing is performed, and local deliveries take place.
17442 However, if any SMTP deliveries are required for domains that match
17443 &%queue_smtp_domains%&, they are not immediately delivered, but instead the
17444 message waits in the queue for the next queue run. Since routing of the message
17445 has taken place, Exim knows to which remote hosts it must be delivered, and so
17446 when the queue run happens, multiple messages for the same host are delivered
17447 over a single SMTP connection. The &%-odqs%& command line option causes all
17448 SMTP deliveries to be queued in this way, and is equivalent to setting
17449 &%queue_smtp_domains%& to &"*"&. See also &%hold_domains%& and
17450 &%queue_domains%&.
17451
17452
17453 .option receive_timeout main time 0s
17454 .cindex "timeout" "for non-SMTP input"
17455 This option sets the timeout for accepting a non-SMTP message, that is, the
17456 maximum time that Exim waits when reading a message on the standard input. If
17457 the value is zero, it will wait forever. This setting is overridden by the
17458 &%-or%& command line option. The timeout for incoming SMTP messages is
17459 controlled by &%smtp_receive_timeout%&.
17460
17461 .option received_header_text main string&!! "see below"
17462 .cindex "customizing" "&'Received:'& header"
17463 .cindex "&'Received:'& header line" "customizing"
17464 This string defines the contents of the &'Received:'& message header that is
17465 added to each message, except for the timestamp, which is automatically added
17466 on at the end (preceded by a semicolon). The string is expanded each time it is
17467 used. If the expansion yields an empty string, no &'Received:'& header line is
17468 added to the message. Otherwise, the string should start with the text
17469 &"Received:"& and conform to the RFC 2822 specification for &'Received:'&
17470 header lines.
17471 The default setting is:
17472
17473 .code
17474 received_header_text = Received: \
17475   ${if def:sender_rcvhost {from $sender_rcvhost\n\t}\
17476     {${if def:sender_ident \
17477       {from ${quote_local_part:$sender_ident} }}\
17478         ${if def:sender_helo_name {(helo=$sender_helo_name)\n\t}}}}\
17479   by $primary_hostname \
17480   ${if def:received_protocol {with $received_protocol }}\
17481   ${if def:tls_in_ver        { ($tls_in_ver)}}\
17482   ${if def:tls_in_cipher_std { tls $tls_in_cipher_std\n\t}}\
17483   (Exim $version_number)\n\t\
17484   ${if def:sender_address \
17485   {(envelope-from <$sender_address>)\n\t}}\
17486   id $message_exim_id\
17487   ${if def:received_for {\n\tfor $received_for}}
17488 .endd
17489
17490 The references to the TLS version and cipher are
17491 omitted when Exim is built without TLS
17492 support. The use of conditional expansions ensures that this works for both
17493 locally generated messages and messages received from remote hosts, giving
17494 header lines such as the following:
17495 .code
17496 Received: from scrooge.carol.example ([192.168.12.25] ident=root)
17497 by marley.carol.example with esmtp (Exim 4.00)
17498 (envelope-from <bob@carol.example>)
17499 id 16IOWa-00019l-00
17500 for chas@dickens.example; Tue, 25 Dec 2001 14:43:44 +0000
17501 Received: by scrooge.carol.example with local (Exim 4.00)
17502 id 16IOWW-000083-00; Tue, 25 Dec 2001 14:43:41 +0000
17503 .endd
17504 Until the body of the message has been received, the timestamp is the time when
17505 the message started to be received. Once the body has arrived, and all policy
17506 checks have taken place, the timestamp is updated to the time at which the
17507 message was accepted.
17508
17509
17510 .option received_headers_max main integer 30
17511 .cindex "loop" "prevention"
17512 .cindex "mail loop prevention"
17513 .cindex "&'Received:'& header line" "counting"
17514 When a message is to be delivered, the number of &'Received:'& headers is
17515 counted, and if it is greater than this parameter, a mail loop is assumed to
17516 have occurred, the delivery is abandoned, and an error message is generated.
17517 This applies to both local and remote deliveries.
17518
17519
17520 .option recipient_unqualified_hosts main "host list&!!" unset
17521 .cindex "unqualified addresses"
17522 .cindex "host" "unqualified addresses from"
17523 This option lists those hosts from which Exim is prepared to accept unqualified
17524 recipient addresses in message envelopes. The addresses are made fully
17525 qualified by the addition of the &%qualify_recipient%& value. This option also
17526 affects message header lines. Exim does not reject unqualified recipient
17527 addresses in headers, but it qualifies them only if the message came from a
17528 host that matches &%recipient_unqualified_hosts%&,
17529 or if the message was submitted locally (not using TCP/IP), and the &%-bnq%&
17530 option was not set.
17531
17532
17533 .option recipients_max main integer&!! 50000
17534 .cindex "limit" "number of recipients"
17535 .cindex "recipient" "maximum number"
17536 If the value resulting from expanding this option
17537 is set greater than zero, it specifies the maximum number of
17538 original recipients for any message. Additional recipients that are generated
17539 by aliasing or forwarding do not count. SMTP messages get a 452 response for
17540 all recipients over the limit; earlier recipients are delivered as normal.
17541 Non-SMTP messages with too many recipients are failed, and no deliveries are
17542 done.
17543
17544 For SMTP message the expansion is done after the connection is
17545 accepted (but before any SMTP conversation) and may depend on
17546 the IP addresses and port numbers of the connection.
17547 &*Note*&: If an expansion is used for the option,
17548 care should be taken that a resonable value results for
17549 non-SMTP messages.
17550
17551 .cindex "RCPT" "maximum number of incoming"
17552 &*Note*&: The RFCs specify that an SMTP server should accept at least 100
17553 RCPT commands in a single message.
17554
17555
17556 .option recipients_max_reject main boolean false
17557 If this option is set true, Exim rejects SMTP messages containing too many
17558 recipients by giving 552 errors to the surplus RCPT commands, and a 554
17559 error to the eventual DATA command. Otherwise (the default) it gives a 452
17560 error to the surplus RCPT commands and accepts the message on behalf of the
17561 initial set of recipients. The remote server should then re-send the message
17562 for the remaining recipients at a later time.
17563
17564
17565 .option remote_max_parallel main integer 4
17566 .cindex "delivery" "parallelism for remote"
17567 This option controls parallel delivery of one message to a number of remote
17568 hosts. If the value is less than 2, parallel delivery is disabled, and Exim
17569 does all the remote deliveries for a message one by one. Otherwise, if a single
17570 message has to be delivered to more than one remote host, or if several copies
17571 have to be sent to the same remote host, up to &%remote_max_parallel%&
17572 deliveries are done simultaneously. If more than &%remote_max_parallel%&
17573 deliveries are required, the maximum number of processes are started, and as
17574 each one finishes, another is begun. The order of starting processes is the
17575 same as if sequential delivery were being done, and can be controlled by the
17576 &%remote_sort_domains%& option. If parallel delivery takes place while running
17577 with debugging turned on, the debugging output from each delivery process is
17578 tagged with its process id.
17579
17580 This option controls only the maximum number of parallel deliveries for one
17581 message in one Exim delivery process. Because Exim has no central queue
17582 manager, there is no way of controlling the total number of simultaneous
17583 deliveries if the configuration allows a delivery attempt as soon as a message
17584 is received.
17585
17586 See also the &%max_parallel%& generic transport option,
17587 and the &%serialize_hosts%& smtp transport option.
17588
17589 .cindex "number of deliveries"
17590 .cindex "delivery" "maximum number of"
17591 If you want to control the total number of deliveries on the system, you
17592 need to set the &%queue_only%& option. This ensures that all incoming messages
17593 are added to the queue without starting a delivery process. Then set up an Exim
17594 daemon to start queue runner processes at appropriate intervals (probably
17595 fairly often, for example, every minute), and limit the total number of queue
17596 runners by setting the &%queue_run_max%& parameter. Because each queue runner
17597 delivers only one message at a time, the maximum number of deliveries that can
17598 then take place at once is &%queue_run_max%& multiplied by
17599 &%remote_max_parallel%&.
17600
17601 If it is purely remote deliveries you want to control, use
17602 &%queue_smtp_domains%& instead of &%queue_only%&. This has the added benefit of
17603 doing the SMTP routing before queueing, so that several messages for the same
17604 host will eventually get delivered down the same connection.
17605
17606
17607 .option remote_sort_domains main "domain list&!!" unset
17608 .cindex "sorting remote deliveries"
17609 .cindex "delivery" "sorting remote"
17610 When there are a number of remote deliveries for a message, they are sorted by
17611 domain into the order given by this list. For example,
17612 .code
17613 remote_sort_domains = *.cam.ac.uk:*.uk
17614 .endd
17615 would attempt to deliver to all addresses in the &'cam.ac.uk'& domain first,
17616 then to those in the &%uk%& domain, then to any others.
17617
17618
17619 .option retry_data_expire main time 7d
17620 .cindex "hints database" "data expiry"
17621 This option sets a &"use before"& time on retry information in Exim's hints
17622 database. Any older retry data is ignored. This means that, for example, once a
17623 host has not been tried for 7 days, Exim behaves as if it has no knowledge of
17624 past failures.
17625
17626
17627 .option retry_interval_max main time 24h
17628 .cindex "retry" "limit on interval"
17629 .cindex "limit" "on retry interval"
17630 Chapter &<<CHAPretry>>& describes Exim's mechanisms for controlling the
17631 intervals between delivery attempts for messages that cannot be delivered
17632 straight away. This option sets an overall limit to the length of time between
17633 retries. It cannot be set greater than 24 hours; any attempt to do so forces
17634 the default value.
17635
17636
17637 .option return_path_remove main boolean true
17638 .cindex "&'Return-path:'& header line" "removing"
17639 RFC 2821, section 4.4, states that an SMTP server must insert a
17640 &'Return-path:'& header line into a message when it makes a &"final delivery"&.
17641 The &'Return-path:'& header preserves the sender address as received in the
17642 MAIL command. This description implies that this header should not be present
17643 in an incoming message. If &%return_path_remove%& is true, any existing
17644 &'Return-path:'& headers are removed from messages at the time they are
17645 received. Exim's transports have options for adding &'Return-path:'& headers at
17646 the time of delivery. They are normally used only for final local deliveries.
17647
17648
17649 .option return_size_limit main integer 100K
17650 This option is an obsolete synonym for &%bounce_return_size_limit%&.
17651
17652
17653 .option rfc1413_hosts main "host list&!!" @[]
17654 .cindex "RFC 1413"
17655 .cindex "host" "for RFC 1413 calls"
17656 RFC 1413 identification calls are made to any client host which matches
17657 an item in the list.
17658 The default value specifies just this host, being any local interface
17659 for the system.
17660
17661 .option rfc1413_query_timeout main time 0s
17662 .cindex "RFC 1413" "query timeout"
17663 .cindex "timeout" "for RFC 1413 call"
17664 This sets the timeout on RFC 1413 identification calls. If it is set to zero,
17665 no RFC 1413 calls are ever made.
17666
17667
17668 .option sender_unqualified_hosts main "host list&!!" unset
17669 .cindex "unqualified addresses"
17670 .cindex "host" "unqualified addresses from"
17671 This option lists those hosts from which Exim is prepared to accept unqualified
17672 sender addresses. The addresses are made fully qualified by the addition of
17673 &%qualify_domain%&. This option also affects message header lines. Exim does
17674 not reject unqualified addresses in headers that contain sender addresses, but
17675 it qualifies them only if the message came from a host that matches
17676 &%sender_unqualified_hosts%&, or if the message was submitted locally (not
17677 using TCP/IP), and the &%-bnq%& option was not set.
17678
17679
17680 .option slow_lookup_log main integer 0
17681 .cindex "logging" "slow lookups"
17682 .cindex "dns" "logging slow lookups"
17683 This option controls logging of slow lookups.
17684 If the value is nonzero it is taken as a number of milliseconds
17685 and lookups taking longer than this are logged.
17686 Currently this applies only to DNS lookups.
17687
17688
17689
17690 .option smtp_accept_keepalive main boolean true
17691 .cindex "keepalive" "on incoming connection"
17692 This option controls the setting of the SO_KEEPALIVE option on incoming
17693 TCP/IP socket connections. When set, it causes the kernel to probe idle
17694 connections periodically, by sending packets with &"old"& sequence numbers. The
17695 other end of the connection should send an acknowledgment if the connection is
17696 still okay or a reset if the connection has been aborted. The reason for doing
17697 this is that it has the beneficial effect of freeing up certain types of
17698 connection that can get stuck when the remote host is disconnected without
17699 tidying up the TCP/IP call properly. The keepalive mechanism takes several
17700 hours to detect unreachable hosts.
17701
17702
17703
17704 .option smtp_accept_max main integer 20
17705 .cindex "limit" "incoming SMTP connections"
17706 .cindex "SMTP" "incoming connection count"
17707 .cindex "inetd"
17708 This option specifies the maximum number of simultaneous incoming SMTP calls
17709 that Exim will accept. It applies only to the listening daemon; there is no
17710 control (in Exim) when incoming SMTP is being handled by &'inetd'&. If the
17711 value is set to zero, no limit is applied. However, it is required to be
17712 non-zero if either &%smtp_accept_max_per_host%& or &%smtp_accept_queue%& is
17713 set. See also &%smtp_accept_reserve%& and &%smtp_load_reserve%&.
17714
17715 A new SMTP connection is immediately rejected if the &%smtp_accept_max%& limit
17716 has been reached. If not, Exim first checks &%smtp_accept_max_per_host%&. If
17717 that limit has not been reached for the client host, &%smtp_accept_reserve%&
17718 and &%smtp_load_reserve%& are then checked before accepting the connection.
17719
17720
17721 .option smtp_accept_max_nonmail main integer 10
17722 .cindex "limit" "non-mail SMTP commands"
17723 .cindex "SMTP" "limiting non-mail commands"
17724 Exim counts the number of &"non-mail"& commands in an SMTP session, and drops
17725 the connection if there are too many. This option defines &"too many"&. The
17726 check catches some denial-of-service attacks, repeated failing AUTHs, or a mad
17727 client looping sending EHLO, for example. The check is applied only if the
17728 client host matches &%smtp_accept_max_nonmail_hosts%&.
17729
17730 When a new message is expected, one occurrence of RSET is not counted. This
17731 allows a client to send one RSET between messages (this is not necessary,
17732 but some clients do it). Exim also allows one uncounted occurrence of HELO
17733 or EHLO, and one occurrence of STARTTLS between messages. After
17734 starting up a TLS session, another EHLO is expected, and so it too is not
17735 counted. The first occurrence of AUTH in a connection, or immediately
17736 following STARTTLS is not counted. Otherwise, all commands other than
17737 MAIL, RCPT, DATA, and QUIT are counted.
17738
17739
17740 .option smtp_accept_max_nonmail_hosts main "host list&!!" *
17741 You can control which hosts are subject to the &%smtp_accept_max_nonmail%&
17742 check by setting this option. The default value makes it apply to all hosts. By
17743 changing the value, you can exclude any badly-behaved hosts that you have to
17744 live with.
17745
17746
17747 . Allow this long option name to split; give it unsplit as a fifth argument
17748 . for the automatic .oindex that is generated by .option.
17749 . We insert " &~&~" which is both pretty nasty visually and results in
17750 . non-searchable text.  HowItWorks.txt mentions an option for inserting
17751 . zero-width-space, which would be nicer visually and results in (at least)
17752 . html that Firefox will split on when it's forced to reflow (rather than
17753 . inserting a horizontal scrollbar).  However, the text is still not
17754 . searchable.  NM changed this occurrence for bug 1197 to no longer allow
17755 . the option name to split.
17756
17757 .option "smtp_accept_max_per_connection" main integer&!! 1000 &&&
17758          smtp_accept_max_per_connection
17759 .cindex "SMTP" "limiting incoming message count"
17760 .cindex "limit" "messages per SMTP connection"
17761 The value of this option limits the number of MAIL commands that Exim is
17762 prepared to accept over a single SMTP connection, whether or not each command
17763 results in the transfer of a message. After the limit is reached, a 421
17764 response is given to subsequent MAIL commands. This limit is a safety
17765 precaution against a client that goes mad (incidents of this type have been
17766 seen).
17767 The option is expanded after the HELO or EHLO is received
17768 and may depend on values available at that time.
17769 An empty or zero value after expansion removes the limit.
17770
17771
17772 .option smtp_accept_max_per_host main string&!! unset
17773 .cindex "limit" "SMTP connections from one host"
17774 .cindex "host" "limiting SMTP connections from"
17775 This option restricts the number of simultaneous IP connections from a single
17776 host (strictly, from a single IP address) to the Exim daemon. The option is
17777 expanded, to enable different limits to be applied to different hosts by
17778 reference to &$sender_host_address$&. Once the limit is reached, additional
17779 connection attempts from the same host are rejected with error code 421. This
17780 is entirely independent of &%smtp_accept_reserve%&. The option's default value
17781 of zero imposes no limit. If this option is set greater than zero, it is
17782 required that &%smtp_accept_max%& be non-zero.
17783
17784 &*Warning*&: When setting this option you should not use any expansion
17785 constructions that take an appreciable amount of time. The expansion and test
17786 happen in the main daemon loop, in order to reject additional connections
17787 without forking additional processes (otherwise a denial-of-service attack
17788 could cause a vast number or processes to be created). While the daemon is
17789 doing this processing, it cannot accept any other incoming connections.
17790
17791
17792
17793 .option smtp_accept_queue main integer 0
17794 .cindex "SMTP" "incoming connection count"
17795 .cindex "queueing incoming messages"
17796 .cindex "message" "queueing by SMTP connection count"
17797 If the number of simultaneous incoming SMTP connections being handled via the
17798 listening daemon exceeds this value, messages received by SMTP are just placed
17799 in the queue; no delivery processes are started automatically. The count is
17800 fixed at the start of an SMTP connection. It cannot be updated in the
17801 subprocess that receives messages, and so the queueing or not queueing applies
17802 to all messages received in the same connection.
17803
17804 A value of zero implies no limit, and clearly any non-zero value is useful only
17805 if it is less than the &%smtp_accept_max%& value (unless that is zero). See
17806 also &%queue_only%&, &%queue_only_load%&, &%queue_smtp_domains%&, and the
17807 various &%-od%&&'x'& command line options.
17808
17809
17810 . See the comment on smtp_accept_max_per_connection
17811
17812 .option "smtp_accept_queue_per_connection" main integer 10 &&&
17813          smtp_accept_queue_per_connection
17814 .cindex "queueing incoming messages"
17815 .cindex "message" "queueing by message count"
17816 This option limits the number of delivery processes that Exim starts
17817 automatically when receiving messages via SMTP, whether via the daemon or by
17818 the use of &%-bs%& or &%-bS%&. If the value of the option is greater than zero,
17819 and the number of messages received in a single SMTP session exceeds this
17820 number, subsequent messages are placed in the queue, but no delivery processes
17821 are started. This helps to limit the number of Exim processes when a server
17822 restarts after downtime and there is a lot of mail waiting for it on other
17823 systems. On large systems, the default should probably be increased, and on
17824 dial-in client systems it should probably be set to zero (that is, disabled).
17825
17826
17827 .option smtp_accept_reserve main integer 0
17828 .cindex "SMTP" "incoming call count"
17829 .cindex "host" "reserved"
17830 When &%smtp_accept_max%& is set greater than zero, this option specifies a
17831 number of SMTP connections that are reserved for connections from the hosts
17832 that are specified in &%smtp_reserve_hosts%&. The value set in
17833 &%smtp_accept_max%& includes this reserve pool. The specified hosts are not
17834 restricted to this number of connections; the option specifies a minimum number
17835 of connection slots for them, not a maximum. It is a guarantee that this group
17836 of hosts can always get at least &%smtp_accept_reserve%& connections. However,
17837 the limit specified by &%smtp_accept_max_per_host%& is still applied to each
17838 individual host.
17839
17840 For example, if &%smtp_accept_max%& is set to 50 and &%smtp_accept_reserve%& is
17841 set to 5, once there are 45 active connections (from any hosts), new
17842 connections are accepted only from hosts listed in &%smtp_reserve_hosts%&,
17843 provided the other criteria for acceptance are met.
17844
17845
17846 .option smtp_active_hostname main string&!! unset
17847 .cindex "host" "name in SMTP responses"
17848 .cindex "SMTP" "host name in responses"
17849 .vindex "&$primary_hostname$&"
17850 This option is provided for multi-homed servers that want to masquerade as
17851 several different hosts. At the start of an incoming SMTP connection, its value
17852 is expanded and used instead of the value of &$primary_hostname$& in SMTP
17853 responses. For example, it is used as domain name in the response to an
17854 incoming HELO or EHLO command.
17855
17856 .vindex "&$smtp_active_hostname$&"
17857 The active hostname is placed in the &$smtp_active_hostname$& variable, which
17858 is saved with any messages that are received. It is therefore available for use
17859 in routers and transports when the message is later delivered.
17860
17861 If this option is unset, or if its expansion is forced to fail, or if the
17862 expansion results in an empty string, the value of &$primary_hostname$& is
17863 used. Other expansion failures cause a message to be written to the main and
17864 panic logs, and the SMTP command receives a temporary error. Typically, the
17865 value of &%smtp_active_hostname%& depends on the incoming interface address.
17866 For example:
17867 .code
17868 smtp_active_hostname = ${if eq{$received_ip_address}{10.0.0.1}\
17869   {cox.mydomain}{box.mydomain}}
17870 .endd
17871
17872 Although &$smtp_active_hostname$& is primarily concerned with incoming
17873 messages, it is also used as the default for HELO commands in callout
17874 verification if there is no remote transport from which to obtain a
17875 &%helo_data%& value.
17876
17877 .option smtp_backlog_monitor main integer 0
17878 .cindex "connection backlog" monitoring
17879 If this option is set to greater than zero, and the backlog of available
17880 TCP connections on a socket listening for SMTP is larger than it, a line
17881 is logged giving the value and the socket address and port.
17882 The value is retrived jsut before an accept call.
17883 This facility is only available on Linux.
17884
17885 .option smtp_banner main string&!! "see below"
17886 .cindex "SMTP" "welcome banner"
17887 .cindex "banner for SMTP"
17888 .cindex "welcome banner for SMTP"
17889 .cindex "customizing" "SMTP banner"
17890 If a connect ACL does not supply a message,
17891 this string (which is expanded every time it is used) is output as the initial
17892 positive response to an SMTP connection. The default setting is:
17893 .code
17894 smtp_banner = $smtp_active_hostname ESMTP Exim \
17895   $version_number $tod_full
17896 .endd
17897 Failure to expand the string causes a panic error;
17898 a forced fail just closes the connection.
17899 If you want to create a
17900 multiline response to the initial SMTP connection, use &"\n"& in the string at
17901 appropriate points, but not at the end. Note that the 220 code is not included
17902 in this string. Exim adds it automatically (several times in the case of a
17903 multiline response).
17904
17905
17906 .option smtp_check_spool_space main boolean true
17907 .cindex "checking disk space"
17908 .cindex "disk space, checking"
17909 .cindex "spool directory" "checking space"
17910 When this option is set, if an incoming SMTP session encounters the SIZE
17911 option on a MAIL command, it checks that there is enough space in the
17912 spool directory's partition to accept a message of that size, while still
17913 leaving free the amount specified by &%check_spool_space%& (even if that value
17914 is zero). If there isn't enough space, a temporary error code is returned.
17915
17916
17917 .option smtp_connect_backlog main integer 20
17918 .cindex "connection backlog" "set maximum"
17919 .cindex "SMTP" "connection backlog"
17920 .cindex "backlog of connections"
17921 This option specifies a maximum number of waiting SMTP connections. Exim passes
17922 this value to the TCP/IP system when it sets up its listener. Once this number
17923 of connections are waiting for the daemon's attention, subsequent connection
17924 attempts are refused at the TCP/IP level. At least, that is what the manuals
17925 say; in some circumstances such connection attempts have been observed to time
17926 out instead. For large systems it is probably a good idea to increase the
17927 value (to 50, say). It also gives some protection against denial-of-service
17928 attacks by SYN flooding.
17929
17930
17931 .option smtp_enforce_sync main boolean true
17932 .cindex "SMTP" "synchronization checking"
17933 .cindex "synchronization checking in SMTP"
17934 The SMTP protocol specification requires the client to wait for a response from
17935 the server at certain points in the dialogue. Without PIPELINING these
17936 synchronization points are after every command; with PIPELINING they are
17937 fewer, but they still exist.
17938
17939 Some spamming sites send out a complete set of SMTP commands without waiting
17940 for any response. Exim protects against this by rejecting a message if the
17941 client has sent further input when it should not have. The error response &"554
17942 SMTP synchronization error"& is sent, and the connection is dropped. Testing
17943 for this error cannot be perfect because of transmission delays (unexpected
17944 input may be on its way but not yet received when Exim checks). However, it
17945 does detect many instances.
17946
17947 The check can be globally disabled by setting &%smtp_enforce_sync%& false.
17948 If you want to disable the check selectively (for example, only for certain
17949 hosts), you can do so by an appropriate use of a &%control%& modifier in an ACL
17950 (see section &<<SECTcontrols>>&). See also &%pipelining_advertise_hosts%&.
17951
17952
17953
17954 .option smtp_etrn_command main string&!! unset
17955 .cindex "ETRN" "command to be run"
17956 .cindex "ESMTP extensions" ETRN
17957 .vindex "&$domain$&"
17958 If this option is set, the given command is run whenever an SMTP ETRN
17959 command is received from a host that is permitted to issue such commands (see
17960 chapter &<<CHAPACL>>&). The string is split up into separate arguments which
17961 are independently expanded. The expansion variable &$domain$& is set to the
17962 argument of the ETRN command, and no syntax checking is done on it. For
17963 example:
17964 .code
17965 smtp_etrn_command = /etc/etrn_command $domain \
17966                     $sender_host_address
17967 .endd
17968 If the option is not set, the argument for the ETRN command must
17969 be a &'#'& followed by an address string.
17970 In this case an &'exim -R <string>'& command is used;
17971 if the ETRN ACL has set up a named-queue then &'-MCG <queue>'& is appended.
17972
17973 A new process is created to run the command, but Exim does not wait for it to
17974 complete. Consequently, its status cannot be checked. If the command cannot be
17975 run, a line is written to the panic log, but the ETRN caller still receives
17976 a 250 success response. Exim is normally running under its own uid when
17977 receiving SMTP, so it is not possible for it to change the uid before running
17978 the command.
17979
17980
17981 .option smtp_etrn_serialize main boolean true
17982 .cindex "ETRN" "serializing"
17983 When this option is set, it prevents the simultaneous execution of more than
17984 one identical command as a result of ETRN in an SMTP connection. See
17985 section &<<SECTETRN>>& for details.
17986
17987
17988 .option smtp_load_reserve main fixed-point unset
17989 .cindex "load average"
17990 If the system load average ever gets higher than this, incoming SMTP calls are
17991 accepted only from those hosts that match an entry in &%smtp_reserve_hosts%&.
17992 If &%smtp_reserve_hosts%& is not set, no incoming SMTP calls are accepted when
17993 the load is over the limit. The option has no effect on ancient operating
17994 systems on which Exim cannot determine the load average. See also
17995 &%deliver_queue_load_max%& and &%queue_only_load%&.
17996
17997
17998
17999 .option smtp_max_synprot_errors main integer 3
18000 .cindex "SMTP" "limiting syntax and protocol errors"
18001 .cindex "limit" "SMTP syntax and protocol errors"
18002 Exim rejects SMTP commands that contain syntax or protocol errors. In
18003 particular, a syntactically invalid email address, as in this command:
18004 .code
18005 RCPT TO:<abc xyz@a.b.c>
18006 .endd
18007 causes immediate rejection of the command, before any other tests are done.
18008 (The ACL cannot be run if there is no valid address to set up for it.) An
18009 example of a protocol error is receiving RCPT before MAIL. If there are
18010 too many syntax or protocol errors in one SMTP session, the connection is
18011 dropped. The limit is set by this option.
18012
18013 .cindex "PIPELINING" "expected errors"
18014 When the PIPELINING extension to SMTP is in use, some protocol errors are
18015 &"expected"&, for instance, a RCPT command after a rejected MAIL command.
18016 Exim assumes that PIPELINING will be used if it advertises it (see
18017 &%pipelining_advertise_hosts%&), and in this situation, &"expected"& errors do
18018 not count towards the limit.
18019
18020
18021
18022 .option smtp_max_unknown_commands main integer 3
18023 .cindex "SMTP" "limiting unknown commands"
18024 .cindex "limit" "unknown SMTP commands"
18025 If there are too many unrecognized commands in an incoming SMTP session, an
18026 Exim server drops the connection. This is a defence against some kinds of abuse
18027 that subvert web
18028 clients
18029 into making connections to SMTP ports; in these circumstances, a number of
18030 non-SMTP command lines are sent first.
18031
18032
18033
18034 .options smtp_ratelimit_hosts main "host list&!!" unset &&&
18035          smtp_ratelimit_mail main string unset &&&
18036          smtp_ratelimit_rcpt main string unset
18037 .cindex "SMTP" "rate limiting"
18038 .cindex "limit" "rate of message arrival"
18039 .cindex "RCPT" "rate limiting"
18040 Some sites find it helpful to be able to limit the rate at which certain hosts
18041 can send them messages, and the rate at which an individual message can specify
18042 recipients.
18043
18044 Exim has two rate-limiting facilities. This section describes the older
18045 facility, which can limit rates within a single connection. The newer
18046 &%ratelimit%& ACL condition can limit rates across all connections. See section
18047 &<<SECTratelimiting>>& for details of the newer facility.
18048
18049 When a host matches &%smtp_ratelimit_hosts%&, the values of
18050 &%smtp_ratelimit_mail%& and &%smtp_ratelimit_rcpt%& are used to control the
18051 rate of acceptance of MAIL and RCPT commands in a single SMTP session,
18052 respectively. Each option, if set, must contain a set of four comma-separated
18053 values:
18054
18055 .ilist
18056 A threshold, before which there is no rate limiting.
18057 .next
18058 An initial time delay. Unlike other times in Exim, numbers with decimal
18059 fractional parts are allowed here.
18060 .next
18061 A factor by which to increase the delay each time.
18062 .next
18063 A maximum value for the delay. This should normally be less than 5 minutes,
18064 because after that time, the client is liable to timeout the SMTP command.
18065 .endlist
18066
18067 For example, these settings have been used successfully at the site which
18068 first suggested this feature, for controlling mail from their customers:
18069 .code
18070 smtp_ratelimit_mail = 2,0.5s,1.05,4m
18071 smtp_ratelimit_rcpt = 4,0.25s,1.015,4m
18072 .endd
18073 The first setting specifies delays that are applied to MAIL commands after
18074 two have been received over a single connection. The initial delay is 0.5
18075 seconds, increasing by a factor of 1.05 each time. The second setting applies
18076 delays to RCPT commands when more than four occur in a single message.
18077
18078
18079
18080 .option smtp_receive_timeout main time&!! 5m
18081 .cindex "timeout" "for SMTP input"
18082 .cindex "SMTP" "input timeout"
18083 This sets a timeout value for SMTP reception. It applies to all forms of SMTP
18084 input, including batch SMTP. If a line of input (either an SMTP command or a
18085 data line) is not received within this time, the SMTP connection is dropped and
18086 the message is abandoned.
18087 A line is written to the log containing one of the following messages:
18088 .code
18089 SMTP command timeout on connection from...
18090 SMTP data timeout on connection from...
18091 .endd
18092 The former means that Exim was expecting to read an SMTP command; the latter
18093 means that it was in the DATA phase, reading the contents of a message.
18094
18095 If the first character of the option is a &"$"& the option is
18096 expanded before use and may depend on
18097 &$sender_host_name$&, &$sender_host_address$& and &$sender_host_port$&.
18098
18099
18100 .oindex "&%-os%&"
18101 The value set by this option can be overridden by the
18102 &%-os%& command-line option. A setting of zero time disables the timeout, but
18103 this should never be used for SMTP over TCP/IP. (It can be useful in some cases
18104 of local input using &%-bs%& or &%-bS%&.) For non-SMTP input, the reception
18105 timeout is controlled by &%receive_timeout%& and &%-or%&.
18106
18107
18108 .option smtp_reserve_hosts main "host list&!!" unset
18109 This option defines hosts for which SMTP connections are reserved; see
18110 &%smtp_accept_reserve%& and &%smtp_load_reserve%& above.
18111
18112
18113 .option smtp_return_error_details main boolean false
18114 .cindex "SMTP" "details policy failures"
18115 .cindex "policy control" "rejection, returning details"
18116 In the default state, Exim uses bland messages such as
18117 &"Administrative prohibition"& when it rejects SMTP commands for policy
18118 reasons. Many sysadmins like this because it gives away little information
18119 to spammers. However, some other sysadmins who are applying strict checking
18120 policies want to give out much fuller information about failures. Setting
18121 &%smtp_return_error_details%& true causes Exim to be more forthcoming. For
18122 example, instead of &"Administrative prohibition"&, it might give:
18123 .code
18124 550-Rejected after DATA: '>' missing at end of address:
18125 550 failing address in "From" header is: <user@dom.ain
18126 .endd
18127
18128
18129 .option smtputf8_advertise_hosts main "host list&!!" *
18130 .cindex "SMTPUTF8" "ESMTP extension, advertising"
18131 .cindex "ESMTP extensions" SMTPUTF8
18132 When Exim is built with support for internationalised mail names,
18133 the availability thereof is advertised in
18134 response to EHLO only to those client hosts that match this option. See
18135 chapter &<<CHAPi18n>>& for details of Exim's support for internationalisation.
18136
18137
18138 .option spamd_address main string "127.0.0.1 783"
18139 This option is available when Exim is compiled with the content-scanning
18140 extension. It specifies how Exim connects to SpamAssassin's &%spamd%& daemon.
18141 See section &<<SECTscanspamass>>& for more details.
18142
18143
18144
18145 .option spf_guess main string "v=spf1 a/24 mx/24 ptr ?all"
18146 This option is available when Exim is compiled with SPF support.
18147 See section &<<SECSPF>>& for more details.
18148
18149 .option spf_smtp_comment_template main string&!! "Please%_see%_http://www.open-spf.org/Why"
18150 This option is available when Exim is compiled with SPF support.  It
18151 allows the customisation of the SMTP comment that the SPF library
18152 generates.  You are strongly encouraged to link to your own explanative
18153 site. The template must not contain spaces. If you need spaces in the
18154 output, use the proper placeholder. If libspf2 can not parse the
18155 template, it uses a built-in default broken link. The following placeholders
18156 (along with Exim variables (but see below)) are allowed in the template:
18157 .ilist
18158 &*%_*&: A space.
18159 .next
18160 &*%{L}*&: Envelope sender's local part.
18161 .next
18162 &*%{S}*&: Envelope sender.
18163 .next
18164 &*%{O}*&: Envelope sender's domain.
18165 .next
18166 &*%{D}*&: Current(?) domain.
18167 .next
18168 &*%{I}*&: SMTP client Ip.
18169 .next
18170 &*%{C}*&: SMTP client pretty IP.
18171 .next
18172 &*%{T}*&: Epoch time (UTC).
18173 .next
18174 &*%{P}*&: SMTP client domain name.
18175 .next
18176 &*%{V}*&: IP version.
18177 .next
18178 &*%{H}*&: EHLO/HELO domain.
18179 .next
18180 &*%{R}*&: Receiving domain.
18181 .endlist
18182 The capitalized placeholders do proper URL encoding, if you use them
18183 lowercased, no encoding takes place.  This list was compiled from the
18184 libspf2 sources.
18185
18186 A note on using Exim variables: As
18187 currently the SPF library is initialized before the SMTP EHLO phase,
18188 the variables useful for expansion are quite limited.
18189
18190
18191 .option split_spool_directory main boolean false
18192 .cindex "multiple spool directories"
18193 .cindex "spool directory" "split"
18194 .cindex "directories, multiple"
18195 If this option is set, it causes Exim to split its input directory into 62
18196 subdirectories, each with a single alphanumeric character as its name. The
18197 sixth character of the message id is used to allocate messages to
18198 subdirectories; this is the least significant base-62 digit of the time of
18199 arrival of the message.
18200
18201 Splitting up the spool in this way may provide better performance on systems
18202 where there are long mail queues, by reducing the number of files in any one
18203 directory. The msglog directory is also split up in a similar way to the input
18204 directory; however, if &%preserve_message_logs%& is set, all old msglog files
18205 are still placed in the single directory &_msglog.OLD_&.
18206
18207 It is not necessary to take any special action for existing messages when
18208 changing &%split_spool_directory%&. Exim notices messages that are in the
18209 &"wrong"& place, and continues to process them. If the option is turned off
18210 after a period of being on, the subdirectories will eventually empty and be
18211 automatically deleted.
18212
18213 When &%split_spool_directory%& is set, the behaviour of queue runner processes
18214 changes. Instead of creating a list of all messages in the queue, and then
18215 trying to deliver each one, in turn, it constructs a list of those in one
18216 sub-directory and tries to deliver them, before moving on to the next
18217 sub-directory. The sub-directories are processed in a random order. This
18218 spreads out the scanning of the input directories, and uses less memory. It is
18219 particularly beneficial when there are lots of messages in the queue. However,
18220 if &%queue_run_in_order%& is set, none of this new processing happens. The
18221 entire queue has to be scanned and sorted before any deliveries can start.
18222
18223
18224 .option spool_directory main string&!! "set at compile time"
18225 .cindex "spool directory" "path to"
18226 This defines the directory in which Exim keeps its spool, that is, the messages
18227 it is waiting to deliver. The default value is taken from the compile-time
18228 configuration setting, if there is one. If not, this option must be set. The
18229 string is expanded, so it can contain, for example, a reference to
18230 &$primary_hostname$&.
18231
18232 If the spool directory name is fixed on your installation, it is recommended
18233 that you set it at build time rather than from this option, particularly if the
18234 log files are being written to the spool directory (see &%log_file_path%&).
18235 Otherwise log files cannot be used for errors that are detected early on, such
18236 as failures in the configuration file.
18237
18238 By using this option to override the compiled-in path, it is possible to run
18239 tests of Exim without using the standard spool.
18240
18241 .option spool_wireformat main boolean false
18242 .cindex "spool directory" "file formats"
18243 If this option is set, Exim may for some messages use an alternative format
18244 for data-files in the spool which matches the wire format.
18245 Doing this permits more efficient message reception and transmission.
18246 Currently it is only done for messages received using the ESMTP CHUNKING
18247 option.
18248
18249 The following variables will not have useful values:
18250 .code
18251 $max_received_linelength
18252 $body_linecount
18253 $body_zerocount
18254 .endd
18255
18256 Users of the local_scan() API (see &<<CHAPlocalscan>>&),
18257 and any external programs which are passed a reference to a message data file
18258 (except via the &"regex"&, &"malware"& or &"spam"&) ACL conditions)
18259 will need to be aware of the different formats potentially available.
18260
18261 Using any of the ACL conditions noted will negate the reception benefit
18262 (as a Unix-mbox-format file is constructed for them).
18263 The transmission benefit is maintained.
18264
18265 .option sqlite_lock_timeout main time 5s
18266 .cindex "sqlite lookup type" "lock timeout"
18267 This option controls the timeout that the &(sqlite)& lookup uses when trying to
18268 access an SQLite database. See section &<<SECTsqlite>>& for more details.
18269
18270 .option strict_acl_vars main boolean false
18271 .cindex "&ACL;" "variables, handling unset"
18272 This option controls what happens if a syntactically valid but undefined ACL
18273 variable is referenced. If it is false (the default), an empty string
18274 is substituted; if it is true, an error is generated. See section
18275 &<<SECTaclvariables>>& for details of ACL variables.
18276
18277 .option strip_excess_angle_brackets main boolean false
18278 .cindex "angle brackets, excess"
18279 If this option is set, redundant pairs of angle brackets round &"route-addr"&
18280 items in addresses are stripped. For example, &'<<xxx@a.b.c.d>>'& is
18281 treated as &'<xxx@a.b.c.d>'&. If this is in the envelope and the message is
18282 passed on to another MTA, the excess angle brackets are not passed on. If this
18283 option is not set, multiple pairs of angle brackets cause a syntax error.
18284
18285
18286 .option strip_trailing_dot main boolean false
18287 .cindex "trailing dot on domain"
18288 .cindex "dot" "trailing on domain"
18289 If this option is set, a trailing dot at the end of a domain in an address is
18290 ignored. If this is in the envelope and the message is passed on to another
18291 MTA, the dot is not passed on. If this option is not set, a dot at the end of a
18292 domain causes a syntax error.
18293 However, addresses in header lines are checked only when an ACL requests header
18294 syntax checking.
18295
18296
18297 .option syslog_duplication main boolean true
18298 .cindex "syslog" "duplicate log lines; suppressing"
18299 When Exim is logging to syslog, it writes the log lines for its three
18300 separate logs at different syslog priorities so that they can in principle
18301 be separated on the logging hosts. Some installations do not require this
18302 separation, and in those cases, the duplication of certain log lines is a
18303 nuisance. If &%syslog_duplication%& is set false, only one copy of any
18304 particular log line is written to syslog. For lines that normally go to
18305 both the main log and the reject log, the reject log version (possibly
18306 containing message header lines) is written, at LOG_NOTICE priority.
18307 Lines that normally go to both the main and the panic log are written at
18308 the LOG_ALERT priority.
18309
18310
18311 .option syslog_facility main string unset
18312 .cindex "syslog" "facility; setting"
18313 This option sets the syslog &"facility"& name, used when Exim is logging to
18314 syslog. The value must be one of the strings &"mail"&, &"user"&, &"news"&,
18315 &"uucp"&, &"daemon"&, or &"local&'x'&"& where &'x'& is a digit between 0 and 7.
18316 If this option is unset, &"mail"& is used. See chapter &<<CHAPlog>>& for
18317 details of Exim's logging.
18318
18319
18320 .option syslog_pid main boolean true
18321 .cindex "syslog" "pid"
18322 If &%syslog_pid%& is set false, the PID on Exim's log lines are
18323 omitted when these lines are sent to syslog. (Syslog normally prefixes
18324 the log lines with the PID of the logging process automatically.) You need
18325 to enable the &`+pid`& log selector item, if you want Exim to write it's PID
18326 into the logs.) See chapter &<<CHAPlog>>& for details of Exim's logging.
18327
18328
18329
18330 .option syslog_processname main string &`exim`&
18331 .cindex "syslog" "process name; setting"
18332 This option sets the syslog &"ident"& name, used when Exim is logging to
18333 syslog. The value must be no longer than 32 characters. See chapter
18334 &<<CHAPlog>>& for details of Exim's logging.
18335
18336
18337
18338 .option syslog_timestamp main boolean true
18339 .cindex "syslog" "timestamps"
18340 .cindex timestamps syslog
18341 If &%syslog_timestamp%& is set false, the timestamps on Exim's log lines are
18342 omitted when these lines are sent to syslog. See chapter &<<CHAPlog>>& for
18343 details of Exim's logging.
18344
18345
18346 .option system_filter main string&!! unset
18347 .cindex "filter" "system filter"
18348 .cindex "system filter" "specifying"
18349 .cindex "Sieve filter" "not available for system filter"
18350 This option specifies an Exim filter file that is applied to all messages at
18351 the start of each delivery attempt, before any routing is done. System filters
18352 must be Exim filters; they cannot be Sieve filters. If the system filter
18353 generates any deliveries to files or pipes, or any new mail messages, the
18354 appropriate &%system_filter_..._transport%& option(s) must be set, to define
18355 which transports are to be used. Details of this facility are given in chapter
18356 &<<CHAPsystemfilter>>&.
18357 A forced expansion failure results in no filter operation.
18358
18359
18360 .option system_filter_directory_transport main string&!! unset
18361 .vindex "&$address_file$&"
18362 This sets the name of the transport driver that is to be used when the
18363 &%save%& command in a system message filter specifies a path ending in &"/"&,
18364 implying delivery of each message into a separate file in some directory.
18365 During the delivery, the variable &$address_file$& contains the path name.
18366
18367
18368 .option system_filter_file_transport main string&!! unset
18369 .cindex "file" "transport for system filter"
18370 This sets the name of the transport driver that is to be used when the &%save%&
18371 command in a system message filter specifies a path not ending in &"/"&. During
18372 the delivery, the variable &$address_file$& contains the path name.
18373
18374 .option system_filter_group main string unset
18375 .cindex "gid (group id)" "system filter"
18376 This option is used only when &%system_filter_user%& is also set. It sets the
18377 gid under which the system filter is run, overriding any gid that is associated
18378 with the user. The value may be numerical or symbolic.
18379
18380 .option system_filter_pipe_transport main string&!! unset
18381 .cindex "&(pipe)& transport" "for system filter"
18382 .vindex "&$address_pipe$&"
18383 This specifies the transport driver that is to be used when a &%pipe%& command
18384 is used in a system filter. During the delivery, the variable &$address_pipe$&
18385 contains the pipe command.
18386
18387
18388 .option system_filter_reply_transport main string&!! unset
18389 .cindex "&(autoreply)& transport" "for system filter"
18390 This specifies the transport driver that is to be used when a &%mail%& command
18391 is used in a system filter.
18392
18393
18394 .option system_filter_user main string unset
18395 .cindex "uid (user id)" "system filter"
18396 If this option is set to root, the system filter is run in the main Exim
18397 delivery process, as root.  Otherwise, the system filter runs in a separate
18398 process, as the given user, defaulting to the Exim run-time user.
18399 Unless the string consists entirely of digits, it
18400 is looked up in the password data. Failure to find the named user causes a
18401 configuration error. The gid is either taken from the password data, or
18402 specified by &%system_filter_group%&. When the uid is specified numerically,
18403 &%system_filter_group%& is required to be set.
18404
18405 If the system filter generates any pipe, file, or reply deliveries, the uid
18406 under which the filter is run is used when transporting them, unless a
18407 transport option overrides.
18408
18409
18410 .option tcp_nodelay main boolean true
18411 .cindex "daemon" "TCP_NODELAY on sockets"
18412 .cindex "Nagle algorithm"
18413 .cindex "TCP_NODELAY on listening sockets"
18414 If this option is set false, it stops the Exim daemon setting the
18415 TCP_NODELAY option on its listening sockets. Setting TCP_NODELAY
18416 turns off the &"Nagle algorithm"&, which is a way of improving network
18417 performance in interactive (character-by-character) situations. Turning it off
18418 should improve Exim's performance a bit, so that is what happens by default.
18419 However, it appears that some broken clients cannot cope, and time out. Hence
18420 this option. It affects only those sockets that are set up for listening by the
18421 daemon. Sockets created by the smtp transport for delivering mail always set
18422 TCP_NODELAY.
18423
18424
18425 .option timeout_frozen_after main time 0s
18426 .cindex "frozen messages" "timing out"
18427 .cindex "timeout" "frozen messages"
18428 If &%timeout_frozen_after%& is set to a time greater than zero, a frozen
18429 message of any kind that has been in the queue for longer than the given time
18430 is automatically cancelled at the next queue run. If the frozen message is a
18431 bounce message, it is just discarded; otherwise, a bounce is sent to the
18432 sender, in a similar manner to cancellation by the &%-Mg%& command line option.
18433 If you want to timeout frozen bounce messages earlier than other kinds of
18434 frozen message, see &%ignore_bounce_errors_after%&.
18435
18436 &*Note:*& the default value of zero means no timeouts; with this setting,
18437 frozen messages remain in the queue forever (except for any frozen bounce
18438 messages that are released by &%ignore_bounce_errors_after%&).
18439
18440
18441 .option timezone main string unset
18442 .cindex "timezone, setting"
18443 .cindex "environment" "values from"
18444 The value of &%timezone%& is used to set the environment variable TZ while
18445 running Exim (if it is different on entry). This ensures that all timestamps
18446 created by Exim are in the required timezone. If you want all your timestamps
18447 to be in UTC (aka GMT) you should set
18448 .code
18449 timezone = UTC
18450 .endd
18451 The default value is taken from TIMEZONE_DEFAULT in &_Local/Makefile_&,
18452 or, if that is not set, from the value of the TZ environment variable when Exim
18453 is built. If &%timezone%& is set to the empty string, either at build or run
18454 time, any existing TZ variable is removed from the environment when Exim
18455 runs. This is appropriate behaviour for obtaining wall-clock time on some, but
18456 unfortunately not all, operating systems.
18457
18458
18459 .option tls_advertise_hosts main "host list&!!" *
18460 .cindex "TLS" "advertising"
18461 .cindex "encryption" "on SMTP connection"
18462 .cindex "SMTP" "encrypted connection"
18463 .cindex "ESMTP extensions" STARTTLS
18464 When Exim is built with support for TLS encrypted connections, the availability
18465 of the STARTTLS command to set up an encrypted session is advertised in
18466 response to EHLO only to those client hosts that match this option. See
18467 chapter &<<CHAPTLS>>& for details of Exim's support for TLS.
18468 Note that the default value requires that a certificate be supplied
18469 using the &%tls_certificate%& option.  If TLS support for incoming connections
18470 is not required the &%tls_advertise_hosts%& option should be set empty.
18471
18472
18473 .option tls_alpn main "string list&!!" "smtp : esmtp"
18474 .cindex TLS "Application Layer Protocol Names"
18475 .cindex TLS ALPN
18476 .cindex ALPN "set acceptable names for server"
18477 If this option is set,
18478 the TLS library supports ALPN,
18479 and the client offers either more than one
18480 ALPN name or a name which does not match the list,
18481 the TLS connection is declined.
18482
18483
18484 .option tls_certificate main "string list&!!" unset
18485 .cindex "TLS" "server certificate; location of"
18486 .cindex "certificate" "server, location of"
18487 The value of this option is expanded, and must then be a list of absolute paths to
18488 files which contain the server's certificates (in PEM format).
18489 Commonly only one file is needed.
18490 The server's private key is also
18491 assumed to be in this file if &%tls_privatekey%& is unset. See chapter
18492 &<<CHAPTLS>>& for further details.
18493
18494 &*Note*&: The certificates defined by this option are used only when Exim is
18495 receiving incoming messages as a server. If you want to supply certificates for
18496 use when sending messages as a client, you must set the &%tls_certificate%&
18497 option in the relevant &(smtp)& transport.
18498
18499 &*Note*&: If you use filenames based on IP addresses, change the list
18500 separator in the usual way (&<<SECTlistsepchange>>&) to avoid confusion under IPv6.
18501
18502 &*Note*&: Under versions of OpenSSL preceding 1.1.1,
18503 when a list of more than one
18504 file is used, the &$tls_in_ourcert$& variable is unreliable.
18505 The macro "_TLS_BAD_MULTICERT_IN_OURCERT" will be defined for those versions.
18506
18507 .cindex SNI "selecting server certificate based on"
18508 If the option contains &$tls_out_sni$& and Exim is built against OpenSSL, then
18509 if the OpenSSL build supports TLS extensions and the TLS client sends the
18510 Server Name Indication extension, then this option and others documented in
18511 &<<SECTtlssni>>& will be re-expanded.
18512
18513 If this option is unset or empty a self-signed certificate will be
18514 used.
18515 Under Linux this is generated at daemon startup; on other platforms it will be
18516 generated fresh for every connection.
18517
18518 .option tls_crl main string&!! unset
18519 .cindex "TLS" "server certificate revocation list"
18520 .cindex "certificate" "revocation list for server"
18521 This option specifies a certificate revocation list. The expanded value must
18522 be the name of a file that contains CRLs in PEM format.
18523
18524 Under OpenSSL the option can specify a directory with CRL files.
18525
18526 &*Note:*& Under OpenSSL the option must, if given, supply a CRL
18527 for each signing element of the certificate chain (i.e. all but the leaf).
18528 For the file variant this can be multiple PEM blocks in the one file.
18529
18530 See &<<SECTtlssni>>& for discussion of when this option might be re-expanded.
18531
18532
18533 .option tls_dh_max_bits main integer 2236
18534 .cindex "TLS" "D-H bit count"
18535 The number of bits used for Diffie-Hellman key-exchange may be suggested by
18536 the chosen TLS library.  That value might prove to be too high for
18537 interoperability.  This option provides a maximum clamp on the value
18538 suggested, trading off security for interoperability.
18539
18540 The value must be at least 1024.
18541
18542 The value 2236 was chosen because, at time of adding the option, it was the
18543 hard-coded maximum value supported by the NSS cryptographic library, as used
18544 by Thunderbird, while GnuTLS was suggesting 2432 bits as normal.
18545
18546 If you prefer more security and are willing to break some clients, raise this
18547 number.
18548
18549 Note that the value passed to GnuTLS for *generating* a new prime may be a
18550 little less than this figure, because GnuTLS is inexact and may produce a
18551 larger prime than requested.
18552
18553
18554 .option tls_dhparam main string&!! unset
18555 .cindex "TLS" "D-H parameters for server"
18556 The value of this option is expanded and indicates the source of DH parameters
18557 to be used by Exim.
18558
18559 &*Note: The Exim Maintainers strongly recommend using a filename with site-generated
18560 local DH parameters*&, which has been supported across all versions of Exim.  The
18561 other specific constants available are a fallback so that even when
18562 "unconfigured", Exim can offer Perfect Forward Secrecy in older ciphersuites in TLS.
18563
18564 If &%tls_dhparam%& is a filename starting with a &`/`&,
18565 then it names a file from which DH
18566 parameters should be loaded.  If the file exists, it should hold a PEM-encoded
18567 PKCS#3 representation of the DH prime.  If the file does not exist, for
18568 OpenSSL it is an error.  For GnuTLS, Exim will attempt to create the file and
18569 fill it with a generated DH prime.  For OpenSSL, if the DH bit-count from
18570 loading the file is greater than &%tls_dh_max_bits%& then it will be ignored,
18571 and treated as though the &%tls_dhparam%& were set to "none".
18572
18573 If this option expands to the string "none", then no DH parameters will be
18574 loaded by Exim.
18575
18576 If this option expands to the string "historic" and Exim is using GnuTLS, then
18577 Exim will attempt to load a file from inside the spool directory.  If the file
18578 does not exist, Exim will attempt to create it.
18579 See section &<<SECTgnutlsparam>>& for further details.
18580
18581 If Exim is using OpenSSL and this option is empty or unset, then Exim will load
18582 a default DH prime; the default is Exim-specific but lacks verifiable provenance.
18583
18584 In older versions of Exim the default was the 2048 bit prime described in section
18585 2.2 of RFC 5114, "2048-bit MODP Group with 224-bit Prime Order Subgroup", which
18586 in IKE is assigned number 23.
18587
18588 Otherwise, the option must expand to the name used by Exim for any of a number
18589 of DH primes specified in RFC 2409, RFC 3526, RFC 5114, RFC 7919, or from other
18590 sources.  As names, Exim uses a standard specified name, else "ike" followed by
18591 the number used by IKE, or "default" which corresponds to
18592 &`exim.dev.20160529.3`&.
18593
18594 The available standard primes are:
18595 &`ffdhe2048`&, &`ffdhe3072`&, &`ffdhe4096`&, &`ffdhe6144`&, &`ffdhe8192`&,
18596 &`ike1`&, &`ike2`&, &`ike5`&,
18597 &`ike14`&, &`ike15`&, &`ike16`&, &`ike17`&, &`ike18`&,
18598 &`ike22`&, &`ike23`& and &`ike24`&.
18599
18600 The available additional primes are:
18601 &`exim.dev.20160529.1`&, &`exim.dev.20160529.2`& and &`exim.dev.20160529.3`&.
18602
18603 Some of these will be too small to be accepted by clients.
18604 Some may be too large to be accepted by clients.
18605 The open cryptographic community has suspicions about the integrity of some
18606 of the later IKE values, which led into RFC7919 providing new fixed constants
18607 (the "ffdhe" identifiers).
18608
18609 At this point, all of the "ike" values should be considered obsolete;
18610 they are still in Exim to avoid breaking unusual configurations, but are
18611 candidates for removal the next time we have backwards-incompatible changes.
18612 Two of them in particular (&`ike1`& and &`ike22`&) are called out by RFC 8247
18613 as MUST NOT use for IPSEC, and two more (&`ike23`& and &`ike24`&) as
18614 SHOULD NOT.
18615 Because of this, Exim regards them as deprecated; if either of the first pair
18616 are used, warnings will be logged in the paniclog, and if any are used then
18617 warnings will be logged in the mainlog.
18618 All four will be removed in a future Exim release.
18619
18620 The TLS protocol does not negotiate an acceptable size for this; clients tend
18621 to hard-drop connections if what is offered by the server is unacceptable,
18622 whether too large or too small, and there's no provision for the client to
18623 tell the server what these constraints are.  Thus, as a server operator, you
18624 need to make an educated guess as to what is most likely to work for your
18625 userbase.
18626
18627 Some known size constraints suggest that a bit-size in the range 2048 to 2236
18628 is most likely to maximise interoperability.  The upper bound comes from
18629 applications using the Mozilla Network Security Services (NSS) library, which
18630 used to set its &`DH_MAX_P_BITS`& upper-bound to 2236.  This affects many
18631 mail user agents (MUAs). The lower bound comes from Debian installs of Exim4
18632 prior to the 4.80 release, as Debian used to patch Exim to raise the minimum
18633 acceptable bound from 1024 to 2048.
18634
18635
18636 .option tls_eccurve main string list&!! &`auto`&
18637 .cindex TLS "EC cryptography"
18638 This option selects EC curves for use by Exim when used with OpenSSL.
18639 It has no effect when Exim is used with GnuTLS
18640 (the equivalent can be done using a priority string for the
18641 &%tls_require_ciphers%& option).
18642
18643 After expansion it must contain
18644 one or (only for OpenSSL versiona 1.1.1 onwards) more
18645 EC curve names, such as &`prime256v1`&, &`secp384r1`&, or &`P-521`&.
18646 Consult your OpenSSL manual for valid curve names.
18647
18648 For OpenSSL versions before (and not including) 1.0.2, the string
18649 &`auto`& selects &`prime256v1`&. For more recent OpenSSL versions
18650 &`auto`& tells the library to choose.
18651
18652 If the option expands to an empty string, the effect is undefined.
18653
18654
18655 .option tls_ocsp_file main string&!! unset
18656 .cindex TLS "certificate status"
18657 .cindex TLS "OCSP proof file"
18658 This option
18659 must if set expand to the absolute path to a file which contains a current
18660 status proof for the server's certificate, as obtained from the
18661 Certificate Authority.
18662
18663 Usable for GnuTLS 3.4.4 or 3.3.17 or OpenSSL 1.1.0 (or later).
18664 The macro "_HAVE_TLS_OCSP" will be defined for those versions.
18665
18666 For OpenSSL 1.1.0 or later, and
18667 for GnuTLS 3.5.6 or later the expanded value of this option can be a list
18668 of files, to match a list given for the &%tls_certificate%& option.
18669 The ordering of the two lists must match.
18670 The macro "_HAVE_TLS_OCSP_LIST" will be defined for those versions.
18671
18672 The file(s) should be in DER format,
18673 except for GnuTLS 3.6.3 or later
18674 or for OpenSSL,
18675 when an optional filetype prefix can be used.
18676 The prefix must be one of "DER" or "PEM", followed by
18677 a single space.  If one is used it sets the format for subsequent
18678 files in the list; the initial format is DER.
18679 If multiple proofs are wanted, for multiple chain elements
18680 (this only works under TLS1.3)
18681 they must be coded as a combined OCSP response.
18682
18683 Although GnuTLS will accept PEM files with multiple separate
18684 PEM blobs (ie. separate OCSP responses), it sends them in the
18685 TLS Certificate record interleaved with the certificates of the chain;
18686 although a GnuTLS client is happy with that, an OpenSSL client is not.
18687
18688 .option tls_on_connect_ports main "string list" unset
18689 .cindex SSMTP
18690 .cindex SMTPS
18691 This option specifies a list of incoming SSMTP (aka SMTPS) ports that should
18692 operate the SSMTP (SMTPS) protocol, where a TLS session is immediately
18693 set up without waiting for the client to issue a STARTTLS command. For
18694 further details, see section &<<SECTsupobssmt>>&.
18695
18696
18697
18698 .option tls_privatekey main "string list&!!" unset
18699 .cindex "TLS" "server private key; location of"
18700 The value of this option is expanded, and must then be a list of absolute paths to
18701 files which contains the server's private keys.
18702 If this option is unset, or if
18703 the expansion is forced to fail, or the result is an empty string, the private
18704 key is assumed to be in the same file as the server's certificates. See chapter
18705 &<<CHAPTLS>>& for further details.
18706
18707 See &<<SECTtlssni>>& for discussion of when this option might be re-expanded.
18708
18709
18710 .option tls_remember_esmtp main boolean false
18711 .cindex "TLS" "esmtp state; remembering"
18712 .cindex "TLS" "broken clients"
18713 If this option is set true, Exim violates the RFCs by remembering that it is in
18714 &"esmtp"& state after successfully negotiating a TLS session. This provides
18715 support for broken clients that fail to send a new EHLO after starting a
18716 TLS session.
18717
18718
18719 .option tls_require_ciphers main string&!! unset
18720 .cindex "TLS" "requiring specific ciphers"
18721 .cindex "cipher" "requiring specific"
18722 This option controls which ciphers can be used for incoming TLS connections.
18723 The &(smtp)& transport has an option of the same name for controlling outgoing
18724 connections. This option is expanded for each connection, so can be varied for
18725 different clients if required. The value of this option must be a list of
18726 permitted cipher suites. The OpenSSL and GnuTLS libraries handle cipher control
18727 in somewhat different ways. If GnuTLS is being used, the client controls the
18728 preference order of the available ciphers. Details are given in sections
18729 &<<SECTreqciphssl>>& and &<<SECTreqciphgnu>>&.
18730
18731
18732 .option tls_resumption_hosts main "host list&!!" unset
18733 .cindex TLS resumption
18734 This option controls which connections to offer the TLS resumption feature.
18735 See &<<SECTresumption>>& for details.
18736
18737
18738 .option tls_try_verify_hosts main "host list&!!" unset
18739 .cindex "TLS" "client certificate verification"
18740 .cindex "certificate" "verification of client"
18741 See &%tls_verify_hosts%& below.
18742
18743
18744 .option tls_verify_certificates main string&!! system
18745 .cindex "TLS" "client certificate verification"
18746 .cindex "certificate" "verification of client"
18747 The value of this option is expanded, and must then be either the
18748 word "system"
18749 or the absolute path to
18750 a file or directory containing permitted certificates for clients that
18751 match &%tls_verify_hosts%& or &%tls_try_verify_hosts%&.
18752
18753 The "system" value for the option will use a
18754 system default location compiled into the SSL library.
18755 This is not available for GnuTLS versions preceding 3.0.20,
18756 and will be taken as empty; an explicit location
18757 must be specified.
18758
18759 The use of a directory for the option value is not available for GnuTLS versions
18760 preceding 3.3.6 and a single file must be used.
18761
18762 With OpenSSL the certificates specified
18763 explicitly
18764 either by file or directory
18765 are added to those given by the system default location.
18766
18767 These certificates should be for the certificate authorities trusted, rather
18768 than the public cert of individual clients.  With both OpenSSL and GnuTLS, if
18769 the value is a file then the certificates are sent by Exim as a server to
18770 connecting clients, defining the list of accepted certificate authorities.
18771 Thus the values defined should be considered public data.  To avoid this,
18772 use the explicit directory version. (If your peer is Exim up to 4.85,
18773 using GnuTLS, you may need to send the CAs (thus using the file
18774 variant). Otherwise the peer doesn't send its certificate.)
18775
18776 See &<<SECTtlssni>>& for discussion of when this option might be re-expanded.
18777
18778 A forced expansion failure or setting to an empty string is equivalent to
18779 being unset.
18780
18781
18782 .option tls_verify_hosts main "host list&!!" unset
18783 .cindex "TLS" "client certificate verification"
18784 .cindex "certificate" "verification of client"
18785 This option, along with &%tls_try_verify_hosts%&, controls the checking of
18786 certificates from clients. The expected certificates are defined by
18787 &%tls_verify_certificates%&, which must be set. A configuration error occurs if
18788 either &%tls_verify_hosts%& or &%tls_try_verify_hosts%& is set and
18789 &%tls_verify_certificates%& is not set.
18790
18791 Any client that matches &%tls_verify_hosts%& is constrained by
18792 &%tls_verify_certificates%&. When the client initiates a TLS session, it must
18793 present one of the listed certificates. If it does not, the connection is
18794 aborted.
18795 &*Warning*&: Including a host in &%tls_verify_hosts%& does not require
18796 the host to use TLS. It can still send SMTP commands through unencrypted
18797 connections. Forcing a client to use TLS has to be done separately using an
18798 ACL to reject inappropriate commands when the connection is not encrypted.
18799
18800 A weaker form of checking is provided by &%tls_try_verify_hosts%&. If a client
18801 matches this option (but not &%tls_verify_hosts%&), Exim requests a
18802 certificate and checks it against &%tls_verify_certificates%&, but does not
18803 abort the connection if there is no certificate or if it does not match. This
18804 state can be detected in an ACL, which makes it possible to implement policies
18805 such as &"accept for relay only if a verified certificate has been received,
18806 but accept for local delivery if encrypted, even without a verified
18807 certificate"&.
18808
18809 Client hosts that match neither of these lists are not asked to present
18810 certificates.
18811
18812
18813 .option trusted_groups main "string list&!!" unset
18814 .cindex "trusted groups"
18815 .cindex "groups" "trusted"
18816 This option is expanded just once, at the start of Exim's processing. If this
18817 option is set, any process that is running in one of the listed groups, or
18818 which has one of them as a supplementary group, is trusted. The groups can be
18819 specified numerically or by name. See section &<<SECTtrustedadmin>>& for
18820 details of what trusted callers are permitted to do. If neither
18821 &%trusted_groups%& nor &%trusted_users%& is set, only root and the Exim user
18822 are trusted.
18823
18824 .option trusted_users main "string list&!!" unset
18825 .cindex "trusted users"
18826 .cindex "user" "trusted"
18827 This option is expanded just once, at the start of Exim's processing. If this
18828 option is set, any process that is running as one of the listed users is
18829 trusted. The users can be specified numerically or by name. See section
18830 &<<SECTtrustedadmin>>& for details of what trusted callers are permitted to do.
18831 If neither &%trusted_groups%& nor &%trusted_users%& is set, only root and the
18832 Exim user are trusted.
18833
18834 .option unknown_login main string&!! unset
18835 .cindex "uid (user id)" "unknown caller"
18836 .vindex "&$caller_uid$&"
18837 This is a specialized feature for use in unusual configurations. By default, if
18838 the uid of the caller of Exim cannot be looked up using &[getpwuid()]&, Exim
18839 gives up. The &%unknown_login%& option can be used to set a login name to be
18840 used in this circumstance. It is expanded, so values like &%user$caller_uid%&
18841 can be set. When &%unknown_login%& is used, the value of &%unknown_username%&
18842 is used for the user's real name (gecos field), unless this has been set by the
18843 &%-F%& option.
18844
18845 .option unknown_username main string unset
18846 See &%unknown_login%&.
18847
18848 .option untrusted_set_sender main "address list&!!" unset
18849 .cindex "trusted users"
18850 .cindex "sender" "setting by untrusted user"
18851 .cindex "untrusted user setting sender"
18852 .cindex "user" "untrusted setting sender"
18853 .cindex "envelope from"
18854 .cindex "envelope sender"
18855 When an untrusted user submits a message to Exim using the standard input, Exim
18856 normally creates an envelope sender address from the user's login and the
18857 default qualification domain. Data from the &%-f%& option (for setting envelope
18858 senders on non-SMTP messages) or the SMTP MAIL command (if &%-bs%& or &%-bS%&
18859 is used) is ignored.
18860
18861 However, untrusted users are permitted to set an empty envelope sender address,
18862 to declare that a message should never generate any bounces. For example:
18863 .code
18864 exim -f '<>' user@domain.example
18865 .endd
18866 .vindex "&$sender_ident$&"
18867 The &%untrusted_set_sender%& option allows you to permit untrusted users to set
18868 other envelope sender addresses in a controlled way. When it is set, untrusted
18869 users are allowed to set envelope sender addresses that match any of the
18870 patterns in the list. Like all address lists, the string is expanded. The
18871 identity of the user is in &$sender_ident$&, so you can, for example, restrict
18872 users to setting senders that start with their login ids
18873 followed by a hyphen
18874 by a setting like this:
18875 .code
18876 untrusted_set_sender = ^$sender_ident-
18877 .endd
18878 If you want to allow untrusted users to set envelope sender addresses without
18879 restriction, you can use
18880 .code
18881 untrusted_set_sender = *
18882 .endd
18883 The &%untrusted_set_sender%& option applies to all forms of local input, but
18884 only to the setting of the envelope sender. It does not permit untrusted users
18885 to use the other options which trusted user can use to override message
18886 parameters. Furthermore, it does not stop Exim from removing an existing
18887 &'Sender:'& header in the message, or from adding a &'Sender:'& header if
18888 necessary. See &%local_sender_retain%& and &%local_from_check%& for ways of
18889 overriding these actions. The handling of the &'Sender:'& header is also
18890 described in section &<<SECTthesenhea>>&.
18891
18892 The log line for a message's arrival shows the envelope sender following
18893 &"<="&. For local messages, the user's login always follows, after &"U="&. In
18894 &%-bp%& displays, and in the Exim monitor, if an untrusted user sets an
18895 envelope sender address, the user's login is shown in parentheses after the
18896 sender address.
18897
18898
18899 .option uucp_from_pattern main string "see below"
18900 .cindex "&""From""& line"
18901 .cindex "UUCP" "&""From""& line"
18902 Some applications that pass messages to an MTA via a command line interface use
18903 an initial line starting with &"From&~"& to pass the envelope sender. In
18904 particular, this is used by UUCP software. Exim recognizes such a line by means
18905 of a regular expression that is set in &%uucp_from_pattern%&. When the pattern
18906 matches, the sender address is constructed by expanding the contents of
18907 &%uucp_from_sender%&, provided that the caller of Exim is a trusted user. The
18908 default pattern recognizes lines in the following two forms:
18909 .code
18910 From ph10 Fri Jan  5 12:35 GMT 1996
18911 From ph10 Fri, 7 Jan 97 14:00:00 GMT
18912 .endd
18913 The pattern can be seen by running
18914 .code
18915 exim -bP uucp_from_pattern
18916 .endd
18917 It checks only up to the hours and minutes, and allows for a 2-digit or 4-digit
18918 year in the second case. The first word after &"From&~"& is matched in the
18919 regular expression by a parenthesized subpattern. The default value for
18920 &%uucp_from_sender%& is &"$1"&, which therefore just uses this first word
18921 (&"ph10"& in the example above) as the message's sender. See also
18922 &%ignore_fromline_hosts%&.
18923
18924
18925 .option uucp_from_sender main string&!! &`$1`&
18926 See &%uucp_from_pattern%& above.
18927
18928
18929 .option warn_message_file main string&!! unset
18930 .cindex "warning of delay" "customizing the message"
18931 .cindex "customizing" "warning message"
18932 This option defines a template file containing paragraphs of text to be used
18933 for constructing the warning message which is sent by Exim when a message has
18934 been in the queue for a specified amount of time, as specified by
18935 &%delay_warning%&. Details of the file's contents are given in chapter
18936 &<<CHAPemsgcust>>&.
18937 .cindex warn_message_file "tainted data"
18938 The option is expanded to give the file path, which must be
18939 absolute and untainted.
18940 See also &%bounce_message_file%&.
18941
18942
18943 .option wellknown_advertise_hosts main boolean unset
18944 .cindex WELLKNOWN advertisement
18945 .cindex "ESMTP extensions" WELLKNOWN
18946 This option enables the advertising of the SMTP WELLKNOWN extension.
18947 See also the &%acl_smtp_wellknown%& ACL (&<<SECTWELLKNOWNACL>>&).
18948
18949 .option write_rejectlog main boolean true
18950 .cindex "reject log" "disabling"
18951 If this option is set false, Exim no longer writes anything to the reject log.
18952 See chapter &<<CHAPlog>>& for details of what Exim writes to its logs.
18953 .ecindex IIDconfima
18954 .ecindex IIDmaiconf
18955
18956
18957
18958
18959 . ////////////////////////////////////////////////////////////////////////////
18960 . ////////////////////////////////////////////////////////////////////////////
18961
18962 .chapter "Generic options for routers" "CHAProutergeneric"
18963 .scindex IIDgenoprou1 "options" "generic; for routers"
18964 .scindex IIDgenoprou2 "generic options" "router"
18965 This chapter describes the generic options that apply to all routers.
18966 Those that are preconditions are marked with &Dagger; in the &"use"& field.
18967
18968 For a general description of how a router operates, see sections
18969 &<<SECTrunindrou>>& and &<<SECTrouprecon>>&. The latter specifies the order in
18970 which the preconditions are tested. The order of expansion of the options that
18971 provide data for a transport is: &%errors_to%&, &%headers_add%&,
18972 &%headers_remove%&, &%transport%&.
18973
18974 The name of a router is limited to be &drivernamemax; ASCII characters long;
18975 prior to Exim 4.95 names would be silently truncated at this length, but now
18976 it is enforced.
18977
18978
18979 .option address_data routers string&!! unset
18980 .cindex "router" "data attached to address"
18981 The string is expanded just before the router is run, that is, after all the
18982 precondition tests have succeeded. If the expansion is forced to fail, the
18983 router declines, the value of &%address_data%& remains unchanged, and the
18984 &%more%& option controls what happens next. Other expansion failures cause
18985 delivery of the address to be deferred.
18986
18987 .vindex "&$address_data$&"
18988 When the expansion succeeds, the value is retained with the address, and can be
18989 accessed using the variable &$address_data$& in the current router, subsequent
18990 routers, and the eventual transport.
18991
18992 &*Warning*&: If the current or any subsequent router is a &(redirect)& router
18993 that runs a user's filter file, the contents of &$address_data$& are accessible
18994 in the filter. This is not normally a problem, because such data is usually
18995 either not confidential or it &"belongs"& to the current user, but if you do
18996 put confidential data into &$address_data$& you need to remember this point.
18997
18998 Even if the router declines or passes, the value of &$address_data$& remains
18999 with the address, though it can be changed by another &%address_data%& setting
19000 on a subsequent router. If a router generates child addresses, the value of
19001 &$address_data$& propagates to them. This also applies to the special kind of
19002 &"child"& that is generated by a router with the &%unseen%& option.
19003
19004 The idea of &%address_data%& is that you can use it to look up a lot of data
19005 for the address once, and then pick out parts of the data later. For example,
19006 you could use a single LDAP lookup to return a string of the form
19007 .code
19008 uid=1234 gid=5678 mailbox=/mail/xyz forward=/home/xyz/.forward
19009 .endd
19010 In the transport you could pick out the mailbox by a setting such as
19011 .code
19012 file = ${extract{mailbox}{$address_data}}
19013 .endd
19014 This makes the configuration file less messy, and also reduces the number of
19015 lookups (though Exim does cache lookups).
19016
19017 See also the &%set%& option below.
19018
19019 .vindex "&$sender_address_data$&"
19020 .vindex "&$address_data$&"
19021 The &%address_data%& facility is also useful as a means of passing information
19022 from one router to another, and from a router to a transport. In addition, if
19023 &$address_data$& is set by a router when verifying a recipient address from an
19024 ACL, it remains available for use in the rest of the ACL statement. After
19025 verifying a sender, the value is transferred to &$sender_address_data$&.
19026
19027
19028
19029 .option address_test routers&!? boolean true
19030 .oindex "&%-bt%&"
19031 .cindex "router" "skipping when address testing"
19032 If this option is set false, the router is skipped when routing is being tested
19033 by means of the &%-bt%& command line option. This can be a convenience when
19034 your first router sends messages to an external scanner, because it saves you
19035 having to set the &"already scanned"& indicator when testing real address
19036 routing.
19037
19038
19039
19040 .option cannot_route_message routers string&!! unset
19041 .cindex "router" "customizing &""cannot route""& message"
19042 .cindex "customizing" "&""cannot route""& message"
19043 This option specifies a text message that is used when an address cannot be
19044 routed because Exim has run out of routers. The default message is
19045 &"Unrouteable address"&. This option is useful only on routers that have
19046 &%more%& set false, or on the very last router in a configuration, because the
19047 value that is used is taken from the last router that is considered. This
19048 includes a router that is skipped because its preconditions are not met, as
19049 well as a router that declines. For example, using the default configuration,
19050 you could put:
19051 .code
19052 cannot_route_message = Remote domain not found in DNS
19053 .endd
19054 on the first router, which is a &(dnslookup)& router with &%more%& set false,
19055 and
19056 .code
19057 cannot_route_message = Unknown local user
19058 .endd
19059 on the final router that checks for local users. If string expansion fails for
19060 this option, the default message is used. Unless the expansion failure was
19061 explicitly forced, a message about the failure is written to the main and panic
19062 logs, in addition to the normal message about the routing failure.
19063
19064
19065 .option caseful_local_part routers boolean false
19066 .cindex "case of local parts"
19067 .cindex "router" "case of local parts"
19068 By default, routers handle the local parts of addresses in a case-insensitive
19069 manner, though the actual case is preserved for transmission with the message.
19070 If you want the case of letters to be significant in a router, you must set
19071 this option true. For individual router options that contain address or local
19072 part lists (for example, &%local_parts%&), case-sensitive matching can be
19073 turned on by &"+caseful"& as a list item. See section &<<SECTcasletadd>>& for
19074 more details.
19075
19076 .vindex "&$local_part$&"
19077 .vindex "&$original_local_part$&"
19078 .vindex "&$parent_local_part$&"
19079 The value of the &$local_part$& variable is forced to lower case while a
19080 router is running unless &%caseful_local_part%& is set. When a router assigns
19081 an address to a transport, the value of &$local_part$& when the transport runs
19082 is the same as it was in the router. Similarly, when a router generates child
19083 addresses by aliasing or forwarding, the values of &$original_local_part$&
19084 and &$parent_local_part$& are those that were used by the redirecting router.
19085
19086 This option applies to the processing of an address by a router. When a
19087 recipient address is being processed in an ACL, there is a separate &%control%&
19088 modifier that can be used to specify case-sensitive processing within the ACL
19089 (see section &<<SECTcontrols>>&).
19090
19091
19092
19093 .option check_local_user routers&!? boolean false
19094 .cindex "local user, checking in router"
19095 .cindex "router" "checking for local user"
19096 .cindex "&_/etc/passwd_&"
19097 .vindex "&$home$&"
19098 When this option is true, Exim checks that the local part of the recipient
19099 address (with affixes removed if relevant) is the name of an account on the
19100 local system. The check is done by calling the &[getpwnam()]& function rather
19101 than trying to read &_/etc/passwd_& directly. This means that other methods of
19102 holding password data (such as NIS) are supported. If the local part is a local
19103 user,
19104 .cindex "tainted data" "de-tainting"
19105 .cindex "de-tainting" "using router check_local_user option"
19106 &$local_part_data$& is set to an untainted version of the local part and
19107 &$home$& is set from the password data. The latter can be tested in other
19108 preconditions that are evaluated after this one (the order of evaluation is
19109 given in section &<<SECTrouprecon>>&). However, the value of &$home$& can be
19110 overridden by &%router_home_directory%&. If the local part is not a local user,
19111 the router is skipped.
19112
19113 If you want to check that the local part is either the name of a local user
19114 or matches something else, you cannot combine &%check_local_user%& with a
19115 setting of &%local_parts%&, because that specifies the logical &'and'& of the
19116 two conditions. However, you can use a &(passwd)& lookup in a &%local_parts%&
19117 setting to achieve this. For example:
19118 .code
19119 local_parts = passwd;$local_part : lsearch;/etc/other/users
19120 .endd
19121 Note, however, that the side effects of &%check_local_user%& (such as setting
19122 up a home directory) do not occur when a &(passwd)& lookup is used in a
19123 &%local_parts%& (or any other) precondition.
19124
19125
19126
19127 .option condition routers&!? string&!! unset
19128 .cindex "router" "customized precondition"
19129 This option specifies a general precondition test that has to succeed for the
19130 router to be called. The &%condition%& option is the last precondition to be
19131 evaluated (see section &<<SECTrouprecon>>&). The string is expanded, and if the
19132 result is a forced failure, or an empty string, or one of the strings &"0"& or
19133 &"no"& or &"false"& (checked without regard to the case of the letters), the
19134 router is skipped, and the address is offered to the next one.
19135
19136 If the result is any other value, the router is run (as this is the last
19137 precondition to be evaluated, all the other preconditions must be true).
19138
19139 This option is unusual in that multiple &%condition%& options may be present.
19140 All &%condition%& options must succeed.
19141
19142 The &%condition%& option provides a means of applying custom conditions to the
19143 running of routers. Note that in the case of a simple conditional expansion,
19144 the default expansion values are exactly what is wanted. For example:
19145 .code
19146 condition = ${if >{$message_age}{600}}
19147 .endd
19148 Because of the default behaviour of the string expansion, this is equivalent to
19149 .code
19150 condition = ${if >{$message_age}{600}{true}{}}
19151 .endd
19152
19153 A multiple condition example, which succeeds:
19154 .code
19155 condition = ${if >{$message_age}{600}}
19156 condition = ${if !eq{${lc:$local_part}}{postmaster}}
19157 condition = foobar
19158 .endd
19159
19160 If the expansion fails (other than forced failure) delivery is deferred. Some
19161 of the other precondition options are common special cases that could in fact
19162 be specified using &%condition%&.
19163
19164 Historical note: We have &%condition%& on ACLs and on Routers.  Routers
19165 are far older, and use one set of semantics.  ACLs are newer and when
19166 they were created, the ACL &%condition%& process was given far stricter
19167 parse semantics.  The &%bool{}%& expansion condition uses the same rules as
19168 ACLs.  The &%bool_lax{}%& expansion condition uses the same rules as
19169 Routers.  More pointedly, the &%bool_lax{}%& was written to match the existing
19170 Router rules processing behavior.
19171
19172 This is best illustrated in an example:
19173 .code
19174 # If used in an ACL condition will fail with a syntax error, but
19175 # in a router condition any extra characters are treated as a string
19176
19177 $ exim -be '${if eq {${lc:GOOGLE.com}} {google.com}} {yes} {no}}'
19178 true {yes} {no}}
19179
19180 $ exim -be '${if eq {${lc:WHOIS.com}} {google.com}} {yes} {no}}'
19181  {yes} {no}}
19182 .endd
19183 In each example above, the &%if%& statement actually ends after
19184 &"{google.com}}"&.  Since no true or false braces were defined, the
19185 default &%if%& behavior is to return a boolean true or a null answer
19186 (which evaluates to false). The rest of the line is then treated as a
19187 string. So the first example resulted in the boolean answer &"true"&
19188 with the string &" {yes} {no}}"& appended to it. The second example
19189 resulted in the null output (indicating false) with the string
19190 &" {yes} {no}}"& appended to it.
19191
19192 In fact you can put excess forward braces in too.  In the router
19193 &%condition%&, Exim's parser only looks for &"{"& symbols when they
19194 mean something, like after a &"$"& or when required as part of a
19195 conditional.  But otherwise &"{"& and &"}"& are treated as ordinary
19196 string characters.
19197
19198 Thus, in a Router, the above expansion strings will both always evaluate
19199 true, as the result of expansion is a non-empty string which doesn't
19200 match an explicit false value.  This can be tricky to debug.  By
19201 contrast, in an ACL either of those strings will always result in an
19202 expansion error because the result doesn't look sufficiently boolean.
19203
19204
19205 .option debug_print routers string&!! unset
19206 .cindex "testing" "variables in drivers"
19207 If this option is set and debugging is enabled (see the &%-d%& command line
19208 option) or in address-testing mode (see the &%-bt%& command line option),
19209 the string is expanded and included in the debugging output.
19210 If expansion of the string fails, the error message is written to the debugging
19211 output, and Exim carries on processing.
19212 This option is provided to help with checking out the values of variables and
19213 so on when debugging router configurations. For example, if a &%condition%&
19214 option appears not to be working, &%debug_print%& can be used to output the
19215 variables it references. The output happens after checks for &%domains%&,
19216 &%local_parts%&, and &%check_local_user%& but before any other preconditions
19217 are tested. A newline is added to the text if it does not end with one.
19218 The variable &$router_name$& contains the name of the router.
19219
19220
19221
19222 .option disable_logging routers boolean false
19223 If this option is set true, nothing is logged for any routing errors
19224 or for any deliveries caused by this router. You should not set this option
19225 unless you really, really know what you are doing. See also the generic
19226 transport option of the same name.
19227
19228 .option dnssec_request_domains routers "domain list&!!" *
19229 .cindex "MX record" "security"
19230 .cindex "DNSSEC" "MX lookup"
19231 .cindex "security" "MX lookup"
19232 .cindex "DNS" "DNSSEC"
19233 DNS lookups for domains matching &%dnssec_request_domains%& will be done with
19234 the DNSSEC request bit set.
19235 This applies to all of the SRV, MX, AAAA, A lookup sequence.
19236
19237 .option dnssec_require_domains routers "domain list&!!" unset
19238 .cindex "MX record" "security"
19239 .cindex "DNSSEC" "MX lookup"
19240 .cindex "security" "MX lookup"
19241 .cindex "DNS" "DNSSEC"
19242 DNS lookups for domains matching &%dnssec_require_domains%& will be done with
19243 the DNSSEC request bit set.  Any returns not having the Authenticated Data bit
19244 (AD bit) set will be ignored and logged as a host-lookup failure.
19245 This applies to all of the SRV, MX, AAAA, A lookup sequence.
19246
19247
19248 .option domains routers&!? "domain list&!!" unset
19249 .cindex "router" "restricting to specific domains"
19250 .vindex "&$domain_data$&"
19251 If this option is set, the router is skipped unless the current domain matches
19252 the list.
19253 The data returned by the list check
19254 is placed in &$domain_data$& for use in string
19255 expansions of the driver's private options and in the transport.
19256 See section &<<SECTrouprecon>>& for
19257 a list of the order in which preconditions are evaluated.
19258
19259 A complex example, using a file like:
19260 .code
19261 alice@dom1
19262 bill@dom1
19263 maggie@dom1
19264 .endd
19265 and checking both domain and local_part
19266 .code
19267 domains =         ${domain:${lookup {$local_part@$domain} lseach,ret=key {/path/to/accountsfile}}}
19268 local_parts = ${local_part:${lookup {$local_part@$domain} lseach,ret=key {/path/to/accountsfile}}}
19269 .endd
19270
19271
19272
19273 .option driver routers string unset
19274 This option must always be set. It specifies which of the available routers is
19275 to be used.
19276
19277
19278 .option dsn_lasthop routers boolean false
19279 .cindex "DSN" "success"
19280 .cindex "Delivery Status Notification" "success"
19281 If this option is set true, and extended DSN (RFC3461) processing is in effect,
19282 Exim will not pass on DSN requests to downstream DSN-aware hosts but will
19283 instead send a success DSN as if the next hop does not support DSN.
19284 Not effective on redirect routers.
19285
19286
19287
19288 .option errors_to routers string&!! unset
19289 .cindex "envelope from"
19290 .cindex "envelope sender"
19291 .cindex "router" "changing address for errors"
19292 If a router successfully handles an address, it may assign the address to a
19293 transport for delivery or it may generate child addresses. In both cases, if
19294 there is a delivery problem during later processing, the resulting bounce
19295 message is sent to the address that results from expanding this string,
19296 provided that the address verifies successfully. The &%errors_to%& option is
19297 expanded before &%headers_add%&, &%headers_remove%&, and &%transport%&.
19298
19299 The &%errors_to%& setting associated with an address can be overridden if it
19300 subsequently passes through other routers that have their own &%errors_to%&
19301 settings, or if the message is delivered by a transport with a &%return_path%&
19302 setting.
19303
19304 If &%errors_to%& is unset, or the expansion is forced to fail, or the result of
19305 the expansion fails to verify, the errors address associated with the incoming
19306 address is used. At top level, this is the envelope sender. A non-forced
19307 expansion failure causes delivery to be deferred.
19308
19309 If an address for which &%errors_to%& has been set ends up being delivered over
19310 SMTP, the envelope sender for that delivery is the &%errors_to%& value, so that
19311 any bounces that are generated by other MTAs on the delivery route are also
19312 sent there. You can set &%errors_to%& to the empty string by either of these
19313 settings:
19314 .code
19315 errors_to =
19316 errors_to = ""
19317 .endd
19318 An expansion item that yields an empty string has the same effect. If you do
19319 this, a locally detected delivery error for addresses processed by this router
19320 no longer gives rise to a bounce message; the error is discarded. If the
19321 address is delivered to a remote host, the return path is set to &`<>`&, unless
19322 overridden by the &%return_path%& option on the transport.
19323
19324 .vindex "&$address_data$&"
19325 If for some reason you want to discard local errors, but use a non-empty
19326 MAIL command for remote delivery, you can preserve the original return
19327 path in &$address_data$& in the router, and reinstate it in the transport by
19328 setting &%return_path%&.
19329
19330 The most common use of &%errors_to%& is to direct mailing list bounces to the
19331 manager of the list, as described in section &<<SECTmailinglists>>&, or to
19332 implement VERP (Variable Envelope Return Paths) (see section &<<SECTverp>>&).
19333
19334
19335
19336 .option expn routers&!? boolean true
19337 .cindex "address" "testing"
19338 .cindex "testing" "addresses"
19339 .cindex "EXPN" "router skipping"
19340 .cindex "router" "skipping for EXPN"
19341 If this option is turned off, the router is skipped when testing an address
19342 as a result of processing an SMTP EXPN command. You might, for example,
19343 want to turn it off on a router for users' &_.forward_& files, while leaving it
19344 on for the system alias file.
19345 See section &<<SECTrouprecon>>& for a list of the order in which preconditions
19346 are evaluated.
19347
19348 The use of the SMTP EXPN command is controlled by an ACL (see chapter
19349 &<<CHAPACL>>&). When Exim is running an EXPN command, it is similar to testing
19350 an address with &%-bt%&. Compare VRFY, whose counterpart is &%-bv%&.
19351
19352
19353
19354 .option fail_verify routers boolean false
19355 .cindex "router" "forcing verification failure"
19356 Setting this option has the effect of setting both &%fail_verify_sender%& and
19357 &%fail_verify_recipient%& to the same value.
19358
19359
19360
19361 .option fail_verify_recipient routers boolean false
19362 If this option is true and an address is accepted by this router when
19363 verifying a recipient, verification fails.
19364
19365
19366
19367 .option fail_verify_sender routers boolean false
19368 If this option is true and an address is accepted by this router when
19369 verifying a sender, verification fails.
19370
19371
19372
19373 .option fallback_hosts routers "string list" unset
19374 .cindex "router" "fallback hosts"
19375 .cindex "fallback" "hosts specified on router"
19376 String expansion is not applied to this option. The argument must be a
19377 colon-separated list of host names or IP addresses. The list separator can be
19378 changed (see section &<<SECTlistsepchange>>&), and a port can be specified with
19379 each name or address. In fact, the format of each item is exactly the same as
19380 defined for the list of hosts in a &(manualroute)& router (see section
19381 &<<SECTformatonehostitem>>&).
19382
19383 If a router queues an address for a remote transport, this host list is
19384 associated with the address, and used instead of the transport's fallback host
19385 list. If &%hosts_randomize%& is set on the transport, the order of the list is
19386 randomized for each use. See the &%fallback_hosts%& option of the &(smtp)&
19387 transport for further details.
19388
19389
19390 .option group routers string&!! "see below"
19391 .cindex "gid (group id)" "local delivery"
19392 .cindex "local transports" "uid and gid"
19393 .cindex "transport" "local"
19394 .cindex "router" "setting group"
19395 When a router queues an address for a transport, and the transport does not
19396 specify a group, the group given here is used when running the delivery
19397 process.
19398 The group may be specified numerically or by name. If expansion fails, the
19399 error is logged and delivery is deferred.
19400 The default is unset, unless &%check_local_user%& is set, when the default
19401 is taken from the password information. See also &%initgroups%& and &%user%&
19402 and the discussion in chapter &<<CHAPenvironment>>&.
19403
19404
19405
19406 .option headers_add routers list&!! unset
19407 .cindex "header lines" "adding"
19408 .cindex "router" "adding header lines"
19409 This option specifies a list of text headers,
19410 newline-separated (by default, changeable in the usual way &<<SECTlistsepchange>>&),
19411 that is associated with any addresses that are accepted by the router.
19412 Each item is separately expanded, at routing time.  However, this
19413 option has no effect when an address is just being verified. The way in which
19414 the text is used to add header lines at transport time is described in section
19415 &<<SECTheadersaddrem>>&. New header lines are not actually added until the
19416 message is in the process of being transported. This means that references to
19417 header lines in string expansions in the transport's configuration do not
19418 &"see"& the added header lines.
19419
19420 The &%headers_add%& option is expanded after &%errors_to%&, but before
19421 &%headers_remove%& and &%transport%&. If an item is empty, or if
19422 an item expansion is forced to fail, the item has no effect. Other expansion
19423 failures are treated as configuration errors.
19424
19425 Unlike most options, &%headers_add%& can be specified multiple times
19426 for a router; all listed headers are added.
19427
19428 &*Warning 1*&: The &%headers_add%& option cannot be used for a &(redirect)&
19429 router that has the &%one_time%& option set.
19430
19431 .cindex "duplicate addresses"
19432 .oindex "&%unseen%&"
19433 &*Warning 2*&: If the &%unseen%& option is set on the router, all header
19434 additions are deleted when the address is passed on to subsequent routers.
19435 For a &%redirect%& router, if a generated address is the same as the incoming
19436 address, this can lead to duplicate addresses with different header
19437 modifications. Exim does not do duplicate deliveries (except, in certain
19438 circumstances, to pipes -- see section &<<SECTdupaddr>>&), but it is undefined
19439 which of the duplicates is discarded, so this ambiguous situation should be
19440 avoided. The &%repeat_use%& option of the &%redirect%& router may be of help.
19441
19442
19443
19444 .option headers_remove routers list&!! unset
19445 .cindex "header lines" "removing"
19446 .cindex "router" "removing header lines"
19447 This option specifies a list of text headers,
19448 colon-separated (by default, changeable in the usual way &<<SECTlistsepchange>>&),
19449 that is associated with any addresses that are accepted by the router.
19450 However, the option has no effect when an address is just being verified.
19451 Each list item is separately expanded, at transport time.
19452 If an item ends in *, it will match any header with the given prefix.
19453 The way in which
19454 the text is used to remove header lines at transport time is described in
19455 section &<<SECTheadersaddrem>>&. Header lines are not actually removed until
19456 the message is in the process of being transported. This means that references
19457 to header lines in string expansions in the transport's configuration still
19458 &"see"& the original header lines.
19459
19460 The &%headers_remove%& option is handled after &%errors_to%& and
19461 &%headers_add%&, but before &%transport%&. If an item expansion is forced to fail,
19462 the item has no effect. Other expansion failures are treated as configuration
19463 errors.
19464
19465 Unlike most options, &%headers_remove%& can be specified multiple times
19466 for a router; all listed headers are removed.
19467
19468 &*Warning 1*&: The &%headers_remove%& option cannot be used for a &(redirect)&
19469 router that has the &%one_time%& option set.
19470
19471 &*Warning 2*&: If the &%unseen%& option is set on the router, all header
19472 removal requests are deleted when the address is passed on to subsequent
19473 routers, and this can lead to problems with duplicates -- see the similar
19474 warning for &%headers_add%& above.
19475
19476 &*Warning 3*&: Because of the separate expansion of the list items,
19477 items that contain a list separator must have it doubled.
19478 To avoid this, change the list separator (&<<SECTlistsepchange>>&).
19479
19480
19481
19482 .option ignore_target_hosts routers "host list&!!" unset
19483 .cindex "IP address" "discarding"
19484 .cindex "router" "discarding IP addresses"
19485 Although this option is a host list, it should normally contain IP address
19486 entries rather than names. If any host that is looked up by the router has an
19487 IP address that matches an item in this list, Exim behaves as if that IP
19488 address did not exist. This option allows you to cope with rogue DNS entries
19489 like
19490 .code
19491 remote.domain.example.  A  127.0.0.1
19492 .endd
19493 by setting
19494 .code
19495 ignore_target_hosts = 127.0.0.1
19496 .endd
19497 on the relevant router. If all the hosts found by a &(dnslookup)& router are
19498 discarded in this way, the router declines. In a conventional configuration, an
19499 attempt to mail to such a domain would normally provoke the &"unrouteable
19500 domain"& error, and an attempt to verify an address in the domain would fail.
19501 Similarly, if &%ignore_target_hosts%& is set on an &(ipliteral)& router, the
19502 router declines if presented with one of the listed addresses.
19503
19504 You can use this option to disable the use of IPv4 or IPv6 for mail delivery by
19505 means of the first or the second of the following settings, respectively:
19506 .code
19507 ignore_target_hosts = 0.0.0.0/0
19508 ignore_target_hosts = <; 0::0/0
19509 .endd
19510 The pattern in the first line matches all IPv4 addresses, whereas the pattern
19511 in the second line matches all IPv6 addresses.
19512
19513 This option may also be useful for ignoring link-local and site-local IPv6
19514 addresses. Because, like all host lists, the value of &%ignore_target_hosts%&
19515 is expanded before use as a list, it is possible to make it dependent on the
19516 domain that is being routed.
19517
19518 .vindex "&$host_address$&"
19519 During its expansion, &$host_address$& is set to the IP address that is being
19520 checked.
19521
19522 .option initgroups routers boolean false
19523 .cindex "additional groups"
19524 .cindex "groups" "additional"
19525 .cindex "local transports" "uid and gid"
19526 .cindex "transport" "local"
19527 If the router queues an address for a transport, and this option is true, and
19528 the uid supplied by the router is not overridden by the transport, the
19529 &[initgroups()]& function is called when running the transport to ensure that
19530 any additional groups associated with the uid are set up. See also &%group%&
19531 and &%user%& and the discussion in chapter &<<CHAPenvironment>>&.
19532
19533
19534
19535 .option local_part_prefix routers&!? "string list" unset
19536 .cindex affix "router precondition"
19537 .cindex "router" "prefix for local part"
19538 .cindex "prefix" "for local part, used in router"
19539 If this option is set, the router is skipped unless the local part starts with
19540 one of the given strings, or &%local_part_prefix_optional%& is true. See
19541 section &<<SECTrouprecon>>& for a list of the order in which preconditions are
19542 evaluated.
19543
19544 The list is scanned from left to right, and the first prefix that matches is
19545 used. A limited form of wildcard is available; if the prefix begins with an
19546 asterisk, it matches the longest possible sequence of arbitrary characters at
19547 the start of the local part. An asterisk should therefore always be followed by
19548 some character that does not occur in normal local parts.
19549 .cindex "multiple mailboxes"
19550 .cindex "mailbox" "multiple"
19551 Wildcarding can be used to set up multiple user mailboxes, as described in
19552 section &<<SECTmulbox>>&.
19553
19554 .vindex "&$local_part$&"
19555 .vindex "&$local_part_prefix$&"
19556 During the testing of the &%local_parts%& option, and while the router is
19557 running, the prefix is removed from the local part, and is available in the
19558 expansion variable &$local_part_prefix$&. When a message is being delivered, if
19559 the router accepts the address, this remains true during subsequent delivery by
19560 a transport. In particular, the local part that is transmitted in the RCPT
19561 command for LMTP, SMTP, and BSMTP deliveries has the prefix removed by default.
19562 This behaviour can be overridden by setting &%rcpt_include_affixes%& true on
19563 the relevant transport.
19564
19565 .vindex &$local_part_prefix_v$&
19566 If wildcarding (above) was used then the part of the prefix matching the
19567 wildcard is available in &$local_part_prefix_v$&.
19568
19569 When an address is being verified, &%local_part_prefix%& affects only the
19570 behaviour of the router. If the callout feature of verification is in use, this
19571 means that the full address, including the prefix, will be used during the
19572 callout.
19573
19574 The prefix facility is commonly used to handle local parts of the form
19575 &%owner-something%&. Another common use is to support local parts of the form
19576 &%real-username%& to bypass a user's &_.forward_& file &-- helpful when trying
19577 to tell a user their forwarding is broken &-- by placing a router like this one
19578 immediately before the router that handles &_.forward_& files:
19579 .code
19580 real_localuser:
19581   driver = accept
19582   local_part_prefix = real-
19583   check_local_user
19584   transport = local_delivery
19585 .endd
19586 For security, it would probably be a good idea to restrict the use of this
19587 router to locally-generated messages, using a condition such as this:
19588 .code
19589   condition = ${if match {$sender_host_address}\
19590                          {\N^(|127\.0\.0\.1)$\N}}
19591 .endd
19592
19593 If both &%local_part_prefix%& and &%local_part_suffix%& are set for a router,
19594 both conditions must be met if not optional. Care must be taken if wildcards
19595 are used in both a prefix and a suffix on the same router. Different
19596 separator characters must be used to avoid ambiguity.
19597
19598
19599 .option local_part_prefix_optional routers boolean false
19600 See &%local_part_prefix%& above.
19601
19602
19603
19604 .option local_part_suffix routers&!? "string list" unset
19605 .cindex "router" "suffix for local part"
19606 .cindex "suffix for local part" "used in router"
19607 This option operates in the same way as &%local_part_prefix%&, except that the
19608 local part must end (rather than start) with the given string, the
19609 &%local_part_suffix_optional%& option determines whether the suffix is
19610 mandatory, and the wildcard * character, if present, must be the last
19611 character of the suffix. This option facility is commonly used to handle local
19612 parts of the form &%something-request%& and multiple user mailboxes of the form
19613 &%username-foo%&.
19614
19615
19616 .option local_part_suffix_optional routers boolean false
19617 See &%local_part_suffix%& above.
19618
19619
19620
19621 .option local_parts routers&!? "local part list&!!" unset
19622 .cindex "router" "restricting to specific local parts"
19623 .cindex "local part" "checking in router"
19624 The router is run only if the local part of the address matches the list.
19625 See section &<<SECTrouprecon>>& for a list of the order in which preconditions
19626 are evaluated, and
19627 section &<<SECTlocparlis>>& for a discussion of local part lists. Because the
19628 string is expanded, it is possible to make it depend on the domain, for
19629 example:
19630 .code
19631 local_parts = dbm;/usr/local/specials/$domain_data
19632 .endd
19633 .vindex "&$local_part_data$&"
19634 the data returned by the list check
19635 for the local part is placed in the variable &$local_part_data$& for use in
19636 expansions of the router's private options or in the transport.
19637 You might use this option, for
19638 example, if you have a large number of local virtual domains, and you want to
19639 send all postmaster mail to the same place without having to set up an alias in
19640 each virtual domain:
19641 .code
19642 postmaster:
19643   driver = redirect
19644   local_parts = postmaster
19645   data = postmaster@real.domain.example
19646 .endd
19647
19648
19649 .option log_as_local routers boolean "see below"
19650 .cindex "log" "delivery line"
19651 .cindex "delivery" "log line format"
19652 Exim has two logging styles for delivery, the idea being to make local
19653 deliveries stand out more visibly from remote ones. In the &"local"& style, the
19654 recipient address is given just as the local part, without a domain. The use of
19655 this style is controlled by this option. It defaults to true for the &(accept)&
19656 router, and false for all the others. This option applies only when a
19657 router assigns an address to a transport. It has no effect on routers that
19658 redirect addresses.
19659
19660
19661
19662 .option more routers boolean&!! true
19663 The result of string expansion for this option must be a valid boolean value,
19664 that is, one of the strings &"yes"&, &"no"&, &"true"&, or &"false"&. Any other
19665 result causes an error, and delivery is deferred. If the expansion is forced to
19666 fail, the default value for the option (true) is used. Other failures cause
19667 delivery to be deferred.
19668
19669 If this option is set false, and the router declines to handle the address, no
19670 further routers are tried, routing fails, and the address is bounced.
19671 .oindex "&%self%&"
19672 However, if the router explicitly passes an address to the following router by
19673 means of the setting
19674 .code
19675 self = pass
19676 .endd
19677 or otherwise, the setting of &%more%& is ignored. Also, the setting of &%more%&
19678 does not affect the behaviour if one of the precondition tests fails. In that
19679 case, the address is always passed to the next router.
19680
19681 Note that &%address_data%& is not considered to be a precondition. If its
19682 expansion is forced to fail, the router declines, and the value of &%more%&
19683 controls what happens next.
19684
19685
19686 .option pass_on_timeout routers boolean false
19687 .cindex "timeout" "of router"
19688 .cindex "router" "timeout"
19689 If a router times out during a host lookup, it normally causes deferral of the
19690 address. If &%pass_on_timeout%& is set, the address is passed on to the next
19691 router, overriding &%no_more%&. This may be helpful for systems that are
19692 intermittently connected to the Internet, or those that want to pass to a smart
19693 host any messages that cannot immediately be delivered.
19694
19695 There are occasional other temporary errors that can occur while doing DNS
19696 lookups. They are treated in the same way as a timeout, and this option
19697 applies to all of them.
19698
19699
19700
19701 .option pass_router routers string unset
19702 .cindex "router" "go to after &""pass""&"
19703 Routers that recognize the generic &%self%& option (&(dnslookup)&,
19704 &(ipliteral)&, and &(manualroute)&) are able to return &"pass"&, forcing
19705 routing to continue, and overriding a false setting of &%more%&. When one of
19706 these routers returns &"pass"&, the address is normally handed on to the next
19707 router in sequence. This can be changed by setting &%pass_router%& to the name
19708 of another router. However (unlike &%redirect_router%&) the named router must
19709 be below the current router, to avoid loops. Note that this option applies only
19710 to the special case of &"pass"&. It does not apply when a router returns
19711 &"decline"& because it cannot handle an address.
19712
19713
19714
19715 .option redirect_router routers string unset
19716 .cindex "router" "start at after redirection"
19717 Sometimes an administrator knows that it is pointless to reprocess addresses
19718 generated from alias or forward files with the same router again. For
19719 example, if an alias file translates real names into login ids there is no
19720 point searching the alias file a second time, especially if it is a large file.
19721
19722 The &%redirect_router%& option can be set to the name of any router instance.
19723 It causes the routing of any generated addresses to start at the named router
19724 instead of at the first router. This option has no effect if the router in
19725 which it is set does not generate new addresses.
19726
19727
19728
19729 .option require_files routers&!? "string list&!!" unset
19730 .cindex "file" "requiring for router"
19731 .cindex "router" "requiring file existence"
19732 This option provides a general mechanism for predicating the running of a
19733 router on the existence or non-existence of certain files or directories.
19734 Before running a router, as one of its precondition tests, Exim works its way
19735 through the &%require_files%& list, expanding each item separately.
19736
19737 Because the list is split before expansion, any colons in expansion items must
19738 be doubled, or the facility for using a different list separator must be used
19739 (&<<SECTlistsepchange>>&).
19740 If any expansion is forced to fail, the item is ignored. Other expansion
19741 failures cause routing of the address to be deferred.
19742
19743 If any expanded string is empty, it is ignored. Otherwise, except as described
19744 below, each string must be a fully qualified file path, optionally preceded by
19745 &"!"&. The paths are passed to the &[stat()]& function to test for the
19746 existence of the files or directories. The router is skipped if any paths not
19747 preceded by &"!"& do not exist, or if any paths preceded by &"!"& do exist.
19748
19749 .cindex "NFS"
19750 If &[stat()]& cannot determine whether a file exists or not, delivery of
19751 the message is deferred. This can happen when NFS-mounted filesystems are
19752 unavailable.
19753
19754 This option is checked after the &%domains%&, &%local_parts%&, and &%senders%&
19755 options, so you cannot use it to check for the existence of a file in which to
19756 look up a domain, local part, or sender. (See section &<<SECTrouprecon>>& for a
19757 full list of the order in which preconditions are evaluated.) However, as
19758 these options are all expanded, you can use the &%exists%& expansion condition
19759 to make such tests. The &%require_files%& option is intended for checking files
19760 that the router may be going to use internally, or which are needed by a
19761 transport (e.g., &_.procmailrc_&).
19762
19763 During delivery, the &[stat()]& function is run as root, but there is a
19764 facility for some checking of the accessibility of a file by another user.
19765 This is not a proper permissions check, but just a &"rough"& check that
19766 operates as follows:
19767
19768 If an item in a &%require_files%& list does not contain any forward slash
19769 characters, it is taken to be the user (and optional group, separated by a
19770 comma) to be checked for subsequent files in the list. If no group is specified
19771 but the user is specified symbolically, the gid associated with the uid is
19772 used. For example:
19773 .code
19774 require_files = mail:/some/file
19775 require_files = $local_part_data:$home/.procmailrc
19776 .endd
19777 If a user or group name in a &%require_files%& list does not exist, the
19778 &%require_files%& condition fails.
19779
19780 Exim performs the check by scanning along the components of the file path, and
19781 checking the access for the given uid and gid. It checks for &"x"& access on
19782 directories, and &"r"& access on the final file. Note that this means that file
19783 access control lists, if the operating system has them, are ignored.
19784
19785 &*Warning 1*&: When the router is being run to verify addresses for an
19786 incoming SMTP message, Exim is not running as root, but under its own uid. This
19787 may affect the result of a &%require_files%& check. In particular, &[stat()]&
19788 may yield the error EACCES (&"Permission denied"&). This means that the Exim
19789 user is not permitted to read one of the directories on the file's path.
19790
19791 &*Warning 2*&: Even when Exim is running as root while delivering a message,
19792 &[stat()]& can yield EACCES for a file in an NFS directory that is mounted
19793 without root access. In this case, if a check for access by a particular user
19794 is requested, Exim creates a subprocess that runs as that user, and tries the
19795 check again in that process.
19796
19797 The default action for handling an unresolved EACCES is to consider it to
19798 be caused by a configuration error, and routing is deferred because the
19799 existence or non-existence of the file cannot be determined. However, in some
19800 circumstances it may be desirable to treat this condition as if the file did
19801 not exist. If the filename (or the exclamation mark that precedes the filename
19802 for non-existence) is preceded by a plus sign, the EACCES error is treated
19803 as if the file did not exist. For example:
19804 .code
19805 require_files = +/some/file
19806 .endd
19807 If the router is not an essential part of verification (for example, it
19808 handles users' &_.forward_& files), another solution is to set the &%verify%&
19809 option false so that the router is skipped when verifying.
19810
19811
19812
19813 .option retry_use_local_part routers boolean "see below"
19814 .cindex "hints database" "retry keys"
19815 .cindex "local part" "in retry keys"
19816 When a delivery suffers a temporary routing failure, a retry record is created
19817 in Exim's hints database. For addresses whose routing depends only on the
19818 domain, the key for the retry record should not involve the local part, but for
19819 other addresses, both the domain and the local part should be included.
19820 Usually, remote routing is of the former kind, and local routing is of the
19821 latter kind.
19822
19823 This option controls whether the local part is used to form the key for retry
19824 hints for addresses that suffer temporary errors while being handled by this
19825 router. The default value is true for any router that has any of
19826 &%check_local_user%&,
19827 &%local_parts%&,
19828 &%condition%&,
19829 &%local_part_prefix%&,
19830 &%local_part_suffix%&,
19831 &%senders%& or
19832 &%require_files%&
19833 set, and false otherwise. Note that this option does not apply to hints keys
19834 for transport delays; they are controlled by a generic transport option of the
19835 same name.
19836
19837 Failing to set this option when it is needed
19838 (because a remote router handles only some of the local-parts for a domain)
19839 can result in incorrect error messages being generated.
19840
19841 The setting of &%retry_use_local_part%& applies only to the router on which it
19842 appears. If the router generates child addresses, they are routed
19843 independently; this setting does not become attached to them.
19844
19845
19846
19847 .option router_home_directory routers string&!! unset
19848 .cindex "router" "home directory for"
19849 .cindex "home directory" "for router"
19850 .vindex "&$home$&"
19851 This option sets a home directory for use while the router is running. (Compare
19852 &%transport_home_directory%&, which sets a home directory for later
19853 transporting.) In particular, if used on a &(redirect)& router, this option
19854 sets a value for &$home$& while a filter is running. The value is expanded;
19855 forced expansion failure causes the option to be ignored &-- other failures
19856 cause the router to defer.
19857
19858 Expansion of &%router_home_directory%& happens immediately after the
19859 &%check_local_user%& test (if configured), before any further expansions take
19860 place.
19861 (See section &<<SECTrouprecon>>& for a list of the order in which preconditions
19862 are evaluated.)
19863 While the router is running, &%router_home_directory%& overrides the value of
19864 &$home$& that came from &%check_local_user%&.
19865
19866 When a router accepts an address and assigns it to a local transport (including
19867 the cases when a &(redirect)& router generates a pipe, file, or autoreply
19868 delivery), the home directory setting for the transport is taken from the first
19869 of these values that is set:
19870
19871 .ilist
19872 The &%home_directory%& option on the transport;
19873 .next
19874 The &%transport_home_directory%& option on the router;
19875 .next
19876 The password data if &%check_local_user%& is set on the router;
19877 .next
19878 The &%router_home_directory%& option on the router.
19879 .endlist
19880
19881 In other words, &%router_home_directory%& overrides the password data for the
19882 router, but not for the transport.
19883
19884
19885
19886 .option self routers string freeze
19887 .cindex "MX record" "pointing to local host"
19888 .cindex "local host" "MX pointing to"
19889 This option applies to those routers that use a recipient address to find a
19890 list of remote hosts. Currently, these are the &(dnslookup)&, &(ipliteral)&,
19891 and &(manualroute)& routers.
19892 Certain configurations of the &(queryprogram)& router can also specify a list
19893 of remote hosts.
19894 Usually such routers are configured to send the message to a remote host via an
19895 &(smtp)& transport. The &%self%& option specifies what happens when the first
19896 host on the list turns out to be the local host.
19897 The way in which Exim checks for the local host is described in section
19898 &<<SECTreclocipadd>>&.
19899
19900 Normally this situation indicates either an error in Exim's configuration (for
19901 example, the router should be configured not to process this domain), or an
19902 error in the DNS (for example, the MX should not point to this host). For this
19903 reason, the default action is to log the incident, defer the address, and
19904 freeze the message. The following alternatives are provided for use in special
19905 cases:
19906
19907 .vlist
19908 .vitem &%defer%&
19909 Delivery of the message is tried again later, but the message is not frozen.
19910
19911 .vitem "&%reroute%&: <&'domain'&>"
19912 The domain is changed to the given domain, and the address is passed back to
19913 be reprocessed by the routers. No rewriting of headers takes place. This
19914 behaviour is essentially a redirection.
19915
19916 .vitem "&%reroute: rewrite:%& <&'domain'&>"
19917 The domain is changed to the given domain, and the address is passed back to be
19918 reprocessed by the routers. Any headers that contain the original domain are
19919 rewritten.
19920
19921 .vitem &%pass%&
19922 .oindex "&%more%&"
19923 .vindex "&$self_hostname$&"
19924 The router passes the address to the next router, or to the router named in the
19925 &%pass_router%& option if it is set. This overrides &%no_more%&. During
19926 subsequent routing and delivery, the variable &$self_hostname$& contains the
19927 name of the local host that the router encountered. This can be used to
19928 distinguish between different cases for hosts with multiple names. The
19929 combination
19930 .code
19931 self = pass
19932 no_more
19933 .endd
19934 ensures that only those addresses that routed to the local host are passed on.
19935 Without &%no_more%&, addresses that were declined for other reasons would also
19936 be passed to the next router.
19937
19938 .vitem &%fail%&
19939 Delivery fails and an error report is generated.
19940
19941 .vitem &%send%&
19942 .cindex "local host" "sending to"
19943 The anomaly is ignored and the address is queued for the transport. This
19944 setting should be used with extreme caution. For an &(smtp)& transport, it
19945 makes sense only in cases where the program that is listening on the SMTP port
19946 is not this version of Exim. That is, it must be some other MTA, or Exim with a
19947 different configuration file that handles the domain in another way.
19948 .endlist
19949
19950
19951
19952 .option senders routers&!? "address list&!!" unset
19953 .cindex "router" "checking senders"
19954 If this option is set, the router is skipped unless the message's sender
19955 address matches something on the list.
19956 See section &<<SECTrouprecon>>& for a list of the order in which preconditions
19957 are evaluated.
19958
19959 There are issues concerning verification when the running of routers is
19960 dependent on the sender. When Exim is verifying the address in an &%errors_to%&
19961 setting, it sets the sender to the null string. When using the &%-bt%& option
19962 to check a configuration file, it is necessary also to use the &%-f%& option to
19963 set an appropriate sender. For incoming mail, the sender is unset when
19964 verifying the sender, but is available when verifying any recipients. If the
19965 SMTP VRFY command is enabled, it must be used after MAIL if the sender address
19966 matters.
19967
19968
19969 .option set routers "string list" unset
19970 .cindex router variables
19971 This option may be used multiple times on a router;
19972 because of this the list aspect is mostly irrelevant.
19973 The list separator is a semicolon but can be changed in the
19974 usual way.
19975
19976 Each list-element given must be of the form &"name = value"&
19977 and the names used must start with the string &"r_"&.
19978 Values containing a list-separator should have them doubled.
19979 When a router runs, the strings are evaluated in order,
19980 to create variables which are added to the set associated with
19981 the address.
19982 This is done immediately after all the preconditions, before the
19983 evaluation of the &%address_data%& option.
19984 The variable is set with the expansion of the value.
19985 The variables can be used by the router options
19986 (not including any preconditions)
19987 and by the transport.
19988 Later definitions of a given named variable will override former ones.
19989 Variable use is via the usual &$r_...$& syntax.
19990
19991 This is similar to the &%address_data%& option, except that
19992 many independent variables can be used, with choice of naming.
19993
19994
19995 .option translate_ip_address routers string&!! unset
19996 .cindex "IP address" "translating"
19997 .cindex "packet radio"
19998 .cindex "router" "IP address translation"
19999 There exist some rare networking situations (for example, packet radio) where
20000 it is helpful to be able to translate IP addresses generated by normal routing
20001 mechanisms into other IP addresses, thus performing a kind of manual IP
20002 routing. This should be done only if the normal IP routing of the TCP/IP stack
20003 is inadequate or broken. Because this is an extremely uncommon requirement, the
20004 code to support this option is not included in the Exim binary unless
20005 SUPPORT_TRANSLATE_IP_ADDRESS=yes is set in &_Local/Makefile_&.
20006
20007 .vindex "&$host_address$&"
20008 The &%translate_ip_address%& string is expanded for every IP address generated
20009 by the router, with the generated address set in &$host_address$&. If the
20010 expansion is forced to fail, no action is taken.
20011 For any other expansion error, delivery of the message is deferred.
20012 If the result of the expansion is an IP address, that replaces the original
20013 address; otherwise the result is assumed to be a host name &-- this is looked
20014 up using &[gethostbyname()]& (or &[getipnodebyname()]& when available) to
20015 produce one or more replacement IP addresses. For example, to subvert all IP
20016 addresses in some specific networks, this could be added to a router:
20017 .code
20018 translate_ip_address = \
20019   ${lookup{${mask:$host_address/26}}lsearch{/some/file}\
20020     {$value}fail}}
20021 .endd
20022 The file would contain lines like
20023 .code
20024 10.2.3.128/26    some.host
20025 10.8.4.34/26     10.44.8.15
20026 .endd
20027 You should not make use of this facility unless you really understand what you
20028 are doing.
20029
20030
20031
20032 .option transport routers string&!! unset
20033 This option specifies the transport to be used when a router accepts an address
20034 and sets it up for delivery. A transport is never needed if a router is used
20035 only for verification. The value of the option is expanded at routing time,
20036 after the expansion of &%errors_to%&, &%headers_add%&, and &%headers_remove%&,
20037 and result must be the name of one of the configured transports. If it is not,
20038 delivery is deferred.
20039
20040 The &%transport%& option is not used by the &(redirect)& router, but it does
20041 have some private options that set up transports for pipe and file deliveries
20042 (see chapter &<<CHAPredirect>>&).
20043
20044
20045
20046 .option transport_current_directory routers string&!! unset
20047 .cindex "current directory for local transport"
20048 This option associates a current directory with any address that is routed
20049 to a local transport. This can happen either because a transport is
20050 explicitly configured for the router, or because it generates a delivery to a
20051 file or a pipe. During the delivery process (that is, at transport time), this
20052 option string is expanded and is set as the current directory, unless
20053 overridden by a setting on the transport.
20054 If the expansion fails for any reason, including forced failure, an error is
20055 logged, and delivery is deferred.
20056 See chapter &<<CHAPenvironment>>& for details of the local delivery
20057 environment.
20058
20059
20060
20061
20062 .option transport_home_directory routers string&!! "see below"
20063 .cindex "home directory" "for local transport"
20064 This option associates a home directory with any address that is routed to a
20065 local transport. This can happen either because a transport is explicitly
20066 configured for the router, or because it generates a delivery to a file or a
20067 pipe. During the delivery process (that is, at transport time), the option
20068 string is expanded and is set as the home directory, unless overridden by a
20069 setting of &%home_directory%& on the transport.
20070 If the expansion fails for any reason, including forced failure, an error is
20071 logged, and delivery is deferred.
20072
20073 If the transport does not specify a home directory, and
20074 &%transport_home_directory%& is not set for the router, the home directory for
20075 the transport is taken from the password data if &%check_local_user%& is set for
20076 the router. Otherwise it is taken from &%router_home_directory%& if that option
20077 is set; if not, no home directory is set for the transport.
20078
20079 See chapter &<<CHAPenvironment>>& for further details of the local delivery
20080 environment.
20081
20082
20083
20084
20085 .option unseen routers boolean&!! false
20086 .cindex "router" "carrying on after success"
20087 The result of string expansion for this option must be a valid boolean value,
20088 that is, one of the strings &"yes"&, &"no"&, &"true"&, or &"false"&. Any other
20089 result causes an error, and delivery is deferred. If the expansion is forced to
20090 fail, the default value for the option (false) is used. Other failures cause
20091 delivery to be deferred.
20092
20093 When this option is set true, routing does not cease if the router accepts the
20094 address. Instead, a copy of the incoming address is passed to the next router,
20095 overriding a false setting of &%more%&. There is little point in setting
20096 &%more%& false if &%unseen%& is always true, but it may be useful in cases when
20097 the value of &%unseen%& contains expansion items (and therefore, presumably, is
20098 sometimes true and sometimes false).
20099
20100 .cindex "copy of message (&%unseen%& option)"
20101 Setting the &%unseen%& option has a similar effect to the &%unseen%& command
20102 qualifier in filter files. It can be used to cause copies of messages to be
20103 delivered to some other destination, while also carrying out a normal delivery.
20104 In effect, the current address is made into a &"parent"& that has two children
20105 &-- one that is delivered as specified by this router, and a clone that goes on
20106 to be routed further. For this reason, &%unseen%& may not be combined with the
20107 &%one_time%& option in a &(redirect)& router.
20108
20109 &*Warning*&: Header lines added to the address (or specified for removal) by
20110 this router or by previous routers affect the &"unseen"& copy of the message
20111 only. The clone that continues to be processed by further routers starts with
20112 no added headers and none specified for removal. For a &%redirect%& router, if
20113 a generated address is the same as the incoming address, this can lead to
20114 duplicate addresses with different header modifications. Exim does not do
20115 duplicate deliveries (except, in certain circumstances, to pipes -- see section
20116 &<<SECTdupaddr>>&), but it is undefined which of the duplicates is discarded,
20117 so this ambiguous situation should be avoided. The &%repeat_use%& option of the
20118 &%redirect%& router may be of help.
20119
20120 Unlike the handling of header modifications, any data that was set by the
20121 &%address_data%& option in the current or previous routers &'is'& passed on to
20122 subsequent routers.
20123
20124
20125 .option user routers string&!! "see below"
20126 .cindex "uid (user id)" "local delivery"
20127 .cindex "local transports" "uid and gid"
20128 .cindex "transport" "local"
20129 .cindex "router" "user for filter processing"
20130 .cindex "filter" "user for processing"
20131 When a router queues an address for a transport, and the transport does not
20132 specify a user, the user given here is used when running the delivery process.
20133 The user may be specified numerically or by name. If expansion fails, the
20134 error is logged and delivery is deferred.
20135 This user is also used by the &(redirect)& router when running a filter file.
20136 The default is unset, except when &%check_local_user%& is set. In this case,
20137 the default is taken from the password information. If the user is specified as
20138 a name, and &%group%& is not set, the group associated with the user is used.
20139 See also &%initgroups%& and &%group%& and the discussion in chapter
20140 &<<CHAPenvironment>>&.
20141
20142
20143
20144 .option verify routers&!? boolean true
20145 Setting this option has the effect of setting &%verify_sender%& and
20146 &%verify_recipient%& to the same value.
20147
20148
20149 .option verify_only routers&!? boolean false
20150 .cindex "EXPN" "with &%verify_only%&"
20151 .oindex "&%-bv%&"
20152 .cindex "router" "used only when verifying"
20153 If this option is set, the router is used only when verifying an address,
20154 delivering in cutthrough mode or
20155 testing with the &%-bv%& option, not when actually doing a delivery, testing
20156 with the &%-bt%& option, or running the SMTP EXPN command. It can be further
20157 restricted to verifying only senders or recipients by means of
20158 &%verify_sender%& and &%verify_recipient%&.
20159
20160 &*Warning*&: When the router is being run to verify addresses for an incoming
20161 SMTP message, Exim is not running as root, but under its own uid. If the router
20162 accesses any files, you need to make sure that they are accessible to the Exim
20163 user or group.
20164
20165
20166 .option verify_recipient routers&!? boolean true
20167 If this option is false, the router is skipped when verifying recipient
20168 addresses,
20169 delivering in cutthrough mode
20170 or testing recipient verification using &%-bv%&.
20171 See section &<<SECTrouprecon>>& for a list of the order in which preconditions
20172 are evaluated.
20173 See also the &$verify_mode$& variable.
20174
20175
20176 .option verify_sender routers&!? boolean true
20177 If this option is false, the router is skipped when verifying sender addresses
20178 or testing sender verification using &%-bvs%&.
20179 See section &<<SECTrouprecon>>& for a list of the order in which preconditions
20180 are evaluated.
20181 See also the &$verify_mode$& variable.
20182 .ecindex IIDgenoprou1
20183 .ecindex IIDgenoprou2
20184
20185
20186
20187
20188
20189
20190 . ////////////////////////////////////////////////////////////////////////////
20191 . ////////////////////////////////////////////////////////////////////////////
20192
20193 .chapter "The accept router" "CHID4"
20194 .cindex "&(accept)& router"
20195 .cindex "routers" "&(accept)&"
20196 The &(accept)& router has no private options of its own. Unless it is being
20197 used purely for verification (see &%verify_only%&) a transport is required to
20198 be defined by the generic &%transport%& option. If the preconditions that are
20199 specified by generic options are met, the router accepts the address and queues
20200 it for the given transport. The most common use of this router is for setting
20201 up deliveries to local mailboxes. For example:
20202 .code
20203 localusers:
20204   driver = accept
20205   domains = mydomain.example
20206   check_local_user
20207   transport = local_delivery
20208 .endd
20209 The &%domains%& condition in this example checks the domain of the address, and
20210 &%check_local_user%& checks that the local part is the login of a local user.
20211 When both preconditions are met, the &(accept)& router runs, and queues the
20212 address for the &(local_delivery)& transport.
20213
20214
20215
20216
20217
20218
20219 . ////////////////////////////////////////////////////////////////////////////
20220 . ////////////////////////////////////////////////////////////////////////////
20221
20222 .chapter "The dnslookup router" "CHAPdnslookup"
20223 .scindex IIDdnsrou1 "&(dnslookup)& router"
20224 .scindex IIDdnsrou2 "routers" "&(dnslookup)&"
20225 The &(dnslookup)& router looks up the hosts that handle mail for the
20226 recipient's domain in the DNS. A transport must always be set for this router,
20227 unless &%verify_only%& is set.
20228
20229 If SRV support is configured (see &%check_srv%& below), Exim first searches for
20230 SRV records. If none are found, or if SRV support is not configured,
20231 MX records are looked up. If no MX records exist, address records are sought.
20232 However, &%mx_domains%& can be set to disable the direct use of address
20233 records.
20234
20235 MX records of equal priority are sorted by Exim into a random order. Exim then
20236 looks for address records for the host names obtained from MX or SRV records.
20237 When a host has more than one IP address, they are sorted into a random order,
20238 except that IPv6 addresses are sorted before IPv4 addresses. If all the
20239 IP addresses found are discarded by a setting of the &%ignore_target_hosts%&
20240 generic option, the router declines.
20241
20242 Unless they have the highest priority (lowest MX value), MX records that point
20243 to the local host, or to any host name that matches &%hosts_treat_as_local%&,
20244 are discarded, together with any other MX records of equal or lower priority.
20245
20246 .cindex "MX record" "pointing to local host"
20247 .cindex "local host" "MX pointing to"
20248 .oindex "&%self%&" "in &(dnslookup)& router"
20249 If the host pointed to by the highest priority MX record, or looked up as an
20250 address record, is the local host, or matches &%hosts_treat_as_local%&, what
20251 happens is controlled by the generic &%self%& option.
20252
20253
20254 .section "Problems with DNS lookups" "SECTprowitdnsloo"
20255 There have been problems with DNS servers when SRV records are looked up.
20256 Some misbehaving servers return a DNS error or timeout when a non-existent
20257 SRV record is sought. Similar problems have in the past been reported for
20258 MX records. The global &%dns_again_means_nonexist%& option can help with this
20259 problem, but it is heavy-handed because it is a global option.
20260
20261 For this reason, there are two options, &%srv_fail_domains%& and
20262 &%mx_fail_domains%&, that control what happens when a DNS lookup in a
20263 &(dnslookup)& router results in a DNS failure or a &"try again"& response. If
20264 an attempt to look up an SRV or MX record causes one of these results, and the
20265 domain matches the relevant list, Exim behaves as if the DNS had responded &"no
20266 such record"&. In the case of an SRV lookup, this means that the router
20267 proceeds to look for MX records; in the case of an MX lookup, it proceeds to
20268 look for A or AAAA records, unless the domain matches &%mx_domains%&, in which
20269 case routing fails.
20270
20271
20272 .section "Declining addresses by dnslookup" "SECTdnslookupdecline"
20273 .cindex "&(dnslookup)& router" "declines"
20274 There are a few cases where a &(dnslookup)& router will decline to accept
20275 an address; if such a router is expected to handle "all remaining non-local
20276 domains", then it is important to set &%no_more%&.
20277
20278 The router will defer rather than decline if the domain
20279 is found in the &%fail_defer_domains%& router option.
20280
20281 Reasons for a &(dnslookup)& router to decline currently include:
20282 .ilist
20283 The domain does not exist in DNS
20284 .next
20285 The domain exists but the MX record's host part is just "."; this is a common
20286 convention (borrowed from SRV) used to indicate that there is no such service
20287 for this domain and to not fall back to trying A/AAAA records.
20288 .next
20289 Ditto, but for SRV records, when &%check_srv%& is set on this router.
20290 .next
20291 MX record points to a non-existent host.
20292 .next
20293 MX record points to an IP address and the main section option
20294 &%allow_mx_to_ip%& is not set.
20295 .next
20296 MX records exist and point to valid hosts, but all hosts resolve only to
20297 addresses blocked by the &%ignore_target_hosts%& generic option on this router.
20298 .next
20299 The domain is not syntactically valid (see also &%allow_utf8_domains%& and
20300 &%dns_check_names_pattern%& for handling one variant of this)
20301 .next
20302 &%check_secondary_mx%& is set on this router but the local host can
20303 not be found in the MX records (see below)
20304 .endlist
20305
20306
20307
20308
20309 .section "Private options for dnslookup" "SECID118"
20310 .cindex "options" "&(dnslookup)& router"
20311 The private options for the &(dnslookup)& router are as follows:
20312
20313 .option check_secondary_mx dnslookup boolean false
20314 .cindex "MX record" "checking for secondary"
20315 If this option is set, the router declines unless the local host is found in
20316 (and removed from) the list of hosts obtained by MX lookup. This can be used to
20317 process domains for which the local host is a secondary mail exchanger
20318 differently to other domains. The way in which Exim decides whether a host is
20319 the local host is described in section &<<SECTreclocipadd>>&.
20320
20321
20322 .option check_srv dnslookup string&!! unset
20323 .cindex "SRV record" "enabling use of"
20324 The &(dnslookup)& router supports the use of SRV records (see RFC 2782) in
20325 addition to MX and address records. The support is disabled by default. To
20326 enable SRV support, set the &%check_srv%& option to the name of the service
20327 required. For example,
20328 .code
20329 check_srv = smtp
20330 .endd
20331 looks for SRV records that refer to the normal smtp service. The option is
20332 expanded, so the service name can vary from message to message or address
20333 to address. This might be helpful if SRV records are being used for a
20334 submission service. If the expansion is forced to fail, the &%check_srv%&
20335 option is ignored, and the router proceeds to look for MX records in the
20336 normal way.
20337
20338 When the expansion succeeds, the router searches first for SRV records for
20339 the given service (it assumes TCP protocol). A single SRV record with a
20340 host name that consists of just a single dot indicates &"no such service for
20341 this domain"&; if this is encountered, the router declines. If other kinds of
20342 SRV record are found, they are used to construct a host list for delivery
20343 according to the rules of RFC 2782. MX records are not sought in this case.
20344
20345 When no SRV records are found, MX records (and address records) are sought in
20346 the traditional way. In other words, SRV records take precedence over MX
20347 records, just as MX records take precedence over address records. Note that
20348 this behaviour is not sanctioned by RFC 2782, though a previous draft RFC
20349 defined it. It is apparently believed that MX records are sufficient for email
20350 and that SRV records should not be used for this purpose. However, SRV records
20351 have an additional &"weight"& feature which some people might find useful when
20352 trying to split an SMTP load between hosts of different power.
20353
20354 See section &<<SECTprowitdnsloo>>& above for a discussion of Exim's behaviour
20355 when there is a DNS lookup error.
20356
20357
20358
20359
20360 .option fail_defer_domains dnslookup "domain list&!!" unset
20361 .cindex "MX record" "not found"
20362 DNS lookups for domains matching &%fail_defer_domains%&
20363 which find no matching record will cause the router to defer
20364 rather than the default behaviour of decline.
20365 This maybe be useful for queueing messages for a newly created
20366 domain while the DNS configuration is not ready.
20367 However, it will result in any message with mistyped domains
20368 also being queued.
20369
20370
20371 .option ipv4_only "string&!!" unset
20372 .cindex IPv6 disabling
20373 .cindex DNS "IPv6 disabling"
20374 The string is expanded, and if the result is anything but a forced failure,
20375 or an empty string, or one of the strings “0” or “no” or “false”
20376 (checked without regard to the case of the letters),
20377 only A records are used.
20378
20379 .option ipv4_prefer "string&!!" unset
20380 .cindex IPv4 preference
20381 .cindex DNS "IPv4 preference"
20382 The string is expanded, and if the result is anything but a forced failure,
20383 or an empty string, or one of the strings “0” or “no” or “false”
20384 (checked without regard to the case of the letters),
20385 A records are sorted before AAAA records (inverting the default).
20386
20387 .option mx_domains dnslookup "domain list&!!" unset
20388 .cindex "MX record" "required to exist"
20389 .cindex "SRV record" "required to exist"
20390 A domain that matches &%mx_domains%& is required to have either an MX or an SRV
20391 record in order to be recognized. (The name of this option could be improved.)
20392 For example, if all the mail hosts in &'fict.example'& are known to have MX
20393 records, except for those in &'discworld.fict.example'&, you could use this
20394 setting:
20395 .code
20396 mx_domains = ! *.discworld.fict.example : *.fict.example
20397 .endd
20398 This specifies that messages addressed to a domain that matches the list but
20399 has no MX record should be bounced immediately instead of being routed using
20400 the address record.
20401
20402
20403 .option mx_fail_domains dnslookup "domain list&!!" unset
20404 If the DNS lookup for MX records for one of the domains in this list causes a
20405 DNS lookup error, Exim behaves as if no MX records were found. See section
20406 &<<SECTprowitdnsloo>>& for more discussion.
20407
20408
20409
20410
20411 .option qualify_single dnslookup boolean true
20412 .cindex "DNS" "resolver options"
20413 .cindex "DNS" "qualifying single-component names"
20414 When this option is true, the resolver option RES_DEFNAMES is set for DNS
20415 lookups. Typically, but not standardly, this causes the resolver to qualify
20416 single-component names with the default domain. For example, on a machine
20417 called &'dictionary.ref.example'&, the domain &'thesaurus'& would be changed to
20418 &'thesaurus.ref.example'& inside the resolver. For details of what your
20419 resolver actually does, consult your man pages for &'resolver'& and
20420 &'resolv.conf'&.
20421
20422
20423
20424 .option rewrite_headers dnslookup boolean true
20425 .cindex "rewriting" "header lines"
20426 .cindex "header lines" "rewriting"
20427 If the domain name in the address that is being processed is not fully
20428 qualified, it may be expanded to its full form by a DNS lookup. For example, if
20429 an address is specified as &'dormouse@teaparty'&, the domain might be
20430 expanded to &'teaparty.wonderland.fict.example'&. Domain expansion can also
20431 occur as a result of setting the &%widen_domains%& option. If
20432 &%rewrite_headers%& is true, all occurrences of the abbreviated domain name in
20433 any &'Bcc:'&, &'Cc:'&, &'From:'&, &'Reply-to:'&, &'Sender:'&, and &'To:'&
20434 header lines of the message are rewritten with the full domain name.
20435
20436 This option should be turned off only when it is known that no message is
20437 ever going to be sent outside an environment where the abbreviation makes
20438 sense.
20439
20440 When an MX record is looked up in the DNS and matches a wildcard record, name
20441 servers normally return a record containing the name that has been looked up,
20442 making it impossible to detect whether a wildcard was present or not. However,
20443 some name servers have recently been seen to return the wildcard entry. If the
20444 name returned by a DNS lookup begins with an asterisk, it is not used for
20445 header rewriting.
20446
20447
20448 .option same_domain_copy_routing dnslookup boolean false
20449 .cindex "address" "copying routing"
20450 Addresses with the same domain are normally routed by the &(dnslookup)& router
20451 to the same list of hosts. However, this cannot be presumed, because the router
20452 options and preconditions may refer to the local part of the address. By
20453 default, therefore, Exim routes each address in a message independently. DNS
20454 servers run caches, so repeated DNS lookups are not normally expensive, and in
20455 any case, personal messages rarely have more than a few recipients.
20456
20457 If you are running mailing lists with large numbers of subscribers at the same
20458 domain, and you are using a &(dnslookup)& router which is independent of the
20459 local part, you can set &%same_domain_copy_routing%& to bypass repeated DNS
20460 lookups for identical domains in one message. In this case, when &(dnslookup)&
20461 routes an address to a remote transport, any other unrouted addresses in the
20462 message that have the same domain are automatically given the same routing
20463 without processing them independently,
20464 provided the following conditions are met:
20465
20466 .ilist
20467 No router that processed the address specified &%headers_add%& or
20468 &%headers_remove%&.
20469 .next
20470 The router did not change the address in any way, for example, by &"widening"&
20471 the domain.
20472 .endlist
20473
20474
20475
20476
20477 .option search_parents dnslookup boolean false
20478 .cindex "DNS" "resolver options"
20479 When this option is true, the resolver option RES_DNSRCH is set for DNS
20480 lookups. This is different from the &%qualify_single%& option in that it
20481 applies to domains containing dots. Typically, but not standardly, it causes
20482 the resolver to search for the name in the current domain and in parent
20483 domains. For example, on a machine in the &'fict.example'& domain, if looking
20484 up &'teaparty.wonderland'& failed, the resolver would try
20485 &'teaparty.wonderland.fict.example'&. For details of what your resolver
20486 actually does, consult your man pages for &'resolver'& and &'resolv.conf'&.
20487
20488 Setting this option true can cause problems in domains that have a wildcard MX
20489 record, because any domain that does not have its own MX record matches the
20490 local wildcard.
20491
20492
20493
20494 .option srv_fail_domains dnslookup "domain list&!!" unset
20495 If the DNS lookup for SRV records for one of the domains in this list causes a
20496 DNS lookup error, Exim behaves as if no SRV records were found. See section
20497 &<<SECTprowitdnsloo>>& for more discussion.
20498
20499
20500
20501
20502 .option widen_domains dnslookup "string list" unset
20503 .cindex "domain" "partial; widening"
20504 If a DNS lookup fails and this option is set, each of its strings in turn is
20505 added onto the end of the domain, and the lookup is tried again. For example,
20506 if
20507 .code
20508 widen_domains = fict.example:ref.example
20509 .endd
20510 is set and a lookup of &'klingon.dictionary'& fails,
20511 &'klingon.dictionary.fict.example'& is looked up, and if this fails,
20512 &'klingon.dictionary.ref.example'& is tried. Note that the &%qualify_single%&
20513 and &%search_parents%& options can cause some widening to be undertaken inside
20514 the DNS resolver. &%widen_domains%& is not applied to sender addresses
20515 when verifying, unless &%rewrite_headers%& is false (not the default).
20516
20517
20518 .section "Effect of qualify_single and search_parents" "SECID119"
20519 When a domain from an envelope recipient is changed by the resolver as a result
20520 of the &%qualify_single%& or &%search_parents%& options, Exim rewrites the
20521 corresponding address in the message's header lines unless &%rewrite_headers%&
20522 is set false. Exim then re-routes the address, using the full domain.
20523
20524 These two options affect only the DNS lookup that takes place inside the router
20525 for the domain of the address that is being routed. They do not affect lookups
20526 such as that implied by
20527 .code
20528 domains = @mx_any
20529 .endd
20530 that may happen while processing a router precondition before the router is
20531 entered. No widening ever takes place for these lookups.
20532 .ecindex IIDdnsrou1
20533 .ecindex IIDdnsrou2
20534
20535
20536
20537
20538
20539
20540
20541
20542
20543 . ////////////////////////////////////////////////////////////////////////////
20544 . ////////////////////////////////////////////////////////////////////////////
20545
20546 .chapter "The ipliteral router" "CHID5"
20547 .cindex "&(ipliteral)& router"
20548 .cindex "domain literal" "routing"
20549 .cindex "routers" "&(ipliteral)&"
20550 This router has no private options. Unless it is being used purely for
20551 verification (see &%verify_only%&) a transport is required to be defined by the
20552 generic &%transport%& option. The router accepts the address if its domain part
20553 takes the form of an RFC 2822 domain literal. For example, the &(ipliteral)&
20554 router handles the address
20555 .code
20556 root@[192.168.1.1]
20557 .endd
20558 by setting up delivery to the host with that IP address. IPv4 domain literals
20559 consist of an IPv4 address enclosed in square brackets. IPv6 domain literals
20560 are similar, but the address is preceded by &`ipv6:`&. For example:
20561 .code
20562 postmaster@[ipv6:fe80::a00:20ff:fe86:a061.5678]
20563 .endd
20564 Exim allows &`ipv4:`& before IPv4 addresses, for consistency, and on the
20565 grounds that sooner or later somebody will try it.
20566
20567 .oindex "&%self%&" "in &(ipliteral)& router"
20568 If the IP address matches something in &%ignore_target_hosts%&, the router
20569 declines. If an IP literal turns out to refer to the local host, the generic
20570 &%self%& option determines what happens.
20571
20572 The RFCs require support for domain literals; however, their use is
20573 controversial in today's Internet. If you want to use this router, you must
20574 also set the main configuration option &%allow_domain_literals%&. Otherwise,
20575 Exim will not recognize the domain literal syntax in addresses.
20576
20577
20578
20579 . ////////////////////////////////////////////////////////////////////////////
20580 . ////////////////////////////////////////////////////////////////////////////
20581
20582 .chapter "The iplookup router" "CHID6"
20583 .cindex "&(iplookup)& router"
20584 .cindex "routers" "&(iplookup)&"
20585 The &(iplookup)& router was written to fulfil a specific requirement in
20586 Cambridge University (which in fact no longer exists). For this reason, it is
20587 not included in the binary of Exim by default. If you want to include it, you
20588 must set
20589 .code
20590 ROUTER_IPLOOKUP=yes
20591 .endd
20592 in your &_Local/Makefile_& configuration file.
20593
20594 The &(iplookup)& router routes an address by sending it over a TCP or UDP
20595 connection to one or more specific hosts. The host can then return the same or
20596 a different address &-- in effect rewriting the recipient address in the
20597 message's envelope. The new address is then passed on to subsequent routers. If
20598 this process fails, the address can be passed on to other routers, or delivery
20599 can be deferred. Since &(iplookup)& is just a rewriting router, a transport
20600 must not be specified for it.
20601
20602 .cindex "options" "&(iplookup)& router"
20603 .option hosts iplookup string unset
20604 This option must be supplied. Its value is a colon-separated list of host
20605 names. The hosts are looked up using &[gethostbyname()]&
20606 (or &[getipnodebyname()]& when available)
20607 and are tried in order until one responds to the query. If none respond, what
20608 happens is controlled by &%optional%&.
20609
20610
20611 .option optional iplookup boolean false
20612 If &%optional%& is true, if no response is obtained from any host, the address
20613 is passed to the next router, overriding &%no_more%&. If &%optional%& is false,
20614 delivery to the address is deferred.
20615
20616
20617 .option port iplookup integer 0
20618 .cindex "port" "&(iplookup)& router"
20619 This option must be supplied. It specifies the port number for the TCP or UDP
20620 call.
20621
20622
20623 .option protocol iplookup string udp
20624 This option can be set to &"udp"& or &"tcp"& to specify which of the two
20625 protocols is to be used.
20626
20627
20628 .option query iplookup string&!! "see below"
20629 This defines the content of the query that is sent to the remote hosts. The
20630 default value is:
20631 .code
20632 $local_part@$domain $local_part@$domain
20633 .endd
20634 The repetition serves as a way of checking that a response is to the correct
20635 query in the default case (see &%response_pattern%& below).
20636
20637
20638 .option reroute iplookup string&!! unset
20639 If this option is not set, the rerouted address is precisely the byte string
20640 returned by the remote host, up to the first white space, if any. If set, the
20641 string is expanded to form the rerouted address. It can include parts matched
20642 in the response by &%response_pattern%& by means of numeric variables such as
20643 &$1$&, &$2$&, etc. The variable &$0$& refers to the entire input string,
20644 whether or not a pattern is in use. In all cases, the rerouted address must end
20645 up in the form &'local_part@domain'&.
20646
20647
20648 .option response_pattern iplookup string unset
20649 This option can be set to a regular expression that is applied to the string
20650 returned from the remote host. If the pattern does not match the response, the
20651 router declines. If &%response_pattern%& is not set, no checking of the
20652 response is done, unless the query was defaulted, in which case there is a
20653 check that the text returned after the first white space is the original
20654 address. This checks that the answer that has been received is in response to
20655 the correct question. For example, if the response is just a new domain, the
20656 following could be used:
20657 .code
20658 response_pattern = ^([^@]+)$
20659 reroute = $local_part@$1
20660 .endd
20661
20662 .option timeout iplookup time 5s
20663 This specifies the amount of time to wait for a response from the remote
20664 machine. The same timeout is used for the &[connect()]& function for a TCP
20665 call. It does not apply to UDP.
20666
20667
20668
20669
20670 . ////////////////////////////////////////////////////////////////////////////
20671 . ////////////////////////////////////////////////////////////////////////////
20672
20673 .chapter "The manualroute router" "CHID7"
20674 .scindex IIDmanrou1 "&(manualroute)& router"
20675 .scindex IIDmanrou2 "routers" "&(manualroute)&"
20676 .cindex "domain" "manually routing"
20677 The &(manualroute)& router is so-called because it provides a way of manually
20678 routing an address according to its domain. It is mainly used when you want to
20679 route addresses to remote hosts according to your own rules, bypassing the
20680 normal DNS routing that looks up MX records. However, &(manualroute)& can also
20681 route to local transports, a facility that may be useful if you want to save
20682 messages for dial-in hosts in local files.
20683
20684 The &(manualroute)& router compares a list of domain patterns with the domain
20685 it is trying to route. If there is no match, the router declines. Each pattern
20686 has associated with it a list of hosts and some other optional data, which may
20687 include a transport. The combination of a pattern and its data is called a
20688 &"routing rule"&. For patterns that do not have an associated transport, the
20689 generic &%transport%& option must specify a transport, unless the router is
20690 being used purely for verification (see &%verify_only%&).
20691
20692 .vindex "&$host$&"
20693 In the case of verification, matching the domain pattern is sufficient for the
20694 router to accept the address. When actually routing an address for delivery,
20695 an address that matches a domain pattern is queued for the associated
20696 transport. If the transport is not a local one, a host list must be associated
20697 with the pattern; IP addresses are looked up for the hosts, and these are
20698 passed to the transport along with the mail address. For local transports, a
20699 host list is optional. If it is present, it is passed in &$host$& as a single
20700 text string.
20701
20702 The list of routing rules can be provided as an inline string in
20703 &%route_list%&, or the data can be obtained by looking up the domain in a file
20704 or database by setting &%route_data%&. Only one of these settings may appear in
20705 any one instance of &(manualroute)&. The format of routing rules is described
20706 below, following the list of private options.
20707
20708
20709 .section "Private options for manualroute" "SECTprioptman"
20710
20711 .cindex "options" "&(manualroute)& router"
20712 The private options for the &(manualroute)& router are as follows:
20713
20714 .option host_all_ignored manualroute string defer
20715 See &%host_find_failed%&.
20716
20717 .option host_find_failed manualroute string freeze
20718 This option controls what happens when &(manualroute)& tries to find an IP
20719 address for a host, and the host does not exist. The option can be set to one
20720 of the following values:
20721 .code
20722 decline
20723 defer
20724 fail
20725 freeze
20726 ignore
20727 pass
20728 .endd
20729 The default (&"freeze"&) assumes that this state is a serious configuration
20730 error. The difference between &"pass"& and &"decline"& is that the former
20731 forces the address to be passed to the next router (or the router defined by
20732 &%pass_router%&),
20733 .oindex "&%more%&"
20734 overriding &%no_more%&, whereas the latter passes the address to the next
20735 router only if &%more%& is true.
20736
20737 The value &"ignore"& causes Exim to completely ignore a host whose IP address
20738 cannot be found. If all the hosts in the list are ignored, the behaviour is
20739 controlled by the &%host_all_ignored%& option. This takes the same values
20740 as &%host_find_failed%&, except that it cannot be set to &"ignore"&.
20741
20742 The &%host_find_failed%& option applies only to a definite &"does not exist"&
20743 state; if a host lookup gets a temporary error, delivery is deferred unless the
20744 generic &%pass_on_timeout%& option is set.
20745
20746
20747 .option hosts_randomize manualroute boolean false
20748 .cindex "randomized host list"
20749 .cindex "host" "list of; randomized"
20750 If this option is set, the order of the items in a host list in a routing rule
20751 is randomized each time the list is used, unless an option in the routing rule
20752 overrides (see below). Randomizing the order of a host list can be used to do
20753 crude load sharing. However, if more than one mail address is routed by the
20754 same router to the same host list, the host lists are considered to be the same
20755 (even though they may be randomized into different orders) for the purpose of
20756 deciding whether to batch the deliveries into a single SMTP transaction.
20757
20758 When &%hosts_randomize%& is true, a host list may be split
20759 into groups whose order is separately randomized. This makes it possible to
20760 set up MX-like behaviour. The boundaries between groups are indicated by an
20761 item that is just &`+`& in the host list. For example:
20762 .code
20763 route_list = * host1:host2:host3:+:host4:host5
20764 .endd
20765 The order of the first three hosts and the order of the last two hosts is
20766 randomized for each use, but the first three always end up before the last two.
20767 If &%hosts_randomize%& is not set, a &`+`& item in the list is ignored. If a
20768 randomized host list is passed to an &(smtp)& transport that also has
20769 &%hosts_randomize set%&, the list is not re-randomized.
20770
20771
20772 .option route_data manualroute string&!! unset
20773 If this option is set, it must expand to yield the data part of a routing rule.
20774 Typically, the expansion string includes a lookup based on the domain. For
20775 example:
20776 .code
20777 route_data = ${lookup{$domain}dbm{/etc/routes}}
20778 .endd
20779 If the expansion is forced to fail, or the result is an empty string, the
20780 router declines. Other kinds of expansion failure cause delivery to be
20781 deferred.
20782
20783
20784 .option route_list manualroute "string list" unset
20785 This string is a list of routing rules, in the form defined below. Note that,
20786 unlike most string lists, the items are separated by semicolons. This is so
20787 that they may contain colon-separated host lists.
20788
20789
20790 .option same_domain_copy_routing manualroute boolean false
20791 .cindex "address" "copying routing"
20792 Addresses with the same domain are normally routed by the &(manualroute)&
20793 router to the same list of hosts. However, this cannot be presumed, because the
20794 router options and preconditions may refer to the local part of the address. By
20795 default, therefore, Exim routes each address in a message independently. DNS
20796 servers run caches, so repeated DNS lookups are not normally expensive, and in
20797 any case, personal messages rarely have more than a few recipients.
20798
20799 If you are running mailing lists with large numbers of subscribers at the same
20800 domain, and you are using a &(manualroute)& router which is independent of the
20801 local part, you can set &%same_domain_copy_routing%& to bypass repeated DNS
20802 lookups for identical domains in one message. In this case, when
20803 &(manualroute)& routes an address to a remote transport, any other unrouted
20804 addresses in the message that have the same domain are automatically given the
20805 same routing without processing them independently. However, this is only done
20806 if &%headers_add%& and &%headers_remove%& are unset.
20807
20808
20809
20810
20811 .section "Routing rules in route_list" "SECID120"
20812 The value of &%route_list%& is a string consisting of a sequence of routing
20813 rules, separated by semicolons. If a semicolon is needed in a rule, it can be
20814 entered as two semicolons. Alternatively, the list separator can be changed as
20815 described (for colon-separated lists) in section &<<SECTlistconstruct>>&.
20816 Empty rules are ignored. The format of each rule is
20817 .display
20818 <&'domain pattern'&>  <&'list of hosts'&>  <&'options'&>
20819 .endd
20820 The following example contains two rules, each with a simple domain pattern and
20821 no options:
20822 .code
20823 route_list = \
20824   dict.ref.example  mail-1.ref.example:mail-2.ref.example ; \
20825   thes.ref.example  mail-3.ref.example:mail-4.ref.example
20826 .endd
20827 The three parts of a rule are separated by white space. The pattern and the
20828 list of hosts can be enclosed in quotes if necessary, and if they are, the
20829 usual quoting rules apply. Each rule in a &%route_list%& must start with a
20830 single domain pattern, which is the only mandatory item in the rule. The
20831 pattern is in the same format as one item in a domain list (see section
20832 &<<SECTdomainlist>>&),
20833 except that it may not be the name of an interpolated file.
20834 That is, it may be wildcarded, or a regular expression, or a file or database
20835 lookup (with semicolons doubled, because of the use of semicolon as a separator
20836 in a &%route_list%&).
20837
20838 The rules in &%route_list%& are searched in order until one of the patterns
20839 matches the domain that is being routed. The list of hosts and then options are
20840 then used as described below. If there is no match, the router declines. When
20841 &%route_list%& is set, &%route_data%& must not be set.
20842
20843
20844
20845 .section "Routing rules in route_data" "SECID121"
20846 The use of &%route_list%& is convenient when there are only a small number of
20847 routing rules. For larger numbers, it is easier to use a file or database to
20848 hold the routing information, and use the &%route_data%& option instead.
20849 The value of &%route_data%& is a list of hosts, followed by (optional) options.
20850 Most commonly, &%route_data%& is set as a string that contains an
20851 expansion lookup. For example, suppose we place two routing rules in a file
20852 like this:
20853 .code
20854 dict.ref.example:  mail-1.ref.example:mail-2.ref.example
20855 thes.ref.example:  mail-3.ref.example:mail-4.ref.example
20856 .endd
20857 This data can be accessed by setting
20858 .code
20859 route_data = ${lookup{$domain}lsearch{/the/file/name}}
20860 .endd
20861 Failure of the lookup results in an empty string, causing the router to
20862 decline. However, you do not have to use a lookup in &%route_data%&. The only
20863 requirement is that the result of expanding the string is a list of hosts,
20864 possibly followed by options, separated by white space. The list of hosts must
20865 be enclosed in quotes if it contains white space.
20866
20867
20868
20869
20870 .section "Format of the list of hosts" "SECID122"
20871 A list of hosts, whether obtained via &%route_data%& or &%route_list%&, is
20872 always separately expanded before use. If the expansion fails, the router
20873 declines. The result of the expansion must be a colon-separated list of names
20874 and/or IP addresses, optionally also including ports.
20875 If the list is written with spaces, it must be protected with quotes.
20876 The format of each item
20877 in the list is described in the next section. The list separator can be changed
20878 as described in section &<<SECTlistsepchange>>&.
20879
20880 If the list of hosts was obtained from a &%route_list%& item, the following
20881 variables are set during its expansion:
20882
20883 .ilist
20884 .cindex "numerical variables (&$1$& &$2$&  etc)" "in &(manualroute)& router"
20885 If the domain was matched against a regular expression, the numeric variables
20886 &$1$&, &$2$&, etc. may be set. For example:
20887 .code
20888 route_list = ^domain(\d+)   host-$1.text.example
20889 .endd
20890 .next
20891 &$0$& is always set to the entire domain.
20892 .next
20893 &$1$& is also set when partial matching is done in a file lookup.
20894
20895 .next
20896 .vindex "&$value$&"
20897 If the pattern that matched the domain was a lookup item, the data that was
20898 looked up is available in the expansion variable &$value$&. For example:
20899 .code
20900 route_list = lsearch;;/some/file.routes  $value
20901 .endd
20902 .endlist
20903
20904 Note the doubling of the semicolon in the pattern that is necessary because
20905 semicolon is the default route list separator.
20906
20907
20908
20909 .section "Format of one host item" "SECTformatonehostitem"
20910 Each item in the list of hosts can be either a host name or an IP address,
20911 optionally with an attached port number, or it can be a single "+"
20912 (see &%hosts_randomize%&).
20913 When no port is given, an IP address
20914 is not enclosed in brackets. When a port is specified, it overrides the port
20915 specification on the transport. The port is separated from the name or address
20916 by a colon. This leads to some complications:
20917
20918 .ilist
20919 Because colon is the default separator for the list of hosts, either
20920 the colon that specifies a port must be doubled, or the list separator must
20921 be changed. The following two examples have the same effect:
20922 .code
20923 route_list = * "host1.tld::1225 : host2.tld::1226"
20924 route_list = * "<+ host1.tld:1225 + host2.tld:1226"
20925 .endd
20926 .next
20927 When IPv6 addresses are involved, it gets worse, because they contain
20928 colons of their own. To make this case easier, it is permitted to
20929 enclose an IP address (either v4 or v6) in square brackets if a port
20930 number follows. For example:
20931 .code
20932 route_list = * "</ [10.1.1.1]:1225 / [::1]:1226"
20933 .endd
20934 .endlist
20935
20936 .section "How the list of hosts is used" "SECThostshowused"
20937 When an address is routed to an &(smtp)& transport by &(manualroute)&, each of
20938 the hosts is tried, in the order specified, when carrying out the SMTP
20939 delivery. However, the order can be changed by setting the &%hosts_randomize%&
20940 option, either on the router (see section &<<SECTprioptman>>& above), or on the
20941 transport.
20942
20943 Hosts may be listed by name or by IP address. An unadorned name in the list of
20944 hosts is interpreted as a host name. A name that is followed by &`/MX`& is
20945 interpreted as an indirection to a sublist of hosts obtained by looking up MX
20946 records in the DNS. For example:
20947 .code
20948 route_list = *  x.y.z:p.q.r/MX:e.f.g
20949 .endd
20950 If this feature is used with a port specifier, the port must come last. For
20951 example:
20952 .code
20953 route_list = *  dom1.tld/mx::1225
20954 .endd
20955 If the &%hosts_randomize%& option is set, the order of the items in the list is
20956 randomized before any lookups are done. Exim then scans the list; for any name
20957 that is not followed by &`/MX`& it looks up an IP address. If this turns out to
20958 be an interface on the local host and the item is not the first in the list,
20959 Exim discards it and any subsequent items. If it is the first item, what
20960 happens is controlled by the
20961 .oindex "&%self%&" "in &(manualroute)& router"
20962 &%self%& option of the router.
20963
20964 A name on the list that is followed by &`/MX`& is replaced with the list of
20965 hosts obtained by looking up MX records for the name. This is always a DNS
20966 lookup; the &%bydns%& and &%byname%& options (see section &<<SECThowoptused>>&
20967 below) are not relevant here. The order of these hosts is determined by the
20968 preference values in the MX records, according to the usual rules. Because
20969 randomizing happens before the MX lookup, it does not affect the order that is
20970 defined by MX preferences.
20971
20972 If the local host is present in the sublist obtained from MX records, but is
20973 not the most preferred host in that list, it and any equally or less
20974 preferred hosts are removed before the sublist is inserted into the main list.
20975
20976 If the local host is the most preferred host in the MX list, what happens
20977 depends on where in the original list of hosts the &`/MX`& item appears. If it
20978 is not the first item (that is, there are previous hosts in the main list),
20979 Exim discards this name and any subsequent items in the main list.
20980
20981 If the MX item is first in the list of hosts, and the local host is the
20982 most preferred host, what happens is controlled by the &%self%& option of the
20983 router.
20984
20985 DNS failures when lookup up the MX records are treated in the same way as DNS
20986 failures when looking up IP addresses: &%pass_on_timeout%& and
20987 &%host_find_failed%& are used when relevant.
20988
20989 The generic &%ignore_target_hosts%& option applies to all hosts in the list,
20990 whether obtained from an MX lookup or not.
20991
20992
20993
20994 .section "How the options are used" "SECThowoptused"
20995 The options are a sequence of words, space-separated.
20996 One of the words can be the name of a transport; this overrides the
20997 &%transport%& option on the router for this particular routing rule only. The
20998 other words (if present) control randomization of the list of hosts on a
20999 per-rule basis, and how the IP addresses of the hosts are to be found when
21000 routing to a remote transport. These options are as follows:
21001
21002 .ilist
21003 &%randomize%&: randomize the order of the hosts in this list, overriding the
21004 setting of &%hosts_randomize%& for this routing rule only.
21005 .next
21006 &%no_randomize%&: do not randomize the order of the hosts in this list,
21007 overriding the setting of &%hosts_randomize%& for this routing rule only.
21008 .next
21009 &%byname%&: use &[getipnodebyname()]& (&[gethostbyname()]& on older systems) to
21010 find IP addresses. This function may ultimately cause a DNS lookup, but it may
21011 also look in &_/etc/hosts_& or other sources of information.
21012 .next
21013 &%bydns%&: look up address records for the hosts directly in the DNS; fail if
21014 no address records are found. If there is a temporary DNS error (such as a
21015 timeout), delivery is deferred.
21016 .next
21017 &%ipv4_only%&: in direct DNS lookups, look up only A records.
21018 .next
21019 &%ipv4_prefer%&: in direct DNS lookups, sort A records before AAAA records.
21020 .endlist
21021
21022 For example:
21023 .code
21024 route_list = domain1  host1:host2:host3  randomize bydns;\
21025              domain2  host4:host5
21026 .endd
21027 If neither &%byname%& nor &%bydns%& is given, Exim behaves as follows: First, a
21028 DNS lookup is done. If this yields anything other than HOST_NOT_FOUND, that
21029 result is used. Otherwise, Exim goes on to try a call to &[getipnodebyname()]&
21030 or &[gethostbyname()]&, and the result of the lookup is the result of that
21031 call.
21032
21033 &*Warning*&: It has been discovered that on some systems, if a DNS lookup
21034 called via &[getipnodebyname()]& times out, HOST_NOT_FOUND is returned
21035 instead of TRY_AGAIN. That is why the default action is to try a DNS
21036 lookup first. Only if that gives a definite &"no such host"& is the local
21037 function called.
21038
21039 &*Compatibility*&: From Exim 4.85 until fixed for 4.90, there was an
21040 inadvertent constraint that a transport name as an option had to be the last
21041 option specified.
21042
21043
21044
21045 If no IP address for a host can be found, what happens is controlled by the
21046 &%host_find_failed%& option.
21047
21048 .vindex "&$host$&"
21049 When an address is routed to a local transport, IP addresses are not looked up.
21050 The host list is passed to the transport in the &$host$& variable.
21051
21052
21053
21054 .section "Manualroute examples" "SECID123"
21055 In some of the examples that follow, the presence of the &%remote_smtp%&
21056 transport, as defined in the default configuration file, is assumed:
21057
21058 .ilist
21059 .cindex "smart host" "example router"
21060 The &(manualroute)& router can be used to forward all external mail to a
21061 &'smart host'&. If you have set up, in the main part of the configuration, a
21062 named domain list that contains your local domains, for example:
21063 .code
21064 domainlist local_domains = my.domain.example
21065 .endd
21066 You can arrange for all other domains to be routed to a smart host by making
21067 your first router something like this:
21068 .code
21069 smart_route:
21070   driver = manualroute
21071   domains = !+local_domains
21072   transport = remote_smtp
21073   route_list = * smarthost.ref.example
21074 .endd
21075 This causes all non-local addresses to be sent to the single host
21076 &'smarthost.ref.example'&. If a colon-separated list of smart hosts is given,
21077 they are tried in order
21078 (but you can use &%hosts_randomize%& to vary the order each time).
21079 Another way of configuring the same thing is this:
21080 .code
21081 smart_route:
21082   driver = manualroute
21083   transport = remote_smtp
21084   route_list = !+local_domains  smarthost.ref.example
21085 .endd
21086 There is no difference in behaviour between these two routers as they stand.
21087 However, they behave differently if &%no_more%& is added to them. In the first
21088 example, the router is skipped if the domain does not match the &%domains%&
21089 precondition; the following router is always tried. If the router runs, it
21090 always matches the domain and so can never decline. Therefore, &%no_more%&
21091 would have no effect. In the second case, the router is never skipped; it
21092 always runs. However, if it doesn't match the domain, it declines. In this case
21093 &%no_more%& would prevent subsequent routers from running.
21094
21095 .next
21096 .cindex "mail hub example"
21097 A &'mail hub'& is a host which receives mail for a number of domains via MX
21098 records in the DNS and delivers it via its own private routing mechanism. Often
21099 the final destinations are behind a firewall, with the mail hub being the one
21100 machine that can connect to machines both inside and outside the firewall. The
21101 &(manualroute)& router is usually used on a mail hub to route incoming messages
21102 to the correct hosts. For a small number of domains, the routing can be inline,
21103 using the &%route_list%& option, but for a larger number a file or database
21104 lookup is easier to manage.
21105
21106 If the domain names are in fact the names of the machines to which the mail is
21107 to be sent by the mail hub, the configuration can be quite simple. For
21108 example:
21109 .code
21110 hub_route:
21111   driver = manualroute
21112   transport = remote_smtp
21113   route_list = *.rhodes.tvs.example  $domain
21114 .endd
21115 This configuration routes domains that match &`*.rhodes.tvs.example`& to hosts
21116 whose names are the same as the mail domains. A similar approach can be taken
21117 if the host name can be obtained from the domain name by a string manipulation
21118 that the expansion facilities can handle. Otherwise, a lookup based on the
21119 domain can be used to find the host:
21120 .code
21121 through_firewall:
21122   driver = manualroute
21123   transport = remote_smtp
21124   route_data = ${lookup {$domain} cdb {/internal/host/routes}}
21125 .endd
21126 The result of the lookup must be the name or IP address of the host (or
21127 hosts) to which the address is to be routed. If the lookup fails, the route
21128 data is empty, causing the router to decline. The address then passes to the
21129 next router.
21130
21131 .next
21132 .cindex "batched SMTP output example"
21133 .cindex "SMTP" "batched outgoing; example"
21134 You can use &(manualroute)& to deliver messages to pipes or files in batched
21135 SMTP format for onward transportation by some other means. This is one way of
21136 storing mail for a dial-up host when it is not connected. The route list entry
21137 can be as simple as a single domain name in a configuration like this:
21138 .code
21139 save_in_file:
21140   driver = manualroute
21141   transport = batchsmtp_appendfile
21142   route_list = saved.domain.example
21143 .endd
21144 though often a pattern is used to pick up more than one domain. If there are
21145 several domains or groups of domains with different transport requirements,
21146 different transports can be listed in the routing information:
21147 .code
21148 save_in_file:
21149   driver = manualroute
21150   route_list = \
21151     *.saved.domain1.example  $domain  batch_appendfile; \
21152     *.saved.domain2.example  \
21153       ${lookup{$domain}dbm{/domain2/hosts}{$value}fail} \
21154       batch_pipe
21155 .endd
21156 .vindex "&$domain$&"
21157 .vindex "&$host$&"
21158 The first of these just passes the domain in the &$host$& variable, which
21159 doesn't achieve much (since it is also in &$domain$&), but the second does a
21160 file lookup to find a value to pass, causing the router to decline to handle
21161 the address if the lookup fails.
21162
21163 .next
21164 .cindex "UUCP" "example of router for"
21165 Routing mail directly to UUCP software is a specific case of the use of
21166 &(manualroute)& in a gateway to another mail environment. This is an example of
21167 one way it can be done:
21168 .code
21169 # Transport
21170 uucp:
21171   driver = pipe
21172   user = nobody
21173   command = /usr/local/bin/uux -r - \
21174     ${substr_-5:$host}!rmail ${local_part}
21175   return_fail_output = true
21176
21177 # Router
21178 uucphost:
21179   transport = uucp
21180   driver = manualroute
21181   route_data = \
21182     ${lookup{$domain}lsearch{/usr/local/exim/uucphosts}}
21183 .endd
21184 The file &_/usr/local/exim/uucphosts_& contains entries like
21185 .code
21186 darksite.ethereal.example:           darksite.UUCP
21187 .endd
21188 It can be set up more simply without adding and removing &".UUCP"& but this way
21189 makes clear the distinction between the domain name
21190 &'darksite.ethereal.example'& and the UUCP host name &'darksite'&.
21191 .endlist
21192 .ecindex IIDmanrou1
21193 .ecindex IIDmanrou2
21194
21195
21196
21197
21198
21199
21200
21201
21202 . ////////////////////////////////////////////////////////////////////////////
21203 . ////////////////////////////////////////////////////////////////////////////
21204
21205 .chapter "The queryprogram router" "CHAPdriverlast"
21206 .scindex IIDquerou1 "&(queryprogram)& router"
21207 .scindex IIDquerou2 "routers" "&(queryprogram)&"
21208 .cindex "routing" "by external program"
21209 The &(queryprogram)& router routes an address by running an external command
21210 and acting on its output. This is an expensive way to route, and is intended
21211 mainly for use in lightly-loaded systems, or for performing experiments.
21212 However, if it is possible to use the precondition options (&%domains%&,
21213 &%local_parts%&, etc) to skip this router for most addresses, it could sensibly
21214 be used in special cases, even on a busy host. There are the following private
21215 options:
21216 .cindex "options" "&(queryprogram)& router"
21217
21218 .option command queryprogram string&!! unset
21219 This option must be set. It specifies the command that is to be run. The
21220 command is split up into a command name and arguments, and then each is
21221 expanded separately (exactly as for a &(pipe)& transport, described in chapter
21222 &<<CHAPpipetransport>>&).
21223
21224
21225 .option command_group queryprogram string unset
21226 .cindex "gid (group id)" "in &(queryprogram)& router"
21227 This option specifies a gid to be set when running the command while routing an
21228 address for deliver. It must be set if &%command_user%& specifies a numerical
21229 uid. If it begins with a digit, it is interpreted as the numerical value of the
21230 gid. Otherwise it is looked up using &[getgrnam()]&.
21231
21232
21233 .option command_user queryprogram string unset
21234 .cindex "uid (user id)" "for &(queryprogram)&"
21235 This option must be set. It specifies the uid which is set when running the
21236 command while routing an address for delivery. If the value begins with a digit,
21237 it is interpreted as the numerical value of the uid. Otherwise, it is looked up
21238 using &[getpwnam()]& to obtain a value for the uid and, if &%command_group%& is
21239 not set, a value for the gid also.
21240
21241 &*Warning:*& Changing uid and gid is possible only when Exim is running as
21242 root, which it does during a normal delivery in a conventional configuration.
21243 However, when an address is being verified during message reception, Exim is
21244 usually running as the Exim user, not as root. If the &(queryprogram)& router
21245 is called from a non-root process, Exim cannot change uid or gid before running
21246 the command. In this circumstance the command runs under the current uid and
21247 gid.
21248
21249
21250 .option current_directory queryprogram string /
21251 This option specifies an absolute path which is made the current directory
21252 before running the command.
21253
21254
21255 .option timeout queryprogram time 1h
21256 If the command does not complete within the timeout period, its process group
21257 is killed and the message is frozen. A value of zero time specifies no
21258 timeout.
21259
21260
21261 The standard output of the command is connected to a pipe, which is read when
21262 the command terminates. It should consist of a single line of output,
21263 containing up to five fields, separated by white space. The maximum length of
21264 the line is 1023 characters. Longer lines are silently truncated. The first
21265 field is one of the following words (case-insensitive):
21266
21267 .ilist
21268 &'Accept'&: routing succeeded; the remaining fields specify what to do (see
21269 below).
21270 .next
21271 &'Decline'&: the router declines; pass the address to the next router, unless
21272 &%no_more%& is set.
21273 .next
21274 &'Fail'&: routing failed; do not pass the address to any more routers. Any
21275 subsequent text on the line is an error message. If the router is run as part
21276 of address verification during an incoming SMTP message, the message is
21277 included in the SMTP response.
21278 .next
21279 &'Defer'&: routing could not be completed at this time; try again later. Any
21280 subsequent text on the line is an error message which is logged. It is not
21281 included in any SMTP response.
21282 .next
21283 &'Freeze'&: the same as &'defer'&, except that the message is frozen.
21284 .next
21285 &'Pass'&: pass the address to the next router (or the router specified by
21286 &%pass_router%&), overriding &%no_more%&.
21287 .next
21288 &'Redirect'&: the message is redirected. The remainder of the line is a list of
21289 new addresses, which are routed independently, starting with the first router,
21290 or the router specified by &%redirect_router%&, if set.
21291 .endlist
21292
21293 When the first word is &'accept'&, the remainder of the line consists of a
21294 number of keyed data values, as follows (split into two lines here, to fit on
21295 the page):
21296 .code
21297 ACCEPT TRANSPORT=<transport> HOSTS=<list of hosts>
21298 LOOKUP=byname|bydns DATA=<text>
21299 .endd
21300 The data items can be given in any order, and all are optional. If no transport
21301 is included, the transport specified by the generic &%transport%& option is
21302 used. The list of hosts and the lookup type are needed only if the transport is
21303 an &(smtp)& transport that does not itself supply a list of hosts.
21304
21305 The format of the list of hosts is the same as for the &(manualroute)& router.
21306 As well as host names and IP addresses with optional port numbers, as described
21307 in section &<<SECTformatonehostitem>>&, it may contain names followed by
21308 &`/MX`& to specify sublists of hosts that are obtained by looking up MX records
21309 (see section &<<SECThostshowused>>&).
21310
21311 If the lookup type is not specified, Exim behaves as follows when trying to
21312 find an IP address for each host: First, a DNS lookup is done. If this yields
21313 anything other than HOST_NOT_FOUND, that result is used. Otherwise, Exim
21314 goes on to try a call to &[getipnodebyname()]& or &[gethostbyname()]&, and the
21315 result of the lookup is the result of that call.
21316
21317 .vindex "&$address_data$&"
21318 If the DATA field is set, its value is placed in the &$address_data$&
21319 variable. For example, this return line
21320 .code
21321 accept hosts=x1.y.example:x2.y.example data="rule1"
21322 .endd
21323 routes the address to the default transport, passing a list of two hosts. When
21324 the transport runs, the string &"rule1"& is in &$address_data$&.
21325 .ecindex IIDquerou1
21326 .ecindex IIDquerou2
21327
21328
21329
21330
21331 . ////////////////////////////////////////////////////////////////////////////
21332 . ////////////////////////////////////////////////////////////////////////////
21333
21334 .chapter "The redirect router" "CHAPredirect"
21335 .scindex IIDredrou1 "&(redirect)& router"
21336 .scindex IIDredrou2 "routers" "&(redirect)&"
21337 .cindex "alias file" "in a &(redirect)& router"
21338 .cindex "address redirection" "&(redirect)& router"
21339 The &(redirect)& router handles several kinds of address redirection. Its most
21340 common uses are for resolving local part aliases from a central alias file
21341 (usually called &_/etc/aliases_&) and for handling users' personal &_.forward_&
21342 files, but it has many other potential uses. The incoming address can be
21343 redirected in several different ways:
21344
21345 .ilist
21346 It can be replaced by one or more new addresses which are themselves routed
21347 independently.
21348 .next
21349 It can be routed to be delivered to a given file or directory.
21350 .next
21351 It can be routed to be delivered to a specified pipe command.
21352 .next
21353 It can cause an automatic reply to be generated.
21354 .next
21355 It can be forced to fail, optionally with a custom error message.
21356 .next
21357 It can be temporarily deferred, optionally with a custom message.
21358 .next
21359 It can be discarded.
21360 .endlist
21361
21362 The generic &%transport%& option must not be set for &(redirect)& routers.
21363 However, there are some private options which define transports for delivery to
21364 files and pipes, and for generating autoreplies. See the &%file_transport%&,
21365 &%pipe_transport%& and &%reply_transport%& descriptions below.
21366
21367 If success DSNs have been requested
21368 .cindex "DSN" "success"
21369 .cindex "Delivery Status Notification" "success"
21370 redirection triggers one and the DSN options are not passed any further.
21371
21372
21373
21374 .section "Redirection data" "SECID124"
21375 The router operates by interpreting a text string which it obtains either by
21376 expanding the contents of the &%data%& option, or by reading the entire
21377 contents of a file whose name is given in the &%file%& option. These two
21378 options are mutually exclusive. The first is commonly used for handling system
21379 aliases, in a configuration like this:
21380 .code
21381 system_aliases:
21382   driver = redirect
21383   data = ${lookup{$local_part}lsearch{/etc/aliases}}
21384 .endd
21385 If the lookup fails, the expanded string in this example is empty. When the
21386 expansion of &%data%& results in an empty string, the router declines. A forced
21387 expansion failure also causes the router to decline; other expansion failures
21388 cause delivery to be deferred.
21389
21390 A configuration using &%file%& is commonly used for handling users'
21391 &_.forward_& files, like this:
21392 .code
21393 userforward:
21394   driver = redirect
21395   check_local_user
21396   file = $home/.forward
21397   no_verify
21398 .endd
21399 If the file does not exist, or causes no action to be taken (for example, it is
21400 empty or consists only of comments), the router declines. &*Warning*&: This
21401 is not the case when the file contains syntactically valid items that happen to
21402 yield empty addresses, for example, items containing only RFC 2822 address
21403 comments.
21404
21405 .cindex "tainted data" "in filenames"
21406 .cindex redirect "tainted data"
21407 Tainted data may not be used for a filename.
21408
21409 &*Warning*&: It is unwise to use &$local_part$& or &$domain$&
21410 directly for redirection,
21411 as they are provided by a potential attacker.
21412 In the examples above, &$local_part$& is used for looking up data held locally
21413 on the system, and not used directly (the second example derives &$home$& via
21414 the passsword file or database, using &$local_part$&).
21415
21416
21417
21418 .section "Forward files and address verification" "SECID125"
21419 .cindex "address redirection" "while verifying"
21420 It is usual to set &%no_verify%& on &(redirect)& routers which handle users'
21421 &_.forward_& files, as in the example above. There are two reasons for this:
21422
21423 .ilist
21424 When Exim is receiving an incoming SMTP message from a remote host, it is
21425 running under the Exim uid, not as root. Exim is unable to change uid to read
21426 the file as the user, and it may not be able to read it as the Exim user. So in
21427 practice the router may not be able to operate.
21428 .next
21429 However, even when the router can operate, the existence of a &_.forward_& file
21430 is unimportant when verifying an address. What should be checked is whether the
21431 local part is a valid user name or not. Cutting out the redirection processing
21432 saves some resources.
21433 .endlist
21434
21435
21436
21437
21438
21439
21440 .section "Interpreting redirection data" "SECID126"
21441 .cindex "Sieve filter" "specifying in redirection data"
21442 .cindex "filter" "specifying in redirection data"
21443 The contents of the data string, whether obtained from &%data%& or &%file%&,
21444 can be interpreted in two different ways:
21445
21446 .ilist
21447 If the &%allow_filter%& option is set true, and the data begins with the text
21448 &"#Exim filter"& or &"#Sieve filter"&, it is interpreted as a list of
21449 &'filtering'& instructions in the form of an Exim or Sieve filter file,
21450 respectively. Details of the syntax and semantics of filter files are described
21451 in a separate document entitled &'Exim's interfaces to mail filtering'&; this
21452 document is intended for use by end users.
21453 .next
21454 Otherwise, the data must be a comma-separated list of redirection items, as
21455 described in the next section.
21456 .endlist
21457
21458 When a message is redirected to a file (a &"mail folder"&), the filename given
21459 in a non-filter redirection list must always be an absolute path. A filter may
21460 generate a relative path &-- how this is handled depends on the transport's
21461 configuration. See section &<<SECTfildiropt>>& for a discussion of this issue
21462 for the &(appendfile)& transport.
21463
21464
21465
21466 .section "Items in a non-filter redirection list" "SECTitenonfilred"
21467 .cindex "address redirection" "non-filter list items"
21468 When the redirection data is not an Exim or Sieve filter, for example, if it
21469 comes from a conventional alias or forward file, it consists of a list of
21470 addresses, filenames, pipe commands, or certain special items (see section
21471 &<<SECTspecitredli>>& below). The special items can be individually enabled or
21472 disabled by means of options whose names begin with &%allow_%& or &%forbid_%&,
21473 depending on their default values. The items in the list are separated by
21474 commas or newlines.
21475 If a comma is required in an item, the entire item must be enclosed in double
21476 quotes.
21477
21478 Lines starting with a # character are comments, and are ignored, and # may
21479 also appear following a comma, in which case everything between the # and the
21480 next newline character is ignored.
21481
21482 If an item is entirely enclosed in double quotes, these are removed. Otherwise
21483 double quotes are retained because some forms of mail address require their use
21484 (but never to enclose the entire address). In the following description,
21485 &"item"& refers to what remains after any surrounding double quotes have been
21486 removed.
21487
21488 .vindex "&$local_part$&"
21489 &*Warning*&: If you use an Exim expansion to construct a redirection address,
21490 and the expansion contains a reference to &$local_part$&, you should make use
21491 of the &%quote_local_part%& expansion operator, in case the local part contains
21492 special characters. For example, to redirect all mail for the domain
21493 &'obsolete.example'&, retaining the existing local part, you could use this
21494 setting:
21495 .code
21496 data = ${quote_local_part:$local_part}@newdomain.example
21497 .endd
21498
21499
21500 .section "Redirecting to a local mailbox" "SECTredlocmai"
21501 .cindex "routing" "loops in"
21502 .cindex "loop" "while routing, avoidance of"
21503 .cindex "address redirection" "to local mailbox"
21504 A redirection item may safely be the same as the address currently under
21505 consideration. This does not cause a routing loop, because a router is
21506 automatically skipped if any ancestor of the address that is being processed
21507 is the same as the current address and was processed by the current router.
21508 Such an address is therefore passed to the following routers, so it is handled
21509 as if there were no redirection. When making this loop-avoidance test, the
21510 complete local part, including any prefix or suffix, is used.
21511
21512 .cindex "address redirection" "local part without domain"
21513 Specifying the same local part without a domain is a common usage in personal
21514 filter files when the user wants to have messages delivered to the local
21515 mailbox and also forwarded elsewhere. For example, the user whose login is
21516 &'cleo'& might have a &_.forward_& file containing this:
21517 .code
21518 cleo, cleopatra@egypt.example
21519 .endd
21520 .cindex "backslash in alias file"
21521 .cindex "alias file" "backslash in"
21522 For compatibility with other MTAs, such unqualified local parts may be
21523 preceded by &"\"&, but this is not a requirement for loop prevention. However,
21524 it does make a difference if more than one domain is being handled
21525 synonymously.
21526
21527 If an item begins with &"\"& and the rest of the item parses as a valid RFC
21528 2822 address that does not include a domain, the item is qualified using the
21529 domain of the incoming address. In the absence of a leading &"\"&, unqualified
21530 addresses are qualified using the value in &%qualify_recipient%&, but you can
21531 force the incoming domain to be used by setting &%qualify_preserve_domain%&.
21532
21533 Care must be taken if there are alias names for local users.
21534 Consider an MTA handling a single local domain where the system alias file
21535 contains:
21536 .code
21537 Sam.Reman: spqr
21538 .endd
21539 Now suppose that Sam (whose login id is &'spqr'&) wants to save copies of
21540 messages in the local mailbox, and also forward copies elsewhere. He creates
21541 this forward file:
21542 .code
21543 Sam.Reman, spqr@reme.elsewhere.example
21544 .endd
21545 With these settings, an incoming message addressed to &'Sam.Reman'& fails. The
21546 &(redirect)& router for system aliases does not process &'Sam.Reman'& the
21547 second time round, because it has previously routed it,
21548 and the following routers presumably cannot handle the alias. The forward file
21549 should really contain
21550 .code
21551 spqr, spqr@reme.elsewhere.example
21552 .endd
21553 but because this is such a common error, the &%check_ancestor%& option (see
21554 below) exists to provide a way to get round it. This is normally set on a
21555 &(redirect)& router that is handling users' &_.forward_& files.
21556
21557
21558
21559 .section "Special items in redirection lists" "SECTspecitredli"
21560 In addition to addresses, the following types of item may appear in redirection
21561 lists (that is, in non-filter redirection data):
21562
21563 .ilist
21564 .cindex "pipe" "in redirection list"
21565 .cindex "address redirection" "to pipe"
21566 An item is treated as a pipe command if it begins with &"|"& and does not parse
21567 as a valid RFC 2822 address that includes a domain. A transport for running the
21568 command must be specified by the &%pipe_transport%& option.
21569 Normally, either the router or the transport specifies a user and a group under
21570 which to run the delivery. The default is to use the Exim user and group.
21571
21572 Single or double quotes can be used for enclosing the individual arguments of
21573 the pipe command; no interpretation of escapes is done for single quotes. If
21574 the command contains a comma character, it is necessary to put the whole item
21575 in double quotes, for example:
21576 .code
21577 "|/some/command ready,steady,go"
21578 .endd
21579 since items in redirection lists are terminated by commas. Do not, however,
21580 quote just the command. An item such as
21581 .code
21582 |"/some/command ready,steady,go"
21583 .endd
21584 is interpreted as a pipe with a rather strange command name, and no arguments.
21585
21586 Note that the above example assumes that the text comes from a lookup source
21587 of some sort, so that the quotes are part of the data.  If composing a
21588 redirect router with a &%data%& option directly specifying this command, the
21589 quotes will be used by the configuration parser to define the extent of one
21590 string, but will not be passed down into the redirect router itself.  There
21591 are two main approaches to get around this: escape quotes to be part of the
21592 data itself, or avoid using this mechanism and instead create a custom
21593 transport with the &%command%& option set and reference that transport from
21594 an &%accept%& router.
21595
21596 .next
21597 .cindex "file" "in redirection list"
21598 .cindex "address redirection" "to file"
21599 An item is interpreted as a path name if it begins with &"/"& and does not
21600 parse as a valid RFC 2822 address that includes a domain. For example,
21601 .code
21602 /home/world/minbari
21603 .endd
21604 is treated as a filename, but
21605 .code
21606 /s=molari/o=babylon/@x400gate.way
21607 .endd
21608 is treated as an address. For a filename, a transport must be specified using
21609 the &%file_transport%& option. However, if the generated path name ends with a
21610 forward slash character, it is interpreted as a directory name rather than a
21611 filename, and &%directory_transport%& is used instead.
21612
21613 Normally, either the router or the transport specifies a user and a group under
21614 which to run the delivery. The default is to use the Exim user and group.
21615
21616 .cindex "&_/dev/null_&"
21617 However, if a redirection item is the path &_/dev/null_&, delivery to it is
21618 bypassed at a high level, and the log entry shows &"**bypassed**"&
21619 instead of a transport name. In this case the user and group are not used.
21620
21621 .next
21622 .cindex "included address list"
21623 .cindex "address redirection" "included external list"
21624 If an item is of the form
21625 .code
21626 :include:<path name>
21627 .endd
21628 a list of further items is taken from the given file and included at that
21629 point. &*Note*&: Such a file can not be a filter file; it is just an
21630 out-of-line addition to the list. The items in the included list are separated
21631 by commas or newlines and are not subject to expansion. If this is the first
21632 item in an alias list in an &(lsearch)& file, a colon must be used to terminate
21633 the alias name. This example is incorrect:
21634 .code
21635 list1    :include:/opt/lists/list1
21636 .endd
21637 It must be given as
21638 .code
21639 list1:   :include:/opt/lists/list1
21640 .endd
21641 .cindex "tainted data" "in filenames"
21642 .cindex redirect "tainted data"
21643 Tainted data may not be used for a filename.
21644 .next
21645 .cindex "address redirection" "to black hole"
21646 .cindex "delivery" "discard"
21647 .cindex "delivery" "blackhole"
21648 .cindex "black hole"
21649 .cindex "abandoning mail"
21650 Sometimes you want to throw away mail to a particular local part.  Making the
21651 &%data%& option expand to an empty string does not work, because that causes
21652 the router to decline. Instead, the alias item
21653 .code
21654 :blackhole:
21655 .endd
21656 can be used. It does what its name implies. No delivery is
21657 done, and no error message is generated. This has the same effect as specifying
21658 &_/dev/null_& as a destination, but it can be independently disabled.
21659
21660 &*Warning*&: If &':blackhole:'& appears anywhere in a redirection list, no
21661 delivery is done for the original local part, even if other redirection items
21662 are present. If you are generating a multi-item list (for example, by reading a
21663 database) and need the ability to provide a no-op item, you must use
21664 &_/dev/null_&.
21665
21666 .next
21667 .cindex "delivery" "forcing failure"
21668 .cindex "delivery" "forcing deferral"
21669 .cindex "failing delivery" "forcing"
21670 .cindex "deferred delivery, forcing"
21671 .cindex "customizing" "failure message"
21672 An attempt to deliver a particular address can be deferred or forced to fail by
21673 redirection items of the form
21674 .code
21675 :defer:
21676 :fail:
21677 .endd
21678 respectively. When a redirection list contains such an item, it applies
21679 to the entire redirection; any other items in the list are ignored. Any
21680 text following &':fail:'& or &':defer:'& is placed in the error text
21681 associated with the failure. For example, an alias file might contain:
21682 .code
21683 X.Employee:  :fail: Gone away, no forwarding address
21684 .endd
21685 In the case of an address that is being verified from an ACL or as the subject
21686 of a
21687 .cindex "VRFY" "error text, display of"
21688 VRFY command, the text is included in the SMTP error response by
21689 default.
21690 .cindex "EXPN" "error text, display of"
21691 The text is not included in the response to an EXPN command. In non-SMTP cases
21692 the text is included in the error message that Exim generates.
21693
21694 .cindex "SMTP" "error codes"
21695 By default for verify, Exim sends a 451 SMTP code for a &':defer:'&, and 550 for
21696 &':fail:'&. However, if the message starts with three digits followed by a
21697 space, optionally followed by an extended code of the form &'n.n.n'&, also
21698 followed by a space, and the very first digit is the same as the default error
21699 code, the code from the message is used instead. If the very first digit is
21700 incorrect, a panic error is logged, and the default code is used. You can
21701 suppress the use of the supplied code in a redirect router by setting the
21702 &%forbid_smtp_code%& option true. In this case, any SMTP code is quietly
21703 ignored.
21704
21705 .vindex "&$acl_verify_message$&"
21706 In an ACL, an explicitly provided message overrides the default, but the
21707 default message is available in the variable &$acl_verify_message$& and can
21708 therefore be included in a custom message if this is desired.
21709
21710 Normally the error text is the rest of the redirection list &-- a comma does
21711 not terminate it &-- but a newline does act as a terminator. Newlines are not
21712 normally present in alias expansions. In &(lsearch)& lookups they are removed
21713 as part of the continuation process, but they may exist in other kinds of
21714 lookup and in &':include:'& files.
21715
21716 During routing for message delivery (as opposed to verification), a redirection
21717 containing &':fail:'& causes an immediate failure of the incoming address,
21718 whereas &':defer:'& causes the message to remain in the queue so that a
21719 subsequent delivery attempt can happen at a later time. If an address is
21720 deferred for too long, it will ultimately fail, because the normal retry
21721 rules still apply.
21722
21723 .next
21724 .cindex "alias file" "exception to default"
21725 Sometimes it is useful to use a single-key search type with a default (see
21726 chapter &<<CHAPfdlookup>>&) to look up aliases. However, there may be a need
21727 for exceptions to the default. These can be handled by aliasing them to
21728 &':unknown:'&. This differs from &':fail:'& in that it causes the &(redirect)&
21729 router to decline, whereas &':fail:'& forces routing to fail. A lookup which
21730 results in an empty redirection list has the same effect.
21731 .endlist
21732
21733
21734 .section "Duplicate addresses" "SECTdupaddr"
21735 .cindex "duplicate addresses"
21736 .cindex "address duplicate, discarding"
21737 .cindex "pipe" "duplicated"
21738 Exim removes duplicate addresses from the list to which it is delivering, so as
21739 to deliver just one copy to each address. This does not apply to deliveries
21740 routed to pipes by different immediate parent addresses, but an indirect
21741 aliasing scheme of the type
21742 .code
21743 pipe:       |/some/command $local_part
21744 localpart1: pipe
21745 localpart2: pipe
21746 .endd
21747 does not work with a message that is addressed to both local parts, because
21748 when the second is aliased to the intermediate local part &"pipe"& it gets
21749 discarded as being the same as a previously handled address. However, a scheme
21750 such as
21751 .code
21752 localpart1: |/some/command $local_part
21753 localpart2: |/some/command $local_part
21754 .endd
21755 does result in two different pipe deliveries, because the immediate parents of
21756 the pipes are distinct.
21757
21758
21759
21760 .section "Repeated redirection expansion" "SECID128"
21761 .cindex "repeated redirection expansion"
21762 .cindex "address redirection" "repeated for each delivery attempt"
21763 When a message cannot be delivered to all of its recipients immediately,
21764 leading to two or more delivery attempts, redirection expansion is carried out
21765 afresh each time for those addresses whose children were not all previously
21766 delivered. If redirection is being used as a mailing list, this can lead to new
21767 members of the list receiving copies of old messages. The &%one_time%& option
21768 can be used to avoid this.
21769
21770
21771 .section "Errors in redirection lists" "SECID129"
21772 .cindex "address redirection" "errors"
21773 If &%skip_syntax_errors%& is set, a malformed address that causes a parsing
21774 error is skipped, and an entry is written to the main log. This may be useful
21775 for mailing lists that are automatically managed. Otherwise, if an error is
21776 detected while generating the list of new addresses, the original address is
21777 deferred. See also &%syntax_errors_to%&.
21778
21779
21780
21781 .section "Private options for the redirect router" "SECID130"
21782
21783 .cindex "options" "&(redirect)& router"
21784 The private options for the &(redirect)& router are as follows:
21785
21786
21787 .option allow_defer redirect boolean false
21788 Setting this option allows the use of &':defer:'& in non-filter redirection
21789 data, or the &%defer%& command in an Exim filter file.
21790
21791
21792 .option allow_fail redirect boolean false
21793 .cindex "failing delivery" "from filter"
21794 If this option is true, the &':fail:'& item can be used in a redirection list,
21795 and the &%fail%& command may be used in an Exim filter file.
21796
21797
21798 .option allow_filter redirect boolean false
21799 .cindex "filter" "enabling use of"
21800 .cindex "Sieve filter" "enabling use of"
21801 Setting this option allows Exim to interpret redirection data that starts with
21802 &"#Exim filter"& or &"#Sieve filter"& as a set of filtering instructions. There
21803 are some features of Exim filter files that some administrators may wish to
21804 lock out; see the &%forbid_filter_%&&'xxx'& options below.
21805
21806 It is also possible to lock out Exim filters or Sieve filters while allowing
21807 the other type; see &%forbid_exim_filter%& and &%forbid_sieve_filter%&.
21808
21809
21810 The filter is run using the uid and gid set by the generic &%user%& and
21811 &%group%& options. These take their defaults from the password data if
21812 &%check_local_user%& is set, so in the normal case of users' personal filter
21813 files, the filter is run as the relevant user. When &%allow_filter%& is set
21814 true, Exim insists that either &%check_local_user%& or &%user%& is set.
21815
21816
21817
21818 .option allow_freeze redirect boolean false
21819 .cindex "freezing messages" "allowing in filter"
21820 Setting this option allows the use of the &%freeze%& command in an Exim filter.
21821 This command is more normally encountered in system filters, and is disabled by
21822 default for redirection filters because it isn't something you usually want to
21823 let ordinary users do.
21824
21825
21826
21827 .option check_ancestor redirect boolean false
21828 This option is concerned with handling generated addresses that are the same
21829 as some address in the list of redirection ancestors of the current address.
21830 Although it is turned off by default in the code, it is set in the default
21831 configuration file for handling users' &_.forward_& files. It is recommended
21832 for this use of the &(redirect)& router.
21833
21834 When &%check_ancestor%& is set, if a generated address (including the domain)
21835 is the same as any ancestor of the current address, it is replaced by a copy of
21836 the current address. This helps in the case where local part A is aliased to B,
21837 and B has a &_.forward_& file pointing back to A. For example, within a single
21838 domain, the local part &"Joe.Bloggs"& is aliased to &"jb"& and
21839 &_&~jb/.forward_& contains:
21840 .code
21841 \Joe.Bloggs, <other item(s)>
21842 .endd
21843 Without the &%check_ancestor%& setting, either local part (&"jb"& or
21844 &"joe.bloggs"&) gets processed once by each router and so ends up as it was
21845 originally. If &"jb"& is the real mailbox name, mail to &"jb"& gets delivered
21846 (having been turned into &"joe.bloggs"& by the &_.forward_& file and back to
21847 &"jb"& by the alias), but mail to &"joe.bloggs"& fails. Setting
21848 &%check_ancestor%& on the &(redirect)& router that handles the &_.forward_&
21849 file prevents it from turning &"jb"& back into &"joe.bloggs"& when that was the
21850 original address. See also the &%repeat_use%& option below.
21851
21852
21853 .option check_group redirect boolean "see below"
21854 When the &%file%& option is used, the group owner of the file is checked only
21855 when this option is set. The permitted groups are those listed in the
21856 &%owngroups%& option, together with the user's default group if
21857 &%check_local_user%& is set. If the file has the wrong group, routing is
21858 deferred. The default setting for this option is true if &%check_local_user%&
21859 is set and the &%modemask%& option permits the group write bit, or if the
21860 &%owngroups%& option is set. Otherwise it is false, and no group check occurs.
21861
21862
21863
21864 .option check_owner redirect boolean "see below"
21865 When the &%file%& option is used, the owner of the file is checked only when
21866 this option is set. If &%check_local_user%& is set, the local user is
21867 permitted; otherwise the owner must be one of those listed in the &%owners%&
21868 option. The default value for this option is true if &%check_local_user%& or
21869 &%owners%& is set. Otherwise the default is false, and no owner check occurs.
21870
21871
21872 .option data redirect string&!! unset
21873 This option is mutually exclusive with &%file%&. One or other of them must be
21874 set, but not both. The contents of &%data%& are expanded, and then used as the
21875 list of forwarding items, or as a set of filtering instructions. If the
21876 expansion is forced to fail, or the result is an empty string or a string that
21877 has no effect (consists entirely of comments), the router declines.
21878
21879 When filtering instructions are used, the string must begin with &"#Exim
21880 filter"&, and all comments in the string, including this initial one, must be
21881 terminated with newline characters. For example:
21882 .code
21883 data = #Exim filter\n\
21884        if $h_to: contains Exim then save $home/mail/exim endif
21885 .endd
21886 If you are reading the data from a database where newlines cannot be included,
21887 you can use the &${sg}$& expansion item to turn the escape string of your
21888 choice into a newline.
21889
21890
21891 .option directory_transport redirect string&!! unset
21892 A &(redirect)& router sets up a direct delivery to a directory when a path name
21893 ending with a slash is specified as a new &"address"&. The transport used is
21894 specified by this option, which, after expansion, must be the name of a
21895 configured transport. This should normally be an &(appendfile)& transport.
21896
21897
21898 .option file redirect string&!! unset
21899 This option specifies the name of a file that contains the redirection data. It
21900 is mutually exclusive with the &%data%& option. The string is expanded before
21901 use; if the expansion is forced to fail, the router declines. Other expansion
21902 failures cause delivery to be deferred. The result of a successful expansion
21903 must be an absolute path. The entire file is read and used as the redirection
21904 data. If the data is an empty string or a string that has no effect (consists
21905 entirely of comments), the router declines.
21906
21907 .cindex "NFS" "checking for file existence"
21908 If the attempt to open the file fails with a &"does not exist"& error, Exim
21909 runs a check on the containing directory,
21910 unless &%ignore_enotdir%& is true (see below).
21911 If the directory does not appear to exist, delivery is deferred. This can
21912 happen when users' &_.forward_& files are in NFS-mounted directories, and there
21913 is a mount problem. If the containing directory does exist, but the file does
21914 not, the router declines.
21915
21916
21917 .option file_transport redirect string&!! unset
21918 .vindex "&$address_file$&"
21919 A &(redirect)& router sets up a direct delivery to a file when a path name not
21920 ending in a slash is specified as a new &"address"&. The transport used is
21921 specified by this option, which, after expansion, must be the name of a
21922 configured transport. This should normally be an &(appendfile)& transport. When
21923 it is running, the filename is in &$address_file$&.
21924
21925
21926 .option filter_prepend_home redirect boolean true
21927 When this option is true, if a &(save)& command in an Exim filter specifies a
21928 relative path, and &$home$& is defined, it is automatically prepended to the
21929 relative path. If this option is set false, this action does not happen. The
21930 relative path is then passed to the transport unmodified.
21931
21932
21933 .option forbid_blackhole redirect boolean false
21934 .cindex "restricting access to features"
21935 .cindex "filter" "locking out certain features"
21936 If this option is true, the &':blackhole:'& item may not appear in a
21937 redirection list.
21938
21939
21940 .option forbid_exim_filter redirect boolean false
21941 .cindex "restricting access to features"
21942 .cindex "filter" "locking out certain features"
21943 If this option is set true, only Sieve filters are permitted when
21944 &%allow_filter%& is true.
21945
21946
21947
21948
21949 .option forbid_file redirect boolean false
21950 .cindex "restricting access to features"
21951 .cindex "delivery" "to file; forbidding"
21952 .cindex "filter" "locking out certain features"
21953 .cindex "Sieve filter" "forbidding delivery to a file"
21954 .cindex "Sieve filter" "&""keep""& facility; disabling"
21955 If this option is true, this router may not generate a new address that
21956 specifies delivery to a local file or directory, either from a filter or from a
21957 conventional forward file. This option is forced to be true if &%one_time%& is
21958 set. It applies to Sieve filters as well as to Exim filters, but if true, it
21959 locks out the Sieve's &"keep"& facility.
21960
21961
21962 .option forbid_filter_dlfunc redirect boolean false
21963 .cindex "restricting access to features"
21964 .cindex "filter" "locking out certain features"
21965 If this option is true, string expansions in Exim filters are not allowed to
21966 make use of the &%dlfunc%& expansion facility to run dynamically loaded
21967 functions.
21968
21969 .option forbid_filter_existstest redirect boolean false
21970 .cindex "restricting access to features"
21971 .cindex "filter" "locking out certain features"
21972 .cindex "expansion" "statting a file"
21973 If this option is true, string expansions in Exim filters are not allowed to
21974 make use of the &%exists%& condition or the &%stat%& expansion item.
21975
21976 .option forbid_filter_logwrite redirect boolean false
21977 .cindex "restricting access to features"
21978 .cindex "filter" "locking out certain features"
21979 If this option is true, use of the logging facility in Exim filters is not
21980 permitted. Logging is in any case available only if the filter is being run
21981 under some unprivileged uid (which is normally the case for ordinary users'
21982 &_.forward_& files).
21983
21984
21985 .option forbid_filter_lookup redirect boolean false
21986 .cindex "restricting access to features"
21987 .cindex "filter" "locking out certain features"
21988 If this option is true, string expansions in Exim filter files are not allowed
21989 to make use of &%lookup%& items.
21990
21991
21992 .option forbid_filter_perl redirect boolean false
21993 .cindex "restricting access to features"
21994 .cindex "filter" "locking out certain features"
21995 This option has an effect only if Exim is built with embedded Perl support. If
21996 it is true, string expansions in Exim filter files are not allowed to make use
21997 of the embedded Perl support.
21998
21999
22000 .option forbid_filter_readfile redirect boolean false
22001 .cindex "restricting access to features"
22002 .cindex "filter" "locking out certain features"
22003 If this option is true, string expansions in Exim filter files are not allowed
22004 to make use of &%readfile%& items.
22005
22006
22007 .option forbid_filter_readsocket redirect boolean false
22008 .cindex "restricting access to features"
22009 .cindex "filter" "locking out certain features"
22010 If this option is true, string expansions in Exim filter files are not allowed
22011 to make use of &%readsocket%& items.
22012
22013
22014 .option forbid_filter_reply redirect boolean false
22015 .cindex "restricting access to features"
22016 .cindex "filter" "locking out certain features"
22017 If this option is true, this router may not generate an automatic reply
22018 message. Automatic replies can be generated only from Exim or Sieve filter
22019 files, not from traditional forward files. This option is forced to be true if
22020 &%one_time%& is set.
22021
22022
22023 .option forbid_filter_run redirect boolean false
22024 .cindex "restricting access to features"
22025 .cindex "filter" "locking out certain features"
22026 If this option is true, string expansions in Exim filter files are not allowed
22027 to make use of &%run%& items.
22028
22029
22030 .option forbid_include redirect boolean false
22031 .cindex "restricting access to features"
22032 .cindex "filter" "locking out certain features"
22033 If this option is true, items of the form
22034 .code
22035 :include:<path name>
22036 .endd
22037 are not permitted in non-filter redirection lists.
22038
22039
22040 .option forbid_pipe redirect boolean false
22041 .cindex "restricting access to features"
22042 .cindex "filter" "locking out certain features"
22043 .cindex "delivery" "to pipe; forbidding"
22044 If this option is true, this router may not generate a new address which
22045 specifies delivery to a pipe, either from an Exim filter or from a conventional
22046 forward file. This option is forced to be true if &%one_time%& is set.
22047
22048
22049 .option forbid_sieve_filter redirect boolean false
22050 .cindex "restricting access to features"
22051 .cindex "filter" "locking out certain features"
22052 If this option is set true, only Exim filters are permitted when
22053 &%allow_filter%& is true.
22054
22055
22056 .cindex "SMTP" "error codes"
22057 .option forbid_smtp_code redirect boolean false
22058 If this option is set true, any SMTP error codes that are present at the start
22059 of messages specified for &`:defer:`& or &`:fail:`& are quietly ignored, and
22060 the default codes (451 and 550, respectively) are always used.
22061
22062
22063
22064
22065 .option hide_child_in_errmsg redirect boolean false
22066 .cindex "bounce message" "redirection details; suppressing"
22067 If this option is true, it prevents Exim from quoting a child address if it
22068 generates a bounce or delay message for it. Instead it says &"an address
22069 generated from <&'the top level address'&>"&. Of course, this applies only to
22070 bounces generated locally. If a message is forwarded to another host, &'its'&
22071 bounce may well quote the generated address.
22072
22073
22074 .option ignore_eacces redirect boolean false
22075 .cindex "EACCES"
22076 If this option is set and an attempt to open a redirection file yields the
22077 EACCES error (permission denied), the &(redirect)& router behaves as if the
22078 file did not exist.
22079
22080
22081 .option ignore_enotdir redirect boolean false
22082 .cindex "ENOTDIR"
22083 If this option is set and an attempt to open a redirection file yields the
22084 ENOTDIR error (something on the path is not a directory), the &(redirect)&
22085 router behaves as if the file did not exist.
22086
22087 Setting &%ignore_enotdir%& has another effect as well: When a &(redirect)&
22088 router that has the &%file%& option set discovers that the file does not exist
22089 (the ENOENT error), it tries to &[stat()]& the parent directory, as a check
22090 against unmounted NFS directories. If the parent can not be statted, delivery
22091 is deferred. However, it seems wrong to do this check when &%ignore_enotdir%&
22092 is set, because that option tells Exim to ignore &"something on the path is not
22093 a directory"& (the ENOTDIR error). This is a confusing area, because it seems
22094 that some operating systems give ENOENT where others give ENOTDIR.
22095
22096
22097
22098 .option include_directory redirect string unset
22099 If this option is set, the path names of any &':include:'& items in a
22100 redirection list must start with this directory.
22101
22102
22103 .option modemask redirect "octal integer" 022
22104 This specifies mode bits which must not be set for a file specified by the
22105 &%file%& option. If any of the forbidden bits are set, delivery is deferred.
22106
22107
22108 .option one_time redirect boolean false
22109 .cindex "one-time aliasing/forwarding expansion"
22110 .cindex "alias file" "one-time expansion"
22111 .cindex "forward file" "one-time expansion"
22112 .cindex "mailing lists" "one-time expansion"
22113 .cindex "address redirection" "one-time expansion"
22114 Sometimes the fact that Exim re-evaluates aliases and reprocesses redirection
22115 files each time it tries to deliver a message causes a problem when one or more
22116 of the generated addresses fails be delivered at the first attempt. The problem
22117 is not one of duplicate delivery &-- Exim is clever enough to handle that &--
22118 but of what happens when the redirection list changes during the time that the
22119 message is on Exim's queue. This is particularly true in the case of mailing
22120 lists, where new subscribers might receive copies of messages that were posted
22121 before they subscribed.
22122
22123 If &%one_time%& is set and any addresses generated by the router fail to
22124 deliver at the first attempt, the failing addresses are added to the message as
22125 &"top level"& addresses, and the parent address that generated them is marked
22126 &"delivered"&. Thus, redirection does not happen again at the next delivery
22127 attempt.
22128
22129 &*Warning 1*&: Any header line addition or removal that is specified by this
22130 router would be lost if delivery did not succeed at the first attempt. For this
22131 reason, the &%headers_add%& and &%headers_remove%& generic options are not
22132 permitted when &%one_time%& is set.
22133
22134 &*Warning 2*&: To ensure that the router generates only addresses (as opposed
22135 to pipe or file deliveries or auto-replies) &%forbid_file%&, &%forbid_pipe%&,
22136 and &%forbid_filter_reply%& are forced to be true when &%one_time%& is set.
22137
22138 &*Warning 3*&: The &%unseen%& generic router option may not be set with
22139 &%one_time%&.
22140
22141 The original top-level address is remembered with each of the generated
22142 addresses, and is output in any log messages. However, any intermediate parent
22143 addresses are not recorded. This makes a difference to the log only if
22144 &%all_parents%& log selector is set. It is expected that &%one_time%& will
22145 typically be used for mailing lists, where there is normally just one level of
22146 expansion.
22147
22148
22149 .option owners redirect "string list" unset
22150 .cindex "ownership" "alias file"
22151 .cindex "ownership" "forward file"
22152 .cindex "alias file" "ownership"
22153 .cindex "forward file" "ownership"
22154 This specifies a list of permitted owners for the file specified by &%file%&.
22155 This list is in addition to the local user when &%check_local_user%& is set.
22156 See &%check_owner%& above.
22157
22158
22159 .option owngroups redirect "string list" unset
22160 This specifies a list of permitted groups for the file specified by &%file%&.
22161 The list is in addition to the local user's primary group when
22162 &%check_local_user%& is set. See &%check_group%& above.
22163
22164
22165 .option pipe_transport redirect string&!! unset
22166 .vindex "&$address_pipe$&"
22167 A &(redirect)& router sets up a direct delivery to a pipe when a string
22168 starting with a vertical bar character is specified as a new &"address"&. The
22169 transport used is specified by this option, which, after expansion, must be the
22170 name of a configured transport. This should normally be a &(pipe)& transport.
22171 When the transport is run, the pipe command is in &$address_pipe$&.
22172
22173
22174 .option qualify_domain redirect string&!! unset
22175 .vindex "&$qualify_recipient$&"
22176 If this option is set, and an unqualified address (one without a domain) is
22177 generated, and that address would normally be qualified by the global setting
22178 in &%qualify_recipient%&, it is instead qualified with the domain specified by
22179 expanding this string. If the expansion fails, the router declines. If you want
22180 to revert to the default, you can have the expansion generate
22181 &$qualify_recipient$&.
22182
22183 This option applies to all unqualified addresses generated by Exim filters,
22184 but for traditional &_.forward_& files, it applies only to addresses that are
22185 not preceded by a backslash. Sieve filters cannot generate unqualified
22186 addresses.
22187
22188 .option qualify_preserve_domain redirect boolean false
22189 .cindex "domain" "in redirection; preserving"
22190 .cindex "preserving domain in redirection"
22191 .cindex "address redirection" "domain; preserving"
22192 If this option is set, the router's local &%qualify_domain%& option must not be
22193 set (a configuration error occurs if it is). If an unqualified address (one
22194 without a domain) is generated, it is qualified with the domain of the parent
22195 address (the immediately preceding ancestor) instead of the global
22196 &%qualify_recipient%& value. In the case of a traditional &_.forward_& file,
22197 this applies whether or not the address is preceded by a backslash.
22198
22199
22200 .option repeat_use redirect boolean true
22201 If this option is set false, the router is skipped for a child address that has
22202 any ancestor that was routed by this router. This test happens before any of
22203 the other preconditions are tested. Exim's default anti-looping rules skip
22204 only when the ancestor is the same as the current address. See also
22205 &%check_ancestor%& above and the generic &%redirect_router%& option.
22206
22207
22208 .option reply_transport redirect string&!! unset
22209 A &(redirect)& router sets up an automatic reply when a &%mail%& or
22210 &%vacation%& command is used in a filter file. The transport used is specified
22211 by this option, which, after expansion, must be the name of a configured
22212 transport. This should normally be an &(autoreply)& transport. Other transports
22213 are unlikely to do anything sensible or useful.
22214
22215
22216 .option rewrite redirect boolean true
22217 .cindex "address redirection" "disabling rewriting"
22218 If this option is set false, addresses generated by the router are not
22219 subject to address rewriting. Otherwise, they are treated like new addresses
22220 and are rewritten according to the global rewriting rules.
22221
22222
22223 .option sieve_subaddress redirect string&!! unset
22224 The value of this option is passed to a Sieve filter to specify the
22225 :subaddress part of an address.
22226
22227 .option sieve_useraddress redirect string&!! unset
22228 The value of this option is passed to a Sieve filter to specify the :user part
22229 of an address. However, if it is unset, the entire original local part
22230 (including any prefix or suffix) is used for :user.
22231
22232
22233 .option sieve_vacation_directory redirect string&!! unset
22234 .cindex "Sieve filter" "vacation directory"
22235 To enable the &"vacation"& extension for Sieve filters, you must set
22236 &%sieve_vacation_directory%& to the directory where vacation databases are held
22237 (do not put anything else in that directory), and ensure that the
22238 &%reply_transport%& option refers to an &(autoreply)& transport. Each user
22239 needs their own directory; Exim will create it if necessary.
22240
22241
22242
22243 .option skip_syntax_errors redirect boolean false
22244 .cindex "forward file" "broken"
22245 .cindex "address redirection" "broken files"
22246 .cindex "alias file" "broken"
22247 .cindex "broken alias or forward files"
22248 .cindex "ignoring faulty addresses"
22249 .cindex "skipping faulty addresses"
22250 .cindex "error" "skipping bad syntax"
22251 If &%skip_syntax_errors%& is set, syntactically malformed addresses in
22252 non-filter redirection data are skipped, and each failing address is logged. If
22253 &%syntax_errors_to%& is set, a message is sent to the address it defines,
22254 giving details of the failures. If &%syntax_errors_text%& is set, its contents
22255 are expanded and placed at the head of the error message generated by
22256 &%syntax_errors_to%&. Usually it is appropriate to set &%syntax_errors_to%& to
22257 be the same address as the generic &%errors_to%& option. The
22258 &%skip_syntax_errors%& option is often used when handling mailing lists.
22259
22260 If all the addresses in a redirection list are skipped because of syntax
22261 errors, the router declines to handle the original address, and it is passed to
22262 the following routers.
22263
22264 If &%skip_syntax_errors%& is set when an Exim filter is interpreted, any syntax
22265 error in the filter causes filtering to be abandoned without any action being
22266 taken. The incident is logged, and the router declines to handle the address,
22267 so it is passed to the following routers.
22268
22269 .cindex "Sieve filter" "syntax errors in"
22270 Syntax errors in a Sieve filter file cause the &"keep"& action to occur. This
22271 action is specified by RFC 3028. The values of &%skip_syntax_errors%&,
22272 &%syntax_errors_to%&, and &%syntax_errors_text%& are not used.
22273
22274 &%skip_syntax_errors%& can be used to specify that errors in users' forward
22275 lists or filter files should not prevent delivery. The &%syntax_errors_to%&
22276 option, used with an address that does not get redirected, can be used to
22277 notify users of these errors, by means of a router like this:
22278 .code
22279 userforward:
22280   driver = redirect
22281   allow_filter
22282   check_local_user
22283   file = $home/.forward
22284   file_transport = address_file
22285   pipe_transport = address_pipe
22286   reply_transport = address_reply
22287   no_verify
22288   skip_syntax_errors
22289   syntax_errors_to = real-$local_part@$domain
22290   syntax_errors_text = \
22291    This is an automatically generated message. An error has\n\
22292    been found in your .forward file. Details of the error are\n\
22293    reported below. While this error persists, you will receive\n\
22294    a copy of this message for every message that is addressed\n\
22295    to you. If your .forward file is a filter file, or if it is\n\
22296    a non-filter file containing no valid forwarding addresses,\n\
22297    a copy of each incoming message will be put in your normal\n\
22298    mailbox. If a non-filter file contains at least one valid\n\
22299    forwarding address, forwarding to the valid addresses will\n\
22300    happen, and those will be the only deliveries that occur.
22301 .endd
22302 You also need a router to ensure that local addresses that are prefixed by
22303 &`real-`& are recognized, but not forwarded or filtered. For example, you could
22304 put this immediately before the &(userforward)& router:
22305 .code
22306 real_localuser:
22307   driver = accept
22308   check_local_user
22309   local_part_prefix = real-
22310   transport = local_delivery
22311 .endd
22312 For security, it would probably be a good idea to restrict the use of this
22313 router to locally-generated messages, using a condition such as this:
22314 .code
22315   condition = ${if match {$sender_host_address}\
22316                          {\N^(|127\.0\.0\.1)$\N}}
22317 .endd
22318
22319
22320 .option syntax_errors_text redirect string&!! unset
22321 See &%skip_syntax_errors%& above.
22322
22323
22324 .option syntax_errors_to redirect string unset
22325 See &%skip_syntax_errors%& above.
22326 .ecindex IIDredrou1
22327 .ecindex IIDredrou2
22328
22329
22330
22331
22332
22333
22334 . ////////////////////////////////////////////////////////////////////////////
22335 . ////////////////////////////////////////////////////////////////////////////
22336
22337 .chapter "Environment for running local transports" "CHAPenvironment" &&&
22338          "Environment for local transports"
22339 .scindex IIDenvlotra1 "local transports" "environment for"
22340 .scindex IIDenvlotra2 "environment" "local transports"
22341 .scindex IIDenvlotra3 "transport" "local; environment for"
22342 Local transports handle deliveries to files and pipes. (The &(autoreply)&
22343 transport can be thought of as similar to a pipe.) Exim always runs transports
22344 in subprocesses, under specified uids and gids. Typical deliveries to local
22345 mailboxes run under the uid and gid of the local user.
22346
22347 Exim also sets a specific current directory while running the transport; for
22348 some transports a home directory setting is also relevant. The &(pipe)&
22349 transport is the only one that sets up environment variables; see section
22350 &<<SECTpipeenv>>& for details.
22351
22352 The values used for the uid, gid, and the directories may come from several
22353 different places. In many cases, the router that handles the address associates
22354 settings with that address as a result of its &%check_local_user%&, &%group%&,
22355 or &%user%& options. However, values may also be given in the transport's own
22356 configuration, and these override anything that comes from the router.
22357
22358
22359
22360 .section "Concurrent deliveries" "SECID131"
22361 .cindex "concurrent deliveries"
22362 .cindex "simultaneous deliveries"
22363 If two different messages for the same local recipient arrive more or less
22364 simultaneously, the two delivery processes are likely to run concurrently. When
22365 the &(appendfile)& transport is used to write to a file, Exim applies locking
22366 rules to stop concurrent processes from writing to the same file at the same
22367 time.
22368
22369 However, when you use a &(pipe)& transport, it is up to you to arrange any
22370 locking that is needed. Here is a silly example:
22371 .code
22372 my_transport:
22373   driver = pipe
22374   command = /bin/sh -c 'cat >>/some/file'
22375 .endd
22376 This is supposed to write the message at the end of the file. However, if two
22377 messages arrive at the same time, the file will be scrambled. You can use the
22378 &%exim_lock%& utility program (see section &<<SECTmailboxmaint>>&) to lock a
22379 file using the same algorithm that Exim itself uses.
22380
22381
22382
22383
22384 .section "Uids and gids" "SECTenvuidgid"
22385 .cindex "local transports" "uid and gid"
22386 .cindex "transport" "local; uid and gid"
22387 All transports have the options &%group%& and &%user%&. If &%group%& is set, it
22388 overrides any group that the router set in the address, even if &%user%& is not
22389 set for the transport. This makes it possible, for example, to run local mail
22390 delivery under the uid of the recipient (set by the router), but in a special
22391 group (set by the transport). For example:
22392 .code
22393 # Routers ...
22394 # User/group are set by check_local_user in this router
22395 local_users:
22396   driver = accept
22397   check_local_user
22398   transport = group_delivery
22399
22400 # Transports ...
22401 # This transport overrides the group
22402 group_delivery:
22403   driver = appendfile
22404   file = /var/spool/mail/$local_part_data
22405   group = mail
22406 .endd
22407 If &%user%& is set for a transport, its value overrides what is set in the
22408 address by the router. If &%user%& is non-numeric and &%group%& is not set, the
22409 gid associated with the user is used. If &%user%& is numeric, &%group%& must be
22410 set.
22411
22412 .oindex "&%initgroups%&"
22413 When the uid is taken from the transport's configuration, the &[initgroups()]&
22414 function is called for the groups associated with that uid if the
22415 &%initgroups%& option is set for the transport. When the uid is not specified
22416 by the transport, but is associated with the address by a router, the option
22417 for calling &[initgroups()]& is taken from the router configuration.
22418
22419 .cindex "&(pipe)& transport" "uid for"
22420 The &(pipe)& transport contains the special option &%pipe_as_creator%&. If this
22421 is set and &%user%& is not set, the uid of the process that called Exim to
22422 receive the message is used, and if &%group%& is not set, the corresponding
22423 original gid is also used.
22424
22425 This is the detailed preference order for obtaining a gid; the first of the
22426 following that is set is used:
22427
22428 .ilist
22429 A &%group%& setting of the transport;
22430 .next
22431 A &%group%& setting of the router;
22432 .next
22433 A gid associated with a user setting of the router, either as a result of
22434 &%check_local_user%& or an explicit non-numeric &%user%& setting;
22435 .next
22436 The group associated with a non-numeric &%user%& setting of the transport;
22437 .next
22438 In a &(pipe)& transport, the creator's gid if &%deliver_as_creator%& is set and
22439 the uid is the creator's uid;
22440 .next
22441 The Exim gid if the Exim uid is being used as a default.
22442 .endlist
22443
22444 If, for example, the user is specified numerically on the router and there are
22445 no group settings, no gid is available. In this situation, an error occurs.
22446 This is different for the uid, for which there always is an ultimate default.
22447 The first of the following that is set is used:
22448
22449 .ilist
22450 A &%user%& setting of the transport;
22451 .next
22452 In a &(pipe)& transport, the creator's uid if &%deliver_as_creator%& is set;
22453 .next
22454 A &%user%& setting of the router;
22455 .next
22456 A &%check_local_user%& setting of the router;
22457 .next
22458 The Exim uid.
22459 .endlist
22460
22461 Of course, an error will still occur if the uid that is chosen is on the
22462 &%never_users%& list.
22463
22464
22465
22466
22467
22468 .section "Current and home directories" "SECID132"
22469 .cindex "current directory for local transport"
22470 .cindex "home directory" "for local transport"
22471 .cindex "transport" "local; home directory for"
22472 .cindex "transport" "local; current directory for"
22473 Routers may set current and home directories for local transports by means of
22474 the &%transport_current_directory%& and &%transport_home_directory%& options.
22475 However, if the transport's &%current_directory%& or &%home_directory%& options
22476 are set, they override the router's values. In detail, the home directory
22477 for a local transport is taken from the first of these values that is set:
22478
22479 .ilist
22480 The &%home_directory%& option on the transport;
22481 .next
22482 The &%transport_home_directory%& option on the router;
22483 .next
22484 The password data if &%check_local_user%& is set on the router;
22485 .next
22486 The &%router_home_directory%& option on the router.
22487 .endlist
22488
22489 The current directory is taken from the first of these values that is set:
22490
22491 .ilist
22492 The &%current_directory%& option on the transport;
22493 .next
22494 The &%transport_current_directory%& option on the router.
22495 .endlist
22496
22497
22498 If neither the router nor the transport sets a current directory, Exim uses the
22499 value of the home directory, if it is set. Otherwise it sets the current
22500 directory to &_/_& before running a local transport.
22501
22502
22503
22504 .section "Expansion variables derived from the address" "SECID133"
22505 .vindex "&$domain$&"
22506 .vindex "&$local_part$&"
22507 .vindex "&$original_domain$&"
22508 Normally a local delivery is handling a single address, and in that case the
22509 variables such as &$domain$& and &$local_part$& are set during local
22510 deliveries. However, in some circumstances more than one address may be handled
22511 at once (for example, while writing batch SMTP for onward transmission by some
22512 other means). In this case, the variables associated with the local part are
22513 never set, &$domain$& is set only if all the addresses have the same domain,
22514 and &$original_domain$& is never set.
22515 .ecindex IIDenvlotra1
22516 .ecindex IIDenvlotra2
22517 .ecindex IIDenvlotra3
22518
22519
22520
22521
22522
22523
22524
22525 . ////////////////////////////////////////////////////////////////////////////
22526 . ////////////////////////////////////////////////////////////////////////////
22527
22528 .chapter "Generic options for transports" "CHAPtransportgeneric"
22529 .scindex IIDgenoptra1 "generic options" "transport"
22530 .scindex IIDgenoptra2 "options" "generic; for transports"
22531 .scindex IIDgenoptra3 "transport" "generic options for"
22532 The name of a transport is limited to be &drivernamemax; ASCII characters long;
22533 prior to Exim 4.95 names would be silently truncated at this length, but now
22534 it is enforced.
22535
22536 The following generic options apply to all transports:
22537
22538
22539 .option body_only transports boolean false
22540 .cindex "transport" "body only"
22541 .cindex "message" "transporting body only"
22542 .cindex "body of message" "transporting"
22543 If this option is set, the message's headers are not transported. It is
22544 mutually exclusive with &%headers_only%&. If it is used with the &(appendfile)&
22545 or &(pipe)& transports, the settings of &%message_prefix%& and
22546 &%message_suffix%& should be checked, because this option does not
22547 automatically suppress them.
22548
22549
22550 .option current_directory transports string&!! unset
22551 .cindex "transport" "current directory for"
22552 This specifies the current directory that is to be set while running the
22553 transport, overriding any value that may have been set by the router.
22554 If the expansion fails for any reason, including forced failure, an error is
22555 logged, and delivery is deferred.
22556
22557
22558 .option disable_logging transports boolean false
22559 If this option is set true, nothing is logged for any
22560 deliveries by the transport or for any
22561 transport errors. You should not set this option unless you really, really know
22562 what you are doing.
22563
22564
22565 .option debug_print transports string&!! unset
22566 .cindex "testing" "variables in drivers"
22567 If this option is set and debugging is enabled (see the &%-d%& command line
22568 option), the string is expanded and included in the debugging output when the
22569 transport is run.
22570 If expansion of the string fails, the error message is written to the debugging
22571 output, and Exim carries on processing.
22572 This facility is provided to help with checking out the values of variables and
22573 so on when debugging driver configurations. For example, if a &%headers_add%&
22574 option is not working properly, &%debug_print%& could be used to output the
22575 variables it references. A newline is added to the text if it does not end with
22576 one.
22577 The variables &$transport_name$& and &$router_name$& contain the name of the
22578 transport and the router that called it.
22579
22580 .option delivery_date_add transports boolean false
22581 .cindex "&'Delivery-date:'& header line"
22582 If this option is true, a &'Delivery-date:'& header is added to the message.
22583 This gives the actual time the delivery was made. As this is not a standard
22584 header, Exim has a configuration option (&%delivery_date_remove%&) which
22585 requests its removal from incoming messages, so that delivered messages can
22586 safely be resent to other recipients.
22587
22588
22589 .option driver transports string unset
22590 This specifies which of the available transport drivers is to be used.
22591 There is no default, and this option must be set for every transport.
22592
22593
22594 .option envelope_to_add transports boolean false
22595 .cindex "&'Envelope-to:'& header line"
22596 If this option is true, an &'Envelope-to:'& header is added to the message.
22597 This gives the original address(es) in the incoming envelope that caused this
22598 delivery to happen. More than one address may be present if the transport is
22599 configured to handle several addresses at once, or if more than one original
22600 address was redirected to the same final address. As this is not a standard
22601 header, Exim has a configuration option (&%envelope_to_remove%&) which requests
22602 its removal from incoming messages, so that delivered messages can safely be
22603 resent to other recipients.
22604
22605 &*Note:*& If used on a transport handling multiple recipients
22606 (the smtp transport unless &%max_rcpt%& is 1, the appendfile, pipe or lmtp
22607 transport if &%batch_max%& is greater than 1)
22608 then information about Bcc recipients will be leaked.
22609 Doing so is generally not advised.
22610
22611
22612 .option event_action transports string&!! unset
22613 .cindex events
22614 This option declares a string to be expanded for Exim's events mechanism.
22615 For details see chapter &<<CHAPevents>>&.
22616
22617
22618 .option group transports string&!! "Exim group"
22619 .cindex "transport" "group; specifying"
22620 This option specifies a gid for running the transport process, overriding any
22621 value that the router supplies, and also overriding any value associated with
22622 &%user%& (see below).
22623
22624
22625 .option headers_add transports list&!! unset
22626 .cindex "header lines" "adding in transport"
22627 .cindex "transport" "header lines; adding"
22628 This option specifies a list of text headers,
22629 newline-separated (by default, changeable in the usual way &<<SECTlistsepchange>>&),
22630 which are (separately) expanded and added to the header
22631 portion of a message as it is transported, as described in section
22632 &<<SECTheadersaddrem>>&. Additional header lines can also be specified by
22633 routers. If the result of the expansion is an empty string, or if the expansion
22634 is forced to fail, no action is taken. Other expansion failures are treated as
22635 errors and cause the delivery to be deferred.
22636
22637 Unlike most options, &%headers_add%& can be specified multiple times
22638 for a transport; all listed headers are added.
22639
22640
22641 .option headers_only transports boolean false
22642 .cindex "transport" "header lines only"
22643 .cindex "message" "transporting headers only"
22644 .cindex "header lines" "transporting"
22645 If this option is set, the message's body is not transported. It is mutually
22646 exclusive with &%body_only%&. If it is used with the &(appendfile)& or &(pipe)&
22647 transports, the settings of &%message_prefix%& and &%message_suffix%& should be
22648 checked, since this option does not automatically suppress them.
22649
22650
22651 .option headers_remove transports list&!! unset
22652 .cindex "header lines" "removing"
22653 .cindex "transport" "header lines; removing"
22654 This option specifies a list of text headers,
22655 colon-separated (by default, changeable in the usual way &<<SECTlistsepchange>>&),
22656 to be removed from the message.
22657 However, the option has no effect when an address is just being verified.
22658 Each list item is separately expanded.
22659 If the result of the expansion is an empty string, or if the expansion
22660 is forced to fail, no action is taken. Other expansion failures are treated as
22661 errors and cause the delivery to be deferred.
22662 If an item ends in *, it will match any header with the given prefix.
22663
22664 Matching headers are omitted from the message as it is transported, as described
22665 in section &<<SECTheadersaddrem>>&. Header removal can also be specified by
22666 routers.
22667
22668 Unlike most options, &%headers_remove%& can be specified multiple times
22669 for a transport; all listed headers are removed.
22670
22671 &*Warning*&: Because of the separate expansion of the list items,
22672 items that contain a list separator must have it doubled.
22673 To avoid this, change the list separator (&<<SECTlistsepchange>>&).
22674
22675
22676
22677 .option headers_rewrite transports string unset
22678 .cindex "transport" "header lines; rewriting"
22679 .cindex "rewriting" "at transport time"
22680 This option allows addresses in header lines to be rewritten at transport time,
22681 that is, as the message is being copied to its destination. The contents of the
22682 option are a colon-separated list of rewriting rules. Each rule is in exactly
22683 the same form as one of the general rewriting rules that are applied when a
22684 message is received. These are described in chapter &<<CHAPrewrite>>&. For
22685 example,
22686 .code
22687 headers_rewrite = a@b c@d f : \
22688                   x@y w@z
22689 .endd
22690 changes &'a@b'& into &'c@d'& in &'From:'& header lines, and &'x@y'& into
22691 &'w@z'& in all address-bearing header lines. The rules are applied to the
22692 header lines just before they are written out at transport time, so they affect
22693 only those copies of the message that pass through the transport. However, only
22694 the message's original header lines, and any that were added by a system
22695 filter, are rewritten. If a router or transport adds header lines, they are not
22696 affected by this option. These rewriting rules are &'not'& applied to the
22697 envelope. You can change the return path using &%return_path%&, but you cannot
22698 change envelope recipients at this time.
22699
22700
22701 .option home_directory transports string&!! unset
22702 .cindex "transport" "home directory for"
22703 .vindex "&$home$&"
22704 This option specifies a home directory setting for a local transport,
22705 overriding any value that may be set by the router. The home directory is
22706 placed in &$home$& while expanding the transport's private options. It is also
22707 used as the current directory if no current directory is set by the
22708 &%current_directory%& option on the transport or the
22709 &%transport_current_directory%& option on the router. If the expansion fails
22710 for any reason, including forced failure, an error is logged, and delivery is
22711 deferred.
22712
22713
22714 .option initgroups transports boolean false
22715 .cindex "additional groups"
22716 .cindex "groups" "additional"
22717 .cindex "transport" "group; additional"
22718 If this option is true and the uid for the delivery process is provided by the
22719 transport, the &[initgroups()]& function is called when running the transport
22720 to ensure that any additional groups associated with the uid are set up.
22721
22722
22723 .option max_parallel transports integer&!! unset
22724 .cindex limit "transport parallelism"
22725 .cindex transport "parallel processes"
22726 .cindex transport "concurrency limit"
22727 .cindex "delivery" "parallelism for transport"
22728 If this option is set and expands to an integer greater than zero
22729 it limits the number of concurrent runs of the transport.
22730 The control does not apply to shadow transports.
22731
22732 .cindex "hints database" "transport concurrency control"
22733 Exim implements this control by means of a hints database in which a record is
22734 incremented whenever a transport process is being created. The record
22735 is decremented and possibly removed when the process terminates.
22736 Obviously there is scope for
22737 records to get left lying around if there is a system or program crash. To
22738 guard against this, Exim ignores any records that are more than six hours old.
22739
22740 If you use this option, you should also arrange to delete the
22741 relevant hints database whenever your system reboots. The names of the files
22742 start with &_misc_& and they are kept in the &_spool/db_& directory. There
22743 may be one or two files, depending on the type of DBM in use. The same files
22744 are used for ETRN and smtp transport serialization.
22745
22746
22747 .option message_size_limit transports string&!! 0
22748 .cindex "limit" "message size per transport"
22749 .cindex "size" "of message, limit"
22750 .cindex "transport" "message size; limiting"
22751 This option controls the size of messages passed through the transport. It is
22752 expanded before use; the result of the expansion must be a sequence of decimal
22753 digits, optionally followed by K or M. If the expansion fails for any reason,
22754 including forced failure, or if the result is not of the required form,
22755 delivery is deferred. If the value is greater than zero and the size of a
22756 message exceeds this limit, the address is failed. If there is any chance that
22757 the resulting bounce message could be routed to the same transport, you should
22758 ensure that &%return_size_limit%& is less than the transport's
22759 &%message_size_limit%&, as otherwise the bounce message will fail to get
22760 delivered.
22761
22762
22763
22764 .option rcpt_include_affixes transports boolean false
22765 .cindex "prefix" "for local part, including in envelope"
22766 .cindex "suffix for local part" "including in envelope"
22767 .cindex "local part" "prefix"
22768 .cindex "local part" "suffix"
22769 When this option is false (the default), and an address that has had any
22770 affixes (prefixes or suffixes) removed from the local part is delivered by any
22771 form of SMTP or LMTP, the affixes are not included. For example, if a router
22772 that contains
22773 .code
22774 local_part_prefix = *-
22775 .endd
22776 routes the address &'abc-xyz@some.domain'& to an SMTP transport, the envelope
22777 is delivered with
22778 .code
22779 RCPT TO:<xyz@some.domain>
22780 .endd
22781 This is also the case when an ACL-time callout is being used to verify a
22782 recipient address. However, if &%rcpt_include_affixes%& is set true, the
22783 whole local part is included in the RCPT command. This option applies to BSMTP
22784 deliveries by the &(appendfile)& and &(pipe)& transports as well as to the
22785 &(lmtp)& and &(smtp)& transports.
22786
22787
22788 .option retry_use_local_part transports boolean "see below"
22789 .cindex "hints database" "retry keys"
22790 When a delivery suffers a temporary failure, a retry record is created
22791 in Exim's hints database. For remote deliveries, the key for the retry record
22792 is based on the name and/or IP address of the failing remote host. For local
22793 deliveries, the key is normally the entire address, including both the local
22794 part and the domain. This is suitable for most common cases of local delivery
22795 temporary failure &-- for example, exceeding a mailbox quota should delay only
22796 deliveries to that mailbox, not to the whole domain.
22797
22798 However, in some special cases you may want to treat a temporary local delivery
22799 as a failure associated with the domain, and not with a particular local part.
22800 (For example, if you are storing all mail for some domain in files.) You can do
22801 this by setting &%retry_use_local_part%& false.
22802
22803 For all the local transports, its default value is true. For remote transports,
22804 the default value is false for tidiness, but changing the value has no effect
22805 on a remote transport in the current implementation.
22806
22807
22808 .option return_path transports string&!! unset
22809 .cindex "envelope sender"
22810 .cindex "envelope from"
22811 .cindex "transport" "return path; changing"
22812 .cindex "return path" "changing in transport"
22813 If this option is set, the string is expanded at transport time and replaces
22814 the existing return path (envelope sender) value in the copy of the message
22815 that is being delivered. An empty return path is permitted. This feature is
22816 designed for remote deliveries, where the value of this option is used in the
22817 SMTP MAIL command. If you set &%return_path%& for a local transport, the
22818 only effect is to change the address that is placed in the &'Return-path:'&
22819 header line, if one is added to the message (see the next option).
22820
22821 &*Note:*& A changed return path is not logged unless you add
22822 &%return_path_on_delivery%& to the log selector.
22823
22824 .vindex "&$return_path$&"
22825 The expansion can refer to the existing value via &$return_path$&. This is
22826 either the message's envelope sender, or an address set by the
22827 &%errors_to%& option on a router. If the expansion is forced to fail, no
22828 replacement occurs; if it fails for another reason, delivery is deferred. This
22829 option can be used to support VERP (Variable Envelope Return Paths) &-- see
22830 section &<<SECTverp>>&.
22831
22832 &*Note*&: If a delivery error is detected locally, including the case when a
22833 remote server rejects a message at SMTP time, the bounce message is not sent to
22834 the value of this option. It is sent to the previously set errors address.
22835 This defaults to the incoming sender address, but can be changed by setting
22836 &%errors_to%& in a router.
22837
22838
22839
22840 .option return_path_add transports boolean false
22841 .chindex Return-path:
22842 If this option is true, a &'Return-path:'& header is added to the message.
22843 Although the return path is normally available in the prefix line of BSD
22844 mailboxes, this is commonly not displayed by MUAs, and so the user does not
22845 have easy access to it.
22846
22847 RFC 2821 states that the &'Return-path:'& header is added to a message &"when
22848 the delivery SMTP server makes the final delivery"&. This implies that this
22849 header should not be present in incoming messages. Exim has a configuration
22850 option, &%return_path_remove%&, which requests removal of this header from
22851 incoming messages, so that delivered messages can safely be resent to other
22852 recipients.
22853
22854
22855 .option shadow_condition transports string&!! unset
22856 See &%shadow_transport%& below.
22857
22858
22859 .option shadow_transport transports string unset
22860 .cindex "shadow transport"
22861 .cindex "transport" "shadow"
22862 A local transport may set the &%shadow_transport%& option to the name of
22863 another local transport. Shadow remote transports are not supported.
22864
22865 Whenever a delivery to the main transport succeeds, and either
22866 &%shadow_condition%& is unset, or its expansion does not result in the empty
22867 string or one of the strings &"0"& or &"no"& or &"false"&, the message is also
22868 passed to the shadow transport, with the same delivery address or addresses. If
22869 expansion fails, no action is taken except that non-forced expansion failures
22870 cause a log line to be written.
22871
22872 The result of the shadow transport is discarded and does not affect the
22873 subsequent processing of the message. Only a single level of shadowing is
22874 provided; the &%shadow_transport%& option is ignored on any transport when it
22875 is running as a shadow. Options concerned with output from pipes are also
22876 ignored. The log line for the successful delivery has an item added on the end,
22877 of the form
22878 .code
22879 ST=<shadow transport name>
22880 .endd
22881 If the shadow transport did not succeed, the error message is put in
22882 parentheses afterwards. Shadow transports can be used for a number of different
22883 purposes, including keeping more detailed log information than Exim normally
22884 provides, and implementing automatic acknowledgment policies based on message
22885 headers that some sites insist on.
22886
22887
22888 .option transport_filter transports string&!! unset
22889 .cindex "transport" "filter"
22890 .cindex "filter" "transport filter"
22891 This option sets up a filtering (in the Unix shell sense) process for messages
22892 at transport time. It should not be confused with mail filtering as set up by
22893 individual users or via a system filter.
22894 If unset, or expanding to an empty string, no filtering is done.
22895
22896 When the message is about to be written out, the command specified by
22897 &%transport_filter%& is started up in a separate, parallel process, and
22898 the entire message, including the header lines, is passed to it on its standard
22899 input (this in fact is done from a third process, to avoid deadlock).
22900 The command must be specified as an absolute path.
22901
22902 The process run by the command must use its standard input as the message
22903 data to be transformed, and write the results on its standard output.
22904
22905 The lines of the message that are written to the transport filter are
22906 terminated by newline (&"\n"&). The message is passed to the filter before any
22907 SMTP-specific processing, such as turning &"\n"& into &"\r\n"& and escaping
22908 lines beginning with a dot, and also before any processing implied by the
22909 settings of &%check_string%& and &%escape_string%& in the &(appendfile)& or
22910 &(pipe)& transports.
22911
22912 The standard error for the filter process is set to the same destination as its
22913 standard output; this is read and written to the message's ultimate
22914 destination. The process that writes the message to the filter, the
22915 filter itself, and the original process that reads the result and delivers it
22916 are all run in parallel, like a shell pipeline.
22917
22918 The filter can perform any transformations it likes, but of course should take
22919 care not to break RFC 2822 syntax. Exim does not check the result, except to
22920 test for a final newline when SMTP is in use. All messages transmitted over
22921 SMTP must end with a newline, so Exim supplies one if it is missing.
22922
22923 .cindex "content scanning" "per user"
22924 A transport filter can be used to provide content-scanning on a per-user basis
22925 at delivery time if the only required effect of the scan is to modify the
22926 message. For example, a content scan could insert a new header line containing
22927 a spam score. This could be interpreted by a filter in the user's MUA. It is
22928 not possible to discard a message at this stage.
22929
22930 .cindex "SIZE" "ESMTP extension"
22931 A problem might arise if the filter increases the size of a message that is
22932 being sent down an SMTP connection. If the receiving SMTP server has indicated
22933 support for the SIZE parameter, Exim will have sent the size of the message
22934 at the start of the SMTP session. If what is actually sent is substantially
22935 more, the server might reject the message. This can be worked round by setting
22936 the &%size_addition%& option on the &(smtp)& transport, either to allow for
22937 additions to the message, or to disable the use of SIZE altogether.
22938
22939 .vindex "&$pipe_addresses$&"
22940 The value of the &%transport_filter%& option is the command string for starting
22941 the filter, which is run directly from Exim, not under a shell. The string is
22942 parsed by Exim in the same way as a command string for the &(pipe)& transport:
22943 Exim breaks it up into arguments and then expands each argument separately (see
22944 section &<<SECThowcommandrun>>&). Any kind of expansion failure causes delivery
22945 to be deferred. The special argument &$pipe_addresses$& is replaced by a number
22946 of arguments, one for each address that applies to this delivery. (This isn't
22947 an ideal name for this feature here, but as it was already implemented for the
22948 &(pipe)& transport, it seemed sensible not to change it.)
22949
22950 .vindex "&$host$&"
22951 .vindex "&$host_address$&"
22952 The expansion variables &$host$& and &$host_address$& are available when the
22953 transport is a remote one. They contain the name and IP address of the host to
22954 which the message is being sent. For example:
22955 . used to have $sender_address in this cmdline, but it's tainted
22956 .code
22957 transport_filter = /some/directory/transport-filter.pl \
22958   $host $host_address $pipe_addresses
22959 .endd
22960
22961 Two problems arise if you want to use more complicated expansion items to
22962 generate transport filter commands, both of which due to the fact that the
22963 command is split up &'before'& expansion.
22964 .ilist
22965 If an expansion item contains white space, you must quote it, so that it is all
22966 part of the same command item. If the entire option setting is one such
22967 expansion item, you have to take care what kind of quoting you use. For
22968 example:
22969 .code
22970 transport_filter = '/bin/cmd${if eq{$host}{a.b.c}{1}{2}}'
22971 .endd
22972 This runs the command &(/bin/cmd1)& if the host name is &'a.b.c'&, and
22973 &(/bin/cmd2)& otherwise.
22974
22975 Option strings in general have any fully-surrounding double quote wrapping
22976 removed early in parsing (see &<<SECTstrings>>&).
22977 Then, for this option, quotes protect against whitespace being
22978 regarded as a separator while splitting into the command argument vector.
22979 Either double or single quotes can be used here;
22980 the former interprets backlash-quoted charachters
22981 and the latter does not.
22982
22983 If double quotes had been used in this example, they would have been
22984 stripped by Exim when it read the option's value. When the value is used, if
22985 the single quotes were missing, the line would be split into two items,
22986 &`/bin/cmd${if`& and &`eq{$host}{a.b.c}{1}{2}`&, and an error would occur when
22987 Exim tried to expand the first one.
22988 .next
22989 Except for the special case of &$pipe_addresses$& that is mentioned above, an
22990 expansion cannot generate multiple arguments, or a command name followed by
22991 arguments. Consider this example:
22992 .code
22993 transport_filter = ${lookup{$host}lsearch{/a/file}\
22994                     {$value}{/bin/cat}}
22995 .endd
22996 The result of the lookup is interpreted as the name of the command, even
22997 if it contains white space. The simplest way round this is to use a shell:
22998 .code
22999 transport_filter = /bin/sh -c ${lookup{$host}lsearch{/a/file}\
23000                                {$value}{/bin/cat}}
23001 .endd
23002 .endlist
23003
23004 The filter process is run under the same uid and gid as the normal delivery.
23005 For remote deliveries this is the Exim uid/gid by default. The command should
23006 normally yield a zero return code. Transport filters are not supposed to fail.
23007 A non-zero code is taken to mean that the transport filter encountered some
23008 serious problem. Delivery of the message is deferred; the message remains on
23009 the queue and is tried again later. It is not possible to cause a message to be
23010 bounced from a transport filter.
23011
23012 If a transport filter is set on an autoreply transport, the original message is
23013 passed through the filter as it is being copied into the newly generated
23014 message, which happens if the &%return_message%& option is set.
23015
23016
23017 .option transport_filter_timeout transports time 5m
23018 .cindex "transport" "filter, timeout"
23019 When Exim is reading the output of a transport filter, it applies a timeout
23020 that can be set by this option. Exceeding the timeout is normally treated as a
23021 temporary delivery failure. However, if a transport filter is used with a
23022 &(pipe)& transport, a timeout in the transport filter is treated in the same
23023 way as a timeout in the pipe command itself. By default, a timeout is a hard
23024 error, but if the &(pipe)& transport's &%timeout_defer%& option is set true, it
23025 becomes a temporary error.
23026
23027
23028 .option user transports string&!! "Exim user"
23029 .cindex "uid (user id)" "local delivery"
23030 .cindex "transport" "user, specifying"
23031 This option specifies the user under whose uid the delivery process is to be
23032 run, overriding any uid that may have been set by the router. If the user is
23033 given as a name, the uid is looked up from the password data, and the
23034 associated group is taken as the value of the gid to be used if the &%group%&
23035 option is not set.
23036
23037 For deliveries that use local transports, a user and group are normally
23038 specified explicitly or implicitly (for example, as a result of
23039 &%check_local_user%&) by the router or transport.
23040
23041 .cindex "hints database" "access by remote transport"
23042 For remote transports, you should leave this option unset unless you really are
23043 sure you know what you are doing. When a remote transport is running, it needs
23044 to be able to access Exim's hints databases, because each host may have its own
23045 retry data.
23046 .ecindex IIDgenoptra1
23047 .ecindex IIDgenoptra2
23048 .ecindex IIDgenoptra3
23049
23050
23051
23052
23053
23054
23055 . ////////////////////////////////////////////////////////////////////////////
23056 . ////////////////////////////////////////////////////////////////////////////
23057
23058 .chapter "Address batching in local transports" "CHAPbatching" &&&
23059          "Address batching"
23060 .cindex "transport" "local; address batching in"
23061 The only remote transport (&(smtp)&) is normally configured to handle more than
23062 one address at a time, so that when several addresses are routed to the same
23063 remote host, just one copy of the message is sent. Local transports, however,
23064 normally handle one address at a time. That is, a separate instance of the
23065 transport is run for each address that is routed to the transport. A separate
23066 copy of the message is delivered each time.
23067
23068 .cindex "batched local delivery"
23069 .oindex "&%batch_max%&"
23070 .oindex "&%batch_id%&"
23071 In special cases, it may be desirable to handle several addresses at once in a
23072 local transport, for example:
23073
23074 .ilist
23075 In an &(appendfile)& transport, when storing messages in files for later
23076 delivery by some other means, a single copy of the message with multiple
23077 recipients saves space.
23078 .next
23079 In an &(lmtp)& transport, when delivering over &"local SMTP"& to some process,
23080 a single copy saves time, and is the normal way LMTP is expected to work.
23081 .next
23082 In a &(pipe)& transport, when passing the message
23083 to a scanner program or
23084 to some other delivery mechanism such as UUCP, multiple recipients may be
23085 acceptable.
23086 .endlist
23087
23088 These three local transports all have the same options for controlling multiple
23089 (&"batched"&) deliveries, namely &%batch_max%& and &%batch_id%&. To save
23090 repeating the information for each transport, these options are described here.
23091
23092 The &%batch_max%& option specifies the maximum number of addresses that can be
23093 delivered together in a single run of the transport. Its default value is one
23094 (no batching). When more than one address is routed to a transport that has a
23095 &%batch_max%& value greater than one, the addresses are delivered in a batch
23096 (that is, in a single run of the transport with multiple recipients), subject
23097 to certain conditions:
23098
23099 .ilist
23100 .vindex "&$local_part$&"
23101 If any of the transport's options contain a reference to &$local_part$&, no
23102 batching is possible.
23103 .next
23104 .vindex "&$domain$&"
23105 If any of the transport's options contain a reference to &$domain$&, only
23106 addresses with the same domain are batched.
23107 .next
23108 .cindex "customizing" "batching condition"
23109 If &%batch_id%& is set, it is expanded for each address, and only those
23110 addresses with the same expanded value are batched. This allows you to specify
23111 customized batching conditions. Failure of the expansion for any reason,
23112 including forced failure, disables batching, but it does not stop the delivery
23113 from taking place.
23114 .next
23115 Batched addresses must also have the same errors address (where to send
23116 delivery errors), the same header additions and removals, the same user and
23117 group for the transport, and if a host list is present, the first host must
23118 be the same.
23119 .endlist
23120
23121 In the case of the &(appendfile)& and &(pipe)& transports, batching applies
23122 both when the file or pipe command is specified in the transport, and when it
23123 is specified by a &(redirect)& router, but all the batched addresses must of
23124 course be routed to the same file or pipe command. These two transports have an
23125 option called &%use_bsmtp%&, which causes them to deliver the message in
23126 &"batched SMTP"& format, with the envelope represented as SMTP commands. The
23127 &%check_string%& and &%escape_string%& options are forced to the values
23128 .code
23129 check_string = "."
23130 escape_string = ".."
23131 .endd
23132 when batched SMTP is in use. A full description of the batch SMTP mechanism is
23133 given in section &<<SECTbatchSMTP>>&. The &(lmtp)& transport does not have a
23134 &%use_bsmtp%& option, because it always delivers using the SMTP protocol.
23135
23136 .cindex "&'Envelope-to:'& header line"
23137 If the generic &%envelope_to_add%& option is set for a batching transport, the
23138 &'Envelope-to:'& header that is added to the message contains all the addresses
23139 that are being processed together. If you are using a batching &(appendfile)&
23140 transport without &%use_bsmtp%&, the only way to preserve the recipient
23141 addresses is to set the &%envelope_to_add%& option.
23142
23143 .cindex "&(pipe)& transport" "with multiple addresses"
23144 .vindex "&$pipe_addresses$&"
23145 If you are using a &(pipe)& transport without BSMTP, and setting the
23146 transport's &%command%& option, you can include &$pipe_addresses$& as part of
23147 the command. This is not a true variable; it is a bit of magic that causes each
23148 of the recipient addresses to be inserted into the command as a separate
23149 argument. This provides a way of accessing all the addresses that are being
23150 delivered in the batch. &*Note:*& This is not possible for pipe commands that
23151 are specified by a &(redirect)& router.
23152
23153
23154
23155
23156 . ////////////////////////////////////////////////////////////////////////////
23157 . ////////////////////////////////////////////////////////////////////////////
23158
23159 .chapter "The appendfile transport" "CHAPappendfile"
23160 .scindex IIDapptra1 "&(appendfile)& transport"
23161 .scindex IIDapptra2 "transports" "&(appendfile)&"
23162 .cindex "directory creation"
23163 .cindex "creating directories"
23164 The &(appendfile)& transport delivers a message by appending it to an existing
23165 file, or by creating an entirely new file in a specified directory. Single
23166 files to which messages are appended can be in the traditional Unix mailbox
23167 format, or optionally in the MBX format supported by the Pine MUA and
23168 University of Washington IMAP daemon, &'inter alia'&. When each message is
23169 being delivered as a separate file, &"maildir"& format can optionally be used
23170 to give added protection against failures that happen part-way through the
23171 delivery. A third form of separate-file delivery known as &"mailstore"& is also
23172 supported. For all file formats, Exim attempts to create as many levels of
23173 directory as necessary, provided that &%create_directory%& is set.
23174
23175 The code for the optional formats is not included in the Exim binary by
23176 default. It is necessary to set SUPPORT_MBX, SUPPORT_MAILDIR and/or
23177 SUPPORT_MAILSTORE in &_Local/Makefile_& to have the appropriate code
23178 included.
23179
23180 .cindex "quota" "system"
23181 Exim recognizes system quota errors, and generates an appropriate message. Exim
23182 also supports its own quota control within the transport, for use when the
23183 system facility is unavailable or cannot be used for some reason.
23184
23185 If there is an error while appending to a file (for example, quota exceeded or
23186 partition filled), Exim attempts to reset the file's length and last
23187 modification time back to what they were before. If there is an error while
23188 creating an entirely new file, the new file is removed.
23189
23190 Before appending to a file, a number of security checks are made, and the
23191 file is locked. A detailed description is given below, after the list of
23192 private options.
23193
23194 The &(appendfile)& transport is most commonly used for local deliveries to
23195 users' mailboxes. However, it can also be used as a pseudo-remote transport for
23196 putting messages into files for remote delivery by some means other than Exim.
23197 &"Batch SMTP"& format is often used in this case (see the &%use_bsmtp%&
23198 option).
23199
23200
23201
23202 .section "The file and directory options" "SECTfildiropt"
23203 The &%file%& option specifies a single file, to which the message is appended;
23204 the &%directory%& option specifies a directory, in which a new file containing
23205 the message is created. Only one of these two options can be set, and for
23206 normal deliveries to mailboxes, one of them &'must'& be set.
23207
23208 .vindex "&$address_file$&"
23209 .vindex "&$local_part$&"
23210 However, &(appendfile)& is also used for delivering messages to files or
23211 directories whose names (or parts of names) are obtained from alias,
23212 forwarding, or filtering operations (for example, a &%save%& command in a
23213 user's Exim filter). When such a transport is running, &$local_part$& contains
23214 the local part that was aliased or forwarded, and &$address_file$& contains the
23215 name (or partial name) of the file or directory generated by the redirection
23216 operation. There are two cases:
23217
23218 .ilist
23219 If neither &%file%& nor &%directory%& is set, the redirection operation
23220 must specify an absolute path (one that begins with &`/`&). This is the most
23221 common case when users with local accounts use filtering to sort mail into
23222 different folders. See for example, the &(address_file)& transport in the
23223 default configuration. If the path ends with a slash, it is assumed to be the
23224 name of a directory. A delivery to a directory can also be forced by setting
23225 &%maildir_format%& or &%mailstore_format%&.
23226 .next
23227 If &%file%& or &%directory%& is set for a delivery from a redirection, it is
23228 used to determine the file or directory name for the delivery. Normally, the
23229 contents of &$address_file$& are used in some way in the string expansion.
23230 .endlist
23231 If the &%create_file%& option is set to a path which
23232 matches (see the option definition below for details)
23233 a file or directory name
23234 for the delivery, that name becomes de-tainted.
23235
23236 .cindex "tainted data" "in filenames"
23237 .cindex appendfile "tainted data"
23238 Tainted data may not be used for a file or directory name.
23239 This means that, for instance, &$local_part$& cannot be used directly
23240 as a component of a path.  It can however be used as the key for a lookup
23241 which returns a path (or component).
23242
23243
23244 .cindex "Sieve filter" "configuring &(appendfile)&"
23245 .cindex "Sieve filter" "relative mailbox path handling"
23246 As an example of the second case, consider an environment where users do not
23247 have home directories. They may be permitted to use Exim filter commands of the
23248 form:
23249 .code
23250 save folder23
23251 .endd
23252 or Sieve filter commands of the form:
23253 .code
23254 require "fileinto";
23255 fileinto "folder23";
23256 .endd
23257 In this situation, the expansion of &%file%& or &%directory%& in the transport
23258 must transform the relative path into an appropriate absolute filename. In the
23259 case of Sieve filters, the name &'inbox'& must be handled. It is the name that
23260 is used as a result of a &"keep"& action in the filter. This example shows one
23261 way of handling this requirement:
23262 .code
23263 file = ${if eq{$address_file}{inbox} \
23264             {/var/mail/$local_part_data} \
23265             {${if eq{${substr_0_1:$address_file}}{/} \
23266                   {$address_file} \
23267                   {$home/mail/$address_file} \
23268             }} \
23269        }
23270 .endd
23271 With this setting of &%file%&, &'inbox'& refers to the standard mailbox
23272 location, absolute paths are used without change, and other folders are in the
23273 &_mail_& directory within the home directory.
23274
23275 &*Note 1*&: While processing an Exim filter, a relative path such as
23276 &_folder23_& is turned into an absolute path if a home directory is known to
23277 the router. In particular, this is the case if &%check_local_user%& is set. If
23278 you want to prevent this happening at routing time, you can set
23279 &%router_home_directory%& empty. This forces the router to pass the relative
23280 path to the transport.
23281
23282 &*Note 2*&: An absolute path in &$address_file$& is not treated specially;
23283 the &%file%& or &%directory%& option is still used if it is set.
23284
23285
23286
23287
23288 .section "Private options for appendfile" "SECID134"
23289 .cindex "options" "&(appendfile)& transport"
23290
23291
23292
23293 .option allow_fifo appendfile boolean false
23294 .cindex "fifo (named pipe)"
23295 .cindex "named pipe (fifo)"
23296 .cindex "pipe" "named (fifo)"
23297 Setting this option permits delivery to named pipes (FIFOs) as well as to
23298 regular files. If no process is reading the named pipe at delivery time, the
23299 delivery is deferred.
23300
23301
23302 .option allow_symlink appendfile boolean false
23303 .cindex "symbolic link" "to mailbox"
23304 .cindex "mailbox" "symbolic link"
23305 By default, &(appendfile)& will not deliver if the path name for the file is
23306 that of a symbolic link. Setting this option relaxes that constraint, but there
23307 are security issues involved in the use of symbolic links. Be sure you know
23308 what you are doing if you set this. Details of exactly what this option affects
23309 are included in the discussion which follows this list of options.
23310
23311
23312 .option batch_id appendfile string&!! unset
23313 See the description of local delivery batching in chapter &<<CHAPbatching>>&.
23314 However, batching is automatically disabled for &(appendfile)& deliveries that
23315 happen as a result of forwarding or aliasing or other redirection directly to a
23316 file.
23317
23318
23319 .option batch_max appendfile integer 1
23320 See the description of local delivery batching in chapter &<<CHAPbatching>>&.
23321
23322
23323 .option check_group appendfile boolean false
23324 When this option is set, the group owner of the file defined by the &%file%&
23325 option is checked to see that it is the same as the group under which the
23326 delivery process is running. The default setting is false because the default
23327 file mode is 0600, which means that the group is irrelevant.
23328
23329
23330 .option check_owner appendfile boolean true
23331 When this option is set, the owner of the file defined by the &%file%& option
23332 is checked to ensure that it is the same as the user under which the delivery
23333 process is running.
23334
23335
23336 .option check_string appendfile string "see below"
23337 .cindex "&""From""& line"
23338 As &(appendfile)& writes the message, the start of each line is tested for
23339 matching &%check_string%&, and if it does, the initial matching characters are
23340 replaced by the contents of &%escape_string%&. The value of &%check_string%& is
23341 a literal string, not a regular expression, and the case of any letters it
23342 contains is significant.
23343
23344 If &%use_bsmtp%& is set the values of &%check_string%& and &%escape_string%&
23345 are forced to &"."& and &".."& respectively, and any settings in the
23346 configuration are ignored. Otherwise, they default to &"From&~"& and
23347 &">From&~"& when the &%file%& option is set, and unset when any of the
23348 &%directory%&, &%maildir%&, or &%mailstore%& options are set.
23349
23350 The default settings, along with &%message_prefix%& and &%message_suffix%&, are
23351 suitable for traditional &"BSD"& mailboxes, where a line beginning with
23352 &"From&~"& indicates the start of a new message. All four options need changing
23353 if another format is used. For example, to deliver to mailboxes in MMDF format:
23354 .cindex "MMDF format mailbox"
23355 .cindex "mailbox" "MMDF format"
23356 .code
23357 check_string = "\1\1\1\1\n"
23358 escape_string = "\1\1\1\1 \n"
23359 message_prefix = "\1\1\1\1\n"
23360 message_suffix = "\1\1\1\1\n"
23361 .endd
23362 .option create_directory appendfile boolean true
23363 .cindex "directory creation"
23364 When this option is true, Exim attempts to create any missing superior
23365 directories for the file that it is about to write. A created directory's mode
23366 is given by the &%directory_mode%& option.
23367
23368 The group ownership of a newly created directory is highly dependent on the
23369 operating system (and possibly the file system) that is being used. For
23370 example, in Solaris, if the parent directory has the setgid bit set, its group
23371 is propagated to the child; if not, the currently set group is used. However,
23372 in FreeBSD, the parent's group is always used.
23373
23374
23375
23376 .option create_file appendfile string anywhere
23377 This option constrains the location of files and directories that are created
23378 by this transport. It applies to files defined by the &%file%& option and
23379 directories defined by the &%directory%& option. In the case of maildir
23380 delivery, it applies to the top level directory, not the maildir directories
23381 beneath.
23382
23383 The option must be set to one of the words &"anywhere"&, &"inhome"&, or
23384 &"belowhome"&, or to an absolute path.
23385
23386 In the second and third cases, a home directory must have been
23387 set for the transport, and the file or directory being created must
23388 reside within it.
23389 The "belowhome" checking additionally checks for attempts to use "../"
23390 to evade the testing.
23391 This option is not useful when an explicit filename is
23392 given for normal mailbox deliveries. It is intended for the case when filenames
23393 are generated from users' &_.forward_& files. These are usually handled
23394 by an &(appendfile)& transport called &%address_file%&. See also
23395 &%file_must_exist%&.
23396
23397 In the fourth case,
23398 the value given for this option must be an absolute path for an
23399 existing directory.
23400 The value is used for checking instead of a home directory;
23401 checking is done in "belowhome" mode.
23402
23403 .cindex "tainted data" "de-tainting"
23404 .cindex "de-tainting" "using appendfile create_file option"
23405 If "belowhome" checking is used, the file or directory path
23406 becomes de-tainted.
23407
23408
23409 .option directory appendfile string&!! unset
23410 This option is mutually exclusive with the &%file%& option, but one of &%file%&
23411 or &%directory%& must be set, unless the delivery is the direct result of a
23412 redirection (see section &<<SECTfildiropt>>&).
23413
23414 When &%directory%& is set, the string is expanded, and the message is delivered
23415 into a new file or files in or below the given directory, instead of being
23416 appended to a single mailbox file. A number of different formats are provided
23417 (see &%maildir_format%& and &%mailstore_format%&), and see section
23418 &<<SECTopdir>>& for further details of this form of delivery.
23419
23420 The result of expansion must not be tainted, unless the &%create_file%& option
23421 specifies a path.
23422
23423
23424 .option directory_file appendfile string&!! "see below"
23425 .cindex "base62"
23426 .vindex "&$inode$&"
23427 When &%directory%& is set, but neither &%maildir_format%& nor
23428 &%mailstore_format%& is set, &(appendfile)& delivers each message into a file
23429 whose name is obtained by expanding this string. The default value is:
23430 .code
23431 q${base62:$tod_epoch}-$inode
23432 .endd
23433 This generates a unique name from the current time, in base 62 form, and the
23434 inode of the file. The variable &$inode$& is available only when expanding this
23435 option.
23436
23437
23438 .option directory_mode appendfile "octal integer" 0700
23439 If &(appendfile)& creates any directories as a result of the
23440 &%create_directory%& option, their mode is specified by this option.
23441
23442
23443 .option escape_string appendfile string "see description"
23444 See &%check_string%& above.
23445
23446
23447 .option file appendfile string&!! unset
23448 This option is mutually exclusive with the &%directory%& option, but one of
23449 &%file%& or &%directory%& must be set, unless the delivery is the direct result
23450 of a redirection (see section &<<SECTfildiropt>>&). The &%file%& option
23451 specifies a single file, to which the message is appended. One or more of
23452 &%use_fcntl_lock%&, &%use_flock_lock%&, or &%use_lockfile%& must be set with
23453 &%file%&.
23454
23455 The result of expansion must not be tainted, unless the &%create_file%& option
23456 specifies a path.
23457
23458 .cindex "NFS" "lock file"
23459 .cindex "locking files"
23460 .cindex "lock files"
23461 If you are using more than one host to deliver over NFS into the same
23462 mailboxes, you should always use lock files.
23463
23464 The string value is expanded for each delivery, and must yield an absolute
23465 path. The most common settings of this option are variations on one of these
23466 examples:
23467 .code
23468 file = /var/spool/mail/$local_part_data
23469 file = /home/$local_part_data/inbox
23470 file = $home/inbox
23471 .endd
23472 .cindex "&""sticky""& bit"
23473 In the first example, all deliveries are done into the same directory. If Exim
23474 is configured to use lock files (see &%use_lockfile%& below) it must be able to
23475 create a file in the directory, so the &"sticky"& bit must be turned on for
23476 deliveries to be possible, or alternatively the &%group%& option can be used to
23477 run the delivery under a group id which has write access to the directory.
23478
23479
23480
23481 .option file_format appendfile string unset
23482 .cindex "file" "mailbox; checking existing format"
23483 This option requests the transport to check the format of an existing file
23484 before adding to it. The check consists of matching a specific string at the
23485 start of the file. The value of the option consists of an even number of
23486 colon-separated strings. The first of each pair is the test string, and the
23487 second is the name of a transport. If the transport associated with a matched
23488 string is not the current transport, control is passed over to the other
23489 transport. For example, suppose the standard &(local_delivery)& transport has
23490 this added to it:
23491 .code
23492 file_format = "From       : local_delivery :\
23493                \1\1\1\1\n : local_mmdf_delivery"
23494 .endd
23495 Mailboxes that begin with &"From"& are still handled by this transport, but if
23496 a mailbox begins with four binary ones followed by a newline, control is passed
23497 to a transport called &%local_mmdf_delivery%&, which presumably is configured
23498 to do the delivery in MMDF format. If a mailbox does not exist or is empty, it
23499 is assumed to match the current transport. If the start of a mailbox doesn't
23500 match any string, or if the transport named for a given string is not defined,
23501 delivery is deferred.
23502
23503
23504 .option file_must_exist appendfile boolean false
23505 If this option is true, the file specified by the &%file%& option must exist.
23506 A temporary error occurs if it does not, causing delivery to be deferred.
23507 If this option is false, the file is created if it does not exist.
23508
23509
23510 .option lock_fcntl_timeout appendfile time 0s
23511 .cindex "timeout" "mailbox locking"
23512 .cindex "mailbox" "locking, blocking and non-blocking"
23513 .cindex "locking files"
23514 By default, the &(appendfile)& transport uses non-blocking calls to &[fcntl()]&
23515 when locking an open mailbox file. If the call fails, the delivery process
23516 sleeps for &%lock_interval%& and tries again, up to &%lock_retries%& times.
23517 Non-blocking calls are used so that the file is not kept open during the wait
23518 for the lock; the reason for this is to make it as safe as possible for
23519 deliveries over NFS in the case when processes might be accessing an NFS
23520 mailbox without using a lock file. This should not be done, but
23521 misunderstandings and hence misconfigurations are not unknown.
23522
23523 On a busy system, however, the performance of a non-blocking lock approach is
23524 not as good as using a blocking lock with a timeout. In this case, the waiting
23525 is done inside the system call, and Exim's delivery process acquires the lock
23526 and can proceed as soon as the previous lock holder releases it.
23527
23528 If &%lock_fcntl_timeout%& is set to a non-zero time, blocking locks, with that
23529 timeout, are used. There may still be some retrying: the maximum number of
23530 retries is
23531 .code
23532 (lock_retries * lock_interval) / lock_fcntl_timeout
23533 .endd
23534 rounded up to the next whole number. In other words, the total time during
23535 which &(appendfile)& is trying to get a lock is roughly the same, unless
23536 &%lock_fcntl_timeout%& is set very large.
23537
23538 You should consider setting this option if you are getting a lot of delayed
23539 local deliveries because of errors of the form
23540 .code
23541 failed to lock mailbox /some/file (fcntl)
23542 .endd
23543
23544 .option lock_flock_timeout appendfile time 0s
23545 This timeout applies to file locking when using &[flock()]& (see
23546 &%use_flock%&); the timeout operates in a similar manner to
23547 &%lock_fcntl_timeout%&.
23548
23549
23550 .option lock_interval appendfile time 3s
23551 This specifies the time to wait between attempts to lock the file. See below
23552 for details of locking.
23553
23554
23555 .option lock_retries appendfile integer 10
23556 This specifies the maximum number of attempts to lock the file. A value of zero
23557 is treated as 1. See below for details of locking.
23558
23559
23560 .option lockfile_mode appendfile "octal integer" 0600
23561 This specifies the mode of the created lock file, when a lock file is being
23562 used (see &%use_lockfile%& and &%use_mbx_lock%&).
23563
23564
23565 .option lockfile_timeout appendfile time 30m
23566 .cindex "timeout" "mailbox locking"
23567 When a lock file is being used (see &%use_lockfile%&), if a lock file already
23568 exists and is older than this value, it is assumed to have been left behind by
23569 accident, and Exim attempts to remove it.
23570
23571
23572 .option mailbox_filecount appendfile string&!! unset
23573 .cindex "mailbox" "specifying size of"
23574 .cindex "size" "of mailbox"
23575 If this option is set, it is expanded, and the result is taken as the current
23576 number of files in the mailbox. It must be a decimal number, optionally
23577 followed by K or M. This provides a way of obtaining this information from an
23578 external source that maintains the data.
23579
23580
23581 .option mailbox_size appendfile string&!! unset
23582 .cindex "mailbox" "specifying size of"
23583 .cindex "size" "of mailbox"
23584 If this option is set, it is expanded, and the result is taken as the current
23585 size the mailbox. It must be a decimal number, optionally followed by K or M.
23586 This provides a way of obtaining this information from an external source that
23587 maintains the data. This is likely to be helpful for maildir deliveries where
23588 it is computationally expensive to compute the size of a mailbox.
23589
23590
23591
23592 .option maildir_format appendfile boolean false
23593 .cindex "maildir format" "specifying"
23594 If this option is set with the &%directory%& option, the delivery is into a new
23595 file, in the &"maildir"& format that is used by other mail software. When the
23596 transport is activated directly from a &(redirect)& router (for example, the
23597 &(address_file)& transport in the default configuration), setting
23598 &%maildir_format%& causes the path received from the router to be treated as a
23599 directory, whether or not it ends with &`/`&. This option is available only if
23600 SUPPORT_MAILDIR is present in &_Local/Makefile_&. See section
23601 &<<SECTmaildirdelivery>>& below for further details.
23602
23603
23604 .option maildir_quota_directory_regex appendfile string "See below"
23605 .cindex "maildir format" "quota; directories included in"
23606 .cindex "quota" "maildir; directories included in"
23607 This option is relevant only when &%maildir_use_size_file%& is set. It defines
23608 a regular expression for specifying directories, relative to the quota
23609 directory (see &%quota_directory%&), that should be included in the quota
23610 calculation. The default value is:
23611 .code
23612 maildir_quota_directory_regex = ^(?:cur|new|\..*)$
23613 .endd
23614 This includes the &_cur_& and &_new_& directories, and any maildir++ folders
23615 (directories whose names begin with a dot). If you want to exclude the
23616 &_Trash_&
23617 folder from the count (as some sites do), you need to change this setting to
23618 .code
23619 maildir_quota_directory_regex = ^(?:cur|new|\.(?!Trash).*)$
23620 .endd
23621 This uses a negative lookahead in the regular expression to exclude the
23622 directory whose name is &_.Trash_&. When a directory is excluded from quota
23623 calculations, quota processing is bypassed for any messages that are delivered
23624 directly into that directory.
23625
23626
23627 .option maildir_retries appendfile integer 10
23628 This option specifies the number of times to retry when writing a file in
23629 &"maildir"& format. See section &<<SECTmaildirdelivery>>& below.
23630
23631
23632 .option maildir_tag appendfile string&!! unset
23633 This option applies only to deliveries in maildir format, and is described in
23634 section &<<SECTmaildirdelivery>>& below.
23635
23636
23637 .option maildir_use_size_file appendfile&!! boolean false
23638 .cindex "maildir format" "&_maildirsize_& file"
23639 The result of string expansion for this option must be a valid boolean value.
23640 If it is true, it enables support for &_maildirsize_& files. Exim
23641 creates a &_maildirsize_& file in a maildir if one does not exist, taking the
23642 quota from the &%quota%& option of the transport. If &%quota%& is unset, the
23643 value is zero. See &%maildir_quota_directory_regex%& above and section
23644 &<<SECTmaildirdelivery>>& below for further details.
23645
23646 .option maildirfolder_create_regex appendfile string unset
23647 .cindex "maildir format" "&_maildirfolder_& file"
23648 .cindex "&_maildirfolder_&, creating"
23649 The value of this option is a regular expression. If it is unset, it has no
23650 effect. Otherwise, before a maildir delivery takes place, the pattern is
23651 matched against the name of the maildir directory, that is, the directory
23652 containing the &_new_& and &_tmp_& subdirectories that will be used for the
23653 delivery. If there is a match, Exim checks for the existence of a file called
23654 &_maildirfolder_& in the directory, and creates it if it does not exist.
23655 See section &<<SECTmaildirdelivery>>& for more details.
23656
23657
23658 .option mailstore_format appendfile boolean false
23659 .cindex "mailstore format" "specifying"
23660 If this option is set with the &%directory%& option, the delivery is into two
23661 new files in  &"mailstore"& format. The option is available only if
23662 SUPPORT_MAILSTORE is present in &_Local/Makefile_&. See section &<<SECTopdir>>&
23663 below for further details.
23664
23665
23666 .option mailstore_prefix appendfile string&!! unset
23667 This option applies only to deliveries in mailstore format, and is described in
23668 section &<<SECTopdir>>& below.
23669
23670
23671 .option mailstore_suffix appendfile string&!! unset
23672 This option applies only to deliveries in mailstore format, and is described in
23673 section &<<SECTopdir>>& below.
23674
23675
23676 .option mbx_format appendfile boolean false
23677 .cindex "locking files"
23678 .cindex "file" "locking"
23679 .cindex "file" "MBX format"
23680 .cindex "MBX format, specifying"
23681 This option is available only if Exim has been compiled with SUPPORT_MBX
23682 set in &_Local/Makefile_&. If &%mbx_format%& is set with the &%file%& option,
23683 the message is appended to the mailbox file in MBX format instead of
23684 traditional Unix format. This format is supported by Pine4 and its associated
23685 IMAP and POP daemons, by means of the &'c-client'& library that they all use.
23686
23687 &*Note*&: The &%message_prefix%& and &%message_suffix%& options are not
23688 automatically changed by the use of &%mbx_format%&. They should normally be set
23689 empty when using MBX format, so this option almost always appears in this
23690 combination:
23691 .code
23692 mbx_format = true
23693 message_prefix =
23694 message_suffix =
23695 .endd
23696 If none of the locking options are mentioned in the configuration,
23697 &%use_mbx_lock%& is assumed and the other locking options default to false. It
23698 is possible to specify the other kinds of locking with &%mbx_format%&, but
23699 &%use_fcntl_lock%& and &%use_mbx_lock%& are mutually exclusive. MBX locking
23700 interworks with &'c-client'&, providing for shared access to the mailbox. It
23701 should not be used if any program that does not use this form of locking is
23702 going to access the mailbox, nor should it be used if the mailbox file is NFS
23703 mounted, because it works only when the mailbox is accessed from a single host.
23704
23705 If you set &%use_fcntl_lock%& with an MBX-format mailbox, you cannot use
23706 the standard version of &'c-client'&, because as long as it has a mailbox open
23707 (this means for the whole of a Pine or IMAP session), Exim will not be able to
23708 append messages to it.
23709
23710
23711 .option message_prefix appendfile string&!! "see below"
23712 .cindex "&""From""& line"
23713 The string specified here is expanded and output at the start of every message.
23714 The default is unset unless &%file%& is specified and &%use_bsmtp%& is not set,
23715 in which case it is:
23716 .code
23717 message_prefix = "From ${if def:return_path{$return_path}\
23718   {MAILER-DAEMON}} $tod_bsdinbox\n"
23719 .endd
23720 &*Note:*& If you set &%use_crlf%& true, you must change any occurrences of
23721 &`\n`& to &`\r\n`& in &%message_prefix%&.
23722
23723 .option message_suffix appendfile string&!! "see below"
23724 The string specified here is expanded and output at the end of every message.
23725 The default is unset unless &%file%& is specified and &%use_bsmtp%& is not set,
23726 in which case it is a single newline character. The suffix can be suppressed by
23727 setting
23728 .code
23729 message_suffix =
23730 .endd
23731 &*Note:*& If you set &%use_crlf%& true, you must change any occurrences of
23732 &`\n`& to &`\r\n`& in &%message_suffix%&.
23733
23734 .option mode appendfile "octal integer" 0600
23735 If the output file is created, it is given this mode. If it already exists and
23736 has wider permissions, they are reduced to this mode. If it has narrower
23737 permissions, an error occurs unless &%mode_fail_narrower%& is false. However,
23738 if the delivery is the result of a &%save%& command in a filter file specifying
23739 a particular mode, the mode of the output file is always forced to take that
23740 value, and this option is ignored.
23741
23742
23743 .option mode_fail_narrower appendfile boolean true
23744 This option applies in the case when an existing mailbox file has a narrower
23745 mode than that specified by the &%mode%& option. If &%mode_fail_narrower%& is
23746 true, the delivery is deferred (&"mailbox has the wrong mode"&); otherwise Exim
23747 continues with the delivery attempt, using the existing mode of the file.
23748
23749
23750 .option notify_comsat appendfile boolean false
23751 If this option is true, the &'comsat'& daemon is notified after every
23752 successful delivery to a user mailbox. This is the daemon that notifies logged
23753 on users about incoming mail.
23754
23755
23756 .option quota appendfile string&!! unset
23757 .cindex "quota" "imposed by Exim"
23758 This option imposes a limit on the size of the file to which Exim is appending,
23759 or to the total space used in the directory tree when the &%directory%& option
23760 is set. In the latter case, computation of the space used is expensive, because
23761 all the files in the directory (and any sub-directories) have to be
23762 individually inspected and their sizes summed. (See &%quota_size_regex%& and
23763 &%maildir_use_size_file%& for ways to avoid this in environments where users
23764 have no shell access to their mailboxes).
23765
23766 As there is no interlock against two simultaneous deliveries into a
23767 multi-file mailbox, it is possible for the quota to be overrun in this case.
23768 For single-file mailboxes, of course, an interlock is a necessity.
23769
23770 A file's size is taken as its &'used'& value. Because of blocking effects, this
23771 may be a lot less than the actual amount of disk space allocated to the file.
23772 If the sizes of a number of files are being added up, the rounding effect can
23773 become quite noticeable, especially on systems that have large block sizes.
23774 Nevertheless, it seems best to stick to the &'used'& figure, because this is
23775 the obvious value which users understand most easily.
23776
23777 The value of the option is expanded, and must then be a numerical value
23778 (decimal point allowed), optionally followed by one of the letters K, M, or G,
23779 for kilobytes, megabytes, or gigabytes, optionally followed by a slash
23780 and further option modifiers. If Exim is running on a system with
23781 large file support (Linux and FreeBSD have this), mailboxes larger than 2G can
23782 be handled.
23783
23784 The option modifier &%no_check%& can be used to force delivery even if the over
23785 quota condition is met. The quota gets updated as usual.
23786
23787 &*Note*&: A value of zero is interpreted as &"no quota"&.
23788
23789 The expansion happens while Exim is running as root, before it changes uid for
23790 the delivery. This means that files that are inaccessible to the end user can
23791 be used to hold quota values that are looked up in the expansion. When delivery
23792 fails because this quota is exceeded, the handling of the error is as for
23793 system quota failures.
23794
23795 By default, Exim's quota checking mimics system quotas, and restricts the
23796 mailbox to the specified maximum size, though the value is not accurate to the
23797 last byte, owing to separator lines and additional headers that may get added
23798 during message delivery. When a mailbox is nearly full, large messages may get
23799 refused even though small ones are accepted, because the size of the current
23800 message is added to the quota when the check is made. This behaviour can be
23801 changed by setting &%quota_is_inclusive%& false. When this is done, the check
23802 for exceeding the quota does not include the current message. Thus, deliveries
23803 continue until the quota has been exceeded; thereafter, no further messages are
23804 delivered. See also &%quota_warn_threshold%&.
23805
23806
23807 .option quota_directory appendfile string&!! unset
23808 This option defines the directory to check for quota purposes when delivering
23809 into individual files. The default is the delivery directory, or, if a file
23810 called &_maildirfolder_& exists in a maildir directory, the parent of the
23811 delivery directory.
23812
23813
23814 .option quota_filecount appendfile string&!! 0
23815 This option applies when the &%directory%& option is set. It limits the total
23816 number of files in the directory (compare the inode limit in system quotas). It
23817 can only be used if &%quota%& is also set. The value is expanded; an expansion
23818 failure causes delivery to be deferred. A value of zero is interpreted as
23819 &"no quota"&.
23820
23821 The option modifier &%no_check%& can be used to force delivery even if the over
23822 quota condition is met. The quota gets updated as usual.
23823
23824 .option quota_is_inclusive appendfile boolean true
23825 See &%quota%& above.
23826
23827
23828 .option quota_size_regex appendfile string unset
23829 This option applies when one of the delivery modes that writes a separate file
23830 for each message is being used. When Exim wants to find the size of one of
23831 these files in order to test the quota, it first checks &%quota_size_regex%&.
23832 If this is set to a regular expression that matches the filename, and it
23833 captures one string, that string is interpreted as a representation of the
23834 file's size. The value of &%quota_size_regex%& is not expanded.
23835
23836 This feature is useful only when users have no shell access to their mailboxes
23837 &-- otherwise they could defeat the quota simply by renaming the files. This
23838 facility can be used with maildir deliveries, by setting &%maildir_tag%& to add
23839 the file length to the filename. For example:
23840 .code
23841 maildir_tag = ,S=$message_size
23842 quota_size_regex = ,S=(\d+)
23843 .endd
23844 An alternative to &$message_size$& is &$message_linecount$&, which contains the
23845 number of lines in the message.
23846
23847 The regular expression should not assume that the length is at the end of the
23848 filename (even though &%maildir_tag%& puts it there) because maildir MUAs
23849 sometimes add other information onto the ends of message filenames.
23850
23851 Section &<<SECID136>>& contains further information.
23852
23853 This option should not be used when other message-handling software
23854 may duplicate messages by making hardlinks to the files.  When that is done Exim
23855 will count the message size once for each filename, in contrast with the actual
23856 disk usage.  When the option is not set, calculating total usage requires
23857 a system-call per file to get the size; the number of links is then available also
23858 as is used to adjust the effective size.
23859
23860
23861 .option quota_warn_message appendfile string&!! "see below"
23862 See below for the use of this option. If it is not set when
23863 &%quota_warn_threshold%& is set, it defaults to
23864 .code
23865 quota_warn_message = "\
23866   To: $local_part@$domain\n\
23867   Subject: Your mailbox\n\n\
23868   This message is automatically created \
23869   by mail delivery software.\n\n\
23870   The size of your mailbox has exceeded \
23871   a warning threshold that is\n\
23872   set by the system administrator.\n"
23873 .endd
23874
23875
23876 .option quota_warn_threshold appendfile string&!! 0
23877 .cindex "quota" "warning threshold"
23878 .cindex "mailbox" "size warning"
23879 .cindex "size" "of mailbox"
23880 This option is expanded in the same way as &%quota%& (see above). If the
23881 resulting value is greater than zero, and delivery of the message causes the
23882 size of the file or total space in the directory tree to cross the given
23883 threshold, a warning message is sent. If &%quota%& is also set, the threshold
23884 may be specified as a percentage of it by following the value with a percent
23885 sign. For example:
23886 .code
23887 quota = 10M
23888 quota_warn_threshold = 75%
23889 .endd
23890 If &%quota%& is not set, a setting of &%quota_warn_threshold%& that ends with a
23891 percent sign is ignored.
23892
23893 The warning message itself is specified by the &%quota_warn_message%& option,
23894 and it must start with a &'To:'& header line containing the recipient(s) of the
23895 warning message. These do not necessarily have to include the recipient(s) of
23896 the original message. A &'Subject:'& line should also normally be supplied. You
23897 can include any other header lines that you want. If you do not include a
23898 &'From:'& line, the default is:
23899 .code
23900 From: Mail Delivery System <mailer-daemon@$qualify_domain_sender>
23901 .endd
23902 .oindex &%errors_reply_to%&
23903 If you supply a &'Reply-To:'& line, it overrides the global &%errors_reply_to%&
23904 option.
23905
23906 The &%quota%& option does not have to be set in order to use this option; they
23907 are independent of one another except when the threshold is specified as a
23908 percentage.
23909
23910
23911 .option use_bsmtp appendfile boolean false
23912 .cindex "envelope from"
23913 .cindex "envelope sender"
23914 If this option is set true, &(appendfile)& writes messages in &"batch SMTP"&
23915 format, with the envelope sender and recipient(s) included as SMTP commands. If
23916 you want to include a leading HELO command with such messages, you can do
23917 so by setting the &%message_prefix%& option. See section &<<SECTbatchSMTP>>&
23918 for details of batch SMTP.
23919
23920
23921 .option use_crlf appendfile boolean false
23922 .cindex "carriage return"
23923 .cindex "linefeed"
23924 This option causes lines to be terminated with the two-character CRLF sequence
23925 (carriage return, linefeed) instead of just a linefeed character. In the case
23926 of batched SMTP, the byte sequence written to the file is then an exact image
23927 of what would be sent down a real SMTP connection.
23928
23929 &*Note:*& The contents of the &%message_prefix%& and &%message_suffix%& options
23930 (which are used to supply the traditional &"From&~"& and blank line separators
23931 in Berkeley-style mailboxes) are written verbatim, so must contain their own
23932 carriage return characters if these are needed. In cases where these options
23933 have non-empty defaults, the values end with a single linefeed, so they must be
23934 changed to end with &`\r\n`& if &%use_crlf%& is set.
23935
23936
23937 .option use_fcntl_lock appendfile boolean "see below"
23938 This option controls the use of the &[fcntl()]& function to lock a file for
23939 exclusive use when a message is being appended. It is set by default unless
23940 &%use_flock_lock%& is set. Otherwise, it should be turned off only if you know
23941 that all your MUAs use lock file locking. When both &%use_fcntl_lock%& and
23942 &%use_flock_lock%& are unset, &%use_lockfile%& must be set.
23943
23944
23945 .option use_flock_lock appendfile boolean false
23946 This option is provided to support the use of &[flock()]& for file locking, for
23947 the few situations where it is needed. Most modern operating systems support
23948 &[fcntl()]& and &[lockf()]& locking, and these two functions interwork with
23949 each other. Exim uses &[fcntl()]& locking by default.
23950
23951 This option is required only if you are using an operating system where
23952 &[flock()]& is used by programs that access mailboxes (typically MUAs), and
23953 where &[flock()]& does not correctly interwork with &[fcntl()]&. You can use
23954 both &[fcntl()]& and &[flock()]& locking simultaneously if you want.
23955
23956 .cindex "Solaris" "&[flock()]& support"
23957 Not all operating systems provide &[flock()]&. Some versions of Solaris do not
23958 have it (and some, I think, provide a not quite right version built on top of
23959 &[lockf()]&). If the OS does not have &[flock()]&, Exim will be built without
23960 the ability to use it, and any attempt to do so will cause a configuration
23961 error.
23962
23963 &*Warning*&: &[flock()]& locks do not work on NFS files (unless &[flock()]&
23964 is just being mapped onto &[fcntl()]& by the OS).
23965
23966
23967 .option use_lockfile appendfile boolean "see below"
23968 If this option is turned off, Exim does not attempt to create a lock file when
23969 appending to a mailbox file. In this situation, the only locking is by
23970 &[fcntl()]&. You should only turn &%use_lockfile%& off if you are absolutely
23971 sure that every MUA that is ever going to look at your users' mailboxes uses
23972 &[fcntl()]& rather than a lock file, and even then only when you are not
23973 delivering over NFS from more than one host.
23974
23975 .cindex "NFS" "lock file"
23976 In order to append to an NFS file safely from more than one host, it is
23977 necessary to take out a lock &'before'& opening the file, and the lock file
23978 achieves this. Otherwise, even with &[fcntl()]& locking, there is a risk of
23979 file corruption.
23980
23981 The &%use_lockfile%& option is set by default unless &%use_mbx_lock%& is set.
23982 It is not possible to turn both &%use_lockfile%& and &%use_fcntl_lock%& off,
23983 except when &%mbx_format%& is set.
23984
23985
23986 .option use_mbx_lock appendfile boolean "see below"
23987 This option is available only if Exim has been compiled with SUPPORT_MBX
23988 set in &_Local/Makefile_&. Setting the option specifies that special MBX
23989 locking rules be used. It is set by default if &%mbx_format%& is set and none
23990 of the locking options are mentioned in the configuration. The locking rules
23991 are the same as are used by the &'c-client'& library that underlies Pine and
23992 the IMAP4 and POP daemons that come with it (see the discussion below). The
23993 rules allow for shared access to the mailbox. However, this kind of locking
23994 does not work when the mailbox is NFS mounted.
23995
23996 You can set &%use_mbx_lock%& with either (or both) of &%use_fcntl_lock%& and
23997 &%use_flock_lock%& to control what kind of locking is used in implementing the
23998 MBX locking rules. The default is to use &[fcntl()]& if &%use_mbx_lock%& is set
23999 without &%use_fcntl_lock%& or &%use_flock_lock%&.
24000
24001
24002
24003
24004 .section "Operational details for appending" "SECTopappend"
24005 .cindex "appending to a file"
24006 .cindex "file" "appending"
24007 Before appending to a file, the following preparations are made:
24008
24009 .ilist
24010 If the name of the file is &_/dev/null_&, no action is taken, and a success
24011 return is given.
24012
24013 .next
24014 .cindex "directory creation"
24015 If any directories on the file's path are missing, Exim creates them if the
24016 &%create_directory%& option is set. A created directory's mode is given by the
24017 &%directory_mode%& option.
24018
24019 .next
24020 If &%file_format%& is set, the format of an existing file is checked. If this
24021 indicates that a different transport should be used, control is passed to that
24022 transport.
24023
24024 .next
24025 .cindex "file" "locking"
24026 .cindex "locking files"
24027 .cindex "NFS" "lock file"
24028 If &%use_lockfile%& is set, a lock file is built in a way that will work
24029 reliably over NFS, as follows:
24030
24031 .olist
24032 Create a &"hitching post"& file whose name is that of the lock file with the
24033 current time, primary host name, and process id added, by opening for writing
24034 as a new file. If this fails with an access error, delivery is deferred.
24035 .next
24036 Close the hitching post file, and hard link it to the lock filename.
24037 .next
24038 If the call to &[link()]& succeeds, creation of the lock file has succeeded.
24039 Unlink the hitching post name.
24040 .next
24041 Otherwise, use &[stat()]& to get information about the hitching post file, and
24042 then unlink hitching post name. If the number of links is exactly two, creation
24043 of the lock file succeeded but something (for example, an NFS server crash and
24044 restart) caused this fact not to be communicated to the &[link()]& call.
24045 .next
24046 If creation of the lock file failed, wait for &%lock_interval%& and try again,
24047 up to &%lock_retries%& times. However, since any program that writes to a
24048 mailbox should complete its task very quickly, it is reasonable to time out old
24049 lock files that are normally the result of user agent and system crashes. If an
24050 existing lock file is older than &%lockfile_timeout%& Exim attempts to unlink
24051 it before trying again.
24052 .endlist olist
24053
24054 .next
24055 A call is made to &[lstat()]& to discover whether the main file exists, and if
24056 so, what its characteristics are. If &[lstat()]& fails for any reason other
24057 than non-existence, delivery is deferred.
24058
24059 .next
24060 .cindex "symbolic link" "to mailbox"
24061 .cindex "mailbox" "symbolic link"
24062 If the file does exist and is a symbolic link, delivery is deferred, unless the
24063 &%allow_symlink%& option is set, in which case the ownership of the link is
24064 checked, and then &[stat()]& is called to find out about the real file, which
24065 is then subjected to the checks below. The check on the top-level link
24066 ownership prevents one user creating a link for another's mailbox in a sticky
24067 directory, though allowing symbolic links in this case is definitely not a good
24068 idea. If there is a chain of symbolic links, the intermediate ones are not
24069 checked.
24070
24071 .next
24072 If the file already exists but is not a regular file, or if the file's owner
24073 and group (if the group is being checked &-- see &%check_group%& above) are
24074 different from the user and group under which the delivery is running,
24075 delivery is deferred.
24076
24077 .next
24078 If the file's permissions are more generous than specified, they are reduced.
24079 If they are insufficient, delivery is deferred, unless &%mode_fail_narrower%&
24080 is set false, in which case the delivery is tried using the existing
24081 permissions.
24082
24083 .next
24084 The file's inode number is saved, and the file is then opened for appending.
24085 If this fails because the file has vanished, &(appendfile)& behaves as if it
24086 hadn't existed (see below). For any other failures, delivery is deferred.
24087
24088 .next
24089 If the file is opened successfully, check that the inode number hasn't
24090 changed, that it is still a regular file, and that the owner and permissions
24091 have not changed. If anything is wrong, defer delivery and freeze the message.
24092
24093 .next
24094 If the file did not exist originally, defer delivery if the &%file_must_exist%&
24095 option is set. Otherwise, check that the file is being created in a permitted
24096 directory if the &%create_file%& option is set (deferring on failure), and then
24097 open for writing as a new file, with the O_EXCL and O_CREAT options,
24098 except when dealing with a symbolic link (the &%allow_symlink%& option must be
24099 set). In this case, which can happen if the link points to a non-existent file,
24100 the file is opened for writing using O_CREAT but not O_EXCL, because
24101 that prevents link following.
24102
24103 .next
24104 .cindex "loop" "while file testing"
24105 If opening fails because the file exists, obey the tests given above for
24106 existing files. However, to avoid looping in a situation where the file is
24107 being continuously created and destroyed, the exists/not-exists loop is broken
24108 after 10 repetitions, and the message is then frozen.
24109
24110 .next
24111 If opening fails with any other error, defer delivery.
24112
24113 .next
24114 .cindex "file" "locking"
24115 .cindex "locking files"
24116 Once the file is open, unless both &%use_fcntl_lock%& and &%use_flock_lock%&
24117 are false, it is locked using &[fcntl()]& or &[flock()]& or both. If
24118 &%use_mbx_lock%& is false, an exclusive lock is requested in each case.
24119 However, if &%use_mbx_lock%& is true, Exim takes out a shared lock on the open
24120 file, and an exclusive lock on the file whose name is
24121 .code
24122 /tmp/.<device-number>.<inode-number>
24123 .endd
24124 using the device and inode numbers of the open mailbox file, in accordance with
24125 the MBX locking rules. This file is created with a mode that is specified by
24126 the &%lockfile_mode%& option.
24127
24128 If Exim fails to lock the file, there are two possible courses of action,
24129 depending on the value of the locking timeout. This is obtained from
24130 &%lock_fcntl_timeout%& or &%lock_flock_timeout%&, as appropriate.
24131
24132 If the timeout value is zero, the file is closed, Exim waits for
24133 &%lock_interval%&, and then goes back and re-opens the file as above and tries
24134 to lock it again. This happens up to &%lock_retries%& times, after which the
24135 delivery is deferred.
24136
24137 If the timeout has a value greater than zero, blocking calls to &[fcntl()]& or
24138 &[flock()]& are used (with the given timeout), so there has already been some
24139 waiting involved by the time locking fails. Nevertheless, Exim does not give up
24140 immediately. It retries up to
24141 .code
24142 (lock_retries * lock_interval) / <timeout>
24143 .endd
24144 times (rounded up).
24145 .endlist
24146
24147 At the end of delivery, Exim closes the file (which releases the &[fcntl()]&
24148 and/or &[flock()]& locks) and then deletes the lock file if one was created.
24149
24150
24151 .section "Operational details for delivery to a new file" "SECTopdir"
24152 .cindex "delivery" "to single file"
24153 .cindex "&""From""& line"
24154 When the &%directory%& option is set instead of &%file%&, each message is
24155 delivered into a newly-created file or set of files. When &(appendfile)& is
24156 activated directly from a &(redirect)& router, neither &%file%& nor
24157 &%directory%& is normally set, because the path for delivery is supplied by the
24158 router. (See for example, the &(address_file)& transport in the default
24159 configuration.) In this case, delivery is to a new file if either the path name
24160 ends in &`/`&, or the &%maildir_format%& or &%mailstore_format%& option is set.
24161
24162 No locking is required while writing the message to a new file, so the various
24163 locking options of the transport are ignored. The &"From"& line that by default
24164 separates messages in a single file is not normally needed, nor is the escaping
24165 of message lines that start with &"From"&, and there is no need to ensure a
24166 newline at the end of each message. Consequently, the default values for
24167 &%check_string%&, &%message_prefix%&, and &%message_suffix%& are all unset when
24168 any of &%directory%&, &%maildir_format%&, or &%mailstore_format%& is set.
24169
24170 If Exim is required to check a &%quota%& setting, it adds up the sizes of all
24171 the files in the delivery directory by default. However, you can specify a
24172 different directory by setting &%quota_directory%&. Also, for maildir
24173 deliveries (see below) the &_maildirfolder_& convention is honoured.
24174
24175
24176 .cindex "maildir format"
24177 .cindex "mailstore format"
24178 There are three different ways in which delivery to individual files can be
24179 done, controlled by the settings of the &%maildir_format%& and
24180 &%mailstore_format%& options. Note that code to support maildir or mailstore
24181 formats is not included in the binary unless SUPPORT_MAILDIR or
24182 SUPPORT_MAILSTORE, respectively, is set in &_Local/Makefile_&.
24183
24184 .cindex "directory creation"
24185 In all three cases an attempt is made to create the directory and any necessary
24186 sub-directories if they do not exist, provided that the &%create_directory%&
24187 option is set (the default). The location of a created directory can be
24188 constrained by setting &%create_file%&. A created directory's mode is given by
24189 the &%directory_mode%& option. If creation fails, or if the
24190 &%create_directory%& option is not set when creation is required, delivery is
24191 deferred.
24192
24193
24194
24195 .section "Maildir delivery" "SECTmaildirdelivery"
24196 .cindex "maildir format" "description of"
24197 If the &%maildir_format%& option is true, Exim delivers each message by writing
24198 it to a file whose name is &_tmp/<stime>.H<mtime>P<pid>.<host>_& in the
24199 directory that is defined by the &%directory%& option (the &"delivery
24200 directory"&). If the delivery is successful, the file is renamed into the
24201 &_new_& subdirectory.
24202
24203 In the filename, <&'stime'&> is the current time of day in seconds, and
24204 <&'mtime'&> is the microsecond fraction of the time. After a maildir delivery,
24205 Exim checks that the time-of-day clock has moved on by at least one microsecond
24206 before terminating the delivery process. This guarantees uniqueness for the
24207 filename. However, as a precaution, Exim calls &[stat()]& for the file before
24208 opening it. If any response other than ENOENT (does not exist) is given,
24209 Exim waits 2 seconds and tries again, up to &%maildir_retries%& times.
24210
24211 Before Exim carries out a maildir delivery, it ensures that subdirectories
24212 called &_new_&, &_cur_&, and &_tmp_& exist in the delivery directory. If they
24213 do not exist, Exim tries to create them and any superior directories in their
24214 path, subject to the &%create_directory%& and &%create_file%& options. If the
24215 &%maildirfolder_create_regex%& option is set, and the regular expression it
24216 contains matches the delivery directory, Exim also ensures that a file called
24217 &_maildirfolder_& exists in the delivery directory. If a missing directory or
24218 &_maildirfolder_& file cannot be created, delivery is deferred.
24219
24220 These features make it possible to use Exim to create all the necessary files
24221 and directories in a maildir mailbox, including subdirectories for maildir++
24222 folders. Consider this example:
24223 .code
24224 maildir_format = true
24225 directory = /var/mail/$local_part_data\
24226            ${if eq{$local_part_suffix}{}{}\
24227            {/.${substr_1:$local_part_suffix}}}
24228 maildirfolder_create_regex = /\.[^/]+$
24229 .endd
24230 If &$local_part_suffix$& is empty (there was no suffix for the local part),
24231 delivery is into a toplevel maildir with a name like &_/var/mail/pimbo_& (for
24232 the user called &'pimbo'&). The pattern in &%maildirfolder_create_regex%& does
24233 not match this name, so Exim will not look for or create the file
24234 &_/var/mail/pimbo/maildirfolder_&, though it will create
24235 &_/var/mail/pimbo/{cur,new,tmp}_& if necessary.
24236
24237 However, if &$local_part_suffix$& contains &`-eximusers`& (for example),
24238 delivery is into the maildir++ folder &_/var/mail/pimbo/.eximusers_&, which
24239 does match &%maildirfolder_create_regex%&. In this case, Exim will create
24240 &_/var/mail/pimbo/.eximusers/maildirfolder_& as well as the three maildir
24241 directories &_/var/mail/pimbo/.eximusers/{cur,new,tmp}_&.
24242
24243 &*Warning:*& Take care when setting &%maildirfolder_create_regex%& that it does
24244 not inadvertently match the toplevel maildir directory, because a
24245 &_maildirfolder_& file at top level would completely break quota calculations.
24246
24247 .cindex "quota" "in maildir delivery"
24248 .cindex "maildir++"
24249 If Exim is required to check a &%quota%& setting before a maildir delivery, and
24250 &%quota_directory%& is not set, it looks for a file called &_maildirfolder_& in
24251 the maildir directory (alongside &_new_&, &_cur_&, &_tmp_&). If this exists,
24252 Exim assumes the directory is a maildir++ folder directory, which is one level
24253 down from the user's top level mailbox directory. This causes it to start at
24254 the parent directory instead of the current directory when calculating the
24255 amount of space used.
24256
24257 One problem with delivering into a multi-file mailbox is that it is
24258 computationally expensive to compute the size of the mailbox for quota
24259 checking. Various approaches have been taken to reduce the amount of work
24260 needed. The next two sections describe two of them. A third alternative is to
24261 use some external process for maintaining the size data, and use the expansion
24262 of the &%mailbox_size%& option as a way of importing it into Exim.
24263
24264
24265
24266
24267 .section "Using tags to record message sizes" "SECID135"
24268 If &%maildir_tag%& is set, the string is expanded for each delivery.
24269 When the maildir file is renamed into the &_new_& sub-directory, the
24270 tag is added to its name. However, if adding the tag takes the length of the
24271 name to the point where the test &[stat()]& call fails with ENAMETOOLONG,
24272 the tag is dropped and the maildir file is created with no tag.
24273
24274
24275 .vindex "&$message_size$&"
24276 Tags can be used to encode the size of files in their names; see
24277 &%quota_size_regex%& above for an example. The expansion of &%maildir_tag%&
24278 happens after the message has been written. The value of the &$message_size$&
24279 variable is set to the number of bytes actually written. If the expansion is
24280 forced to fail, the tag is ignored, but a non-forced failure causes delivery to
24281 be deferred. The expanded tag may contain any printing characters except &"/"&.
24282 Non-printing characters in the string are ignored; if the resulting string is
24283 empty, it is ignored. If it starts with an alphanumeric character, a leading
24284 colon is inserted; this default has not proven to be the path that popular
24285 maildir implementations have chosen (but changing it in Exim would break
24286 backwards compatibility).
24287
24288 For one common implementation, you might set:
24289 .code
24290 maildir_tag = ,S=${message_size}
24291 .endd
24292 but you should check the documentation of the other software to be sure.
24293
24294 It is advisable to also set &%quota_size_regex%& when setting &%maildir_tag%&
24295 as this allows Exim to extract the size from your tag, instead of having to
24296 &[stat()]& each message file.
24297
24298
24299 .section "Using a maildirsize file" "SECID136"
24300 .cindex "quota" "in maildir delivery"
24301 .cindex "maildir format" "&_maildirsize_& file"
24302 If &%maildir_use_size_file%& is true, Exim implements the maildir++ rules for
24303 storing quota and message size information in a file called &_maildirsize_&
24304 within the toplevel maildir directory. If this file does not exist, Exim
24305 creates it, setting the quota from the &%quota%& option of the transport. If
24306 the maildir directory itself does not exist, it is created before any attempt
24307 to write a &_maildirsize_& file.
24308
24309 The &_maildirsize_& file is used to hold information about the sizes of
24310 messages in the maildir, thus speeding up quota calculations. The quota value
24311 in the file is just a cache; if the quota is changed in the transport, the new
24312 value overrides the cached value when the next message is delivered. The cache
24313 is maintained for the benefit of other programs that access the maildir and
24314 need to know the quota.
24315
24316 If the &%quota%& option in the transport is unset or zero, the &_maildirsize_&
24317 file is maintained (with a zero quota setting), but no quota is imposed.
24318
24319 A regular expression is available for controlling which directories in the
24320 maildir participate in quota calculations when a &_maildirsizefile_& is in use.
24321 See the description of the &%maildir_quota_directory_regex%& option above for
24322 details.
24323
24324
24325 .section "Mailstore delivery" "SECID137"
24326 .cindex "mailstore format" "description of"
24327 If the &%mailstore_format%& option is true, each message is written as two
24328 files in the given directory. A unique base name is constructed from the
24329 message id and the current delivery process, and the files that are written use
24330 this base name plus the suffixes &_.env_& and &_.msg_&. The &_.env_& file
24331 contains the message's envelope, and the &_.msg_& file contains the message
24332 itself. The base name is placed in the variable &$mailstore_basename$&.
24333
24334 During delivery, the envelope is first written to a file with the suffix
24335 &_.tmp_&. The &_.msg_& file is then written, and when it is complete, the
24336 &_.tmp_& file is renamed as the &_.env_& file. Programs that access messages in
24337 mailstore format should wait for the presence of both a &_.msg_& and a &_.env_&
24338 file before accessing either of them. An alternative approach is to wait for
24339 the absence of a &_.tmp_& file.
24340
24341 The envelope file starts with any text defined by the &%mailstore_prefix%&
24342 option, expanded and terminated by a newline if there isn't one. Then follows
24343 the sender address on one line, then all the recipient addresses, one per line.
24344 There can be more than one recipient only if the &%batch_max%& option is set
24345 greater than one. Finally, &%mailstore_suffix%& is expanded and the result
24346 appended to the file, followed by a newline if it does not end with one.
24347
24348 If expansion of &%mailstore_prefix%& or &%mailstore_suffix%& ends with a forced
24349 failure, it is ignored. Other expansion errors are treated as serious
24350 configuration errors, and delivery is deferred. The variable
24351 &$mailstore_basename$& is available for use during these expansions.
24352
24353
24354 .section "Non-special new file delivery" "SECID138"
24355 If neither &%maildir_format%& nor &%mailstore_format%& is set, a single new
24356 file is created directly in the named directory. For example, when delivering
24357 messages into files in batched SMTP format for later delivery to some host (see
24358 section &<<SECTbatchSMTP>>&), a setting such as
24359 .code
24360 directory = /var/bsmtp/$host
24361 .endd
24362 might be used. A message is written to a file with a temporary name, which is
24363 then renamed when the delivery is complete. The final name is obtained by
24364 expanding the contents of the &%directory_file%& option.
24365 .ecindex IIDapptra1
24366 .ecindex IIDapptra2
24367
24368
24369
24370
24371
24372
24373 . ////////////////////////////////////////////////////////////////////////////
24374 . ////////////////////////////////////////////////////////////////////////////
24375
24376 .chapter "The autoreply transport" "CHID8"
24377 .scindex IIDauttra1 "transports" "&(autoreply)&"
24378 .scindex IIDauttra2 "&(autoreply)& transport"
24379 The &(autoreply)& transport is not a true transport in that it does not cause
24380 the message to be transmitted. Instead, it generates a new mail message as an
24381 automatic reply to the incoming message. &'References:'& and
24382 &'Auto-Submitted:'& header lines are included. These are constructed according
24383 to the rules in RFCs 2822 and 3834, respectively.
24384
24385 If the router that passes the message to this transport does not have the
24386 &%unseen%& option set, the original message (for the current recipient) is not
24387 delivered anywhere. However, when the &%unseen%& option is set on the router
24388 that passes the message to this transport, routing of the address continues, so
24389 another router can set up a normal message delivery.
24390
24391
24392 The &(autoreply)& transport is usually run as the result of mail filtering, a
24393 &"vacation"& message being the standard example. However, it can also be run
24394 directly from a router like any other transport. To reduce the possibility of
24395 message cascades, messages created by the &(autoreply)& transport always have
24396 empty envelope sender addresses, like bounce messages.
24397
24398 The parameters of the message to be sent can be specified in the configuration
24399 by options described below. However, these are used only when the address
24400 passed to the transport does not contain its own reply information. When the
24401 transport is run as a consequence of a
24402 &%mail%&
24403 or &%vacation%& command in a filter file, the parameters of the message are
24404 supplied by the filter, and passed with the address. The transport's options
24405 that define the message are then ignored (so they are not usually set in this
24406 case). The message is specified entirely by the filter or by the transport; it
24407 is never built from a mixture of options. However, the &%file_optional%&,
24408 &%mode%&, and &%return_message%& options apply in all cases.
24409
24410 &(Autoreply)& is implemented as a local transport. When used as a result of a
24411 command in a user's filter file, &(autoreply)& normally runs under the uid and
24412 gid of the user, and with appropriate current and home directories (see chapter
24413 &<<CHAPenvironment>>&).
24414
24415 There is a subtle difference between routing a message to a &(pipe)& transport
24416 that generates some text to be returned to the sender, and routing it to an
24417 &(autoreply)& transport. This difference is noticeable only if more than one
24418 address from the same message is so handled. In the case of a pipe, the
24419 separate outputs from the different addresses are gathered up and returned to
24420 the sender in a single message, whereas if &(autoreply)& is used, a separate
24421 message is generated for each address that is passed to it.
24422
24423 Non-printing characters are not permitted in the header lines generated for the
24424 message that &(autoreply)& creates, with the exception of newlines that are
24425 immediately followed by white space. If any non-printing characters are found,
24426 the transport defers.
24427 Whether characters with the top bit set count as printing characters or not is
24428 controlled by the &%print_topbitchars%& global option.
24429
24430 If any of the generic options for manipulating headers (for example,
24431 &%headers_add%&) are set on an &(autoreply)& transport, they apply to the copy
24432 of the original message that is included in the generated message when
24433 &%return_message%& is set. They do not apply to the generated message itself.
24434
24435 .vindex "&$sender_address$&"
24436 If the &(autoreply)& transport receives return code 2 from Exim when it submits
24437 the message, indicating that there were no recipients, it does not treat this
24438 as an error. This means that autoreplies sent to &$sender_address$& when this
24439 is empty (because the incoming message is a bounce message) do not cause
24440 problems. They are just discarded.
24441
24442
24443
24444 .section "Private options for autoreply" "SECID139"
24445 .cindex "options" "&(autoreply)& transport"
24446
24447 .option bcc autoreply string&!! unset
24448 This specifies the addresses that are to receive &"blind carbon copies"& of the
24449 message when the message is specified by the transport.
24450
24451
24452 .option cc autoreply string&!! unset
24453 This specifies recipients of the message and the contents of the &'Cc:'& header
24454 when the message is specified by the transport.
24455
24456
24457 .option file autoreply string&!! unset
24458 The contents of the file are sent as the body of the message when the message
24459 is specified by the transport. If both &%file%& and &%text%& are set, the text
24460 string comes first.
24461
24462
24463 .option file_expand autoreply boolean false
24464 If this is set, the contents of the file named by the &%file%& option are
24465 subjected to string expansion as they are added to the message.
24466
24467
24468 .option file_optional autoreply boolean false
24469 If this option is true, no error is generated if the file named by the &%file%&
24470 option or passed with the address does not exist or cannot be read.
24471
24472
24473 .option from autoreply string&!! unset
24474 This specifies the contents of the &'From:'& header when the message is
24475 specified by the transport.
24476
24477
24478 .option headers autoreply string&!! unset
24479 This specifies additional RFC 2822 headers that are to be added to the message
24480 when the message is specified by the transport. Several can be given by using
24481 &"\n"& to separate them. There is no check on the format.
24482
24483
24484 .option log autoreply string&!! unset
24485 This option names a file in which a record of every message sent is logged when
24486 the message is specified by the transport.
24487
24488
24489 .option mode autoreply "octal integer" 0600
24490 If either the log file or the &"once"& file has to be created, this mode is
24491 used.
24492
24493
24494 .option never_mail autoreply "address list&!!" unset
24495 If any run of the transport creates a message with a recipient that matches any
24496 item in the list, that recipient is quietly discarded. If all recipients are
24497 discarded, no message is created. This applies both when the recipients are
24498 generated by a filter and when they are specified in the transport.
24499
24500
24501
24502 .option once autoreply string&!! unset
24503 This option names a file or DBM database in which a record of each &'To:'&
24504 recipient is kept when the message is specified by the transport. &*Note*&:
24505 This does not apply to &'Cc:'& or &'Bcc:'& recipients.
24506
24507 If &%once%& is unset, or is set to an empty string, the message is always sent.
24508 By default, if &%once%& is set to a non-empty filename, the message
24509 is not sent if a potential recipient is already listed in the database.
24510 However, if the &%once_repeat%& option specifies a time greater than zero, the
24511 message is sent if that much time has elapsed since a message was last sent to
24512 this recipient. A setting of zero time for &%once_repeat%& (the default)
24513 prevents a message from being sent a second time &-- in this case, zero means
24514 infinity.
24515
24516 If &%once_file_size%& is zero, a DBM database is used to remember recipients,
24517 and it is allowed to grow as large as necessary. If &%once_file_size%& is set
24518 greater than zero, it changes the way Exim implements the &%once%& option.
24519 Instead of using a DBM file to record every recipient it sends to, it uses a
24520 regular file, whose size will never get larger than the given value.
24521
24522 In the file, Exim keeps a linear list of recipient addresses and the times at
24523 which they were sent messages. If the file is full when a new address needs to
24524 be added, the oldest address is dropped. If &%once_repeat%& is not set, this
24525 means that a given recipient may receive multiple messages, but at
24526 unpredictable intervals that depend on the rate of turnover of addresses in the
24527 file. If &%once_repeat%& is set, it specifies a maximum time between repeats.
24528
24529
24530 .option once_file_size autoreply integer 0
24531 See &%once%& above.
24532
24533
24534 .option once_repeat autoreply time&!! 0s
24535 See &%once%& above.
24536 After expansion, the value of this option must be a valid time value.
24537
24538
24539 .option reply_to autoreply string&!! unset
24540 This specifies the contents of the &'Reply-To:'& header when the message is
24541 specified by the transport.
24542
24543
24544 .option return_message autoreply boolean false
24545 If this is set, a copy of the original message is returned with the new
24546 message, subject to the maximum size set in the &%return_size_limit%& global
24547 configuration option.
24548
24549
24550 .option subject autoreply string&!! unset
24551 This specifies the contents of the &'Subject:'& header when the message is
24552 specified by the transport. It is tempting to quote the original subject in
24553 automatic responses. For example:
24554 .code
24555 subject = Re: $h_subject:
24556 .endd
24557 There is a danger in doing this, however. It may allow a third party to
24558 subscribe your users to an opt-in mailing list, provided that the list accepts
24559 bounce messages as subscription confirmations. Well-managed lists require a
24560 non-bounce message to confirm a subscription, so the danger is relatively
24561 small.
24562
24563
24564
24565 .option text autoreply string&!! unset
24566 This specifies a single string to be used as the body of the message when the
24567 message is specified by the transport. If both &%text%& and &%file%& are set,
24568 the text comes first.
24569
24570
24571 .option to autoreply string&!! unset
24572 This specifies recipients of the message and the contents of the &'To:'& header
24573 when the message is specified by the transport.
24574 .ecindex IIDauttra1
24575 .ecindex IIDauttra2
24576
24577
24578
24579
24580 . ////////////////////////////////////////////////////////////////////////////
24581 . ////////////////////////////////////////////////////////////////////////////
24582
24583 .chapter "The lmtp transport" "CHAPLMTP"
24584 .cindex "transports" "&(lmtp)&"
24585 .cindex "&(lmtp)& transport"
24586 .cindex "LMTP" "over a pipe"
24587 .cindex "LMTP" "over a unix-domain socket"
24588 The &(lmtp)& transport runs the LMTP protocol (RFC 2033) over a pipe to a
24589 specified command
24590 or by interacting with a Unix domain socket.
24591 This transport is something of a cross between the &(pipe)& and &(smtp)&
24592 transports. Exim also has support for using LMTP over TCP/IP; this is
24593 implemented as an option for the &(smtp)& transport. Because LMTP is expected
24594 to be of minority interest, the default build-time configure in &_src/EDITME_&
24595 has it commented out. You need to ensure that
24596 .code
24597 TRANSPORT_LMTP=yes
24598 .endd
24599 .cindex "options" "&(lmtp)& transport"
24600 is present in your &_Local/Makefile_& in order to have the &(lmtp)& transport
24601 included in the Exim binary. The private options of the &(lmtp)& transport are
24602 as follows:
24603
24604 .option batch_id lmtp string&!! unset
24605 See the description of local delivery batching in chapter &<<CHAPbatching>>&.
24606
24607
24608 .option batch_max lmtp integer 1
24609 This limits the number of addresses that can be handled in a single delivery.
24610 Most LMTP servers can handle several addresses at once, so it is normally a
24611 good idea to increase this value. See the description of local delivery
24612 batching in chapter &<<CHAPbatching>>&.
24613
24614
24615 .option command lmtp string&!! unset
24616 This option must be set if &%socket%& is not set. The string is a command which
24617 is run in a separate process. It is split up into a command name and list of
24618 arguments, each of which is separately expanded (so expansion cannot change the
24619 number of arguments). The command is run directly, not via a shell. The message
24620 is passed to the new process using the standard input and output to operate the
24621 LMTP protocol.
24622
24623 .option ignore_quota lmtp boolean false
24624 .cindex "LMTP" "ignoring quota errors"
24625 If this option is set true, the string &`IGNOREQUOTA`& is added to RCPT
24626 commands, provided that the LMTP server has advertised support for IGNOREQUOTA
24627 in its response to the LHLO command.
24628
24629 .option socket lmtp string&!! unset
24630 This option must be set if &%command%& is not set. The result of expansion must
24631 be the name of a Unix domain socket. The transport connects to the socket and
24632 delivers the message to it using the LMTP protocol.
24633
24634
24635 .option timeout lmtp time 5m
24636 The transport is aborted if the created process or Unix domain socket does not
24637 respond to LMTP commands or message input within this timeout. Delivery
24638 is deferred, and will be tried again later. Here is an example of a typical
24639 LMTP transport:
24640 .code
24641 lmtp:
24642   driver = lmtp
24643   command = /some/local/lmtp/delivery/program
24644   batch_max = 20
24645   user = exim
24646 .endd
24647 This delivers up to 20 addresses at a time, in a mixture of domains if
24648 necessary, running as the user &'exim'&.
24649
24650
24651
24652 . ////////////////////////////////////////////////////////////////////////////
24653 . ////////////////////////////////////////////////////////////////////////////
24654
24655 .chapter "The pipe transport" "CHAPpipetransport"
24656 .scindex IIDpiptra1 "transports" "&(pipe)&"
24657 .scindex IIDpiptra2 "&(pipe)& transport"
24658 The &(pipe)& transport is used to deliver messages via a pipe to a command
24659 running in another process. One example is the use of &(pipe)& as a
24660 pseudo-remote transport for passing messages to some other delivery mechanism
24661 (such as UUCP). Another is the use by individual users to automatically process
24662 their incoming messages. The &(pipe)& transport can be used in one of the
24663 following ways:
24664
24665 .ilist
24666 .vindex "&$local_part$&"
24667 A router routes one address to a transport in the normal way, and the
24668 transport is configured as a &(pipe)& transport. In this case, &$local_part$&
24669 contains the local part of the address (as usual), and the command that is run
24670 is specified by the &%command%& option on the transport.
24671 .next
24672 .vindex "&$pipe_addresses$&"
24673 If the &%batch_max%& option is set greater than 1 (the default is 1), the
24674 transport can handle more than one address in a single run. In this case, when
24675 more than one address is routed to the transport, &$local_part$& is not set
24676 (because it is not unique). However, the pseudo-variable &$pipe_addresses$&
24677 (described in section &<<SECThowcommandrun>>& below) contains all the addresses
24678 that are routed to the transport.
24679 .next
24680 .vindex "&$address_pipe$&"
24681 A router redirects an address directly to a pipe command (for example, from an
24682 alias or forward file). In this case, &$address_pipe$& contains the text of the
24683 pipe command, and the &%command%& option on the transport is ignored unless
24684 &%force_command%& is set. If only one address is being transported
24685 (&%batch_max%& is not greater than one, or only one address was redirected to
24686 this pipe command), &$local_part$& contains the local part that was redirected.
24687 .endlist
24688
24689
24690 The &(pipe)& transport is a non-interactive delivery method. Exim can also
24691 deliver messages over pipes using the LMTP interactive protocol. This is
24692 implemented by the &(lmtp)& transport.
24693
24694 In the case when &(pipe)& is run as a consequence of an entry in a local user's
24695 &_.forward_& file, the command runs under the uid and gid of that user. In
24696 other cases, the uid and gid have to be specified explicitly, either on the
24697 transport or on the router that handles the address. Current and &"home"&
24698 directories are also controllable. See chapter &<<CHAPenvironment>>& for
24699 details of the local delivery environment and chapter &<<CHAPbatching>>&
24700 for a discussion of local delivery batching.
24701
24702 .cindex "tainted data" "in pipe command"
24703 .cindex pipe "tainted data"
24704 Tainted data may not be used for the command name.
24705
24706
24707 .section "Concurrent delivery" "SECID140"
24708 If two messages arrive at almost the same time, and both are routed to a pipe
24709 delivery, the two pipe transports may be run concurrently. You must ensure that
24710 any pipe commands you set up are robust against this happening. If the commands
24711 write to a file, the &%exim_lock%& utility might be of use.
24712 Alternatively the &%max_parallel%& option could be used with a value
24713 of "1" to enforce serialization.
24714
24715
24716
24717
24718 .section "Returned status and data" "SECID141"
24719 .cindex "&(pipe)& transport" "returned data"
24720 If the command exits with a non-zero return code, the delivery is deemed to
24721 have failed, unless either the &%ignore_status%& option is set (in which case
24722 the return code is treated as zero), or the return code is one of those listed
24723 in the &%temp_errors%& option, which are interpreted as meaning &"try again
24724 later"&. In this case, delivery is deferred. Details of a permanent failure are
24725 logged, but are not included in the bounce message, which merely contains
24726 &"local delivery failed"&.
24727
24728 If the command exits on a signal and the &%freeze_signal%& option is set then
24729 the message will be frozen in the queue. If that option is not set, a bounce
24730 will be sent as normal.
24731
24732 If the return code is greater than 128 and the command being run is a shell
24733 script, it normally means that the script was terminated by a signal whose
24734 value is the return code minus 128. The &%freeze_signal%& option does not
24735 apply in this case.
24736
24737 If Exim is unable to run the command (that is, if &[execve()]& fails), the
24738 return code is set to 127. This is the value that a shell returns if it is
24739 asked to run a non-existent command. The wording for the log line suggests that
24740 a non-existent command may be the problem.
24741
24742 The &%return_output%& option can affect the result of a pipe delivery. If it is
24743 set and the command produces any output on its standard output or standard
24744 error streams, the command is considered to have failed, even if it gave a zero
24745 return code or if &%ignore_status%& is set. The output from the command is
24746 included as part of the bounce message. The &%return_fail_output%& option is
24747 similar, except that output is returned only when the command exits with a
24748 failure return code, that is, a value other than zero or a code that matches
24749 &%temp_errors%&.
24750
24751
24752
24753 .section "How the command is run" "SECThowcommandrun"
24754 .cindex "&(pipe)& transport" "path for command"
24755 The command line is (by default) broken down into a command name and arguments
24756 by the &(pipe)& transport itself. The &%allow_commands%& and
24757 &%restrict_to_path%& options can be used to restrict the commands that may be
24758 run.
24759
24760 .cindex "quoting" "in pipe command"
24761 Unquoted arguments are delimited by white space. If an argument appears in
24762 double quotes, backslash is interpreted as an escape character in the usual
24763 way. If an argument appears in single quotes, no escaping is done.
24764
24765 String expansion is applied to the command line except when it comes from a
24766 traditional &_.forward_& file (commands from a filter file are expanded). The
24767 expansion is applied to each argument in turn rather than to the whole line.
24768 For this reason, any string expansion item that contains white space must be
24769 quoted so as to be contained within a single argument. A setting such as
24770 .code
24771 command = /some/path ${if eq{$local_part}{postmaster}{xx}{yy}}
24772 .endd
24773 will not work, because the expansion item gets split between several
24774 arguments. You have to write
24775 .code
24776 command = /some/path "${if eq{$local_part}{postmaster}{xx}{yy}}"
24777 .endd
24778 to ensure that it is all in one argument. The expansion is done in this way,
24779 argument by argument, so that the number of arguments cannot be changed as a
24780 result of expansion, and quotes or backslashes in inserted variables do not
24781 interact with external quoting. However, this leads to problems if you want to
24782 generate multiple arguments (or the command name plus arguments) from a single
24783 expansion. In this situation, the simplest solution is to use a shell. For
24784 example:
24785 .code
24786 command = /bin/sh -c ${lookup{$local_part}lsearch{/some/file}}
24787 .endd
24788
24789 .cindex "transport" "filter"
24790 .cindex "filter" "transport filter"
24791 .vindex "&$pipe_addresses$&"
24792 Special handling takes place when an argument consists of precisely the text
24793 &`$pipe_addresses`& (no quotes).
24794 This is not a general expansion variable; the only
24795 place this string is recognized is when it appears as an argument for a pipe or
24796 transport filter command. It causes each address that is being handled to be
24797 inserted in the argument list at that point &'as a separate argument'&. This
24798 avoids any problems with spaces or shell metacharacters, and is of use when a
24799 &(pipe)& transport is handling groups of addresses in a batch.
24800
24801 If &%force_command%& is enabled on the transport, special handling takes place
24802 for an argument that consists of precisely the text &`$address_pipe`&.  It
24803 is handled similarly to &$pipe_addresses$& above.  It is expanded and each
24804 argument is inserted in the argument list at that point
24805 &'as a separate argument'&.  The &`$address_pipe`& item does not need to be
24806 the only item in the argument; in fact, if it were then &%force_command%&
24807 should behave as a no-op.  Rather, it should be used to adjust the command
24808 run while preserving the argument vector separation.
24809
24810 After splitting up into arguments and expansion, the resulting command is run
24811 in a subprocess directly from the transport, &'not'& under a shell. The
24812 message that is being delivered is supplied on the standard input, and the
24813 standard output and standard error are both connected to a single pipe that is
24814 read by Exim. The &%max_output%& option controls how much output the command
24815 may produce, and the &%return_output%& and &%return_fail_output%& options
24816 control what is done with it.
24817
24818 Not running the command under a shell (by default) lessens the security risks
24819 in cases when a command from a user's filter file is built out of data that was
24820 taken from an incoming message. If a shell is required, it can of course be
24821 explicitly specified as the command to be run. However, there are circumstances
24822 where existing commands (for example, in &_.forward_& files) expect to be run
24823 under a shell and cannot easily be modified. To allow for these cases, there is
24824 an option called &%use_shell%&, which changes the way the &(pipe)& transport
24825 works. Instead of breaking up the command line as just described, it expands it
24826 as a single string and passes the result to &_/bin/sh_&. The
24827 &%restrict_to_path%& option and the &$pipe_addresses$& facility cannot be used
24828 with &%use_shell%&, and the whole mechanism is inherently less secure.
24829
24830
24831
24832 .section "Environment variables" "SECTpipeenv"
24833 .cindex "&(pipe)& transport" "environment for command"
24834 .cindex "environment" "&(pipe)& transport"
24835 The environment variables listed below are set up when the command is invoked.
24836 This list is a compromise for maximum compatibility with other MTAs. Note that
24837 the &%environment%& option can be used to add additional variables to this
24838 environment. The environment for the &(pipe)& transport is not subject
24839 to the &%add_environment%& and &%keep_environment%& main config options.
24840 &*Note*&: Using enviroment variables loses track of tainted data.
24841 Writers of &(pipe)& transport commands should be wary of data supplied
24842 by potential attackers.
24843 .display
24844 &`DOMAIN            `&   the domain of the address
24845 &`HOME              `&   the home directory, if set
24846 &`HOST              `&   the host name when called from a router (see below)
24847 &`LOCAL_PART        `&   see below
24848 &`LOCAL_PART_PREFIX `&   see below
24849 &`LOCAL_PART_SUFFIX `&   see below
24850 &`LOGNAME           `&   see below
24851 &`MESSAGE_ID        `&   Exim's local ID for the message
24852 &`PATH              `&   as specified by the &%path%& option below
24853 &`QUALIFY_DOMAIN    `&   the sender qualification domain
24854 &`RECIPIENT         `&   the complete recipient address
24855 &`SENDER            `&   the sender of the message (empty if a bounce)
24856 &`SHELL             `&   &`/bin/sh`&
24857 &`TZ                `&   the value of the &%timezone%& option, if set
24858 &`USER              `&   see below
24859 .endd
24860 When a &(pipe)& transport is called directly from (for example) an &(accept)&
24861 router, LOCAL_PART is set to the local part of the address. When it is
24862 called as a result of a forward or alias expansion, LOCAL_PART is set to
24863 the local part of the address that was expanded. In both cases, any affixes are
24864 removed from the local part, and made available in LOCAL_PART_PREFIX and
24865 LOCAL_PART_SUFFIX, respectively. LOGNAME and USER are set to the
24866 same value as LOCAL_PART for compatibility with other MTAs.
24867
24868 .cindex "HOST"
24869 HOST is set only when a &(pipe)& transport is called from a router that
24870 associates hosts with an address, typically when using &(pipe)& as a
24871 pseudo-remote transport. HOST is set to the first host name specified by
24872 the router.
24873
24874 .cindex "HOME"
24875 If the transport's generic &%home_directory%& option is set, its value is used
24876 for the HOME environment variable. Otherwise, a home directory may be set
24877 by the router's &%transport_home_directory%& option, which defaults to the
24878 user's home directory if &%check_local_user%& is set.
24879
24880
24881 .section "Private options for pipe" "SECID142"
24882 .cindex "options" "&(pipe)& transport"
24883
24884
24885
24886 .option allow_commands pipe "string list&!!" unset
24887 .cindex "&(pipe)& transport" "permitted commands"
24888 The string is expanded, and is then interpreted as a colon-separated list of
24889 permitted commands. If &%restrict_to_path%& is not set, the only commands
24890 permitted are those in the &%allow_commands%& list. They need not be absolute
24891 paths; the &%path%& option is still used for relative paths. If
24892 &%restrict_to_path%& is set with &%allow_commands%&, the command must either be
24893 in the &%allow_commands%& list, or a name without any slashes that is found on
24894 the path. In other words, if neither &%allow_commands%& nor
24895 &%restrict_to_path%& is set, there is no restriction on the command, but
24896 otherwise only commands that are permitted by one or the other are allowed. For
24897 example, if
24898 .code
24899 allow_commands = /usr/bin/vacation
24900 .endd
24901 and &%restrict_to_path%& is not set, the only permitted command is
24902 &_/usr/bin/vacation_&. The &%allow_commands%& option may not be set if
24903 &%use_shell%& is set.
24904
24905
24906 .option batch_id pipe string&!! unset
24907 See the description of local delivery batching in chapter &<<CHAPbatching>>&.
24908
24909
24910 .option batch_max pipe integer 1
24911 This limits the number of addresses that can be handled in a single delivery.
24912 See the description of local delivery batching in chapter &<<CHAPbatching>>&.
24913
24914
24915 .option check_string pipe string unset
24916 As &(pipe)& writes the message, the start of each line is tested for matching
24917 &%check_string%&, and if it does, the initial matching characters are replaced
24918 by the contents of &%escape_string%&, provided both are set. The value of
24919 &%check_string%& is a literal string, not a regular expression, and the case of
24920 any letters it contains is significant. When &%use_bsmtp%& is set, the contents
24921 of &%check_string%& and &%escape_string%& are forced to values that implement
24922 the SMTP escaping protocol. Any settings made in the configuration file are
24923 ignored.
24924
24925
24926 .option command pipe string&!! unset
24927 This option need not be set when &(pipe)& is being used to deliver to pipes
24928 obtained directly from address redirections. In other cases, the option must be
24929 set, to provide a command to be run. It need not yield an absolute path (see
24930 the &%path%& option below). The command is split up into separate arguments by
24931 Exim, and each argument is separately expanded, as described in section
24932 &<<SECThowcommandrun>>& above.
24933
24934 .cindex "tainted data"
24935 No part of the resulting command may be tainted.
24936
24937
24938 .option environment pipe "string list&!!" unset
24939 .cindex "&(pipe)& transport" "environment for command"
24940 .cindex "environment" "&(pipe)& transport"
24941 This option is used to add additional variables to the environment in which the
24942 command runs (see section &<<SECTpipeenv>>& for the default list). Its value is
24943 a string which is expanded, and then interpreted as a colon-separated list of
24944 environment settings of the form <&'name'&>=<&'value'&>.
24945
24946
24947 .option escape_string pipe string unset
24948 See &%check_string%& above.
24949
24950
24951 .option freeze_exec_fail pipe boolean false
24952 .cindex "exec failure"
24953 .cindex "failure of exec"
24954 .cindex "&(pipe)& transport" "failure of exec"
24955 Failure to exec the command in a pipe transport is by default treated like
24956 any other failure while running the command. However, if &%freeze_exec_fail%&
24957 is set, failure to exec is treated specially, and causes the message to be
24958 frozen, whatever the setting of &%ignore_status%&.
24959
24960
24961 .option freeze_signal pipe boolean false
24962 .cindex "signal exit"
24963 .cindex "&(pipe)& transport", "signal exit"
24964 Normally if the process run by a command in a pipe transport exits on a signal,
24965 a bounce message is sent. If &%freeze_signal%& is set, the message will be
24966 frozen in Exim's queue instead.
24967
24968
24969 .option force_command pipe boolean false
24970 .cindex "force command"
24971 .cindex "&(pipe)& transport", "force command"
24972 Normally when a router redirects an address directly to a pipe command
24973 the &%command%& option on the transport is ignored.  If &%force_command%&
24974 is set, the &%command%& option will used. This is especially
24975 useful for forcing a wrapper or additional argument to be added to the
24976 command. For example:
24977 .code
24978 command = /usr/bin/remote_exec myhost -- $address_pipe
24979 force_command
24980 .endd
24981
24982 Note that &$address_pipe$& is handled specially in &%command%& when
24983 &%force_command%& is set, expanding out to the original argument vector as
24984 separate items, similarly to a Unix shell &`"$@"`& construct.
24985
24986
24987 .option ignore_status pipe boolean false
24988 If this option is true, the status returned by the subprocess that is set up to
24989 run the command is ignored, and Exim behaves as if zero had been returned.
24990 Otherwise, a non-zero status or termination by signal causes an error return
24991 from the transport unless the status value is one of those listed in
24992 &%temp_errors%&; these cause the delivery to be deferred and tried again later.
24993
24994 &*Note*&: This option does not apply to timeouts, which do not return a status.
24995 See the &%timeout_defer%& option for how timeouts are handled.
24996
24997
24998 .option log_defer_output pipe boolean false
24999 .cindex "&(pipe)& transport" "logging output"
25000 If this option is set, and the status returned by the command is
25001 one of the codes listed in &%temp_errors%& (that is, delivery was deferred),
25002 and any output was produced on stdout or stderr, the first line of it is
25003 written to the main log.
25004
25005
25006 .option log_fail_output pipe boolean false
25007 If this option is set, and the command returns any output on stdout or
25008 stderr, and also ends with a return code that is neither zero nor one of
25009 the return codes listed in &%temp_errors%& (that is, the delivery
25010 failed), the first line of output is written to the main log. This
25011 option and &%log_output%& are mutually exclusive.  Only one of them may
25012 be set.
25013
25014
25015 .option log_output pipe boolean false
25016 If this option is set and the command returns any output on stdout or
25017 stderr, the first line of output is written to the main log, whatever
25018 the return code. This option and &%log_fail_output%& are mutually
25019 exclusive. Only one of them may be set.
25020
25021
25022 .option max_output pipe integer 20K
25023 This specifies the maximum amount of output that the command may produce on its
25024 standard output and standard error file combined. If the limit is exceeded, the
25025 process running the command is killed. This is intended as a safety measure to
25026 catch runaway processes. The limit is applied independently of the settings of
25027 the options that control what is done with such output (for example,
25028 &%return_output%&). Because of buffering effects, the amount of output may
25029 exceed the limit by a small amount before Exim notices.
25030
25031
25032 .option message_prefix pipe string&!! "see below"
25033 The string specified here is expanded and output at the start of every message.
25034 The default is unset if &%use_bsmtp%& is set. Otherwise it is
25035 .code
25036 message_prefix = \
25037   From ${if def:return_path{$return_path}{MAILER-DAEMON}}\
25038   ${tod_bsdinbox}\n
25039 .endd
25040 .cindex "Cyrus"
25041 .cindex "&%tmail%&"
25042 .cindex "&""From""& line"
25043 This is required by the commonly used &_/usr/bin/vacation_& program.
25044 However, it must &'not'& be present if delivery is to the Cyrus IMAP server,
25045 or to the &%tmail%& local delivery agent. The prefix can be suppressed by
25046 setting
25047 .code
25048 message_prefix =
25049 .endd
25050 &*Note:*& If you set &%use_crlf%& true, you must change any occurrences of
25051 &`\n`& to &`\r\n`& in &%message_prefix%&.
25052
25053
25054 .option message_suffix pipe string&!! "see below"
25055 The string specified here is expanded and output at the end of every message.
25056 The default is unset if &%use_bsmtp%& is set. Otherwise it is a single newline.
25057 The suffix can be suppressed by setting
25058 .code
25059 message_suffix =
25060 .endd
25061 &*Note:*& If you set &%use_crlf%& true, you must change any occurrences of
25062 &`\n`& to &`\r\n`& in &%message_suffix%&.
25063
25064
25065 .option path pipe string&!! "/bin:/usr/bin"
25066 This option is expanded and
25067 specifies the string that is set up in the PATH environment
25068 variable of the subprocess.
25069 If the &%command%& option does not yield an absolute path name, the command is
25070 sought in the PATH directories, in the usual way. &*Warning*&: This does not
25071 apply to a command specified as a transport filter.
25072
25073
25074 .option permit_coredump pipe boolean false
25075 Normally Exim inhibits core-dumps during delivery.  If you have a need to get
25076 a core-dump of a pipe command, enable this command.  This enables core-dumps
25077 during delivery and affects both the Exim binary and the pipe command run.
25078 It is recommended that this option remain off unless and until you have a need
25079 for it and that this only be enabled when needed, as the risk of excessive
25080 resource consumption can be quite high.  Note also that Exim is typically
25081 installed as a setuid binary and most operating systems will inhibit coredumps
25082 of these by default, so further OS-specific action may be required.
25083
25084
25085 .option pipe_as_creator pipe boolean false
25086 .cindex "uid (user id)" "local delivery"
25087 If the generic &%user%& option is not set and this option is true, the delivery
25088 process is run under the uid that was in force when Exim was originally called
25089 to accept the message. If the group id is not otherwise set (via the generic
25090 &%group%& option), the gid that was in force when Exim was originally called to
25091 accept the message is used.
25092
25093
25094 .option restrict_to_path pipe boolean false
25095 When this option is set, any command name not listed in &%allow_commands%& must
25096 contain no slashes. The command is searched for only in the directories listed
25097 in the &%path%& option. This option is intended for use in the case when a pipe
25098 command has been generated from a user's &_.forward_& file. This is usually
25099 handled by a &(pipe)& transport called &%address_pipe%&.
25100
25101
25102 .option return_fail_output pipe boolean false
25103 If this option is true, and the command produced any output and ended with a
25104 return code other than zero or one of the codes listed in &%temp_errors%& (that
25105 is, the delivery failed), the output is returned in the bounce message.
25106 However, if the message has a null sender (that is, it is itself a bounce
25107 message), output from the command is discarded. This option and
25108 &%return_output%& are mutually exclusive. Only one of them may be set.
25109
25110
25111
25112 .option return_output pipe boolean false
25113 If this option is true, and the command produced any output, the delivery is
25114 deemed to have failed whatever the return code from the command, and the output
25115 is returned in the bounce message. Otherwise, the output is just discarded.
25116 However, if the message has a null sender (that is, it is a bounce message),
25117 output from the command is always discarded, whatever the setting of this
25118 option. This option and &%return_fail_output%& are mutually exclusive. Only one
25119 of them may be set.
25120
25121
25122
25123 .option temp_errors pipe "string list" "see below"
25124 .cindex "&(pipe)& transport" "temporary failure"
25125 This option contains either a colon-separated list of numbers, or a single
25126 asterisk. If &%ignore_status%& is false
25127 and &%return_output%& is not set,
25128 and the command exits with a non-zero return code, the failure is treated as
25129 temporary and the delivery is deferred if the return code matches one of the
25130 numbers, or if the setting is a single asterisk. Otherwise, non-zero return
25131 codes are treated as permanent errors. The default setting contains the codes
25132 defined by EX_TEMPFAIL and EX_CANTCREAT in &_sysexits.h_&. If Exim is
25133 compiled on a system that does not define these macros, it assumes values of 75
25134 and 73, respectively.
25135
25136
25137 .option timeout pipe time 1h
25138 If the command fails to complete within this time, it is killed. This normally
25139 causes the delivery to fail (but see &%timeout_defer%&). A zero time interval
25140 specifies no timeout. In order to ensure that any subprocesses created by the
25141 command are also killed, Exim makes the initial process a process group leader,
25142 and kills the whole process group on a timeout. However, this can be defeated
25143 if one of the processes starts a new process group.
25144
25145 .option timeout_defer pipe boolean false
25146 A timeout in a &(pipe)& transport, either in the command that the transport
25147 runs, or in a transport filter that is associated with it, is by default
25148 treated as a hard error, and the delivery fails. However, if &%timeout_defer%&
25149 is set true, both kinds of timeout become temporary errors, causing the
25150 delivery to be deferred.
25151
25152 .option umask pipe "octal integer" 022
25153 This specifies the umask setting for the subprocess that runs the command.
25154
25155
25156 .option use_bsmtp pipe boolean false
25157 .cindex "envelope sender"
25158 If this option is set true, the &(pipe)& transport writes messages in &"batch
25159 SMTP"& format, with the envelope sender and recipient(s) included as SMTP
25160 commands. If you want to include a leading HELO command with such messages,
25161 you can do so by setting the &%message_prefix%& option. See section
25162 &<<SECTbatchSMTP>>& for details of batch SMTP.
25163
25164 .option use_classresources pipe boolean false
25165 .cindex "class resources (BSD)"
25166 This option is available only when Exim is running on FreeBSD, NetBSD, or
25167 BSD/OS. If it is set true, the &[setclassresources()]& function is used to set
25168 resource limits when a &(pipe)& transport is run to perform a delivery. The
25169 limits for the uid under which the pipe is to run are obtained from the login
25170 class database.
25171
25172
25173 .option use_crlf pipe boolean false
25174 .cindex "carriage return"
25175 .cindex "linefeed"
25176 This option causes lines to be terminated with the two-character CRLF sequence
25177 (carriage return, linefeed) instead of just a linefeed character. In the case
25178 of batched SMTP, the byte sequence written to the pipe is then an exact image
25179 of what would be sent down a real SMTP connection.
25180
25181 The contents of the &%message_prefix%& and &%message_suffix%& options are
25182 written verbatim, so must contain their own carriage return characters if these
25183 are needed. When &%use_bsmtp%& is not set, the default values for both
25184 &%message_prefix%& and &%message_suffix%& end with a single linefeed, so their
25185 values must be changed to end with &`\r\n`& if &%use_crlf%& is set.
25186
25187
25188 .option use_shell pipe boolean false
25189 .vindex "&$pipe_addresses$&"
25190 If this option is set, it causes the command to be passed to &_/bin/sh_&
25191 instead of being run directly from the transport, as described in section
25192 &<<SECThowcommandrun>>&. This is less secure, but is needed in some situations
25193 where the command is expected to be run under a shell and cannot easily be
25194 modified. The &%allow_commands%& and &%restrict_to_path%& options, and the
25195 &`$pipe_addresses`& facility are incompatible with &%use_shell%&. The
25196 command is expanded as a single string, and handed to &_/bin/sh_& as data for
25197 its &%-c%& option.
25198
25199
25200
25201 .section "Using an external local delivery agent" "SECID143"
25202 .cindex "local delivery" "using an external agent"
25203 .cindex "&'procmail'&"
25204 .cindex "external local delivery"
25205 .cindex "delivery" "&'procmail'&"
25206 .cindex "delivery" "by external agent"
25207 The &(pipe)& transport can be used to pass all messages that require local
25208 delivery to a separate local delivery agent such as &%procmail%&. When doing
25209 this, care must be taken to ensure that the pipe is run under an appropriate
25210 uid and gid. In some configurations one wants this to be a uid that is trusted
25211 by the delivery agent to supply the correct sender of the message. It may be
25212 necessary to recompile or reconfigure the delivery agent so that it trusts an
25213 appropriate user. The following is an example transport and router
25214 configuration for &%procmail%&:
25215 .code
25216 # transport
25217 procmail_pipe:
25218   driver = pipe
25219   command = /usr/local/bin/procmail -d $local_part_data
25220   return_path_add
25221   delivery_date_add
25222   envelope_to_add
25223   check_string = "From "
25224   escape_string = ">From "
25225   umask = 077
25226   user = $local_part_data
25227   group = mail
25228
25229 # router
25230 procmail:
25231   driver = accept
25232   check_local_user
25233   transport = procmail_pipe
25234 .endd
25235 In this example, the pipe is run as the local user, but with the group set to
25236 &'mail'&. An alternative is to run the pipe as a specific user such as &'mail'&
25237 or &'exim'&, but in this case you must arrange for &%procmail%& to trust that
25238 user to supply a correct sender address. If you do not specify either a
25239 &%group%& or a &%user%& option, the pipe command is run as the local user. The
25240 home directory is the user's home directory by default.
25241
25242 &*Note*&: The command that the pipe transport runs does &'not'& begin with
25243 .code
25244 IFS=" "
25245 .endd
25246 as shown in some &%procmail%& documentation, because Exim does not by default
25247 use a shell to run pipe commands.
25248
25249 .cindex "Cyrus"
25250 The next example shows a transport and a router for a system where local
25251 deliveries are handled by the Cyrus IMAP server.
25252 . Used to have R: local_part_suffix = .* +  T:   -m $local_part_suffix_v
25253 . but that suffix is tainted so cannot be used in a command arg
25254 . Really, you'd want to use a lookup for acceptable suffixes to do real detainting
25255 .code
25256 # transport
25257 local_delivery_cyrus:
25258   driver = pipe
25259   command = /usr/cyrus/bin/deliver \
25260             -- $local_part_data
25261   user = cyrus
25262   group = mail
25263   return_output
25264   log_output
25265   message_prefix =
25266   message_suffix =
25267
25268 # router
25269 local_user_cyrus:
25270   driver = accept
25271   check_local_user
25272   transport = local_delivery_cyrus
25273 .endd
25274 Note the unsetting of &%message_prefix%& and &%message_suffix%&, and the use of
25275 &%return_output%& to cause any text written by Cyrus to be returned to the
25276 sender.
25277 .ecindex IIDpiptra1
25278 .ecindex IIDpiptra2
25279
25280
25281 . ////////////////////////////////////////////////////////////////////////////
25282 . ////////////////////////////////////////////////////////////////////////////
25283
25284 .chapter "The smtp transport" "CHAPsmtptrans"
25285 .scindex IIDsmttra1 "transports" "&(smtp)&"
25286 .scindex IIDsmttra2 "&(smtp)& transport"
25287 The &(smtp)& transport delivers messages over TCP/IP connections using the SMTP
25288 or LMTP protocol. The list of hosts to try can either be taken from the address
25289 that is being processed (having been set up by the router), or specified
25290 explicitly for the transport. Timeout and retry processing (see chapter
25291 &<<CHAPretry>>&) is applied to each IP address independently.
25292
25293
25294 .section "Multiple messages on a single connection" "SECID144"
25295 The sending of multiple messages over a single TCP/IP connection can arise in
25296 two ways:
25297
25298 .ilist
25299 If a message contains more than &%max_rcpt%& (see below) addresses that are
25300 routed to the same host, more than one copy of the message has to be sent to
25301 that host. In this situation, multiple copies may be sent in a single run of
25302 the &(smtp)& transport over a single TCP/IP connection. (What Exim actually
25303 does when it has too many addresses to send in one message also depends on the
25304 value of the global &%remote_max_parallel%& option. Details are given in
25305 section &<<SECToutSMTPTCP>>&.)
25306 .next
25307 .cindex "hints database" "remembering routing"
25308 When a message has been successfully delivered over a TCP/IP connection, Exim
25309 looks in its hints database to see if there are any other messages awaiting a
25310 connection to the same host. If there are, a new delivery process is started
25311 for one of them, and the current TCP/IP connection is passed on to it. The new
25312 process may in turn send multiple copies and possibly create yet another
25313 process.
25314 .endlist
25315
25316
25317 For each copy sent over the same TCP/IP connection, a sequence counter is
25318 incremented, and if it ever gets to the value of &%connection_max_messages%&,
25319 no further messages are sent over that connection.
25320
25321
25322
25323 .section "Use of the $host and $host_address variables" "SECID145"
25324 .vindex "&$host$&"
25325 .vindex "&$host_address$&"
25326 At the start of a run of the &(smtp)& transport, the values of &$host$& and
25327 &$host_address$& are the name and IP address of the first host on the host list
25328 passed by the router. However, when the transport is about to connect to a
25329 specific host, and while it is connected to that host, &$host$& and
25330 &$host_address$& are set to the values for that host. These are the values
25331 that are in force when the &%helo_data%&, &%hosts_try_auth%&, &%interface%&,
25332 &%serialize_hosts%&, and the various TLS options are expanded.
25333
25334
25335 .section "Use of $tls_cipher and $tls_peerdn" "usecippeer"
25336 .vindex &$tls_bits$&
25337 .vindex &$tls_cipher$&
25338 .vindex &$tls_peerdn$&
25339 .vindex &$tls_sni$&
25340 At the start of a run of the &(smtp)& transport, the values of &$tls_bits$&,
25341 &$tls_cipher$&, &$tls_peerdn$& and &$tls_sni$&
25342 are the values that were set when the message was received.
25343 These are the values that are used for options that are expanded before any
25344 SMTP connections are made. Just before each connection is made, these four
25345 variables are emptied. If TLS is subsequently started, they are set to the
25346 appropriate values for the outgoing connection, and these are the values that
25347 are in force when any authenticators are run and when the
25348 &%authenticated_sender%& option is expanded.
25349
25350 These variables are deprecated in favour of &$tls_in_cipher$& et. al.
25351 and will be removed in a future release.
25352
25353
25354 .section "Private options for smtp" "SECID146"
25355 .cindex "options" "&(smtp)& transport"
25356 The private options of the &(smtp)& transport are as follows:
25357
25358
25359 .option address_retry_include_sender smtp boolean true
25360 .cindex "4&'xx'& responses" "retrying after"
25361 When an address is delayed because of a 4&'xx'& response to a RCPT command, it
25362 is the combination of sender and recipient that is delayed in subsequent queue
25363 runs until the retry time is reached. You can delay the recipient without
25364 reference to the sender (which is what earlier versions of Exim did), by
25365 setting &%address_retry_include_sender%& false. However, this can lead to
25366 problems with servers that regularly issue 4&'xx'& responses to RCPT commands.
25367
25368 .option allow_localhost smtp boolean false
25369 .cindex "local host" "sending to"
25370 .cindex "fallback" "hosts specified on transport"
25371 When a host specified in &%hosts%& or &%fallback_hosts%& (see below) turns out
25372 to be the local host, or is listed in &%hosts_treat_as_local%&, delivery is
25373 deferred by default. However, if &%allow_localhost%& is set, Exim goes on to do
25374 the delivery anyway. This should be used only in special cases when the
25375 configuration ensures that no looping will result (for example, a differently
25376 configured Exim is listening on the port to which the message is sent).
25377
25378
25379 .option authenticated_sender smtp string&!! unset
25380 .cindex "Cyrus"
25381 When Exim has authenticated as a client, or if &%authenticated_sender_force%&
25382 is true, this option sets a value for the AUTH= item on outgoing MAIL commands,
25383 overriding any existing authenticated sender value. If the string expansion is
25384 forced to fail, the option is ignored. Other expansion failures cause delivery
25385 to be deferred. If the result of expansion is an empty string, that is also
25386 ignored.
25387
25388 The expansion happens after the outgoing connection has been made and TLS
25389 started, if required. This means that the &$host$&, &$host_address$&,
25390 &$tls_out_cipher$&, and &$tls_out_peerdn$& variables are set according to the
25391 particular connection.
25392
25393 If the SMTP session is not authenticated, the expansion of
25394 &%authenticated_sender%& still happens (and can cause the delivery to be
25395 deferred if it fails), but no AUTH= item is added to MAIL commands
25396 unless &%authenticated_sender_force%& is true.
25397
25398 This option allows you to use the &(smtp)& transport in LMTP mode to
25399 deliver mail to Cyrus IMAP and provide the proper local part as the
25400 &"authenticated sender"&, via a setting such as:
25401 .code
25402 authenticated_sender = $local_part
25403 .endd
25404 This removes the need for IMAP subfolders to be assigned special ACLs to
25405 allow direct delivery to those subfolders.
25406
25407 Because of expected uses such as that just described for Cyrus (when no
25408 domain is involved), there is no checking on the syntax of the provided
25409 value.
25410
25411
25412 .option authenticated_sender_force smtp boolean false
25413 If this option is set true, the &%authenticated_sender%& option's value
25414 is used for the AUTH= item on outgoing MAIL commands, even if Exim has not
25415 authenticated as a client.
25416
25417
25418 .option command_timeout smtp time 5m
25419 .cindex timeout "smtp transport command"
25420 This sets a timeout for receiving a response to an SMTP command that has been
25421 sent out. It is also used when waiting for the initial banner line from the
25422 remote host. Its value must not be zero.
25423
25424
25425 .option connect_timeout smtp time 5m
25426 .cindex timeout "smtp transport connect"
25427 This sets a timeout for the &[connect()]& function, which sets up a TCP/IP call
25428 to a remote host. A setting of zero allows the system timeout (typically
25429 several minutes) to act. To have any effect, the value of this option must be
25430 less than the system timeout. However, it has been observed that on some
25431 systems there is no system timeout, which is why the default value for this
25432 option is 5 minutes, a value recommended by RFC 1123.
25433
25434
25435 .option connection_max_messages smtp integer 500
25436 .cindex "SMTP" "passed connection"
25437 .cindex "SMTP" "multiple deliveries"
25438 .cindex "multiple SMTP deliveries"
25439 This controls the maximum number of separate message deliveries that are sent
25440 over a single TCP/IP connection. If the value is zero, there is no limit.
25441 For testing purposes, this value can be overridden by the &%-oB%& command line
25442 option.
25443
25444 .cindex "ESMTP extensions" LIMITS
25445 If the peer advertises a LIMITS extension with a MAILMAX value,
25446 and either TLSS is in use or was not advertised,
25447 that value also constrains the result of this option.
25448
25449
25450 .option dane_require_tls_ciphers smtp string&!! unset
25451 .cindex "TLS" "requiring specific ciphers for DANE"
25452 .cindex "cipher" "requiring specific"
25453 .cindex DANE "TLS ciphers"
25454 This option may be used to override &%tls_require_ciphers%& for connections
25455 where DANE has been determined to be in effect.
25456 If not set, then &%tls_require_ciphers%& will be used.
25457 Normal SMTP delivery is not able to make strong demands of TLS cipher
25458 configuration, because delivery will fall back to plaintext.  Once DANE has
25459 been determined to be in effect, there is no plaintext fallback and making the
25460 TLS cipherlist configuration stronger will increase security, rather than
25461 counter-intuitively decreasing it.
25462 If the option expands to be empty or is forced to fail, then it will
25463 be treated as unset and &%tls_require_ciphers%& will be used instead.
25464
25465
25466 .option data_timeout smtp time 5m
25467 .cindex timeout "for transmitted SMTP data blocks"
25468 This sets a timeout for the transmission of each block in the data portion of
25469 the message. As a result, the overall timeout for a message depends on the size
25470 of the message. Its value must not be zero. See also &%final_timeout%&.
25471
25472
25473 .option dkim_canon smtp string&!! unset
25474 DKIM signing option.  For details see section &<<SECDKIMSIGN>>&.
25475 .option dkim_domain smtp "string list&!!" unset
25476 DKIM signing option.  For details see section &<<SECDKIMSIGN>>&.
25477 .option dkim_hash smtp string&!! sha256
25478 DKIM signing option.  For details see section &<<SECDKIMSIGN>>&.
25479 .option dkim_identity smtp string&!! unset
25480 DKIM signing option.  For details see section &<<SECDKIMSIGN>>&.
25481 .option dkim_private_key smtp string&!! unset
25482 DKIM signing option.  For details see section &<<SECDKIMSIGN>>&.
25483 .option dkim_selector smtp string&!! unset
25484 DKIM signing option.  For details see section &<<SECDKIMSIGN>>&.
25485 .option dkim_strict smtp string&!! unset
25486 DKIM signing option.  For details see section &<<SECDKIMSIGN>>&.
25487 .option dkim_sign_headers smtp string&!! "per RFC"
25488 DKIM signing option.  For details see section &<<SECDKIMSIGN>>&.
25489 .option dkim_timestamps smtp string&!! unset
25490 DKIM signing option.  For details see section &<<SECDKIMSIGN>>&.
25491
25492
25493 .option delay_after_cutoff smtp boolean true
25494 .cindex "final cutoff" "retries, controlling"
25495 .cindex retry "final cutoff"
25496 This option controls what happens when all remote IP addresses for a given
25497 domain have been inaccessible for so long that they have passed their retry
25498 cutoff times.
25499
25500 In the default state, if the next retry time has not been reached for any of
25501 them, the address is bounced without trying any deliveries. In other words,
25502 Exim delays retrying an IP address after the final cutoff time until a new
25503 retry time is reached, and can therefore bounce an address without ever trying
25504 a delivery, when machines have been down for a long time. Some people are
25505 unhappy at this prospect, so...
25506
25507 If &%delay_after_cutoff%& is set false, Exim behaves differently. If all IP
25508 addresses are past their final cutoff time, Exim tries to deliver to those
25509 IP addresses that have not been tried since the message arrived. If there are
25510 none, of if they all fail, the address is bounced. In other words, it does not
25511 delay when a new message arrives, but immediately tries those expired IP
25512 addresses that haven't been tried since the message arrived. If there is a
25513 continuous stream of messages for the dead hosts, unsetting
25514 &%delay_after_cutoff%& means that there will be many more attempts to deliver
25515 to them.
25516
25517
25518 .option dns_qualify_single smtp boolean true
25519 If the &%hosts%& or &%fallback_hosts%& option is being used,
25520 and the &%gethostbyname%& option is false,
25521 the RES_DEFNAMES resolver option is set. See the &%qualify_single%& option
25522 in chapter &<<CHAPdnslookup>>& for more details.
25523
25524
25525 .option dns_search_parents smtp boolean false
25526 If the &%hosts%& or &%fallback_hosts%& option is being used, and the
25527 &%gethostbyname%& option is false, the RES_DNSRCH resolver option is set.
25528 See the &%search_parents%& option in chapter &<<CHAPdnslookup>>& for more
25529 details.
25530
25531
25532 .option dnssec_request_domains smtp "domain list&!!" *
25533 .cindex "MX record" "security"
25534 .cindex "DNSSEC" "MX lookup"
25535 .cindex "security" "MX lookup"
25536 .cindex "DNS" "DNSSEC"
25537 DNS lookups for domains matching &%dnssec_request_domains%& will be done with
25538 the DNSSEC request bit set. Setting this transport option is only useful if the
25539 transport overrides or sets the host names. See the &%dnssec_request_domains%&
25540 router option.
25541
25542
25543
25544 .option dnssec_require_domains smtp "domain list&!!" unset
25545 .cindex "MX record" "security"
25546 .cindex "DNSSEC" "MX lookup"
25547 .cindex "security" "MX lookup"
25548 .cindex "DNS" "DNSSEC"
25549 DNS lookups for domains matching &%dnssec_require_domains%& will be done with
25550 the DNSSEC request bit set.  Setting this transport option is only
25551 useful if the transport overrides or sets the host names. See the
25552 &%dnssec_require_domains%& router option.
25553
25554
25555
25556 .option dscp smtp string&!! unset
25557 .cindex "DCSP" "outbound"
25558 This option causes the DSCP value associated with a socket to be set to one
25559 of a number of fixed strings or to numeric value.
25560 The &%-bI:dscp%& option may be used to ask Exim which names it knows of.
25561 Common values include &`throughput`&, &`mincost`&, and on newer systems
25562 &`ef`&, &`af41`&, etc.  Numeric values may be in the range 0 to 0x3F.
25563
25564 The outbound packets from Exim will be marked with this value in the header
25565 (for IPv4, the TOS field; for IPv6, the TCLASS field); there is no guarantee
25566 that these values will have any effect, not be stripped by networking
25567 equipment, or do much of anything without cooperation with your Network
25568 Engineer and those of all network operators between the source and destination.
25569
25570
25571 .option fallback_hosts smtp "string list" unset
25572 .cindex "fallback" "hosts specified on transport"
25573 String expansion is not applied to this option. The argument must be a
25574 colon-separated list of host names or IP addresses, optionally also including
25575 port numbers, though the separator can be changed, as described in section
25576 &<<SECTlistconstruct>>&. Each individual item in the list is the same as an
25577 item in a &%route_list%& setting for the &(manualroute)& router, as described
25578 in section &<<SECTformatonehostitem>>&.
25579
25580 Fallback hosts can also be specified on routers, which associate them with the
25581 addresses they process. As for the &%hosts%& option without &%hosts_override%&,
25582 &%fallback_hosts%& specified on the transport is used only if the address does
25583 not have its own associated fallback host list. Unlike &%hosts%&, a setting of
25584 &%fallback_hosts%& on an address is not overridden by &%hosts_override%&.
25585 However, &%hosts_randomize%& does apply to fallback host lists.
25586
25587 If Exim is unable to deliver to any of the hosts for a particular address, and
25588 the errors are not permanent rejections, the address is put on a separate
25589 transport queue with its host list replaced by the fallback hosts, unless the
25590 address was routed via MX records and the current host was in the original MX
25591 list. In that situation, the fallback host list is not used.
25592
25593 Once normal deliveries are complete, the fallback queue is delivered by
25594 re-running the same transports with the new host lists. If several failing
25595 addresses have the same fallback hosts (and &%max_rcpt%& permits it), a single
25596 copy of the message is sent.
25597
25598 The resolution of the host names on the fallback list is controlled by the
25599 &%gethostbyname%& option, as for the &%hosts%& option. Fallback hosts apply
25600 both to cases when the host list comes with the address and when it is taken
25601 from &%hosts%&. This option provides a &"use a smart host only if delivery
25602 fails"& facility.
25603
25604
25605 .option final_timeout smtp time 10m
25606 .cindex timeout "for transmitted SMTP data accept"
25607 This is the timeout that applies while waiting for the response to the final
25608 line containing just &"."& that terminates a message. Its value must not be
25609 zero.
25610
25611 .option gethostbyname smtp boolean false
25612 If this option is true when the &%hosts%& and/or &%fallback_hosts%& options are
25613 being used, names are looked up using &[gethostbyname()]&
25614 (or &[getipnodebyname()]& when available)
25615 instead of using the DNS. Of course, that function may in fact use the DNS, but
25616 it may also consult other sources of information such as &_/etc/hosts_&.
25617
25618 .option gnutls_compat_mode smtp boolean unset
25619 This option controls whether GnuTLS is used in compatibility mode in an Exim
25620 server. This reduces security slightly, but improves interworking with older
25621 implementations of TLS.
25622
25623 .option helo_data smtp string&!! "see below"
25624 .cindex "HELO" "argument, setting"
25625 .cindex "EHLO" "argument, setting"
25626 .cindex "LHLO argument setting"
25627 The value of this option is expanded after a connection to a another host has
25628 been set up. The result is used as the argument for the EHLO, HELO, or LHLO
25629 command that starts the outgoing SMTP or LMTP session. The default value of the
25630 option is:
25631 .code
25632 $primary_hostname
25633 .endd
25634 During the expansion, the variables &$host$& and &$host_address$& are set to
25635 the identity of the remote host, and the variables &$sending_ip_address$& and
25636 &$sending_port$& are set to the local IP address and port number that are being
25637 used. These variables can be used to generate different values for different
25638 servers or different local IP addresses. For example, if you want the string
25639 that is used for &%helo_data%& to be obtained by a DNS lookup of the outgoing
25640 interface address, you could use this:
25641 .code
25642 helo_data = ${lookup dnsdb{ptr=$sending_ip_address} \
25643   {${listextract{1}{<\n $value}}} \
25644   {$primary_hostname}}
25645 .endd
25646 The use of &%helo_data%& applies both to sending messages and when doing
25647 callouts.
25648
25649 .option host_name_extract smtp "string list&!!" "see below"
25650 .cindex "load balancer" "hosts behind"
25651 .cindex TLS resumption
25652 Some mail-accepting sites
25653 (notably Microsoft)
25654 operate many servers behind a network load-balancer.  When this is done,
25655 with separated TLS session caches, TLS session resuption becomes problematic.
25656 It will only succeed when the same server happens to be selected by the
25657 load-balancer, matching the session stored in the client's cache.
25658
25659 Exim can pull out a server name, if there is one, from the response to the
25660 client's SMTP EHLO command.
25661 For normal STARTTLS use, the default value of this option:
25662 .code
25663     ${if and { {match {$host} {.outlook.com\$}} \
25664                {match {$item} {\N^250-([\w.]+)\s\N}} \
25665              } {$1}}
25666 .endd
25667 suffices for one known case.
25668
25669 During the expansion of this option the &$item$& variable will have the
25670 server's EHLO response.
25671
25672 For TLS-on-connect connections we do not have an EHLO
25673 response to use. Because of this the default value of this option is
25674 set to a static string for those cases, meaning that resumption will
25675 always be attempted if permitted by the &%tls_resumption_hosts%& option.
25676
25677 The result of the option expansion is included in the key used to store and
25678 retrieve the TLS session, for session resumption.
25679
25680 Operators of high-load sites may wish to evaluate their logs for indications
25681 of other destination sites operating load-balancers, and develop a suitable
25682 expression for this option.
25683 The smtp:ehlo event and the &$tls_out_resumption$& variable
25684 will be useful for such work.
25685
25686 .option hosts smtp "string list&!!" unset
25687 Hosts are associated with an address by a router such as &(dnslookup)&, which
25688 finds the hosts by looking up the address domain in the DNS, or by
25689 &(manualroute)&, which has lists of hosts in its configuration. However,
25690 email addresses can be passed to the &(smtp)& transport by any router, and not
25691 all of them can provide an associated list of hosts.
25692
25693 The &%hosts%& option specifies a list of hosts to be used if the address being
25694 processed does not have any hosts associated with it. The hosts specified by
25695 &%hosts%& are also used, whether or not the address has its own hosts, if
25696 &%hosts_override%& is set.
25697
25698 The string is first expanded, before being interpreted as a colon-separated
25699 list of host names or IP addresses, possibly including port numbers. The
25700 separator may be changed to something other than colon, as described in section
25701 &<<SECTlistconstruct>>&. Each individual item in the list is the same as an
25702 item in a &%route_list%& setting for the &(manualroute)& router, as described
25703 in section &<<SECTformatonehostitem>>&. However, note that the &`/MX`& facility
25704 of the &(manualroute)& router is not available here.
25705
25706 If the expansion fails, delivery is deferred. Unless the failure was caused by
25707 the inability to complete a lookup, the error is logged to the panic log as
25708 well as the main log. Host names are looked up either by searching directly for
25709 address records in the DNS or by calling &[gethostbyname()]& (or
25710 &[getipnodebyname()]& when available), depending on the setting of the
25711 &%gethostbyname%& option. When Exim is compiled with IPv6 support, if a host
25712 that is looked up in the DNS has both IPv4 and IPv6 addresses, both types of
25713 address are used.
25714
25715 During delivery, the hosts are tried in order, subject to their retry status,
25716 unless &%hosts_randomize%& is set.
25717
25718
25719 .option hosts_avoid_esmtp smtp "host list&!!" unset
25720 .cindex "ESMTP, avoiding use of"
25721 .cindex "HELO" "forcing use of"
25722 .cindex "EHLO" "avoiding use of"
25723 .cindex "PIPELINING" "avoiding the use of"
25724 This option is for use with broken hosts that announce ESMTP facilities (for
25725 example, PIPELINING) and then fail to implement them properly. When a host
25726 matches &%hosts_avoid_esmtp%&, Exim sends HELO rather than EHLO at the
25727 start of the SMTP session. This means that it cannot use any of the ESMTP
25728 facilities such as AUTH, PIPELINING, SIZE, and STARTTLS.
25729
25730
25731 .option hosts_avoid_pipelining smtp "host list&!!" unset
25732 .cindex "PIPELINING" "avoiding the use of"
25733 .cindex "ESMTP extensions" PIPELINING
25734 Exim will not use the ESMTP PIPELINING extension when delivering to any host
25735 that matches this list, even if the server host advertises PIPELINING support.
25736
25737 .option hosts_pipe_connect smtp "host list&!!" unset
25738 .cindex "pipelining" "early connection"
25739 .cindex "pipelining" PIPECONNECT
25740 If Exim is built with the SUPPORT_PIPE_CONNECT build option
25741 this option controls which to hosts the facility watched for
25742 and recorded, and used for subsequent connections.
25743
25744 The retry hints database is used for the record,
25745 and records are subject to the &%retry_data_expire%& option.
25746 When used, the pipelining saves on roundtrip times.
25747 It also turns SMTP into a client-first protocol
25748 so combines well with TCP Fast Open.
25749
25750 See also the &%pipelining_connect_advertise_hosts%& main option.
25751
25752 Note:
25753 When the facility is used, if the transport &%interface%& option is unset
25754 the &%helo_data%& option
25755 will be expanded before the &$sending_ip_address$& variable
25756 is filled in.
25757 A check is made for the use of that variable, without the
25758 presence of a &"def:"& test on it, but suitably complex coding
25759 can avoid the check and produce unexpected results.
25760 You have been warned.
25761
25762
25763 .option hosts_avoid_tls smtp "host list&!!" unset
25764 .cindex "TLS" "avoiding for certain hosts"
25765 Exim will not try to start a TLS session when delivering to any host that
25766 matches this list. See chapter &<<CHAPTLS>>& for details of TLS.
25767
25768 .option hosts_verify_avoid_tls smtp "host list&!!" unset
25769 .cindex "TLS" "avoiding for certain hosts"
25770 Exim will not try to start a TLS session for a verify callout,
25771 or when delivering in cutthrough mode,
25772 to any host that matches this list.
25773
25774
25775 .option hosts_max_try smtp integer 5
25776 .cindex "host" "maximum number to try"
25777 .cindex "limit" "number of hosts tried"
25778 .cindex "limit" "number of MX tried"
25779 .cindex "MX record" "maximum tried"
25780 This option limits the number of IP addresses that are tried for any one
25781 delivery in cases where there are temporary delivery errors. Section
25782 &<<SECTvalhosmax>>& describes in detail how the value of this option is used.
25783
25784
25785 .option hosts_max_try_hardlimit smtp integer 50
25786 This is an additional check on the maximum number of IP addresses that Exim
25787 tries for any one delivery. Section &<<SECTvalhosmax>>& describes its use and
25788 why it exists.
25789
25790
25791
25792 .option hosts_nopass_tls smtp "host list&!!" unset
25793 .cindex "TLS" "passing connection"
25794 .cindex "multiple SMTP deliveries"
25795 .cindex "TLS" "multiple message deliveries"
25796 For any host that matches this list, a connection on which a TLS session has
25797 been started will not be passed to a new delivery process for sending another
25798 message on the same connection. See section &<<SECTmulmessam>>& for an
25799 explanation of when this might be needed.
25800
25801 .option hosts_noproxy_tls smtp "host list&!!" unset
25802 .cindex "TLS" "passing connection"
25803 .cindex "multiple SMTP deliveries"
25804 .cindex "TLS" "multiple message deliveries"
25805 For any host that matches this list, a TLS session which has
25806 been started will not be passed to a new delivery process for sending another
25807 message on the same session.
25808
25809 The traditional implementation closes down TLS and re-starts it in the new
25810 process, on the same open TCP connection, for each successive message
25811 sent.  If permitted by this option a pipe to to the new process is set up
25812 instead, and the original process maintains the TLS connection and proxies
25813 the SMTP connection from and to the new process and any subsequents.
25814 The new process has no access to TLS information, so cannot include it in
25815 logging.
25816
25817
25818
25819 .option hosts_override smtp boolean false
25820 If this option is set and the &%hosts%& option is also set, any hosts that are
25821 attached to the address are ignored, and instead the hosts specified by the
25822 &%hosts%& option are always used. This option does not apply to
25823 &%fallback_hosts%&.
25824
25825
25826 .option hosts_randomize smtp boolean false
25827 .cindex "randomized host list"
25828 .cindex "host" "list of; randomized"
25829 .cindex "fallback" "randomized hosts"
25830 If this option is set, and either the list of hosts is taken from the
25831 &%hosts%& or the &%fallback_hosts%& option, or the hosts supplied by the router
25832 were not obtained from MX records (this includes fallback hosts from the
25833 router), and were not randomized by the router, the order of trying the hosts
25834 is randomized each time the transport runs. Randomizing the order of a host
25835 list can be used to do crude load sharing.
25836
25837 When &%hosts_randomize%& is true, a host list may be split into groups whose
25838 order is separately randomized. This makes it possible to set up MX-like
25839 behaviour. The boundaries between groups are indicated by an item that is just
25840 &`+`& in the host list. For example:
25841 .code
25842 hosts = host1:host2:host3:+:host4:host5
25843 .endd
25844 The order of the first three hosts and the order of the last two hosts is
25845 randomized for each use, but the first three always end up before the last two.
25846 If &%hosts_randomize%& is not set, a &`+`& item in the list is ignored.
25847
25848 .option hosts_require_auth smtp "host list&!!" unset
25849 .cindex "authentication" "required by client"
25850 This option provides a list of servers for which authentication must succeed
25851 before Exim will try to transfer a message. If authentication fails for
25852 servers which are not in this list, Exim tries to send unauthenticated. If
25853 authentication fails for one of these servers, delivery is deferred. This
25854 temporary error is detectable in the retry rules, so it can be turned into a
25855 hard failure if required. See also &%hosts_try_auth%&, and chapter
25856 &<<CHAPSMTPAUTH>>& for details of authentication.
25857
25858
25859 .option hosts_request_ocsp smtp "host list&!!" "see below"
25860 .cindex "TLS" "requiring for certain servers"
25861 Exim will request a Certificate Status on a
25862 TLS session for any host that matches this list.
25863 &%tls_verify_certificates%& should also be set for the transport.
25864
25865 The default is &"**"& if DANE is not in use for the connection,
25866 or if DANE-TA us used.
25867 It is empty if DANE-EE is used.
25868
25869 .option hosts_require_alpn smtp "host list&!!" unset
25870 .cindex ALPN "require negotiation in client"
25871 .cindex TLS ALPN
25872 .cindex TLS "Application Layer Protocol Names"
25873 If the TLS library supports ALPN
25874 then a successful negotiation of ALPN will be required for any host
25875 matching the list, for TLS to be used.
25876 See also the &%tls_alpn%& option.
25877
25878 &*Note*&: prevention of fallback to in-clear connection is not
25879 managed by this option; see &%hosts_require_tls%&.
25880
25881 .option hosts_require_dane smtp "host list&!!" unset
25882 .cindex DANE "transport options"
25883 .cindex DANE "requiring for certain servers"
25884 If built with DANE support, Exim  will require that a DNSSEC-validated
25885 TLSA record is present for any host matching the list,
25886 and that a DANE-verified TLS connection is made.
25887 There will be no fallback to in-clear communication.
25888 See the &%dnssec_request_domains%& router and transport options.
25889 See section &<<SECDANE>>&.
25890
25891 .option hosts_require_ocsp smtp "host list&!!" unset
25892 .cindex "TLS" "requiring for certain servers"
25893 Exim will request, and check for a valid Certificate Status being given, on a
25894 TLS session for any host that matches this list.
25895 &%tls_verify_certificates%& should also be set for the transport.
25896
25897 .option hosts_require_tls smtp "host list&!!" unset
25898 .cindex "TLS" "requiring for certain servers"
25899 Exim will insist on using a TLS session when delivering to any host that
25900 matches this list. See chapter &<<CHAPTLS>>& for details of TLS.
25901 &*Note*&: This option affects outgoing mail only. To insist on TLS for
25902 incoming messages, use an appropriate ACL.
25903
25904 .option hosts_try_auth smtp "host list&!!" unset
25905 .cindex "authentication" "optional in client"
25906 This option provides a list of servers to which, provided they announce
25907 authentication support, Exim will attempt to authenticate as a client when it
25908 connects. If authentication fails
25909 and &%hosts_require_auth%& permits,
25910 Exim will try to transfer the message unauthenticated.
25911 See also chapter &<<CHAPSMTPAUTH>>& for details of authentication.
25912
25913 .option hosts_try_chunking smtp "host list&!!" *
25914 .cindex CHUNKING "enabling, in client"
25915 .cindex BDAT "SMTP command"
25916 .cindex "RFC 3030" "CHUNKING"
25917 This option provides a list of servers to which, provided they announce
25918 CHUNKING support, Exim will attempt to use BDAT commands rather than DATA.
25919 Unless DKIM signing is being done,
25920 BDAT will not be used in conjunction with a transport filter.
25921
25922 .option hosts_try_dane smtp "host list&!!" *
25923 .cindex DANE "transport options"
25924 .cindex DANE "attempting for certain servers"
25925 If built with DANE support, Exim  will look up a
25926 TLSA record for any host matching the list,
25927 If one is found and that lookup was DNSSEC-validated,
25928 then Exim requires that a DANE-verified TLS connection is made for that host;
25929 there will be no fallback to in-clear communication.
25930 See the &%dnssec_request_domains%& router and transport options.
25931 See section &<<SECDANE>>&.
25932
25933 .option hosts_try_fastopen smtp "host list&!!" *
25934 .cindex "fast open, TCP" "enabling, in client"
25935 .cindex "TCP Fast Open" "enabling, in client"
25936 .cindex "RFC 7413" "TCP Fast Open"
25937 This option provides a list of servers to which, provided
25938 the facility is supported by this system, Exim will attempt to
25939 perform a TCP Fast Open.
25940 No data is sent on the SYN segment but, if the remote server also
25941 supports the facility, it can send its SMTP banner immediately after
25942 the SYN,ACK segment.  This can save up to one round-trip time.
25943
25944 The facility is only active for previously-contacted servers,
25945 as the initiator must present a cookie in the SYN segment.
25946
25947 On (at least some) current Linux distributions the facility must be enabled
25948 in the kernel by the sysadmin before the support is usable.
25949 There is no option for control of the server side; if the system supports
25950 it it is always enabled.  Note that lengthy operations in the connect ACL,
25951 such as DNSBL lookups, will still delay the emission of the SMTP banner.
25952
25953 .option hosts_try_prdr smtp "host list&!!" *
25954 .cindex "PRDR" "enabling, optional in client"
25955 .cindex "ESMTP extensions" PRDR
25956 This option provides a list of servers to which, provided they announce
25957 PRDR support, Exim will attempt to negotiate PRDR
25958 for multi-recipient messages.
25959 The option can usually be left as default.
25960
25961 .option interface smtp "string list&!!" unset
25962 .cindex "bind IP address"
25963 .cindex "IP address" "binding"
25964 .vindex "&$host$&"
25965 .vindex "&$host_address$&"
25966 This option specifies which interface to bind to when making an outgoing SMTP
25967 call. The value is an IP address, not an interface name such as
25968 &`eth0`&. Do not confuse this with the interface address that was used when a
25969 message was received, which is in &$received_ip_address$&, formerly known as
25970 &$interface_address$&. The name was changed to minimize confusion with the
25971 outgoing interface address. There is no variable that contains an outgoing
25972 interface address because, unless it is set by this option, its value is
25973 unknown.
25974
25975 During the expansion of the &%interface%& option the variables &$host$& and
25976 &$host_address$& refer to the host to which a connection is about to be made
25977 during the expansion of the string. Forced expansion failure, or an empty
25978 string result causes the option to be ignored. Otherwise, after expansion, the
25979 string must be a list of IP addresses, colon-separated by default, but the
25980 separator can be changed in the usual way (&<<SECTlistsepchange>>&).
25981 For example:
25982 .code
25983 interface = <; 192.168.123.123 ; 3ffe:ffff:836f::fe86:a061
25984 .endd
25985 The first interface of the correct type (IPv4 or IPv6) is used for the outgoing
25986 connection. If none of them are the correct type, the option is ignored. If
25987 &%interface%& is not set, or is ignored, the system's IP functions choose which
25988 interface to use if the host has more than one.
25989
25990
25991 .option keepalive smtp boolean true
25992 .cindex "keepalive" "on outgoing connection"
25993 This option controls the setting of SO_KEEPALIVE on outgoing TCP/IP socket
25994 connections. When set, it causes the kernel to probe idle connections
25995 periodically, by sending packets with &"old"& sequence numbers. The other end
25996 of the connection should send a acknowledgment if the connection is still okay
25997 or a reset if the connection has been aborted. The reason for doing this is
25998 that it has the beneficial effect of freeing up certain types of connection
25999 that can get stuck when the remote host is disconnected without tidying up the
26000 TCP/IP call properly. The keepalive mechanism takes several hours to detect
26001 unreachable hosts.
26002
26003
26004 .option lmtp_ignore_quota smtp boolean false
26005 .cindex "LMTP" "ignoring quota errors"
26006 If this option is set true when the &%protocol%& option is set to &"lmtp"&, the
26007 string &`IGNOREQUOTA`& is added to RCPT commands, provided that the LMTP server
26008 has advertised support for IGNOREQUOTA in its response to the LHLO command.
26009
26010 .option max_rcpt smtp integer&!! 100
26011 .cindex "RCPT" "maximum number of outgoing"
26012 This option,
26013 after expansion,
26014 limits the number of RCPT commands that are sent in a single
26015 SMTP message transaction.
26016 A value setting of zero disables the limit.
26017
26018 If a constant is given,
26019 each set of addresses is treated independently, and
26020 so can cause parallel connections to the same host if &%remote_max_parallel%&
26021 permits this.
26022
26023 .cindex "ESMTP extensions" LIMITS
26024 If the peer advertises a LIMITS extension with a RCPTMAX value,
26025 and either TLSS is in use or was not advertised,
26026 that value also constrains the result of this option
26027 and no parallel connections will be caused on meeting the RCPTMAX limit.
26028
26029
26030 .option message_linelength_limit smtp integer 998
26031 .cindex "line length" limit
26032 This option sets the maximum line length, in bytes, that the transport
26033 will send.  Any messages with lines exceeding the given value
26034 (before a transport filter, if any)
26035 will fail and a failure-DSN ("bounce") message will if possible be returned
26036 to the sender.
26037 The default value is that defined by the SMTP standards.
26038
26039 It is generally wise to also check in the data ACL so that messages
26040 received via SMTP can be refused without producing a bounce.
26041
26042
26043 .option multi_domain smtp boolean&!! true
26044 .vindex "&$domain$&"
26045 When this option is set, the &(smtp)& transport can handle a number of
26046 addresses containing a mixture of different domains provided they all resolve
26047 to the same list of hosts. Turning the option off restricts the transport to
26048 handling only one domain at a time. This is useful if you want to use
26049 &$domain$& in an expansion for the transport, because it is set only when there
26050 is a single domain involved in a remote delivery.
26051
26052 It is expanded per-address and can depend on any of
26053 &$address_data$&, &$domain_data$&, &$local_part_data$&,
26054 &$host$&, &$host_address$& and &$host_port$&.
26055
26056 If the connection is DANE-enabled then this option is ignored;
26057 only messages having the domain used for the DANE TLSA lookup are
26058 sent on the connection.
26059
26060 .cindex "ESMTP extensions" LIMITS
26061 If the peer advertises a LIMITS extension with a RCPTDOMAINMAX value,
26062 and either TLSS is in use or was not advertised,
26063 this option is regarded as being false.
26064
26065
26066 .option port smtp string&!! "see below"
26067 .cindex "port" "sending TCP/IP"
26068 .cindex "TCP/IP" "setting outgoing port"
26069 This option specifies the TCP/IP port on the server to which Exim connects.
26070 &*Note:*& Do not confuse this with the port that was used when a message was
26071 received, which is in &$received_port$&, formerly known as &$interface_port$&.
26072 The name was changed to minimize confusion with the outgoing port. There is no
26073 variable that contains an outgoing port.
26074
26075 If the value of this option begins with a digit it is taken as a port number;
26076 otherwise it is looked up using &[getservbyname()]&. The default value is
26077 normally &"smtp"&,
26078 but if &%protocol%& is set to &"lmtp"& the default is &"lmtp"&
26079 and if &%protocol%& is set to &"smtps"& the default is &"smtps"&.
26080 If the expansion fails, or if a port number cannot be found, delivery
26081 is deferred.
26082
26083 Note that at least one Linux distribution has been seen failing
26084 to put &"smtps"& in its &"/etc/services"& file, resulting is such deferrals.
26085
26086
26087
26088 .option protocol smtp string smtp
26089 .cindex "LMTP" "over TCP/IP"
26090 .cindex "ssmtp protocol" "outbound"
26091 .cindex "TLS" "SSL-on-connect outbound"
26092 .vindex "&$port$&"
26093 If this option is set to &"lmtp"& instead of &"smtp"&, the default value for
26094 the &%port%& option changes to &"lmtp"&, and the transport operates the LMTP
26095 protocol (RFC 2033) instead of SMTP. This protocol is sometimes used for local
26096 deliveries into closed message stores. Exim also has support for running LMTP
26097 over a pipe to a local process &-- see chapter &<<CHAPLMTP>>&.
26098
26099 &*Note*&: When using LMTP it should be considered whether the default values
26100 for some other features, such as DANE, are appropriate.
26101
26102 If this option is set to &"smtps"&, the default value for the &%port%& option
26103 changes to &"smtps"&, and the transport initiates TLS immediately after
26104 connecting, as an outbound SSL-on-connect, instead of using STARTTLS to upgrade.
26105 The Internet standards bodies used to strongly discourage use of this mode,
26106 but as of RFC 8314 it is preferred over STARTTLS for message submission
26107 (as distinct from MTA-MTA communication).
26108
26109
26110 .option retry_include_ip_address smtp boolean&!! true
26111 Exim normally includes both the host name and the IP address in the key it
26112 constructs for indexing retry data after a temporary delivery failure. This
26113 means that when one of several IP addresses for a host is failing, it gets
26114 tried periodically (controlled by the retry rules), but use of the other IP
26115 addresses is not affected.
26116
26117 However, in some dialup environments hosts are assigned a different IP address
26118 each time they connect. In this situation the use of the IP address as part of
26119 the retry key leads to undesirable behaviour. Setting this option false causes
26120 Exim to use only the host name.
26121 Since it is expanded it can be made to depend on the host or domain.
26122
26123
26124 .option serialize_hosts smtp "host list&!!" unset
26125 .cindex "serializing connections"
26126 .cindex "host" "serializing connections"
26127 Because Exim operates in a distributed manner, if several messages for the same
26128 host arrive at around the same time, more than one simultaneous connection to
26129 the remote host can occur. This is not usually a problem except when there is a
26130 slow link between the hosts. In that situation it may be helpful to restrict
26131 Exim to one connection at a time. This can be done by setting
26132 &%serialize_hosts%& to match the relevant hosts.
26133
26134 .cindex "hints database" "serializing deliveries to a host"
26135 Exim implements serialization by means of a hints database in which a record is
26136 written whenever a process connects to one of the restricted hosts. The record
26137 is deleted when the connection is completed. Obviously there is scope for
26138 records to get left lying around if there is a system or program crash. To
26139 guard against this, Exim ignores any records that are more than six hours old.
26140
26141 If you set up this kind of serialization, you should also arrange to delete the
26142 relevant hints database whenever your system reboots. The names of the files
26143 start with &_misc_& and they are kept in the &_spool/db_& directory. There
26144 may be one or two files, depending on the type of DBM in use. The same files
26145 are used for ETRN serialization.
26146
26147 See also the &%max_parallel%& generic transport option.
26148
26149
26150 .option size_addition smtp integer 1024
26151 .cindex "SIZE" "ESMTP extension"
26152 .cindex "message" "size issue for transport filter"
26153 .cindex "size" "of message"
26154 .cindex "transport" "filter"
26155 .cindex "filter" "transport filter"
26156 If a remote SMTP server indicates that it supports the SIZE option of the
26157 MAIL command, Exim uses this to pass over the message size at the start of
26158 an SMTP transaction. It adds the value of &%size_addition%& to the value it
26159 sends, to allow for headers and other text that may be added during delivery by
26160 configuration options or in a transport filter. It may be necessary to increase
26161 this if a lot of text is added to messages.
26162
26163 Alternatively, if the value of &%size_addition%& is set negative, it disables
26164 the use of the SIZE option altogether.
26165
26166
26167 .option socks_proxy smtp string&!! unset
26168 .cindex proxy SOCKS
26169 This option enables use of SOCKS proxies for connections made by the
26170 transport.  For details see section &<<SECTproxySOCKS>>&.
26171
26172
26173 .option tls_alpn smtp string&!! unset
26174 .cindex TLS "Application Layer Protocol Names"
26175 .cindex TLS ALPN
26176 .cindex ALPN "set name in client"
26177 If this option is set
26178 and the TLS library supports ALPN,
26179 the value given is used.
26180
26181 As of writing no value has been standardised for email use.
26182 The authors suggest using &"smtp"&.
26183
26184
26185
26186 .option tls_certificate smtp string&!! unset
26187 .cindex "TLS" "client certificate, location of"
26188 .cindex "certificate" "client, location of"
26189 .vindex "&$host$&"
26190 .vindex "&$host_address$&"
26191 The value of this option must be the absolute path to a file which contains the
26192 client's certificate, for possible use when sending a message over an encrypted
26193 connection. The values of &$host$& and &$host_address$& are set to the name and
26194 address of the server during the expansion. See chapter &<<CHAPTLS>>& for
26195 details of TLS.
26196
26197 &*Note*&: This option must be set if you want Exim to be able to use a TLS
26198 certificate when sending messages as a client. The global option of the same
26199 name specifies the certificate for Exim as a server; it is not automatically
26200 assumed that the same certificate should be used when Exim is operating as a
26201 client.
26202
26203
26204 .option tls_crl smtp string&!! unset
26205 .cindex "TLS" "client certificate revocation list"
26206 .cindex "certificate" "revocation list for client"
26207 This option specifies a certificate revocation list. The expanded value must
26208 be the name of a file that contains a CRL in PEM format.
26209
26210
26211 .option tls_dh_min_bits smtp integer 1024
26212 .cindex "TLS" "Diffie-Hellman minimum acceptable size"
26213 When establishing a TLS session, if a ciphersuite which uses Diffie-Hellman
26214 key agreement is negotiated, the server will provide a large prime number
26215 for use.  This option establishes the minimum acceptable size of that number.
26216 If the parameter offered by the server is too small, then the TLS handshake
26217 will fail.
26218
26219 Only supported when using GnuTLS.
26220
26221
26222 .option tls_privatekey smtp string&!! unset
26223 .cindex "TLS" "client private key, location of"
26224 .vindex "&$host$&"
26225 .vindex "&$host_address$&"
26226 The value of this option must be the absolute path to a file which contains the
26227 client's private key. This is used when sending a message over an encrypted
26228 connection using a client certificate. The values of &$host$& and
26229 &$host_address$& are set to the name and address of the server during the
26230 expansion. If this option is unset, or the expansion is forced to fail, or the
26231 result is an empty string, the private key is assumed to be in the same file as
26232 the certificate. See chapter &<<CHAPTLS>>& for details of TLS.
26233
26234
26235 .option tls_require_ciphers smtp string&!! unset
26236 .cindex "TLS" "requiring specific ciphers"
26237 .cindex "cipher" "requiring specific"
26238 .vindex "&$host$&"
26239 .vindex "&$host_address$&"
26240 The value of this option must be a list of permitted cipher suites, for use
26241 when setting up an outgoing encrypted connection. (There is a global option of
26242 the same name for controlling incoming connections.) The values of &$host$& and
26243 &$host_address$& are set to the name and address of the server during the
26244 expansion. See chapter &<<CHAPTLS>>& for details of TLS; note that this option
26245 is used in different ways by OpenSSL and GnuTLS (see sections
26246 &<<SECTreqciphssl>>& and &<<SECTreqciphgnu>>&). For GnuTLS, the order of the
26247 ciphers is a preference order.
26248
26249
26250 .option tls_resumption_hosts smtp "host list&!!" unset
26251 .cindex TLS resumption
26252 This option controls which connections to use the TLS resumption feature.
26253 See &<<SECTresumption>>& for details.
26254
26255
26256
26257 .option tls_sni smtp string&!! unset
26258 .cindex "TLS" "Server Name Indication"
26259 .cindex "TLS" SNI
26260 .cindex SNI "setting in client"
26261 .vindex "&$tls_sni$&"
26262 If this option is set
26263 and the connection is not DANE-validated
26264 then it sets the $tls_out_sni variable and causes any
26265 TLS session to pass this value as the Server Name Indication extension to
26266 the remote side, which can be used by the remote side to select an appropriate
26267 certificate and private key for the session.
26268
26269 See &<<SECTtlssni>>& for more information.
26270
26271 Note that for OpenSSL, this feature requires a build of OpenSSL that supports
26272 TLS extensions.
26273
26274
26275
26276
26277 .option tls_tempfail_tryclear smtp boolean true
26278 .cindex "4&'xx'& responses" "to STARTTLS"
26279 When the server host is not in &%hosts_require_tls%&, and there is a problem in
26280 setting up a TLS session, this option determines whether or not Exim should try
26281 to deliver the message unencrypted. If it is set false, delivery to the
26282 current host is deferred; if there are other hosts, they are tried. If this
26283 option is set true, Exim attempts to deliver unencrypted after a 4&'xx'&
26284 response to STARTTLS. Also, if STARTTLS is accepted, but the subsequent
26285 TLS negotiation fails, Exim closes the current connection (because it is in an
26286 unknown state), opens a new one to the same host, and then tries the delivery
26287 in clear.
26288
26289
26290 .option tls_try_verify_hosts smtp "host list&!!" *
26291 .cindex "TLS" "server certificate verification"
26292 .cindex "certificate" "verification of server"
26293 This option gives a list of hosts for which, on encrypted connections,
26294 certificate verification will be tried but need not succeed.
26295 The &%tls_verify_certificates%& option must also be set.
26296 Note that unless the host is in this list
26297 TLS connections will be denied to hosts using self-signed certificates
26298 when &%tls_verify_certificates%& is matched.
26299 The &$tls_out_certificate_verified$& variable is set when
26300 certificate verification succeeds.
26301
26302
26303 .option tls_verify_cert_hostnames smtp "host list&!!" *
26304 .cindex "TLS" "server certificate hostname verification"
26305 .cindex "certificate" "verification of server"
26306 This option give a list of hosts for which,
26307 while verifying the server certificate,
26308 checks will be included on the host name
26309 (note that this will generally be the result of a DNS MX lookup)
26310 versus the Subject-Alternate-Name (or, if none, Subject-Name) fields.
26311 Wildcard names are permitted,
26312 limited to being the initial component of a 3-or-more component FQDN.
26313
26314 There is no equivalent checking on client certificates.
26315
26316
26317 .option tls_verify_certificates smtp string&!! system
26318 .cindex "TLS" "server certificate verification"
26319 .cindex "certificate" "verification of server"
26320 .vindex "&$host$&"
26321 .vindex "&$host_address$&"
26322 The value of this option must be either the
26323 word "system"
26324 or the absolute path to
26325 a file or directory containing permitted certificates for servers,
26326 for use when setting up an encrypted connection.
26327
26328 The "system" value for the option will use a location compiled into the SSL library.
26329 This is not available for GnuTLS versions preceding 3.0.20; a value of "system"
26330 is taken as empty and an explicit location
26331 must be specified.
26332
26333 The use of a directory for the option value is not available for GnuTLS versions
26334 preceding 3.3.6 and a single file must be used.
26335
26336 With OpenSSL the certificates specified
26337 explicitly
26338 either by file or directory
26339 are added to those given by the system default location.
26340
26341 The values of &$host$& and
26342 &$host_address$& are set to the name and address of the server during the
26343 expansion of this option. See chapter &<<CHAPTLS>>& for details of TLS.
26344
26345 For back-compatibility,
26346 if neither tls_verify_hosts nor tls_try_verify_hosts are set
26347 (a single-colon empty list counts as being set)
26348 and certificate verification fails the TLS connection is closed.
26349
26350
26351 .option tls_verify_hosts smtp "host list&!!" unset
26352 .cindex "TLS" "server certificate verification"
26353 .cindex "certificate" "verification of server"
26354 This option gives a list of hosts for which, on encrypted connections,
26355 certificate verification must succeed.
26356 The &%tls_verify_certificates%& option must also be set.
26357 If both this option and &%tls_try_verify_hosts%& are unset
26358 operation is as if this option selected all hosts.
26359 &*Warning*&: Including a host in &%tls_verify_hosts%& does not require
26360 that connections use TLS.
26361 Fallback to in-clear communication will be done unless restricted by
26362 the &%hosts_require_tls%& option.
26363
26364 .option utf8_downconvert smtp integer&!! -1
26365 .cindex utf8 "address downconversion"
26366 .cindex i18n "utf8 address downconversion"
26367 If built with internationalization support,
26368 this option controls conversion of UTF-8 in message envelope addresses
26369 to a-label form.
26370 If, after expansion, the value is 1, 0, or -1 then this value overrides
26371 any value previously set for the message.  Otherwise, any previously
26372 set value is used.  To permit use of a previous value,
26373 set this option to an empty string.
26374 For details on the values see section &<<SECTi18nMTA>>&.
26375
26376
26377
26378
26379 .section "How the limits for the number of hosts to try are used" &&&
26380          "SECTvalhosmax"
26381 .cindex "host" "maximum number to try"
26382 .cindex "limit" "hosts; maximum number tried"
26383 There are two options that are concerned with the number of hosts that are
26384 tried when an SMTP delivery takes place. They are &%hosts_max_try%& and
26385 &%hosts_max_try_hardlimit%&.
26386
26387
26388 The &%hosts_max_try%& option limits the number of hosts that are tried
26389 for a single delivery. However, despite the term &"host"& in its name, the
26390 option actually applies to each IP address independently. In other words, a
26391 multihomed host is treated as several independent hosts, just as it is for
26392 retrying.
26393
26394 Many of the larger ISPs have multiple MX records which often point to
26395 multihomed hosts. As a result, a list of a dozen or more IP addresses may be
26396 created as a result of routing one of these domains.
26397
26398 Trying every single IP address on such a long list does not seem sensible; if
26399 several at the top of the list fail, it is reasonable to assume there is some
26400 problem that is likely to affect all of them. Roughly speaking, the value of
26401 &%hosts_max_try%& is the maximum number that are tried before deferring the
26402 delivery. However, the logic cannot be quite that simple.
26403
26404 Firstly, IP addresses that are skipped because their retry times have not
26405 arrived do not count, and in addition, addresses that are past their retry
26406 limits are also not counted, even when they are tried. This means that when
26407 some IP addresses are past their retry limits, more than the value of
26408 &%hosts_max_retry%& may be tried. The reason for this behaviour is to ensure
26409 that all IP addresses are considered before timing out an email address (but
26410 see below for an exception).
26411
26412 Secondly, when the &%hosts_max_try%& limit is reached, Exim looks down the host
26413 list to see if there is a subsequent host with a different (higher valued) MX.
26414 If there is, that host is considered next, and the current IP address is used
26415 but not counted. This behaviour helps in the case of a domain with a retry rule
26416 that hardly ever delays any hosts, as is now explained:
26417
26418 Consider the case of a long list of hosts with one MX value, and a few with a
26419 higher MX value. If &%hosts_max_try%& is small (the default is 5) only a few
26420 hosts at the top of the list are tried at first. With the default retry rule,
26421 which specifies increasing retry times, the higher MX hosts are eventually
26422 tried when those at the top of the list are skipped because they have not
26423 reached their retry times.
26424
26425 However, it is common practice to put a fixed short retry time on domains for
26426 large ISPs, on the grounds that their servers are rarely down for very long.
26427 Unfortunately, these are exactly the domains that tend to resolve to long lists
26428 of hosts. The short retry time means that the lowest MX hosts are tried every
26429 time. The attempts may be in a different order because of random sorting, but
26430 without the special MX check, the higher MX hosts would never be tried until
26431 all the lower MX hosts had timed out (which might be several days), because
26432 there are always some lower MX hosts that have reached their retry times. With
26433 the special check, Exim considers at least one IP address from each MX value at
26434 every delivery attempt, even if the &%hosts_max_try%& limit has already been
26435 reached.
26436
26437 The above logic means that &%hosts_max_try%& is not a hard limit, and in
26438 particular, Exim normally eventually tries all the IP addresses before timing
26439 out an email address. When &%hosts_max_try%& was implemented, this seemed a
26440 reasonable thing to do. Recently, however, some lunatic DNS configurations have
26441 been set up with hundreds of IP addresses for some domains. It can
26442 take a very long time indeed for an address to time out in these cases.
26443
26444 The &%hosts_max_try_hardlimit%& option was added to help with this problem.
26445 Exim never tries more than this number of IP addresses; if it hits this limit
26446 and they are all timed out, the email address is bounced, even though not all
26447 possible IP addresses have been tried.
26448 .ecindex IIDsmttra1
26449 .ecindex IIDsmttra2
26450
26451
26452
26453
26454
26455 . ////////////////////////////////////////////////////////////////////////////
26456 . ////////////////////////////////////////////////////////////////////////////
26457
26458 .chapter "Address rewriting" "CHAPrewrite"
26459 .scindex IIDaddrew "rewriting" "addresses"
26460 There are some circumstances in which Exim automatically rewrites domains in
26461 addresses. The two most common are when an address is given without a domain
26462 (referred to as an &"unqualified address"&) or when an address contains an
26463 abbreviated domain that is expanded by DNS lookup.
26464
26465 Unqualified envelope addresses are accepted only for locally submitted
26466 messages, or for messages that are received from hosts matching
26467 &%sender_unqualified_hosts%& or &%recipient_unqualified_hosts%&, as
26468 appropriate. Unqualified addresses in header lines are qualified if they are in
26469 locally submitted messages, or messages from hosts that are permitted to send
26470 unqualified envelope addresses. Otherwise, unqualified addresses in header
26471 lines are neither qualified nor rewritten.
26472
26473 One situation in which Exim does &'not'& automatically rewrite a domain is
26474 when it is the name of a CNAME record in the DNS. The older RFCs suggest that
26475 such a domain should be rewritten using the &"canonical"& name, and some MTAs
26476 do this. The new RFCs do not contain this suggestion.
26477
26478
26479 .section "Explicitly configured address rewriting" "SECID147"
26480 This chapter describes the rewriting rules that can be used in the
26481 main rewrite section of the configuration file, and also in the generic
26482 &%headers_rewrite%& option that can be set on any transport.
26483
26484 Some people believe that configured address rewriting is a Mortal Sin.
26485 Others believe that life is not possible without it. Exim provides the
26486 facility; you do not have to use it.
26487
26488 The main rewriting rules that appear in the &"rewrite"& section of the
26489 configuration file are applied to addresses in incoming messages, both envelope
26490 addresses and addresses in header lines. Each rule specifies the types of
26491 address to which it applies.
26492
26493 Whether or not addresses in header lines are rewritten depends on the origin of
26494 the headers and the type of rewriting. Global rewriting, that is, rewriting
26495 rules from the rewrite section of the configuration file, is applied only to
26496 those headers that were received with the message. Header lines that are added
26497 by ACLs or by a system filter or by individual routers or transports (which
26498 are specific to individual recipient addresses) are not rewritten by the global
26499 rules.
26500
26501 Rewriting at transport time, by means of the &%headers_rewrite%& option,
26502 applies all headers except those added by routers and transports. That is, as
26503 well as the headers that were received with the message, it also applies to
26504 headers that were added by an ACL or a system filter.
26505
26506
26507 In general, rewriting addresses from your own system or domain has some
26508 legitimacy. Rewriting other addresses should be done only with great care and
26509 in special circumstances. The author of Exim believes that rewriting should be
26510 used sparingly, and mainly for &"regularizing"& addresses in your own domains.
26511 Although it can sometimes be used as a routing tool, this is very strongly
26512 discouraged.
26513
26514 There are two commonly encountered circumstances where rewriting is used, as
26515 illustrated by these examples:
26516
26517 .ilist
26518 The company whose domain is &'hitch.fict.example'& has a number of hosts that
26519 exchange mail with each other behind a firewall, but there is only a single
26520 gateway to the outer world. The gateway rewrites &'*.hitch.fict.example'& as
26521 &'hitch.fict.example'& when sending mail off-site.
26522 .next
26523 A host rewrites the local parts of its own users so that, for example,
26524 &'fp42@hitch.fict.example'& becomes &'Ford.Prefect@hitch.fict.example'&.
26525 .endlist
26526
26527
26528
26529 .section "When does rewriting happen?" "SECID148"
26530 .cindex "rewriting" "timing of"
26531 .cindex "&ACL;" "rewriting addresses in"
26532 Configured address rewriting can take place at several different stages of a
26533 message's processing.
26534
26535 .vindex "&$sender_address$&"
26536 At the start of an ACL for MAIL, the sender address may have been rewritten
26537 by a special SMTP-time rewrite rule (see section &<<SSECTrewriteS>>&), but no
26538 ordinary rewrite rules have yet been applied. If, however, the sender address
26539 is verified in the ACL, it is rewritten before verification, and remains
26540 rewritten thereafter. The subsequent value of &$sender_address$& is the
26541 rewritten address. This also applies if sender verification happens in a
26542 RCPT ACL. Otherwise, when the sender address is not verified, it is
26543 rewritten as soon as a message's header lines have been received.
26544
26545 .vindex "&$domain$&"
26546 .vindex "&$local_part$&"
26547 Similarly, at the start of an ACL for RCPT, the current recipient's address
26548 may have been rewritten by a special SMTP-time rewrite rule, but no ordinary
26549 rewrite rules have yet been applied to it. However, the behaviour is different
26550 from the sender address when a recipient is verified. The address is rewritten
26551 for the verification, but the rewriting is not remembered at this stage. The
26552 value of &$local_part$& and &$domain$& after verification are always the same
26553 as they were before (that is, they contain the unrewritten &-- except for
26554 SMTP-time rewriting &-- address).
26555
26556 As soon as a message's header lines have been received, all the envelope
26557 recipient addresses are permanently rewritten, and rewriting is also applied to
26558 the addresses in the header lines (if configured). This happens before adding
26559 any header lines that were specified in MAIL or RCPT ACLs, and
26560 .cindex "&[local_scan()]& function" "address rewriting; timing of"
26561 before the DATA ACL and &[local_scan()]& functions are run.
26562
26563 When an address is being routed, either for delivery or for verification,
26564 rewriting is applied immediately to child addresses that are generated by
26565 redirection, unless &%no_rewrite%& is set on the router.
26566
26567 .cindex "envelope from"
26568 .cindex "envelope sender" "rewriting at transport time"
26569 .cindex "rewriting" "at transport time"
26570 .cindex "header lines" "rewriting at transport time"
26571 At transport time, additional rewriting of addresses in header lines can be
26572 specified by setting the generic &%headers_rewrite%& option on a transport.
26573 This option contains rules that are identical in form to those in the rewrite
26574 section of the configuration file. They are applied to the original message
26575 header lines and any that were added by ACLs or a system filter. They are not
26576 applied to header lines that are added by routers or the transport.
26577
26578 The outgoing envelope sender can be rewritten by means of the &%return_path%&
26579 transport option. However, it is not possible to rewrite envelope recipients at
26580 transport time.
26581
26582
26583
26584
26585 .section "Testing the rewriting rules that apply on input" "SECID149"
26586 .cindex "rewriting" "testing"
26587 .cindex "testing" "rewriting"
26588 Exim's input rewriting configuration appears in a part of the runtime
26589 configuration file headed by &"begin rewrite"&. It can be tested by the
26590 &%-brw%& command line option. This takes an address (which can be a full RFC
26591 2822 address) as its argument. The output is a list of how the address would be
26592 transformed by the rewriting rules for each of the different places it might
26593 appear in an incoming message, that is, for each different header and for the
26594 envelope sender and recipient fields. For example,
26595 .code
26596 exim -brw ph10@exim.workshop.example
26597 .endd
26598 might produce the output
26599 .code
26600 sender: Philip.Hazel@exim.workshop.example
26601 from: Philip.Hazel@exim.workshop.example
26602 to: ph10@exim.workshop.example
26603 cc: ph10@exim.workshop.example
26604 bcc: ph10@exim.workshop.example
26605 reply-to: Philip.Hazel@exim.workshop.example
26606 env-from: Philip.Hazel@exim.workshop.example
26607 env-to: ph10@exim.workshop.example
26608 .endd
26609 which shows that rewriting has been set up for that address when used in any of
26610 the source fields, but not when it appears as a recipient address. At the
26611 present time, there is no equivalent way of testing rewriting rules that are
26612 set for a particular transport.
26613
26614
26615 .section "Rewriting rules" "SECID150"
26616 .cindex "rewriting" "rules"
26617 The rewrite section of the configuration file consists of lines of rewriting
26618 rules in the form
26619 .display
26620 <&'source pattern'&>  <&'replacement'&>  <&'flags'&>
26621 .endd
26622 Rewriting rules that are specified for the &%headers_rewrite%& generic
26623 transport option are given as a colon-separated list. Each item in the list
26624 takes the same form as a line in the main rewriting configuration (except that
26625 any colons must be doubled, of course).
26626
26627 The formats of source patterns and replacement strings are described below.
26628 Each is terminated by white space, unless enclosed in double quotes, in which
26629 case normal quoting conventions apply inside the quotes. The flags are single
26630 characters which may appear in any order. Spaces and tabs between them are
26631 ignored.
26632
26633 For each address that could potentially be rewritten, the rules are scanned in
26634 order, and replacements for the address from earlier rules can themselves be
26635 replaced by later rules (but see the &"q"& and &"R"& flags).
26636
26637 The order in which addresses are rewritten is undefined, may change between
26638 releases, and must not be relied on, with one exception: when a message is
26639 received, the envelope sender is always rewritten first, before any header
26640 lines are rewritten. For example, the replacement string for a rewrite of an
26641 address in &'To:'& must not assume that the message's address in &'From:'& has
26642 (or has not) already been rewritten. However, a rewrite of &'From:'& may assume
26643 that the envelope sender has already been rewritten.
26644
26645 .vindex "&$domain$&"
26646 .vindex "&$local_part$&"
26647 The variables &$local_part$& and &$domain$& can be used in the replacement
26648 string to refer to the address that is being rewritten. Note that lookup-driven
26649 rewriting can be done by a rule of the form
26650 .code
26651 *@*   ${lookup ...
26652 .endd
26653 where the lookup key uses &$1$& and &$2$& or &$local_part$& and &$domain$& to
26654 refer to the address that is being rewritten.
26655
26656
26657 .section "Rewriting patterns" "SECID151"
26658 .cindex "rewriting" "patterns"
26659 .cindex "address list" "in a rewriting pattern"
26660 The source pattern in a rewriting rule is any item which may appear in an
26661 address list (see section &<<SECTaddresslist>>&). It is in fact processed as a
26662 single-item address list, which means that it is expanded before being tested
26663 against the address. As always, if you use a regular expression as a pattern,
26664 you must take care to escape dollar and backslash characters, or use the &`\N`&
26665 facility to suppress string expansion within the regular expression.
26666
26667 Domains in patterns should be given in lower case. Local parts in patterns are
26668 case-sensitive. If you want to do case-insensitive matching of local parts, you
26669 can use a regular expression that starts with &`^(?i)`&.
26670
26671 .cindex "numerical variables (&$1$& &$2$& etc)" "in rewriting rules"
26672 After matching, the numerical variables &$1$&, &$2$&, etc. may be set,
26673 depending on the type of match which occurred. These can be used in the
26674 replacement string to insert portions of the incoming address. &$0$& always
26675 refers to the complete incoming address. When a regular expression is used, the
26676 numerical variables are set from its capturing subexpressions. For other types
26677 of pattern they are set as follows:
26678
26679 .ilist
26680 If a local part or domain starts with an asterisk, the numerical variables
26681 refer to the character strings matched by asterisks, with &$1$& associated with
26682 the first asterisk, and &$2$& with the second, if present. For example, if the
26683 pattern
26684 .code
26685 *queen@*.fict.example
26686 .endd
26687 is matched against the address &'hearts-queen@wonderland.fict.example'& then
26688 .code
26689 $0 = hearts-queen@wonderland.fict.example
26690 $1 = hearts-
26691 $2 = wonderland
26692 .endd
26693 Note that if the local part does not start with an asterisk, but the domain
26694 does, it is &$1$& that contains the wild part of the domain.
26695
26696 .next
26697 If the domain part of the pattern is a partial lookup, the wild and fixed parts
26698 of the domain are placed in the next available numerical variables. Suppose,
26699 for example, that the address &'foo@bar.baz.example'& is processed by a
26700 rewriting rule of the form
26701 .display
26702 &`*@partial-dbm;/some/dbm/file`&    <&'replacement string'&>
26703 .endd
26704 and the key in the file that matches the domain is &`*.baz.example`&. Then
26705 .code
26706 $1 = foo
26707 $2 = bar
26708 $3 = baz.example
26709 .endd
26710 If the address &'foo@baz.example'& is looked up, this matches the same
26711 wildcard file entry, and in this case &$2$& is set to the empty string, but
26712 &$3$& is still set to &'baz.example'&. If a non-wild key is matched in a
26713 partial lookup, &$2$& is again set to the empty string and &$3$& is set to the
26714 whole domain. For non-partial domain lookups, no numerical variables are set.
26715 .endlist
26716
26717
26718 .section "Rewriting replacements" "SECID152"
26719 .cindex "rewriting" "replacements"
26720 If the replacement string for a rule is a single asterisk, addresses that
26721 match the pattern and the flags are &'not'& rewritten, and no subsequent
26722 rewriting rules are scanned. For example,
26723 .code
26724 hatta@lookingglass.fict.example  *  f
26725 .endd
26726 specifies that &'hatta@lookingglass.fict.example'& is never to be rewritten in
26727 &'From:'& headers.
26728
26729 .vindex "&$domain$&"
26730 .vindex "&$local_part$&"
26731 If the replacement string is not a single asterisk, it is expanded, and must
26732 yield a fully qualified address. Within the expansion, the variables
26733 &$local_part$& and &$domain$& refer to the address that is being rewritten.
26734 Any letters they contain retain their original case &-- they are not lower
26735 cased. The numerical variables are set up according to the type of pattern that
26736 matched the address, as described above. If the expansion is forced to fail by
26737 the presence of &"fail"& in a conditional or lookup item, rewriting by the
26738 current rule is abandoned, but subsequent rules may take effect. Any other
26739 expansion failure causes the entire rewriting operation to be abandoned, and an
26740 entry written to the panic log.
26741
26742
26743
26744 .subsection "Rewriting flags" "SSECID153"
26745 There are three different kinds of flag that may appear on rewriting rules:
26746
26747 .ilist
26748 Flags that specify which headers and envelope addresses to rewrite: E, F, T, b,
26749 c, f, h, r, s, t.
26750 .next
26751 A flag that specifies rewriting at SMTP time: S.
26752 .next
26753 Flags that control the rewriting process: Q, q, R, w.
26754 .endlist
26755
26756 For rules that are part of the &%headers_rewrite%& generic transport option,
26757 E, F, T, and S are not permitted.
26758
26759
26760
26761 .subsection "Flags specifying which headers and envelope addresses to rewrite" &&&
26762          "SSECID154"
26763 .cindex rewriting flags
26764 If none of the following flag letters, nor the &"S"& flag (see section
26765 &<<SSECTrewriteS>>&) are present, a main rewriting rule applies to all headers
26766 and to both the sender and recipient fields of the envelope, whereas a
26767 transport-time rewriting rule just applies to all headers. Otherwise, the
26768 rewriting rule is skipped unless the relevant addresses are being processed.
26769 .display
26770 &`E`&       rewrite all envelope fields
26771 &`F`&       rewrite the envelope From field
26772 &`T`&       rewrite the envelope To field
26773 &`b`&       rewrite the &'Bcc:'& header
26774 &`c`&       rewrite the &'Cc:'& header
26775 &`f`&       rewrite the &'From:'& header
26776 &`h`&       rewrite all headers
26777 &`r`&       rewrite the &'Reply-To:'& header
26778 &`s`&       rewrite the &'Sender:'& header
26779 &`t`&       rewrite the &'To:'& header
26780 .endd
26781 "All headers" means all of the headers listed above that can be selected
26782 individually, plus their &'Resent-'& versions. It does not include
26783 other headers such as &'Subject:'& etc.
26784
26785 You should be particularly careful about rewriting &'Sender:'& headers, and
26786 restrict this to special known cases in your own domains.
26787
26788
26789 .subsection "The SMTP-time rewriting flag" SSECTrewriteS
26790 .cindex SMTP "rewriting malformed addresses"
26791 .cindex RCPT "rewriting argument of"
26792 .cindex MAIL "rewriting argument of"
26793 The rewrite flag &"S"& specifies a rewrite of incoming envelope addresses at
26794 SMTP time, as soon as an address is received in a MAIL or RCPT command, and
26795 before any other processing; even before syntax checking. The pattern is
26796 required to be a regular expression, and it is matched against the whole of the
26797 data for the command, including any surrounding angle brackets.
26798
26799 .vindex "&$domain$&"
26800 .vindex "&$local_part$&"
26801 This form of rewrite rule allows for the handling of addresses that are not
26802 compliant with RFCs 2821 and 2822 (for example, &"bang paths"& in batched SMTP
26803 input). Because the input is not required to be a syntactically valid address,
26804 the variables &$local_part$& and &$domain$& are not available during the
26805 expansion of the replacement string. The result of rewriting replaces the
26806 original address in the MAIL or RCPT command.
26807
26808
26809 .subsection "Flags controlling the rewriting process" SSECID155
26810 There are four flags which control the way the rewriting process works. These
26811 take effect only when a rule is invoked, that is, when the address is of the
26812 correct type (matches the flags) and matches the pattern:
26813
26814 .ilist
26815 If the &"Q"& flag is set on a rule, the rewritten address is permitted to be an
26816 unqualified local part. It is qualified with &%qualify_recipient%&. In the
26817 absence of &"Q"& the rewritten address must always include a domain.
26818 .next
26819 If the &"q"& flag is set on a rule, no further rewriting rules are considered,
26820 even if no rewriting actually takes place because of a &"fail"& in the
26821 expansion. The &"q"& flag is not effective if the address is of the wrong type
26822 (does not match the flags) or does not match the pattern.
26823 .next
26824 The &"R"& flag causes a successful rewriting rule to be re-applied to the new
26825 address, up to ten times. It can be combined with the &"q"& flag, to stop
26826 rewriting once it fails to match (after at least one successful rewrite).
26827 .next
26828 .cindex "rewriting" "whole addresses"
26829 When an address in a header is rewritten, the rewriting normally applies only
26830 to the working part of the address, with any comments and RFC 2822 &"phrase"&
26831 left unchanged. For example, rewriting might change
26832 .code
26833 From: Ford Prefect <fp42@restaurant.hitch.fict.example>
26834 .endd
26835 into
26836 .code
26837 From: Ford Prefect <prefectf@hitch.fict.example>
26838 .endd
26839 .cindex "RFC 2047"
26840 Sometimes there is a need to replace the whole address item, and this can be
26841 done by adding the flag letter &"w"& to a rule. If this is set on a rule that
26842 causes an address in a header line to be rewritten, the entire address is
26843 replaced, not just the working part. The replacement must be a complete RFC
26844 2822 address, including the angle brackets if necessary. If text outside angle
26845 brackets contains a character whose value is greater than 126 or less than 32
26846 (except for tab), the text is encoded according to RFC 2047. The character set
26847 is taken from &%headers_charset%&, which gets its default at build time.
26848
26849 When the &"w"& flag is set on a rule that causes an envelope address to be
26850 rewritten, all but the working part of the replacement address is discarded.
26851 .endlist
26852
26853
26854 .section "Rewriting examples" "SECID156"
26855 Here is an example of the two common rewriting paradigms:
26856 .code
26857 *@*.hitch.fict.example  $1@hitch.fict.example
26858 *@hitch.fict.example    ${lookup{$1}dbm{/etc/realnames}\
26859                      {$value}fail}@hitch.fict.example bctfrF
26860 .endd
26861 Note the use of &"fail"& in the lookup expansion in the second rule, forcing
26862 the string expansion to fail if the lookup does not succeed. In this context it
26863 has the effect of leaving the original address unchanged, but Exim goes on to
26864 consider subsequent rewriting rules, if any, because the &"q"& flag is not
26865 present in that rule. An alternative to &"fail"& would be to supply &$1$&
26866 explicitly, which would cause the rewritten address to be the same as before,
26867 at the cost of a small bit of processing. Not supplying either of these is an
26868 error, since the rewritten address would then contain no local part.
26869
26870 The first example above replaces the domain with a superior, more general
26871 domain. This may not be desirable for certain local parts. If the rule
26872 .code
26873 root@*.hitch.fict.example  *
26874 .endd
26875 were inserted before the first rule, rewriting would be suppressed for the
26876 local part &'root'& at any domain ending in &'hitch.fict.example'&.
26877
26878 Rewriting can be made conditional on a number of tests, by making use of
26879 &${if$& in the expansion item. For example, to apply a rewriting rule only to
26880 messages that originate outside the local host:
26881 .code
26882 *@*.hitch.fict.example  "${if !eq {$sender_host_address}{}\
26883                          {$1@hitch.fict.example}fail}"
26884 .endd
26885 The replacement string is quoted in this example because it contains white
26886 space.
26887
26888 .cindex "rewriting" "bang paths"
26889 .cindex "bang paths" "rewriting"
26890 Exim does not handle addresses in the form of &"bang paths"&. If it sees such
26891 an address it treats it as an unqualified local part which it qualifies with
26892 the local qualification domain (if the source of the message is local or if the
26893 remote host is permitted to send unqualified addresses). Rewriting can
26894 sometimes be used to handle simple bang paths with a fixed number of
26895 components. For example, the rule
26896 .code
26897 \N^([^!]+)!(.*)@your.domain.example$\N   $2@$1
26898 .endd
26899 rewrites a two-component bang path &'host.name!user'& as the domain address
26900 &'user@host.name'&. However, there is a security implication in using this as
26901 a global rewriting rule for envelope addresses. It can provide a backdoor
26902 method for using your system as a relay, because the incoming addresses appear
26903 to be local. If the bang path addresses are received via SMTP, it is safer to
26904 use the &"S"& flag to rewrite them as they are received, so that relay checking
26905 can be done on the rewritten addresses.
26906 .ecindex IIDaddrew
26907
26908
26909
26910
26911
26912 . ////////////////////////////////////////////////////////////////////////////
26913 . ////////////////////////////////////////////////////////////////////////////
26914
26915 .chapter "Retry configuration" "CHAPretry"
26916 .scindex IIDretconf1 "retry" "configuration, description of"
26917 .scindex IIDregconf2 "configuration file" "retry section"
26918 The &"retry"& section of the runtime configuration file contains a list of
26919 retry rules that control how often Exim tries to deliver messages that cannot
26920 be delivered at the first attempt. If there are no retry rules (the section is
26921 empty or not present), there are no retries. In this situation, temporary
26922 errors are treated as permanent. The default configuration contains a single,
26923 general-purpose retry rule (see section &<<SECID57>>&). The &%-brt%& command
26924 line option can be used to test which retry rule will be used for a given
26925 address, domain and error.
26926
26927 The most common cause of retries is temporary failure to deliver to a remote
26928 host because the host is down, or inaccessible because of a network problem.
26929 Exim's retry processing in this case is applied on a per-host (strictly, per IP
26930 address) basis, not on a per-message basis. Thus, if one message has recently
26931 been delayed, delivery of a new message to the same host is not immediately
26932 tried, but waits for the host's retry time to arrive. If the &%retry_defer%&
26933 log selector is set, the message
26934 .cindex "retry" "time not reached"
26935 &"retry time not reached"& is written to the main log whenever a delivery is
26936 skipped for this reason. Section &<<SECToutSMTPerr>>& contains more details of
26937 the handling of errors during remote deliveries.
26938
26939 Retry processing applies to routing as well as to delivering, except as covered
26940 in the next paragraph. The retry rules do not distinguish between these
26941 actions. It is not possible, for example, to specify different behaviour for
26942 failures to route the domain &'snark.fict.example'& and failures to deliver to
26943 the host &'snark.fict.example'&. I didn't think anyone would ever need this
26944 added complication, so did not implement it. However, although they share the
26945 same retry rule, the actual retry times for routing and transporting a given
26946 domain are maintained independently.
26947
26948 When a delivery is not part of a queue run (typically an immediate delivery on
26949 receipt of a message), the routers are always run, and local deliveries are
26950 always attempted, even if retry times are set for them. This makes for better
26951 behaviour if one particular message is causing problems (for example, causing
26952 quota overflow, or provoking an error in a filter file). If such a delivery
26953 suffers a temporary failure, the retry data is updated as normal, and
26954 subsequent delivery attempts from queue runs occur only when the retry time for
26955 the local address is reached.
26956
26957 .section "Changing retry rules" "SECID157"
26958 If you change the retry rules in your configuration, you should consider
26959 whether or not to delete the retry data that is stored in Exim's spool area in
26960 files with names like &_db/retry_&. Deleting any of Exim's hints files is
26961 always safe; that is why they are called &"hints"&.
26962
26963 The hints retry data contains suggested retry times based on the previous
26964 rules. In the case of a long-running problem with a remote host, it might
26965 record the fact that the host has timed out. If your new rules increase the
26966 timeout time for such a host, you should definitely remove the old retry data
26967 and let Exim recreate it, based on the new rules. Otherwise Exim might bounce
26968 messages that it should now be retaining.
26969
26970
26971
26972 .section "Format of retry rules" "SECID158"
26973 .cindex "retry" "rules"
26974 Each retry rule occupies one line and consists of three or four parts,
26975 separated by white space: a pattern, an error name, an optional list of sender
26976 addresses, and a list of retry parameters. The pattern and sender lists must be
26977 enclosed in double quotes if they contain white space. The rules are searched
26978 in order until one is found where the pattern, error name, and sender list (if
26979 present) match the failing host or address, the error that occurred, and the
26980 message's sender, respectively.
26981
26982
26983 The pattern is any single item that may appear in an address list (see section
26984 &<<SECTaddresslist>>&). It is in fact processed as a one-item address list,
26985 which means that it is expanded before being tested against the address that
26986 has been delayed. A negated address list item is permitted. Address
26987 list processing treats a plain domain name as if it were preceded by &"*@"&,
26988 which makes it possible for many retry rules to start with just a domain. For
26989 example,
26990 .code
26991 lookingglass.fict.example        *  F,24h,30m;
26992 .endd
26993 provides a rule for any address in the &'lookingglass.fict.example'& domain,
26994 whereas
26995 .code
26996 alice@lookingglass.fict.example  *  F,24h,30m;
26997 .endd
26998 applies only to temporary failures involving the local part &%alice%&.
26999 In practice, almost all rules start with a domain name pattern without a local
27000 part.
27001
27002 .cindex "regular expressions" "in retry rules"
27003 &*Warning*&: If you use a regular expression in a retry rule pattern, it
27004 must match a complete address, not just a domain, because that is how regular
27005 expressions work in address lists.
27006 .display
27007 &`^\Nxyz\d+\.abc\.example$\N        *  G,1h,10m,2`&     &%Wrong%&
27008 &`^\N[^@]+@xyz\d+\.abc\.example$\N  *  G,1h,10m,2`&     &%Right%&
27009 .endd
27010
27011
27012 .section "Choosing which retry rule to use for address errors" "SECID159"
27013 When Exim is looking for a retry rule after a routing attempt has failed (for
27014 example, after a DNS timeout), each line in the retry configuration is tested
27015 against the complete address only if &%retry_use_local_part%& is set for the
27016 router. Otherwise, only the domain is used, except when matching against a
27017 regular expression, when the local part of the address is replaced with &"*"&.
27018 A domain on its own can match a domain pattern, or a pattern that starts with
27019 &"*@"&. By default, &%retry_use_local_part%& is true for routers where
27020 &%check_local_user%& is true, and false for other routers.
27021
27022 Similarly, when Exim is looking for a retry rule after a local delivery has
27023 failed (for example, after a mailbox full error), each line in the retry
27024 configuration is tested against the complete address only if
27025 &%retry_use_local_part%& is set for the transport (it defaults true for all
27026 local transports).
27027
27028 .cindex "4&'xx'& responses" "retry rules for"
27029 However, when Exim is looking for a retry rule after a remote delivery attempt
27030 suffers an address error (a 4&'xx'& SMTP response for a recipient address), the
27031 whole address is always used as the key when searching the retry rules. The
27032 rule that is found is used to create a retry time for the combination of the
27033 failing address and the message's sender. It is the combination of sender and
27034 recipient that is delayed in subsequent queue runs until its retry time is
27035 reached. You can delay the recipient without regard to the sender by setting
27036 &%address_retry_include_sender%& false in the &(smtp)& transport but this can
27037 lead to problems with servers that regularly issue 4&'xx'& responses to RCPT
27038 commands.
27039
27040
27041
27042 .section "Choosing which retry rule to use for host and message errors" &&&
27043          "SECID160"
27044 For a temporary error that is not related to an individual address (for
27045 example, a connection timeout), each line in the retry configuration is checked
27046 twice. First, the name of the remote host is used as a domain name (preceded by
27047 &"*@"& when matching a regular expression). If this does not match the line,
27048 the domain from the email address is tried in a similar fashion. For example,
27049 suppose the MX records for &'a.b.c.example'& are
27050 .code
27051 a.b.c.example  MX  5  x.y.z.example
27052                MX  6  p.q.r.example
27053                MX  7  m.n.o.example
27054 .endd
27055 and the retry rules are
27056 .code
27057 p.q.r.example    *      F,24h,30m;
27058 a.b.c.example    *      F,4d,45m;
27059 .endd
27060 and a delivery to the host &'x.y.z.example'& suffers a connection failure. The
27061 first rule matches neither the host nor the domain, so Exim looks at the second
27062 rule. This does not match the host, but it does match the domain, so it is used
27063 to calculate the retry time for the host &'x.y.z.example'&. Meanwhile, Exim
27064 tries to deliver to &'p.q.r.example'&. If this also suffers a host error, the
27065 first retry rule is used, because it matches the host.
27066
27067 In other words, temporary failures to deliver to host &'p.q.r.example'& use the
27068 first rule to determine retry times, but for all the other hosts for the domain
27069 &'a.b.c.example'&, the second rule is used. The second rule is also used if
27070 routing to &'a.b.c.example'& suffers a temporary failure.
27071
27072 &*Note*&: The host name is used when matching the patterns, not its IP address.
27073 However, if a message is routed directly to an IP address without the use of a
27074 host name, for example, if a &(manualroute)& router contains a setting such as:
27075 .code
27076 route_list = *.a.example  192.168.34.23
27077 .endd
27078 then the &"host name"& that is used when searching for a retry rule is the
27079 textual form of the IP address.
27080
27081 .section "Retry rules for specific errors" "SECID161"
27082 .cindex "retry" "specific errors; specifying"
27083 The second field in a retry rule is the name of a particular error, or an
27084 asterisk, which matches any error. The errors that can be tested for are:
27085
27086 .vlist
27087 .vitem &%auth_failed%&
27088 Authentication failed when trying to send to a host in the
27089 &%hosts_require_auth%& list in an &(smtp)& transport.
27090
27091 .vitem &%data_4xx%&
27092 A 4&'xx'& error was received for an outgoing DATA command, either immediately
27093 after the command, or after sending the message's data.
27094
27095 .vitem &%mail_4xx%&
27096 A 4&'xx'& error was received for an outgoing MAIL command.
27097
27098 .vitem &%rcpt_4xx%&
27099 A 4&'xx'& error was received for an outgoing RCPT command.
27100 .endlist
27101
27102 For the three 4&'xx'& errors, either the first or both of the x's can be given
27103 as specific digits, for example: &`mail_45x`& or &`rcpt_436`&. For example, to
27104 recognize 452 errors given to RCPT commands for addresses in a certain domain,
27105 and have retries every ten minutes with a one-hour timeout, you could set up a
27106 retry rule of this form:
27107 .code
27108 the.domain.name  rcpt_452   F,1h,10m
27109 .endd
27110 These errors apply to both outgoing SMTP (the &(smtp)& transport) and outgoing
27111 LMTP (either the &(lmtp)& transport, or the &(smtp)& transport in LMTP mode).
27112
27113 .vlist
27114 .vitem &%lost_connection%&
27115 A server unexpectedly closed the SMTP connection. There may, of course,
27116 legitimate reasons for this (host died, network died), but if it repeats a lot
27117 for the same host, it indicates something odd.
27118
27119 .vitem &%lookup%&
27120 A DNS lookup for a host failed.
27121 Note that a &%dnslookup%& router will need to have matched
27122 its &%fail_defer_domains%& option for this retry type to be usable.
27123 Also note that a &%manualroute%& router will probably need
27124 its &%host_find_failed%& option set to &%defer%&.
27125
27126 .vitem &%refused_MX%&
27127 A connection to a host obtained from an MX record was refused.
27128
27129 .vitem &%refused_A%&
27130 A connection to a host not obtained from an MX record was refused.
27131
27132 .vitem &%refused%&
27133 A connection was refused.
27134
27135 .vitem &%timeout_connect_MX%&
27136 A connection attempt to a host obtained from an MX record timed out.
27137
27138 .vitem &%timeout_connect_A%&
27139 A connection attempt to a host not obtained from an MX record timed out.
27140
27141 .vitem &%timeout_connect%&
27142 A connection attempt timed out.
27143
27144 .vitem &%timeout_MX%&
27145 There was a timeout while connecting or during an SMTP session with a host
27146 obtained from an MX record.
27147
27148 .vitem &%timeout_A%&
27149 There was a timeout while connecting or during an SMTP session with a host not
27150 obtained from an MX record.
27151
27152 .vitem &%timeout%&
27153 There was a timeout while connecting or during an SMTP session.
27154
27155 .vitem &%tls_required%&
27156 The server was required to use TLS (it matched &%hosts_require_tls%& in the
27157 &(smtp)& transport), but either did not offer TLS, or it responded with 4&'xx'&
27158 to STARTTLS, or there was a problem setting up the TLS connection.
27159
27160 .vitem &%quota%&
27161 A mailbox quota was exceeded in a local delivery by the &(appendfile)&
27162 transport.
27163
27164 .vitem &%quota_%&<&'time'&>
27165 .cindex "quota" "error testing in retry rule"
27166 .cindex "retry" "quota error testing"
27167 A mailbox quota was exceeded in a local delivery by the &(appendfile)&
27168 transport, and the mailbox has not been accessed for <&'time'&>. For example,
27169 &'quota_4d'& applies to a quota error when the mailbox has not been accessed
27170 for four days.
27171 .endlist
27172
27173 .cindex "mailbox" "time of last read"
27174 The idea of &%quota_%&<&'time'&> is to make it possible to have shorter
27175 timeouts when the mailbox is full and is not being read by its owner. Ideally,
27176 it should be based on the last time that the user accessed the mailbox.
27177 However, it is not always possible to determine this. Exim uses the following
27178 heuristic rules:
27179
27180 .ilist
27181 If the mailbox is a single file, the time of last access (the &"atime"&) is
27182 used. As no new messages are being delivered (because the mailbox is over
27183 quota), Exim does not access the file, so this is the time of last user access.
27184 .next
27185 .cindex "maildir format" "time of last read"
27186 For a maildir delivery, the time of last modification of the &_new_&
27187 subdirectory is used. As the mailbox is over quota, no new files are created in
27188 the &_new_& subdirectory, because no new messages are being delivered. Any
27189 change to the &_new_& subdirectory is therefore assumed to be the result of an
27190 MUA moving a new message to the &_cur_& directory when it is first read. The
27191 time that is used is therefore the last time that the user read a new message.
27192 .next
27193 For other kinds of multi-file mailbox, the time of last access cannot be
27194 obtained, so a retry rule that uses this type of error field is never matched.
27195 .endlist
27196
27197 The quota errors apply both to system-enforced quotas and to Exim's own quota
27198 mechanism in the &(appendfile)& transport. The &'quota'& error also applies
27199 when a local delivery is deferred because a partition is full (the ENOSPC
27200 error).
27201
27202
27203
27204 .section "Retry rules for specified senders" "SECID162"
27205 .cindex "retry" "rules; sender-specific"
27206 You can specify retry rules that apply only when the failing message has a
27207 specific sender. In particular, this can be used to define retry rules that
27208 apply only to bounce messages. The third item in a retry rule can be of this
27209 form:
27210 .display
27211 &`senders=`&<&'address list'&>
27212 .endd
27213 The retry timings themselves are then the fourth item. For example:
27214 .code
27215 *   rcpt_4xx   senders=:   F,1h,30m
27216 .endd
27217 matches recipient 4&'xx'& errors for bounce messages sent to any address at any
27218 host. If the address list contains white space, it must be enclosed in quotes.
27219 For example:
27220 .code
27221 a.domain  rcpt_452  senders="xb.dom : yc.dom"  G,8h,10m,1.5
27222 .endd
27223 &*Warning*&: This facility can be unhelpful if it is used for host errors
27224 (which do not depend on the recipient). The reason is that the sender is used
27225 only to match the retry rule. Once the rule has been found for a host error,
27226 its contents are used to set a retry time for the host, and this will apply to
27227 all messages, not just those with specific senders.
27228
27229 When testing retry rules using &%-brt%&, you can supply a sender using the
27230 &%-f%& command line option, like this:
27231 .code
27232 exim -f "" -brt user@dom.ain
27233 .endd
27234 If you do not set &%-f%& with &%-brt%&, a retry rule that contains a senders
27235 list is never matched.
27236
27237
27238
27239
27240
27241 .section "Retry parameters" "SECID163"
27242 .cindex "retry" "parameters in rules"
27243 The third (or fourth, if a senders list is present) field in a retry rule is a
27244 sequence of retry parameter sets, separated by semicolons. Each set consists of
27245 .display
27246 <&'letter'&>,<&'cutoff time'&>,<&'arguments'&>
27247 .endd
27248 The letter identifies the algorithm for computing a new retry time; the cutoff
27249 time is the time beyond which this algorithm no longer applies, and the
27250 arguments vary the algorithm's action. The cutoff time is measured from the
27251 time that the first failure for the domain (combined with the local part if
27252 relevant) was detected, not from the time the message was received.
27253
27254 .cindex "retry" "algorithms"
27255 .cindex "retry" "fixed intervals"
27256 .cindex "retry" "increasing intervals"
27257 .cindex "retry" "random intervals"
27258 The available algorithms are:
27259
27260 .ilist
27261 &'F'&: retry at fixed intervals. There is a single time parameter specifying
27262 the interval.
27263 .next
27264 &'G'&: retry at geometrically increasing intervals. The first argument
27265 specifies a starting value for the interval, and the second a multiplier, which
27266 is used to increase the size of the interval at each retry.
27267 .next
27268 &'H'&: retry at randomized intervals. The arguments are as for &'G'&. For each
27269 retry, the previous interval is multiplied by the factor in order to get a
27270 maximum for the next interval. The minimum interval is the first argument of
27271 the parameter, and an actual interval is chosen randomly between them. Such a
27272 rule has been found to be helpful in cluster configurations when all the
27273 members of the cluster restart at once, and may therefore synchronize their
27274 queue processing times.
27275 .endlist
27276
27277 When computing the next retry time, the algorithm definitions are scanned in
27278 order until one whose cutoff time has not yet passed is reached. This is then
27279 used to compute a new retry time that is later than the current time. In the
27280 case of fixed interval retries, this simply means adding the interval to the
27281 current time. For geometrically increasing intervals, retry intervals are
27282 computed from the rule's parameters until one that is greater than the previous
27283 interval is found. The main configuration variable
27284 .cindex "limit" "retry interval"
27285 .cindex "retry" "interval, maximum"
27286 .oindex "&%retry_interval_max%&"
27287 &%retry_interval_max%& limits the maximum interval between retries. It
27288 cannot be set greater than &`24h`&, which is its default value.
27289
27290 A single remote domain may have a number of hosts associated with it, and each
27291 host may have more than one IP address. Retry algorithms are selected on the
27292 basis of the domain name, but are applied to each IP address independently. If,
27293 for example, a host has two IP addresses and one is unusable, Exim will
27294 generate retry times for it and will not try to use it until its next retry
27295 time comes. Thus the good IP address is likely to be tried first most of the
27296 time.
27297
27298 .cindex "hints database" "use for retrying"
27299 Retry times are hints rather than promises. Exim does not make any attempt to
27300 run deliveries exactly at the computed times. Instead, a queue runner process
27301 starts delivery processes for delayed messages periodically, and these attempt
27302 new deliveries only for those addresses that have passed their next retry time.
27303 If a new message arrives for a deferred address, an immediate delivery attempt
27304 occurs only if the address has passed its retry time. In the absence of new
27305 messages, the minimum time between retries is the interval between queue runner
27306 processes. There is not much point in setting retry times of five minutes if
27307 your queue runners happen only once an hour, unless there are a significant
27308 number of incoming messages (which might be the case on a system that is
27309 sending everything to a smart host, for example).
27310
27311 The data in the retry hints database can be inspected by using the
27312 &'exim_dumpdb'& or &'exim_fixdb'& utility programs (see chapter
27313 &<<CHAPutils>>&). The latter utility can also be used to change the data. The
27314 &'exinext'& utility script can be used to find out what the next retry times
27315 are for the hosts associated with a particular mail domain, and also for local
27316 deliveries that have been deferred.
27317
27318
27319 .section "Retry rule examples" "SECID164"
27320 Here are some example retry rules:
27321 .code
27322 alice@wonderland.fict.example quota_5d  F,7d,3h
27323 wonderland.fict.example       quota_5d
27324 wonderland.fict.example       *         F,1h,15m; G,2d,1h,2;
27325 lookingglass.fict.example     *         F,24h,30m;
27326 *                 refused_A   F,2h,20m;
27327 *                 *           F,2h,15m; G,16h,1h,1.5; F,5d,8h
27328 .endd
27329 The first rule sets up special handling for mail to
27330 &'alice@wonderland.fict.example'& when there is an over-quota error and the
27331 mailbox has not been read for at least 5 days. Retries continue every three
27332 hours for 7 days. The second rule handles over-quota errors for all other local
27333 parts at &'wonderland.fict.example'&; the absence of a local part has the same
27334 effect as supplying &"*@"&. As no retry algorithms are supplied, messages that
27335 fail are bounced immediately if the mailbox has not been read for at least 5
27336 days.
27337
27338 The third rule handles all other errors at &'wonderland.fict.example'&; retries
27339 happen every 15 minutes for an hour, then with geometrically increasing
27340 intervals until two days have passed since a delivery first failed. After the
27341 first hour there is a delay of one hour, then two hours, then four hours, and
27342 so on (this is a rather extreme example).
27343
27344 The fourth rule controls retries for the domain &'lookingglass.fict.example'&.
27345 They happen every 30 minutes for 24 hours only. The remaining two rules handle
27346 all other domains, with special action for connection refusal from hosts that
27347 were not obtained from an MX record.
27348
27349 The final rule in a retry configuration should always have asterisks in the
27350 first two fields so as to provide a general catch-all for any addresses that do
27351 not have their own special handling. This example tries every 15 minutes for 2
27352 hours, then with intervals starting at one hour and increasing by a factor of
27353 1.5 up to 16 hours, then every 8 hours up to 5 days.
27354
27355
27356
27357 .section "Timeout of retry data" "SECID165"
27358 .cindex "timeout" "of retry data"
27359 .oindex "&%retry_data_expire%&"
27360 .cindex "hints database" "data expiry"
27361 .cindex "retry" "timeout of data"
27362 Exim timestamps the data that it writes to its retry hints database. When it
27363 consults the data during a delivery it ignores any that is older than the value
27364 set in &%retry_data_expire%& (default 7 days). If, for example, a host hasn't
27365 been tried for 7 days, Exim will try to deliver to it immediately a message
27366 arrives, and if that fails, it will calculate a retry time as if it were
27367 failing for the first time.
27368
27369 This improves the behaviour for messages routed to rarely-used hosts such as MX
27370 backups. If such a host was down at one time, and happens to be down again when
27371 Exim tries a month later, using the old retry data would imply that it had been
27372 down all the time, which is not a justified assumption.
27373
27374 If a host really is permanently dead, this behaviour causes a burst of retries
27375 every now and again, but only if messages routed to it are rare. If there is a
27376 message at least once every 7 days the retry data never expires.
27377
27378
27379
27380
27381 .section "Long-term failures" "SECID166"
27382 .cindex "delivery failure, long-term"
27383 .cindex "retry" "after long-term failure"
27384 Special processing happens when an email address has been failing for so long
27385 that the cutoff time for the last algorithm is reached. For example, using the
27386 default retry rule:
27387 .code
27388 * * F,2h,15m; G,16h,1h,1.5; F,4d,6h
27389 .endd
27390 the cutoff time is four days. Reaching the retry cutoff is independent of how
27391 long any specific message has been failing; it is the length of continuous
27392 failure for the recipient address that counts.
27393
27394 When the cutoff time is reached for a local delivery, or for all the IP
27395 addresses associated with a remote delivery, a subsequent delivery failure
27396 causes Exim to give up on the address, and a bounce message is generated.
27397 In order to cater for new messages that use the failing address, a next retry
27398 time is still computed from the final algorithm, and is used as follows:
27399
27400 For local deliveries, one delivery attempt is always made for any subsequent
27401 messages. If this delivery fails, the address fails immediately. The
27402 post-cutoff retry time is not used.
27403
27404 .cindex "final cutoff" "retries, controlling"
27405 .cindex retry "final cutoff"
27406 If the delivery is remote, there are two possibilities, controlled by the
27407 .oindex "&%delay_after_cutoff%&"
27408 &%delay_after_cutoff%& option of the &(smtp)& transport. The option is true by
27409 default. Until the post-cutoff retry time for one of the IP addresses,
27410 as set by the &%retry_data_expire%& option, is
27411 reached, the failing email address is bounced immediately, without a delivery
27412 attempt taking place. After that time, one new delivery attempt is made to
27413 those IP addresses that are past their retry times, and if that still fails,
27414 the address is bounced and new retry times are computed.
27415
27416 In other words, when all the hosts for a given email address have been failing
27417 for a long time, Exim bounces rather then defers until one of the hosts' retry
27418 times is reached. Then it tries once, and bounces if that attempt fails. This
27419 behaviour ensures that few resources are wasted in repeatedly trying to deliver
27420 to a broken destination, but if the host does recover, Exim will eventually
27421 notice.
27422
27423 If &%delay_after_cutoff%& is set false, Exim behaves differently. If all IP
27424 addresses are past their final cutoff time, Exim tries to deliver to those IP
27425 addresses that have not been tried since the message arrived. If there are
27426 no suitable IP addresses, or if they all fail, the address is bounced. In other
27427 words, it does not delay when a new message arrives, but tries the expired
27428 addresses immediately, unless they have been tried since the message arrived.
27429 If there is a continuous stream of messages for the failing domains, setting
27430 &%delay_after_cutoff%& false means that there will be many more attempts to
27431 deliver to permanently failing IP addresses than when &%delay_after_cutoff%& is
27432 true.
27433
27434 .section "Deliveries that work intermittently" "SECID167"
27435 .cindex "retry" "intermittently working deliveries"
27436 Some additional logic is needed to cope with cases where a host is
27437 intermittently available, or when a message has some attribute that prevents
27438 its delivery when others to the same address get through. In this situation,
27439 because some messages are successfully delivered, the &"retry clock"& for the
27440 host or address keeps getting reset by the successful deliveries, and so
27441 failing messages remain in the queue for ever because the cutoff time is never
27442 reached.
27443
27444 Two exceptional actions are applied to prevent this happening. The first
27445 applies to errors that are related to a message rather than a remote host.
27446 Section &<<SECToutSMTPerr>>& has a discussion of the different kinds of error;
27447 examples of message-related errors are 4&'xx'& responses to MAIL or DATA
27448 commands, and quota failures. For this type of error, if a message's arrival
27449 time is earlier than the &"first failed"& time for the error, the earlier time
27450 is used when scanning the retry rules to decide when to try next and when to
27451 time out the address.
27452
27453 The exceptional second action applies in all cases. If a message has been on
27454 the queue for longer than the cutoff time of any applicable retry rule for a
27455 given address, a delivery is attempted for that address, even if it is not yet
27456 time, and if this delivery fails, the address is timed out. A new retry time is
27457 not computed in this case, so that other messages for the same address are
27458 considered immediately.
27459 .ecindex IIDretconf1
27460 .ecindex IIDregconf2
27461
27462
27463
27464
27465
27466
27467 . ////////////////////////////////////////////////////////////////////////////
27468 . ////////////////////////////////////////////////////////////////////////////
27469
27470 .chapter "SMTP authentication" "CHAPSMTPAUTH"
27471 .scindex IIDauthconf1 "SMTP" "authentication configuration"
27472 .scindex IIDauthconf2 "authentication"
27473 The &"authenticators"& section of Exim's runtime configuration is concerned
27474 with SMTP authentication. This facility is an extension to the SMTP protocol,
27475 described in RFC 2554, which allows a client SMTP host to authenticate itself
27476 to a server. This is a common way for a server to recognize clients that are
27477 permitted to use it as a relay. SMTP authentication is not of relevance to the
27478 transfer of mail between servers that have no managerial connection with each
27479 other.
27480
27481 The name of an authenticator is limited to be &drivernamemax; ASCII characters long;
27482 prior to Exim 4.95 names would be silently truncated at this length, but now
27483 it is enforced.
27484
27485 .cindex "AUTH" "description of"
27486 .cindex "ESMTP extensions" AUTH
27487 Very briefly, the way SMTP authentication works is as follows:
27488
27489 .olist
27490 The server advertises a number of authentication &'mechanisms'& in response to
27491 the client's EHLO command.
27492 .next
27493 The client issues an AUTH command, naming a specific mechanism. The command
27494 may, optionally, contain some authentication data.
27495 .next
27496 The server may issue one or more &'challenges'&, to which the client must send
27497 appropriate responses. In simple authentication mechanisms, the challenges are
27498 just prompts for user names and passwords. The server does not have to issue
27499 any challenges &-- in some mechanisms the relevant data may all be transmitted
27500 with the AUTH command.
27501 .next
27502 The server either accepts or denies authentication.
27503 .next
27504 If authentication succeeds, the client may optionally make use of the AUTH
27505 option on the MAIL command to pass an authenticated sender in subsequent
27506 mail transactions. Authentication lasts for the remainder of the SMTP
27507 connection.
27508 .next
27509 If authentication fails, the client may give up, or it may try a different
27510 authentication mechanism, or it may try transferring mail over the
27511 unauthenticated connection.
27512 .endlist
27513
27514 If you are setting up a client, and want to know which authentication
27515 mechanisms the server supports, you can use Telnet to connect to port 25 (the
27516 SMTP port) on the server, and issue an EHLO command. The response to this
27517 includes the list of supported mechanisms. For example:
27518 .display
27519 &`$ `&&*&`telnet server.example 25`&*&
27520 &`Trying 192.168.34.25...`&
27521 &`Connected to server.example.`&
27522 &`Escape character is &#x0027;^]&#x0027;.`&
27523 &`220 server.example ESMTP Exim 4.20 ...`&
27524 &*&`ehlo client.example`&*&
27525 &`250-server.example Hello client.example [10.8.4.5]`&
27526 &`250-SIZE 52428800`&
27527 &`250-PIPELINING`&
27528 &`250-AUTH PLAIN`&
27529 &`250 HELP`&
27530 .endd
27531 The second-last line of this example output shows that the server supports
27532 authentication using the PLAIN mechanism. In Exim, the different authentication
27533 mechanisms are configured by specifying &'authenticator'& drivers. Like the
27534 routers and transports, which authenticators are included in the binary is
27535 controlled by build-time definitions. The following are currently available,
27536 included by setting
27537 .code
27538 AUTH_CRAM_MD5=yes
27539 AUTH_CYRUS_SASL=yes
27540 AUTH_DOVECOT=yes
27541 AUTH_EXTERNAL=yes
27542 AUTH_GSASL=yes
27543 AUTH_HEIMDAL_GSSAPI=yes
27544 AUTH_PLAINTEXT=yes
27545 AUTH_SPA=yes
27546 AUTH_TLS=yes
27547 .endd
27548 in &_Local/Makefile_&, respectively. The first of these supports the CRAM-MD5
27549 authentication mechanism (RFC 2195), and the second provides an interface to
27550 the Cyrus SASL authentication library.
27551 The third is an interface to Dovecot's authentication system, delegating the
27552 work via a socket interface.
27553 The fourth provides for negotiation of authentication done via non-SMTP means,
27554 as defined by RFC 4422 Appendix A.
27555 The fifth provides an interface to the GNU SASL authentication library, which
27556 provides mechanisms but typically not data sources.
27557 The sixth provides direct access to Heimdal GSSAPI, geared for Kerberos, but
27558 supporting setting a server keytab.
27559 The seventh can be configured to support
27560 the PLAIN authentication mechanism (RFC 2595) or the LOGIN mechanism, which is
27561 not formally documented, but used by several MUAs.
27562 The eighth authenticator
27563 supports Microsoft's &'Secure Password Authentication'& mechanism.
27564 The last is an Exim authenticator but not an SMTP one;
27565 instead it can use information from a TLS negotiation.
27566
27567 The authenticators are configured using the same syntax as other drivers (see
27568 section &<<SECTfordricon>>&). If no authenticators are required, no
27569 authentication section need be present in the configuration file. Each
27570 authenticator can in principle have both server and client functions. When Exim
27571 is receiving SMTP mail, it is acting as a server; when it is sending out
27572 messages over SMTP, it is acting as a client. Authenticator configuration
27573 options are provided for use in both these circumstances.
27574
27575 To make it clear which options apply to which situation, the prefixes
27576 &%server_%& and &%client_%& are used on option names that are specific to
27577 either the server or the client function, respectively. Server and client
27578 functions are disabled if none of their options are set. If an authenticator is
27579 to be used for both server and client functions, a single definition, using
27580 both sets of options, is required. For example:
27581 .code
27582 cram:
27583   driver = cram_md5
27584   public_name = CRAM-MD5
27585   server_secret = ${if eq{$auth1}{ph10}{secret1}fail}
27586   client_name = ph10
27587   client_secret = secret2
27588 .endd
27589 The &%server_%& option is used when Exim is acting as a server, and the
27590 &%client_%& options when it is acting as a client.
27591
27592 Descriptions of the individual authenticators are given in subsequent chapters.
27593 The remainder of this chapter covers the generic options for the
27594 authenticators, followed by general discussion of the way authentication works
27595 in Exim.
27596
27597 &*Beware:*& the meaning of &$auth1$&, &$auth2$&, ... varies on a per-driver and
27598 per-mechanism basis.  Please read carefully to determine which variables hold
27599 account labels such as usercodes and which hold passwords or other
27600 authenticating data.
27601
27602 Note that some mechanisms support two different identifiers for accounts: the
27603 &'authentication id'& and the &'authorization id'&.  The contractions &'authn'&
27604 and &'authz'& are commonly encountered.  The American spelling is standard here.
27605 Conceptually, authentication data such as passwords are tied to the identifier
27606 used to authenticate; servers may have rules to permit one user to act as a
27607 second user, so that after login the session is treated as though that second
27608 user had logged in.  That second user is the &'authorization id'&.  A robust
27609 configuration might confirm that the &'authz'& field is empty or matches the
27610 &'authn'& field.  Often this is just ignored.  The &'authn'& can be considered
27611 as verified data, the &'authz'& as an unverified request which the server might
27612 choose to honour.
27613
27614 A &'realm'& is a text string, typically a domain name, presented by a server
27615 to a client to help it select an account and credentials to use.  In some
27616 mechanisms, the client and server provably agree on the realm, but clients
27617 typically can not treat the realm as secure data to be blindly trusted.
27618
27619
27620
27621 .section "Generic options for authenticators" "SECID168"
27622 .cindex "authentication" "generic options"
27623 .cindex "options" "generic; for authenticators"
27624
27625 .option client_condition authenticators string&!! unset
27626 When Exim is authenticating as a client, it skips any authenticator whose
27627 &%client_condition%& expansion yields &"0"&, &"no"&, or &"false"&. This can be
27628 used, for example, to skip plain text authenticators when the connection is not
27629 encrypted by a setting such as:
27630 .code
27631 client_condition = ${if !eq{$tls_out_cipher}{}}
27632 .endd
27633
27634
27635 .option client_set_id authenticators string&!! unset
27636 When client authentication succeeds, this condition is expanded; the
27637 result is used in the log lines for outbound messages.
27638 Typically it will be the user name used for authentication.
27639
27640
27641 .option driver authenticators string unset
27642 This option must always be set. It specifies which of the available
27643 authenticators is to be used.
27644
27645
27646 .option public_name authenticators string unset
27647 This option specifies the name of the authentication mechanism that the driver
27648 implements, and by which it is known to the outside world. These names should
27649 contain only upper case letters, digits, underscores, and hyphens (RFC 2222),
27650 but Exim in fact matches them caselessly. If &%public_name%& is not set, it
27651 defaults to the driver's instance name.
27652
27653
27654 .option server_advertise_condition authenticators string&!! unset
27655 When a server is about to advertise an authentication mechanism, the condition
27656 is expanded. If it yields the empty string, &"0"&, &"no"&, or &"false"&, the
27657 mechanism is not advertised.
27658 If the expansion fails, the mechanism is not advertised. If the failure was not
27659 forced, and was not caused by a lookup defer, the incident is logged.
27660 See section &<<SECTauthexiser>>& below for further discussion.
27661
27662
27663 .option server_condition authenticators string&!! unset
27664 This option must be set for a &%plaintext%& server authenticator, where it
27665 is used directly to control authentication. See section &<<SECTplainserver>>&
27666 for details.
27667
27668 For the &(gsasl)& authenticator, this option is required for various
27669 mechanisms; see chapter &<<CHAPgsasl>>& for details.
27670
27671 For the other authenticators, &%server_condition%& can be used as an additional
27672 authentication or authorization mechanism that is applied after the other
27673 authenticator conditions succeed. If it is set, it is expanded when the
27674 authenticator would otherwise return a success code. If the expansion is forced
27675 to fail, authentication fails. Any other expansion failure causes a temporary
27676 error code to be returned. If the result of a successful expansion is an empty
27677 string, &"0"&, &"no"&, or &"false"&, authentication fails. If the result of the
27678 expansion is &"1"&, &"yes"&, or &"true"&, authentication succeeds. For any
27679 other result, a temporary error code is returned, with the expanded string as
27680 the error text.
27681
27682
27683 .option server_debug_print authenticators string&!! unset
27684 If this option is set and authentication debugging is enabled (see the &%-d%&
27685 command line option), the string is expanded and included in the debugging
27686 output when the authenticator is run as a server. This can help with checking
27687 out the values of variables.
27688 If expansion of the string fails, the error message is written to the debugging
27689 output, and Exim carries on processing.
27690
27691
27692 .option server_set_id authenticators string&!! unset
27693 .vindex "&$authenticated_id$&"
27694 .vindex "&$authenticated_fail_id$&"
27695 When an Exim server successfully authenticates a client, this string is
27696 expanded using data from the authentication, and preserved for any incoming
27697 messages in the variable &$authenticated_id$&. It is also included in the log
27698 lines for incoming messages. For example, a user/password authenticator
27699 configuration might preserve the user name that was used to authenticate, and
27700 refer to it subsequently during delivery of the message.
27701 On a failing authentication the expansion result is instead saved in
27702 the &$authenticated_fail_id$& variable.
27703 If expansion fails, the option is ignored.
27704
27705
27706 .option server_mail_auth_condition authenticators string&!! unset
27707 This option allows a server to discard authenticated sender addresses supplied
27708 as part of MAIL commands in SMTP connections that are authenticated by the
27709 driver on which &%server_mail_auth_condition%& is set. The option is not used
27710 as part of the authentication process; instead its (unexpanded) value is
27711 remembered for later use.
27712 How it is used is described in the following section.
27713
27714
27715
27716
27717
27718 .section "The AUTH parameter on MAIL commands" "SECTauthparamail"
27719 .cindex "authentication" "sender; authenticated"
27720 .cindex "AUTH" "on MAIL command"
27721 When a client supplied an AUTH= item on a MAIL command, Exim applies
27722 the following checks before accepting it as the authenticated sender of the
27723 message:
27724
27725 .ilist
27726 If the connection is not using extended SMTP (that is, HELO was used rather
27727 than EHLO), the use of AUTH= is a syntax error.
27728 .next
27729 If the value of the AUTH= parameter is &"<>"&, it is ignored.
27730 .next
27731 .vindex "&$authenticated_sender$&"
27732 If &%acl_smtp_mailauth%& is defined, the ACL it specifies is run. While it is
27733 running, the value of &$authenticated_sender$& is set to the value obtained
27734 from the AUTH= parameter. If the ACL does not yield &"accept"&, the value of
27735 &$authenticated_sender$& is deleted. The &%acl_smtp_mailauth%& ACL may not
27736 return &"drop"& or &"discard"&. If it defers, a temporary error code (451) is
27737 given for the MAIL command.
27738 .next
27739 If &%acl_smtp_mailauth%& is not defined, the value of the AUTH= parameter
27740 is accepted and placed in &$authenticated_sender$& only if the client has
27741 authenticated.
27742 .next
27743 If the AUTH= value was accepted by either of the two previous rules, and
27744 the client has authenticated, and the authenticator has a setting for the
27745 &%server_mail_auth_condition%&, the condition is checked at this point. The
27746 valued that was saved from the authenticator is expanded. If the expansion
27747 fails, or yields an empty string, &"0"&, &"no"&, or &"false"&, the value of
27748 &$authenticated_sender$& is deleted. If the expansion yields any other value,
27749 the value of &$authenticated_sender$& is retained and passed on with the
27750 message.
27751 .endlist
27752
27753
27754 When &$authenticated_sender$& is set for a message, it is passed on to other
27755 hosts to which Exim authenticates as a client. Do not confuse this value with
27756 &$authenticated_id$&, which is a string obtained from the authentication
27757 process, and which is not usually a complete email address.
27758
27759 .vindex "&$sender_address$&"
27760 Whenever an AUTH= value is ignored, the incident is logged. The ACL for
27761 MAIL, if defined, is run after AUTH= is accepted or ignored. It can
27762 therefore make use of &$authenticated_sender$&. The converse is not true: the
27763 value of &$sender_address$& is not yet set up when the &%acl_smtp_mailauth%&
27764 ACL is run.
27765
27766
27767
27768 .section "Authentication on an Exim server" "SECTauthexiser"
27769 .cindex "authentication" "on an Exim server"
27770 When Exim receives an EHLO command, it advertises the public names of those
27771 authenticators that are configured as servers, subject to the following
27772 conditions:
27773
27774 .ilist
27775 The client host must match &%auth_advertise_hosts%& (default *).
27776 .next
27777 If the &%server_advertise_condition%& option is set, its expansion must not
27778 yield the empty string, &"0"&, &"no"&, or &"false"&.
27779 .endlist
27780
27781 The order in which the authenticators are defined controls the order in which
27782 the mechanisms are advertised.
27783
27784 Some mail clients (for example, some versions of Netscape) require the user to
27785 provide a name and password for authentication whenever AUTH is advertised,
27786 even though authentication may not in fact be needed (for example, Exim may be
27787 set up to allow unconditional relaying from the client by an IP address check).
27788 You can make such clients more friendly by not advertising AUTH to them.
27789 For example, if clients on the 10.9.8.0/24 network are permitted (by the ACL
27790 that runs for RCPT) to relay without authentication, you should set
27791 .code
27792 auth_advertise_hosts = ! 10.9.8.0/24
27793 .endd
27794 so that no authentication mechanisms are advertised to them.
27795
27796 The &%server_advertise_condition%& controls the advertisement of individual
27797 authentication mechanisms. For example, it can be used to restrict the
27798 advertisement of a particular mechanism to encrypted connections, by a setting
27799 such as:
27800 .code
27801 server_advertise_condition = ${if eq{$tls_in_cipher}{}{no}{yes}}
27802 .endd
27803 .vindex "&$tls_in_cipher$&"
27804 If the session is encrypted, &$tls_in_cipher$& is not empty, and so the expansion
27805 yields &"yes"&, which allows the advertisement to happen.
27806
27807 When an Exim server receives an AUTH command from a client, it rejects it
27808 immediately if AUTH was not advertised in response to an earlier EHLO
27809 command. This is the case if
27810
27811 .ilist
27812 The client host does not match &%auth_advertise_hosts%&; or
27813 .next
27814 No authenticators are configured with server options; or
27815 .next
27816 Expansion of &%server_advertise_condition%& blocked the advertising of all the
27817 server authenticators.
27818 .endlist
27819
27820
27821 Otherwise, Exim runs the ACL specified by &%acl_smtp_auth%& in order
27822 to decide whether to accept the command. If &%acl_smtp_auth%& is not set,
27823 AUTH is accepted from any client host.
27824
27825 If AUTH is not rejected by the ACL, Exim searches its configuration for a
27826 server authentication mechanism that was advertised in response to EHLO and
27827 that matches the one named in the AUTH command. If it finds one, it runs
27828 the appropriate authentication protocol, and authentication either succeeds or
27829 fails. If there is no matching advertised mechanism, the AUTH command is
27830 rejected with a 504 error.
27831
27832 .vindex "&$received_protocol$&"
27833 .vindex "&$sender_host_authenticated$&"
27834 When a message is received from an authenticated host, the value of
27835 &$received_protocol$& is set to &"esmtpa"& or &"esmtpsa"& instead of &"esmtp"&
27836 or &"esmtps"&, and &$sender_host_authenticated$& contains the name (not the
27837 public name) of the authenticator driver that successfully authenticated the
27838 client from which the message was received. This variable is empty if there was
27839 no successful authentication.
27840
27841 .cindex authentication "expansion item"
27842 Successful authentication sets up information used by the
27843 &%authresults%& expansion item.
27844
27845 .cindex authentication "failure event, server"
27846 If an authenticator is run and does not succeed,
27847 an event (see &<<CHAPevents>>&) of type "auth:fail" is raised.
27848 While the event is being processed the variables
27849 &$sender_host_authenticated$& (with the authenticator name)
27850 and &$authenticated_fail_id$& (as set by the authenticator &%server_set_id%& option)
27851 will be valid.
27852 If the event is serviced and a string is returned then the string will be logged
27853 instead of the default log line.
27854 See <<CHAPevents>> for details on events.
27855
27856
27857 .section "Testing server authentication" "SECID169"
27858 .cindex "authentication" "testing a server"
27859 .cindex "AUTH" "testing a server"
27860 .cindex "base64 encoding" "creating authentication test data"
27861 Exim's &%-bh%& option can be useful for testing server authentication
27862 configurations. The data for the AUTH command has to be sent using base64
27863 encoding. A quick way to produce such data for testing is the following Perl
27864 script:
27865 .code
27866 use MIME::Base64;
27867 printf ("%s", encode_base64(eval "\"$ARGV[0]\""));
27868 .endd
27869 .cindex "binary zero" "in authentication data"
27870 This interprets its argument as a Perl string, and then encodes it. The
27871 interpretation as a Perl string allows binary zeros, which are required for
27872 some kinds of authentication, to be included in the data. For example, a
27873 command line to run this script on such data might be
27874 .code
27875 encode '\0user\0password'
27876 .endd
27877 Note the use of single quotes to prevent the shell interpreting the
27878 backslashes, so that they can be interpreted by Perl to specify characters
27879 whose code value is zero.
27880
27881 &*Warning 1*&: If either of the user or password strings starts with an octal
27882 digit, you must use three zeros instead of one after the leading backslash. If
27883 you do not, the octal digit that starts your string will be incorrectly
27884 interpreted as part of the code for the first character.
27885
27886 &*Warning 2*&: If there are characters in the strings that Perl interprets
27887 specially, you must use a Perl escape to prevent them being misinterpreted. For
27888 example, a command such as
27889 .code
27890 encode '\0user@domain.com\0pas$$word'
27891 .endd
27892 gives an incorrect answer because of the unescaped &"@"& and &"$"& characters.
27893
27894 If you have the &%mimencode%& command installed, another way to produce
27895 base64-encoded strings is to run the command
27896 .code
27897 echo -e -n `\0user\0password' | mimencode
27898 .endd
27899 The &%-e%& option of &%echo%& enables the interpretation of backslash escapes
27900 in the argument, and the &%-n%& option specifies no newline at the end of its
27901 output. However, not all versions of &%echo%& recognize these options, so you
27902 should check your version before relying on this suggestion.
27903
27904
27905
27906 .section "Authentication by an Exim client" "SECID170"
27907 .cindex "authentication" "on an Exim client"
27908 The &(smtp)& transport has two options called &%hosts_require_auth%& and
27909 &%hosts_try_auth%&. When the &(smtp)& transport connects to a server that
27910 announces support for authentication, and the host matches an entry in either
27911 of these options, Exim (as a client) tries to authenticate as follows:
27912
27913 .ilist
27914 For each authenticator that is configured as a client, in the order in which
27915 they are defined in the configuration, it searches the authentication
27916 mechanisms announced by the server for one whose name matches the public name
27917 of the authenticator.
27918 .next
27919 .vindex "&$host$&"
27920 .vindex "&$host_address$&"
27921 When it finds one that matches, it runs the authenticator's client code. The
27922 variables &$host$& and &$host_address$& are available for any string expansions
27923 that the client might do. They are set to the server's name and IP address. If
27924 any expansion is forced to fail, the authentication attempt is abandoned, and
27925 Exim moves on to the next authenticator. Otherwise an expansion failure causes
27926 delivery to be deferred.
27927 .next
27928 If the result of the authentication attempt is a temporary error or a timeout,
27929 Exim abandons trying to send the message to the host for the moment. It will
27930 try again later. If there are any backup hosts available, they are tried in the
27931 usual way.
27932
27933 .next
27934 .cindex authentication "failure event, client"
27935 If the response to authentication is a permanent error (5&'xx'& code),
27936 an event (see &<<CHAPevents>>&) of type "auth:fail" is raised.
27937 While the event is being processed the variable
27938 &$sender_host_authenticated$& (with the authenticator name)
27939 will be valid.
27940 If the event is serviced and a string is returned then the string will be logged.
27941 See <<CHAPevents>> for details on events.
27942
27943 .next
27944 If the response to authentication is a permanent error (5&'xx'& code), Exim
27945 carries on searching the list of authenticators and tries another one if
27946 possible. If all authentication attempts give permanent errors, or if there are
27947 no attempts because no mechanisms match (or option expansions force failure),
27948 what happens depends on whether the host matches &%hosts_require_auth%& or
27949 &%hosts_try_auth%&. In the first case, a temporary error is generated, and
27950 delivery is deferred. The error can be detected in the retry rules, and thereby
27951 turned into a permanent error if you wish. In the second case, Exim tries to
27952 deliver the message unauthenticated.
27953 .endlist
27954
27955 Note that the hostlist test for whether to do authentication can be
27956 confused if name-IP lookups change between the time the peer is decided
27957 upon and the time that the transport runs.  For example, with a manualroute
27958 router given a host name, and with DNS "round-robin" used by that name: if
27959 the local resolver cache times out between the router and the transport
27960 running, the transport may get an IP for the name for its authentication
27961 check which does not match the connection peer IP.
27962 No authentication will then be done, despite the names being identical.
27963
27964 For such cases use a separate transport which always authenticates.
27965
27966 .cindex "AUTH" "on MAIL command"
27967 When Exim has authenticated itself to a remote server, it adds the AUTH
27968 parameter to the MAIL commands it sends, if it has an authenticated sender for
27969 the message. If the message came from a remote host, the authenticated sender
27970 is the one that was receiving on an incoming MAIL command, provided that the
27971 incoming connection was authenticated and the &%server_mail_auth%& condition
27972 allowed the authenticated sender to be retained. If a local process calls Exim
27973 to send a message, the sender address that is built from the login name and
27974 &%qualify_domain%& is treated as authenticated. However, if the
27975 &%authenticated_sender%& option is set on the &(smtp)& transport, it overrides
27976 the authenticated sender that was received with the message.
27977 .ecindex IIDauthconf1
27978 .ecindex IIDauthconf2
27979
27980
27981
27982
27983
27984
27985 . ////////////////////////////////////////////////////////////////////////////
27986 . ////////////////////////////////////////////////////////////////////////////
27987
27988 .chapter "The plaintext authenticator" "CHAPplaintext"
27989 .scindex IIDplaiauth1 "&(plaintext)& authenticator"
27990 .scindex IIDplaiauth2 "authenticators" "&(plaintext)&"
27991 The &(plaintext)& authenticator can be configured to support the PLAIN and
27992 LOGIN authentication mechanisms, both of which transfer authentication data as
27993 plain (unencrypted) text (though base64 encoded). The use of plain text is a
27994 security risk; you are strongly advised to insist on the use of SMTP encryption
27995 (see chapter &<<CHAPTLS>>&) if you use the PLAIN or LOGIN mechanisms. If you do
27996 use unencrypted plain text, you should not use the same passwords for SMTP
27997 connections as you do for login accounts.
27998
27999 .section "Avoiding cleartext use" "SECTplain_TLS"
28000 The following generic option settings will disable &(plaintext)& authenticators when
28001 TLS is not being used:
28002 .code
28003   server_advertise_condition = ${if def:tls_in_cipher }
28004   client_condition =           ${if def:tls_out_cipher}
28005 .endd
28006
28007 &*Note*&: a plaintext SMTP AUTH done inside TLS is not vulnerable to casual snooping,
28008 but is still vulnerable to a Man In The Middle attack unless certificates
28009 (including their names) have been properly verified.
28010
28011 .section "Plaintext server options" "SECID171"
28012 .cindex "options" "&(plaintext)& authenticator (server)"
28013 When configured as a server, &(plaintext)& uses the following options:
28014
28015 .option server_condition authenticators string&!! unset
28016 This is actually a global authentication option, but it must be set in order to
28017 configure the &(plaintext)& driver as a server. Its use is described below.
28018
28019 .option server_prompts plaintext "string list&!!" unset
28020 The contents of this option, after expansion, must be a colon-separated list of
28021 prompt strings. If expansion fails, a temporary authentication rejection is
28022 given.
28023
28024 .section "Using plaintext in a server" "SECTplainserver"
28025 .cindex "AUTH" "in &(plaintext)& authenticator"
28026 .cindex "binary zero" "in &(plaintext)& authenticator"
28027 .cindex "numerical variables (&$1$& &$2$& etc)" &&&
28028         "in &(plaintext)& authenticator"
28029 .vindex "&$auth1$&, &$auth2$&, etc"
28030 .cindex "base64 encoding" "in &(plaintext)& authenticator"
28031
28032 When running as a server, &(plaintext)& performs the authentication test by
28033 expanding a string. The data sent by the client with the AUTH command, or in
28034 response to subsequent prompts, is base64 encoded, and so may contain any byte
28035 values when decoded. If any data is supplied with the command, it is treated as
28036 a list of strings, separated by NULs (binary zeros), the first three of which
28037 are placed in the expansion variables &$auth1$&, &$auth2$&, and &$auth3$&
28038 (neither LOGIN nor PLAIN uses more than three strings).
28039
28040 For compatibility with previous releases of Exim, the values are also placed in
28041 the expansion variables &$1$&, &$2$&, and &$3$&. However, the use of these
28042 variables for this purpose is now deprecated, as it can lead to confusion in
28043 string expansions that also use them for other things.
28044
28045 If there are more strings in &%server_prompts%& than the number of strings
28046 supplied with the AUTH command, the remaining prompts are used to obtain more
28047 data. Each response from the client may be a list of NUL-separated strings.
28048
28049 .vindex "&$authenticated_id$&"
28050 Once a sufficient number of data strings have been received,
28051 &%server_condition%& is expanded. If the expansion is forced to fail,
28052 authentication fails. Any other expansion failure causes a temporary error code
28053 to be returned. If the result of a successful expansion is an empty string,
28054 &"0"&, &"no"&, or &"false"&, authentication fails. If the result of the
28055 expansion is &"1"&, &"yes"&, or &"true"&, authentication succeeds and the
28056 generic &%server_set_id%& option is expanded and saved in &$authenticated_id$&.
28057 For any other result, a temporary error code is returned, with the expanded
28058 string as the error text.
28059
28060 &*Warning*&: If you use a lookup in the expansion to find the user's
28061 password, be sure to make the authentication fail if the user is unknown.
28062 There are good and bad examples at the end of the next section.
28063
28064
28065
28066 .section "The PLAIN authentication mechanism" "SECID172"
28067 .cindex "PLAIN authentication mechanism"
28068 .cindex authentication PLAIN
28069 .cindex "binary zero" "in &(plaintext)& authenticator"
28070 The PLAIN authentication mechanism (RFC 2595) specifies that three strings be
28071 sent as one item of data (that is, one combined string containing two NUL
28072 separators). The data is sent either as part of the AUTH command, or
28073 subsequently in response to an empty prompt from the server.
28074
28075 The second and third strings are a user name and a corresponding password.
28076 Using a single fixed user name and password as an example, this could be
28077 configured as follows:
28078 .code
28079 fixed_plain:
28080   driver = plaintext
28081   public_name = PLAIN
28082   server_prompts = :
28083   server_condition = \
28084     ${if and {{eq{$auth2}{username}}{eq{$auth3}{mysecret}}}}
28085   server_set_id = $auth2
28086 .endd
28087 Note that the default result strings from &%if%& (&"true"& or an empty string)
28088 are exactly what we want here, so they need not be specified. Obviously, if the
28089 password contains expansion-significant characters such as dollar, backslash,
28090 or closing brace, they have to be escaped.
28091
28092 The &%server_prompts%& setting specifies a single, empty prompt (empty items at
28093 the end of a string list are ignored). If all the data comes as part of the
28094 AUTH command, as is commonly the case, the prompt is not used. This
28095 authenticator is advertised in the response to EHLO as
28096 .code
28097 250-AUTH PLAIN
28098 .endd
28099 and a client host can authenticate itself by sending the command
28100 .code
28101 AUTH PLAIN AHVzZXJuYW1lAG15c2VjcmV0
28102 .endd
28103 As this contains three strings (more than the number of prompts), no further
28104 data is required from the client. Alternatively, the client may just send
28105 .code
28106 AUTH PLAIN
28107 .endd
28108 to initiate authentication, in which case the server replies with an empty
28109 prompt. The client must respond with the combined data string.
28110
28111 The data string is base64 encoded, as required by the RFC. This example,
28112 when decoded, is <&'NUL'&>&`username`&<&'NUL'&>&`mysecret`&, where <&'NUL'&>
28113 represents a zero byte. This is split up into three strings, the first of which
28114 is empty. The &%server_condition%& option in the authenticator checks that the
28115 second two are &`username`& and &`mysecret`& respectively.
28116
28117 Having just one fixed user name and password, as in this example, is not very
28118 realistic, though for a small organization with only a handful of
28119 authenticating clients it could make sense.
28120
28121 A more sophisticated instance of this authenticator could use the user name in
28122 &$auth2$& to look up a password in a file or database, and maybe do an encrypted
28123 comparison (see &%crypteq%& in chapter &<<CHAPexpand>>&). Here is a example of
28124 this approach, where the passwords are looked up in a DBM file. &*Warning*&:
28125 This is an incorrect example:
28126 .code
28127 server_condition = \
28128   ${if eq{$auth3}{${lookup{$auth2}dbm{/etc/authpwd}}}}
28129 .endd
28130 The expansion uses the user name (&$auth2$&) as the key to look up a password,
28131 which it then compares to the supplied password (&$auth3$&). Why is this example
28132 incorrect? It works fine for existing users, but consider what happens if a
28133 non-existent user name is given. The lookup fails, but as no success/failure
28134 strings are given for the lookup, it yields an empty string. Thus, to defeat
28135 the authentication, all a client has to do is to supply a non-existent user
28136 name and an empty password. The correct way of writing this test is:
28137 .code
28138 server_condition = ${lookup{$auth2}dbm{/etc/authpwd}\
28139   {${if eq{$value}{$auth3}}} {false}}
28140 .endd
28141 In this case, if the lookup succeeds, the result is checked; if the lookup
28142 fails, &"false"& is returned and authentication fails. If &%crypteq%& is being
28143 used instead of &%eq%&, the first example is in fact safe, because &%crypteq%&
28144 always fails if its second argument is empty. However, the second way of
28145 writing the test makes the logic clearer.
28146
28147
28148 .section "The LOGIN authentication mechanism" "SECID173"
28149 .cindex "LOGIN authentication mechanism"
28150 .cindex authentication LOGIN
28151 The LOGIN authentication mechanism is not documented in any RFC, but is in use
28152 in a number of programs. No data is sent with the AUTH command. Instead, a
28153 user name and password are supplied separately, in response to prompts. The
28154 plaintext authenticator can be configured to support this as in this example:
28155 .code
28156 fixed_login:
28157   driver = plaintext
28158   public_name = LOGIN
28159   server_prompts = User Name : Password
28160   server_condition = \
28161     ${if and {{eq{$auth1}{username}}{eq{$auth2}{mysecret}}}}
28162   server_set_id = $auth1
28163 .endd
28164 Because of the way plaintext operates, this authenticator accepts data supplied
28165 with the AUTH command (in contravention of the specification of LOGIN), but
28166 if the client does not supply it (as is the case for LOGIN clients), the prompt
28167 strings are used to obtain two data items.
28168
28169 Some clients are very particular about the precise text of the prompts. For
28170 example, Outlook Express is reported to recognize only &"Username:"& and
28171 &"Password:"&. Here is an example of a LOGIN authenticator that uses those
28172 strings. It uses the &%ldapauth%& expansion condition to check the user
28173 name and password by binding to an LDAP server:
28174 .code
28175 login:
28176   driver = plaintext
28177   public_name = LOGIN
28178   server_prompts = Username:: : Password::
28179   server_condition = ${if and{{ \
28180     !eq{}{$auth1} }{ \
28181     ldapauth{\
28182       user="uid=${quote_ldap_dn:$auth1},ou=people,o=example.org" \
28183       pass=${quote:$auth2} \
28184       ldap://ldap.example.org/} }} }
28185   server_set_id = uid=$auth1,ou=people,o=example.org
28186 .endd
28187 We have to check that the username is not empty before using it, because LDAP
28188 does not permit empty DN components. We must also use the &%quote_ldap_dn%&
28189 operator to correctly quote the DN for authentication. However, the basic
28190 &%quote%& operator, rather than any of the LDAP quoting operators, is the
28191 correct one to use for the password, because quoting is needed only to make
28192 the password conform to the Exim syntax. At the LDAP level, the password is an
28193 uninterpreted string.
28194
28195
28196 .section "Support for different kinds of authentication" "SECID174"
28197 A number of string expansion features are provided for the purpose of
28198 interfacing to different ways of user authentication. These include checking
28199 traditionally encrypted passwords from &_/etc/passwd_& (or equivalent), PAM,
28200 Radius, &%ldapauth%&, &'pwcheck'&, and &'saslauthd'&. For details see section
28201 &<<SECTexpcond>>&.
28202
28203
28204
28205
28206 .section "Using plaintext in a client" "SECID175"
28207 .cindex "options" "&(plaintext)& authenticator (client)"
28208 The &(plaintext)& authenticator has two client options:
28209
28210 .option client_ignore_invalid_base64 plaintext boolean false
28211 If the client receives a server prompt that is not a valid base64 string,
28212 authentication is abandoned by default. However, if this option is set true,
28213 the error in the challenge is ignored and the client sends the response as
28214 usual.
28215
28216 .option client_send plaintext string&!! unset
28217 The string is a colon-separated list of authentication data strings. Each
28218 string is independently expanded before being sent to the server. The first
28219 string is sent with the AUTH command; any more strings are sent in response
28220 to prompts from the server. Before each string is expanded, the value of the
28221 most recent prompt is placed in the next &$auth$&<&'n'&> variable, starting
28222 with &$auth1$& for the first prompt. Up to three prompts are stored in this
28223 way. Thus, the prompt that is received in response to sending the first string
28224 (with the AUTH command) can be used in the expansion of the second string, and
28225 so on. If an invalid base64 string is received when
28226 &%client_ignore_invalid_base64%& is set, an empty string is put in the
28227 &$auth$&<&'n'&> variable.
28228
28229 &*Note*&: You cannot use expansion to create multiple strings, because
28230 splitting takes priority and happens first.
28231
28232 Because the PLAIN authentication mechanism requires NUL (binary zero) bytes in
28233 the data, further processing is applied to each string before it is sent. If
28234 there are any single circumflex characters in the string, they are converted to
28235 NULs. Should an actual circumflex be required as data, it must be doubled in
28236 the string.
28237
28238 This is an example of a client configuration that implements the PLAIN
28239 authentication mechanism with a fixed user name and password:
28240 .code
28241 fixed_plain:
28242   driver = plaintext
28243   public_name = PLAIN
28244   client_send = ^username^mysecret
28245 .endd
28246 The lack of colons means that the entire text is sent with the AUTH
28247 command, with the circumflex characters converted to NULs.
28248 Note that due to the ambiguity of parsing three consectutive circumflex characters
28249 there is no way to provide a password having a leading circumflex.
28250
28251
28252 A similar example
28253 that uses the LOGIN mechanism is:
28254 .code
28255 fixed_login:
28256   driver = plaintext
28257   public_name = LOGIN
28258   client_send = : username : mysecret
28259 .endd
28260 The initial colon means that the first string is empty, so no data is sent with
28261 the AUTH command itself. The remaining strings are sent in response to
28262 prompts.
28263 .ecindex IIDplaiauth1
28264 .ecindex IIDplaiauth2
28265
28266
28267
28268
28269 . ////////////////////////////////////////////////////////////////////////////
28270 . ////////////////////////////////////////////////////////////////////////////
28271
28272 .chapter "The cram_md5 authenticator" "CHID9"
28273 .scindex IIDcramauth1 "&(cram_md5)& authenticator"
28274 .scindex IIDcramauth2 "authenticators" "&(cram_md5)&"
28275 .cindex "CRAM-MD5 authentication mechanism"
28276 .cindex authentication CRAM-MD5
28277 The CRAM-MD5 authentication mechanism is described in RFC 2195. The server
28278 sends a challenge string to the client, and the response consists of a user
28279 name and the CRAM-MD5 digest of the challenge string combined with a secret
28280 string (password) which is known to both server and client. Thus, the secret
28281 is not sent over the network as plain text, which makes this authenticator more
28282 secure than &(plaintext)&. However, the downside is that the secret has to be
28283 available in plain text at either end.
28284
28285
28286 .section "Using cram_md5 as a server" "SECID176"
28287 .cindex "options" "&(cram_md5)& authenticator (server)"
28288 This authenticator has one server option, which must be set to configure the
28289 authenticator as a server:
28290
28291 .option server_secret cram_md5 string&!! unset
28292 .cindex "numerical variables (&$1$& &$2$& etc)" "in &(cram_md5)& authenticator"
28293 When the server receives the client's response, the user name is placed in
28294 the expansion variable &$auth1$&, and &%server_secret%& is expanded to
28295 obtain the password for that user. The server then computes the CRAM-MD5 digest
28296 that the client should have sent, and checks that it received the correct
28297 string. If the expansion of &%server_secret%& is forced to fail, authentication
28298 fails. If the expansion fails for some other reason, a temporary error code is
28299 returned to the client.
28300
28301 For compatibility with previous releases of Exim, the user name is also placed
28302 in &$1$&. However, the use of this variables for this purpose is now
28303 deprecated, as it can lead to confusion in string expansions that also use
28304 numeric variables for other things.
28305
28306 For example, the following authenticator checks that the user name given by the
28307 client is &"ph10"&, and if so, uses &"secret"& as the password. For any other
28308 user name, authentication fails.
28309 .code
28310 fixed_cram:
28311   driver = cram_md5
28312   public_name = CRAM-MD5
28313   server_secret = ${if eq{$auth1}{ph10}{secret}fail}
28314   server_set_id = $auth1
28315 .endd
28316 .vindex "&$authenticated_id$&"
28317 If authentication succeeds, the setting of &%server_set_id%& preserves the user
28318 name in &$authenticated_id$&. A more typical configuration might look up the
28319 secret string in a file, using the user name as the key. For example:
28320 .code
28321 lookup_cram:
28322   driver = cram_md5
28323   public_name = CRAM-MD5
28324   server_secret = ${lookup{$auth1}lsearch{/etc/authpwd}\
28325                   {$value}fail}
28326   server_set_id = $auth1
28327 .endd
28328 Note that this expansion explicitly forces failure if the lookup fails
28329 because &$auth1$& contains an unknown user name.
28330
28331 As another example, if you wish to re-use a Cyrus SASL sasldb2 file without
28332 using the relevant libraries, you need to know the realm to specify in the
28333 lookup and then ask for the &"userPassword"& attribute for that user in that
28334 realm, with:
28335 .code
28336 cyrusless_crammd5:
28337   driver = cram_md5
28338   public_name = CRAM-MD5
28339   server_secret = ${lookup{$auth1:mail.example.org:userPassword}\
28340                   dbmjz{/etc/sasldb2}{$value}fail}
28341   server_set_id = $auth1
28342 .endd
28343
28344 .section "Using cram_md5 as a client" "SECID177"
28345 .cindex "options" "&(cram_md5)& authenticator (client)"
28346 When used as a client, the &(cram_md5)& authenticator has two options:
28347
28348
28349
28350 .option client_name cram_md5 string&!! "the primary host name"
28351 This string is expanded, and the result used as the user name data when
28352 computing the response to the server's challenge.
28353
28354
28355 .option client_secret cram_md5 string&!! unset
28356 This option must be set for the authenticator to work as a client. Its value is
28357 expanded and the result used as the secret string when computing the response.
28358
28359
28360 .vindex "&$host$&"
28361 .vindex "&$host_address$&"
28362 Different user names and secrets can be used for different servers by referring
28363 to &$host$& or &$host_address$& in the options. Forced failure of either
28364 expansion string is treated as an indication that this authenticator is not
28365 prepared to handle this case. Exim moves on to the next configured client
28366 authenticator. Any other expansion failure causes Exim to give up trying to
28367 send the message to the current server.
28368
28369 A simple example configuration of a &(cram_md5)& authenticator, using fixed
28370 strings, is:
28371 .code
28372 fixed_cram:
28373   driver = cram_md5
28374   public_name = CRAM-MD5
28375   client_name = ph10
28376   client_secret = secret
28377 .endd
28378 .ecindex IIDcramauth1
28379 .ecindex IIDcramauth2
28380
28381
28382
28383 . ////////////////////////////////////////////////////////////////////////////
28384 . ////////////////////////////////////////////////////////////////////////////
28385
28386 .chapter "The cyrus_sasl authenticator" "CHID10"
28387 .scindex IIDcyrauth1 "&(cyrus_sasl)& authenticator"
28388 .scindex IIDcyrauth2 "authenticators" "&(cyrus_sasl)&"
28389 .cindex "Cyrus" "SASL library"
28390 .cindex "Kerberos"
28391 The code for this authenticator was provided by Matthew Byng-Maddick while
28392 at A L Digital Ltd.
28393
28394 The &(cyrus_sasl)& authenticator provides server support for the Cyrus SASL
28395 library implementation of the RFC 2222 (&"Simple Authentication and Security
28396 Layer"&). This library supports a number of authentication mechanisms,
28397 including PLAIN and LOGIN, but also several others that Exim does not support
28398 directly. In particular, there is support for Kerberos authentication.
28399
28400 The &(cyrus_sasl)& authenticator provides a gatewaying mechanism directly to
28401 the Cyrus interface, so if your Cyrus library can do, for example, CRAM-MD5,
28402 then so can the &(cyrus_sasl)& authenticator. By default it uses the public
28403 name of the driver to determine which mechanism to support.
28404
28405 Where access to some kind of secret file is required, for example, in GSSAPI
28406 or CRAM-MD5, it is worth noting that the authenticator runs as the Exim
28407 user, and that the Cyrus SASL library has no way of escalating privileges
28408 by default. You may also find you need to set environment variables,
28409 depending on the driver you are using.
28410
28411 The application name provided by Exim is &"exim"&, so various SASL options may
28412 be set in &_exim.conf_& in your SASL directory. If you are using GSSAPI for
28413 Kerberos, note that because of limitations in the GSSAPI interface,
28414 changing the server keytab might need to be communicated down to the Kerberos
28415 layer independently. The mechanism for doing so is dependent upon the Kerberos
28416 implementation.
28417
28418 For example, for older releases of Heimdal, the environment variable KRB5_KTNAME
28419 may be set to point to an alternative keytab file. Exim will pass this
28420 variable through from its own inherited environment when started as root or the
28421 Exim user. The keytab file needs to be readable by the Exim user.
28422 With newer releases of Heimdal, a setuid Exim may cause Heimdal to discard the
28423 environment variable.  In practice, for those releases, the Cyrus authenticator
28424 is not a suitable interface for GSSAPI (Kerberos) support.  Instead, consider
28425 the &(heimdal_gssapi)& authenticator, described in chapter &<<CHAPheimdalgss>>&
28426
28427
28428 .section "Using cyrus_sasl as a server" "SECID178"
28429 The &(cyrus_sasl)& authenticator has four private options. It puts the username
28430 (on a successful authentication) into &$auth1$&. For compatibility with
28431 previous releases of Exim, the username is also placed in &$1$&. However, the
28432 use of this variable for this purpose is now deprecated, as it can lead to
28433 confusion in string expansions that also use numeric variables for other
28434 things.
28435
28436
28437 .option server_hostname cyrus_sasl string&!! "see below"
28438 This option selects the hostname that is used when communicating with the
28439 library. The default value is &`$primary_hostname`&. It is up to the underlying
28440 SASL plug-in what it does with this data.
28441
28442
28443 .option server_mech cyrus_sasl string "see below"
28444 This option selects the authentication mechanism this driver should use. The
28445 default is the value of the generic &%public_name%& option. This option allows
28446 you to use a different underlying mechanism from the advertised name. For
28447 example:
28448 .code
28449 sasl:
28450   driver = cyrus_sasl
28451   public_name = X-ANYTHING
28452   server_mech = CRAM-MD5
28453   server_set_id = $auth1
28454 .endd
28455
28456 .option server_realm cyrus_sasl string&!! unset
28457 This specifies the SASL realm that the server claims to be in.
28458
28459
28460 .option server_service cyrus_sasl string &`smtp`&
28461 This is the SASL service that the server claims to implement.
28462
28463
28464 For straightforward cases, you do not need to set any of the authenticator's
28465 private options. All you need to do is to specify an appropriate mechanism as
28466 the public name. Thus, if you have a SASL library that supports CRAM-MD5 and
28467 PLAIN, you could have two authenticators as follows:
28468 .code
28469 sasl_cram_md5:
28470   driver = cyrus_sasl
28471   public_name = CRAM-MD5
28472   server_set_id = $auth1
28473
28474 sasl_plain:
28475   driver = cyrus_sasl
28476   public_name = PLAIN
28477   server_set_id = $auth2
28478 .endd
28479 Cyrus SASL does implement the LOGIN authentication method, even though it is
28480 not a standard method. It is disabled by default in the source distribution,
28481 but it is present in many binary distributions.
28482 .ecindex IIDcyrauth1
28483 .ecindex IIDcyrauth2
28484
28485
28486
28487
28488 . ////////////////////////////////////////////////////////////////////////////
28489 . ////////////////////////////////////////////////////////////////////////////
28490 .chapter "The dovecot authenticator" "CHAPdovecot"
28491 .scindex IIDdcotauth1 "&(dovecot)& authenticator"
28492 .scindex IIDdcotauth2 "authenticators" "&(dovecot)&"
28493 This authenticator is an interface to the authentication facility of the
28494 Dovecot 2 POP/IMAP server, which can support a number of authentication methods.
28495 Note that Dovecot must be configured to use auth-client not auth-userdb.
28496 If you are using Dovecot to authenticate POP/IMAP clients, it might be helpful
28497 to use the same mechanisms for SMTP authentication. This is a server
28498 authenticator only. There is only one non-generic option:
28499
28500 .option server_socket dovecot string unset
28501
28502 This option must specify the UNIX socket that is the interface to Dovecot
28503 authentication. The &%public_name%& option must specify an authentication
28504 mechanism that Dovecot is configured to support. You can have several
28505 authenticators for different mechanisms. For example:
28506 .code
28507 dovecot_plain:
28508   driver = dovecot
28509   public_name = PLAIN
28510   server_advertise_condition = ${if def:tls_in_cipher}
28511   server_socket = /var/run/dovecot/auth-client
28512   server_set_id = $auth1
28513
28514 dovecot_ntlm:
28515   driver = dovecot
28516   public_name = NTLM
28517   server_socket = /var/run/dovecot/auth-client
28518   server_set_id = $auth1
28519 .endd
28520
28521 &*Note*&: plaintext authentication methods such as PLAIN and LOGIN
28522 should not be advertised on cleartext SMTP connections.
28523 See the discussion in section &<<SECTplain_TLS>>&.
28524
28525 If the SMTP connection is encrypted, or if &$sender_host_address$& is equal to
28526 &$received_ip_address$& (that is, the connection is local), the &"secured"&
28527 option is passed in the Dovecot authentication command. If, for a TLS
28528 connection, a client certificate has been verified, the &"valid-client-cert"&
28529 option is passed. When authentication succeeds, the identity of the user
28530 who authenticated is placed in &$auth1$&.
28531
28532 The Dovecot configuration to match the above will look
28533 something like:
28534 .code
28535 conf.d/10-master.conf :-
28536
28537 service auth {
28538 ...
28539 #SASL
28540   unix_listener auth-client {
28541     mode = 0660
28542     user = mail
28543   }
28544 ...
28545 }
28546
28547 conf.d/10-auth.conf :-
28548
28549 auth_mechanisms = plain login ntlm
28550 .endd
28551
28552 .ecindex IIDdcotauth1
28553 .ecindex IIDdcotauth2
28554
28555
28556 . ////////////////////////////////////////////////////////////////////////////
28557 . ////////////////////////////////////////////////////////////////////////////
28558 .chapter "The gsasl authenticator" "CHAPgsasl"
28559 .scindex IIDgsaslauth1 "&(gsasl)& authenticator"
28560 .scindex IIDgsaslauth2 "authenticators" "&(gsasl)&"
28561 .cindex "authentication" "GNU SASL"
28562 .cindex "authentication" "SASL"
28563 .cindex "authentication" "EXTERNAL"
28564 .cindex "authentication" "ANONYMOUS"
28565 .cindex "authentication" "PLAIN"
28566 .cindex "authentication" "LOGIN"
28567 .cindex "authentication" "DIGEST-MD5"
28568 .cindex "authentication" "CRAM-MD5"
28569 .cindex "authentication" "SCRAM family"
28570 The &(gsasl)& authenticator provides integration for the GNU SASL
28571 library and the mechanisms it provides.  This is new as of the 4.80 release
28572 and there are a few areas where the library does not let Exim smoothly
28573 scale to handle future authentication mechanisms, so no guarantee can be
28574 made that any particular new authentication mechanism will be supported
28575 without code changes in Exim.
28576
28577 The library is expected to add support in an upcoming
28578 realease for the SCRAM-SHA-256 method.
28579 The macro _HAVE_AUTH_GSASL_SCRAM_SHA_256 will be defined
28580 when this happens.
28581
28582 To see the list of mechanisms supported by the library run Exim with "auth" debug
28583 enabled and look for a line containing "GNU SASL supports".
28584 Note however that some may not have been tested from Exim.
28585
28586
28587 .option client_authz gsasl string&!! unset
28588 This option can be used to supply an &'authorization id'&
28589 which is different to the &'authentication_id'& provided
28590 by &%client_username%& option.
28591 If unset or (after expansion) empty it is not used,
28592 which is the common case.
28593
28594 .option client_channelbinding gsasl boolean false
28595 See &%server_channelbinding%& below.
28596
28597 .option client_password gsasl string&!! unset
28598 This option is exapanded before use, and should result in
28599 the password to be used, in clear.
28600
28601 .option client_username gsasl string&!! unset
28602 This option is exapanded before use, and should result in
28603 the account name to be used.
28604
28605
28606 .option client_spassword gsasl string&!! unset
28607 This option is only supported for library versions 1.9.1 and greater.
28608 The macro _HAVE_AUTH_GSASL_SCRAM_S_KEY will be defined when this is so.
28609
28610 If a SCRAM mechanism is being used and this option is set
28611 and correctly sized
28612 it is used in preference to &%client_password%&.
28613 The value after expansion should be
28614 a 40 (for SHA-1) or 64 (for SHA-256) character string
28615 with the PBKDF2-prepared password, hex-encoded.
28616
28617 Note that this value will depend on the salt and iteration-count
28618 supplied by the server.
28619 The option is expanded before use.
28620 During the expansion &$auth1$& is set with the client username,
28621 &$auth2$& with the iteration count, and
28622 &$auth3$& with the salt.
28623
28624 The intent of this option
28625 is to support clients that can cache thes salted password
28626 to save on recalculation costs.
28627 The cache lookup should return an unusable value
28628 (eg. an empty string)
28629 if the salt or iteration count has changed
28630
28631 If the authentication succeeds then the above variables are set,
28632 .vindex "&$auth4$&"
28633 plus the calculated salted password value value in &$auth4$&,
28634 during the expansion of the &%client_set_id%& option.
28635 A side-effect of this expansion can be used to prime the cache.
28636
28637
28638 .option server_channelbinding gsasl boolean false
28639 Some authentication mechanisms are able to use external context at both ends
28640 of the session to bind the authentication to that context, and fail the
28641 authentication process if that context differs.  Specifically, some TLS
28642 ciphersuites can provide identifying information about the cryptographic
28643 context.
28644
28645 This should have meant that certificate identity and verification becomes a
28646 non-issue, as a man-in-the-middle attack will cause the correct client and
28647 server to see different identifiers and authentication will fail.
28648
28649 This is
28650 only usable by mechanisms which support "channel binding"; at time of
28651 writing, that's the SCRAM family.
28652 When using this feature the "-PLUS" variants of the method names need to be used.
28653
28654 This defaults off to ensure smooth upgrade across Exim releases, in case
28655 this option causes some clients to start failing.  Some future release
28656 of Exim might have switched the default to be true.
28657
28658 . However, Channel Binding in TLS has proven to be vulnerable in current versions.
28659 . Do not plan to rely upon this feature for security, ever, without consulting
28660 . with a subject matter expert (a cryptographic engineer).
28661
28662 This option was deprecated in previous releases due to doubts over
28663 the "Triple Handshake" vulnerability.
28664 Exim takes suitable precausions (requiring Extended Master Secret if TLS
28665 Session Resumption was used) for safety.
28666
28667
28668 .option server_hostname gsasl string&!! "see below"
28669 This option selects the hostname that is used when communicating with the
28670 library. The default value is &`$primary_hostname`&.
28671 Some mechanisms will use this data.
28672
28673
28674 .option server_mech gsasl string "see below"
28675 This option selects the authentication mechanism this driver should use. The
28676 default is the value of the generic &%public_name%& option. This option allows
28677 you to use a different underlying mechanism from the advertised name. For
28678 example:
28679 .code
28680 sasl:
28681   driver = gsasl
28682   public_name = X-ANYTHING
28683   server_mech = CRAM-MD5
28684   server_set_id = $auth1
28685 .endd
28686
28687
28688 .option server_password gsasl string&!! unset
28689 Various mechanisms need access to the cleartext password on the server, so
28690 that proof-of-possession can be demonstrated on the wire, without sending
28691 the password itself.
28692
28693 The data available for lookup varies per mechanism.
28694 In all cases, &$auth1$& is set to the &'authentication id'&.
28695 The &$auth2$& variable will always be the &'authorization id'& (&'authz'&)
28696 if available, else the empty string.
28697 The &$auth3$& variable will always be the &'realm'& if available,
28698 else the empty string.
28699
28700 A forced failure will cause authentication to defer.
28701
28702 If using this option, it may make sense to set the &%server_condition%&
28703 option to be simply "true".
28704
28705
28706 .option server_realm gsasl string&!! unset
28707 This specifies the SASL realm that the server claims to be in.
28708 Some mechanisms will use this data.
28709
28710
28711 .option server_scram_iter gsasl string&!! 4096
28712 This option provides data for the SCRAM family of mechanisms.
28713 The &$auth1$&, &$auth2$& and &$auth3$& variables are available
28714 when this option is expanded.
28715
28716 The result of expansion should be a decimal number,
28717 and represents both a lower-bound on the security, and
28718 a compute cost factor imposed on the client
28719 (if it does not cache results, or the server changes
28720 either the iteration count or the salt).
28721 A minimum value of 4096 is required by the standards
28722 for all current SCRAM mechanism variants.
28723
28724 .option server_scram_salt gsasl string&!! unset
28725 This option provides data for the SCRAM family of mechanisms.
28726 The &$auth1$&, &$auth2$& and &$auth3$& variables are available
28727 when this option is expanded.
28728 The value should be a base64-encoded string,
28729 of random data typically 4-to-16 bytes long.
28730 If unset or empty after expansion the library will provides a value for the
28731 protocol conversation.
28732
28733
28734 .option server_key gsasl string&!! unset
28735 .option server_skey gsasl string&!! unset
28736 These options can be used for the SCRAM family of mechanisms
28737 to provide stored information related to a password,
28738 the storage of which is preferable to plaintext.
28739
28740 &%server_key%& is the value defined in the SCRAM standards as ServerKey;
28741 &%server_skey%& is StoredKey.
28742
28743 They are only available for version 1.9.0 (or later) of the gsasl library.
28744 When this is so, the macros
28745 _OPT_AUTHENTICATOR_GSASL_SERVER_KEY
28746 and _HAVE_AUTH_GSASL_SCRAM_S_KEY
28747 will be defined.
28748
28749 The &$authN$& variables are available when these options are expanded.
28750
28751 If set, the results of expansion should for each
28752 should be a 28 (for SHA-1) or 44 (for SHA-256) character string
28753 of base64-coded data, and will be used in preference to the
28754 &%server_password%& option.
28755 If unset or not of the right length, &%server_password%& will be used.
28756
28757 The libgsasl library release includes a utility &'gsasl'& which can be used
28758 to generate these values.
28759
28760
28761 .option server_service gsasl string &`smtp`&
28762 This is the SASL service that the server claims to implement.
28763 Some mechanisms will use this data.
28764
28765
28766 .section "&(gsasl)& auth variables" "SECTgsaslauthvar"
28767 .vindex "&$auth1$&, &$auth2$&, etc"
28768 These may be set when evaluating specific options, as detailed above.
28769 They will also be set when evaluating &%server_condition%&.
28770
28771 Unless otherwise stated below, the &(gsasl)& integration will use the following
28772 meanings for these variables:
28773
28774 .ilist
28775 .vindex "&$auth1$&"
28776 &$auth1$&: the &'authentication id'&
28777 .next
28778 .vindex "&$auth2$&"
28779 &$auth2$&: the &'authorization id'&
28780 .next
28781 .vindex "&$auth3$&"
28782 &$auth3$&: the &'realm'&
28783 .endlist
28784
28785 On a per-mechanism basis:
28786
28787 .ilist
28788 .cindex "authentication" "EXTERNAL"
28789 EXTERNAL: only &$auth1$& is set, to the possibly empty &'authorization id'&;
28790 the &%server_condition%& option must be present.
28791 .next
28792 .cindex "authentication" "ANONYMOUS"
28793 ANONYMOUS: only &$auth1$& is set, to the possibly empty &'anonymous token'&;
28794 the &%server_condition%& option must be present.
28795 .next
28796 .cindex "authentication" "GSSAPI"
28797 GSSAPI: &$auth1$& will be set to the &'GSSAPI Display Name'&;
28798 &$auth2$& will be set to the &'authorization id'&,
28799 the &%server_condition%& option must be present.
28800 .endlist
28801
28802 An &'anonymous token'& is something passed along as an unauthenticated
28803 identifier; this is analogous to FTP anonymous authentication passing an
28804 email address, or software-identifier@, as the "password".
28805
28806
28807 An example showing the password having the realm specified in the callback
28808 and demonstrating a Cyrus SASL to GSASL migration approach is:
28809 .code
28810 gsasl_cyrusless_crammd5:
28811   driver = gsasl
28812   public_name = CRAM-MD5
28813   server_realm = imap.example.org
28814   server_password = ${lookup{$auth1:$auth3:userPassword}\
28815                     dbmjz{/etc/sasldb2}{$value}fail}
28816   server_set_id = ${quote:$auth1}
28817   server_condition = yes
28818 .endd
28819
28820
28821 . ////////////////////////////////////////////////////////////////////////////
28822 . ////////////////////////////////////////////////////////////////////////////
28823
28824 .chapter "The heimdal_gssapi authenticator" "CHAPheimdalgss"
28825 .scindex IIDheimdalgssauth1 "&(heimdal_gssapi)& authenticator"
28826 .scindex IIDheimdalgssauth2 "authenticators" "&(heimdal_gssapi)&"
28827 .cindex "authentication" "GSSAPI"
28828 .cindex "authentication" "Kerberos"
28829 The &(heimdal_gssapi)& authenticator provides server integration for the
28830 Heimdal GSSAPI/Kerberos library, permitting Exim to set a keytab pathname
28831 reliably.
28832
28833 .option server_hostname heimdal_gssapi string&!! "see below"
28834 This option selects the hostname that is used, with &%server_service%&,
28835 for constructing the GSS server name, as a &'GSS_C_NT_HOSTBASED_SERVICE'&
28836 identifier.  The default value is &`$primary_hostname`&.
28837
28838 .option server_keytab heimdal_gssapi string&!! unset
28839 If set, then Heimdal will not use the system default keytab (typically
28840 &_/etc/krb5.keytab_&) but instead the pathname given in this option.
28841 The value should be a pathname, with no &"file:"& prefix.
28842
28843 .option server_service heimdal_gssapi string&!! "smtp"
28844 This option specifies the service identifier used, in conjunction with
28845 &%server_hostname%&, for building the identifier for finding credentials
28846 from the keytab.
28847
28848
28849 .section "&(heimdal_gssapi)& auth variables" "SECTheimdalgssauthvar"
28850 Beware that these variables will typically include a realm, thus will appear
28851 to be roughly like an email address already.  The &'authzid'& in &$auth2$& is
28852 not verified, so a malicious client can set it to anything.
28853
28854 The &$auth1$& field should be safely trustable as a value from the Key
28855 Distribution Center.  Note that these are not quite email addresses.
28856 Each identifier is for a role, and so the left-hand-side may include a
28857 role suffix.  For instance, &"joe/admin@EXAMPLE.ORG"&.
28858
28859 .vindex "&$auth1$&, &$auth2$&, etc"
28860 .ilist
28861 .vindex "&$auth1$&"
28862 &$auth1$&: the &'authentication id'&, set to the GSS Display Name.
28863 .next
28864 .vindex "&$auth2$&"
28865 &$auth2$&: the &'authorization id'&, sent within SASL encapsulation after
28866 authentication.  If that was empty, this will also be set to the
28867 GSS Display Name.
28868 .endlist
28869
28870
28871 . ////////////////////////////////////////////////////////////////////////////
28872 . ////////////////////////////////////////////////////////////////////////////
28873
28874 .chapter "The spa authenticator" "CHAPspa"
28875 .scindex IIDspaauth1 "&(spa)& authenticator"
28876 .scindex IIDspaauth2 "authenticators" "&(spa)&"
28877 .cindex "authentication" "Microsoft Secure Password"
28878 .cindex "authentication" "NTLM"
28879 .cindex "Microsoft Secure Password Authentication"
28880 .cindex "NTLM authentication"
28881 The &(spa)& authenticator provides client support for Microsoft's &'Secure
28882 Password Authentication'& mechanism,
28883 which is also sometimes known as NTLM (NT LanMan). The code for client side of
28884 this authenticator was contributed by Marc Prud'hommeaux, and much of it is
28885 taken from the Samba project (&url(https://www.samba.org/)). The code for the
28886 server side was subsequently contributed by Tom Kistner. The mechanism works as
28887 follows:
28888
28889 .ilist
28890 After the AUTH command has been accepted, the client sends an SPA
28891 authentication request based on the user name and optional domain.
28892 .next
28893 The server sends back a challenge.
28894 .next
28895 The client builds a challenge response which makes use of the user's password
28896 and sends it to the server, which then accepts or rejects it.
28897 .endlist
28898
28899 Encryption is used to protect the password in transit.
28900
28901
28902
28903 .section "Using spa as a server" "SECID179"
28904 .cindex "options" "&(spa)& authenticator (server)"
28905 The &(spa)& authenticator has just one server option:
28906
28907 .option server_password spa string&!! unset
28908 .cindex "numerical variables (&$1$& &$2$& etc)" "in &(spa)& authenticator"
28909 This option is expanded, and the result must be the cleartext password for the
28910 authenticating user, whose name is at this point in &$auth1$&. For
28911 compatibility with previous releases of Exim, the user name is also placed in
28912 &$1$&. However, the use of this variable for this purpose is now deprecated, as
28913 it can lead to confusion in string expansions that also use numeric variables
28914 for other things. For example:
28915 .code
28916 spa:
28917   driver = spa
28918   public_name = NTLM
28919   server_password = \
28920     ${lookup{$auth1}lsearch{/etc/exim/spa_clearpass}{$value}fail}
28921 .endd
28922 If the expansion is forced to fail, authentication fails. Any other expansion
28923 failure causes a temporary error code to be returned.
28924
28925
28926
28927
28928
28929 .section "Using spa as a client" "SECID180"
28930 .cindex "options" "&(spa)& authenticator (client)"
28931 The &(spa)& authenticator has the following client options:
28932
28933
28934
28935 .option client_domain spa string&!! unset
28936 This option specifies an optional domain for the authentication.
28937
28938
28939 .option client_password spa string&!! unset
28940 This option specifies the user's password, and must be set.
28941
28942
28943 .option client_username spa string&!! unset
28944 This option specifies the user name, and must be set. Here is an example of a
28945 configuration of this authenticator for use with the mail servers at
28946 &'msn.com'&:
28947 .code
28948 msn:
28949   driver = spa
28950   public_name = MSN
28951   client_username = msn/msn_username
28952   client_password = msn_plaintext_password
28953   client_domain = DOMAIN_OR_UNSET
28954 .endd
28955 .ecindex IIDspaauth1
28956 .ecindex IIDspaauth2
28957
28958
28959
28960
28961
28962 . ////////////////////////////////////////////////////////////////////////////
28963 . ////////////////////////////////////////////////////////////////////////////
28964
28965 .chapter "The external authenticator" "CHAPexternauth"
28966 .scindex IIDexternauth1 "&(external)& authenticator"
28967 .scindex IIDexternauth2 "authenticators" "&(external)&"
28968 .cindex "authentication" "Client Certificate"
28969 .cindex "authentication" "X509"
28970 .cindex "Certificate-based authentication"
28971 The &(external)& authenticator provides support for
28972 authentication based on non-SMTP information.
28973 The specification is in RFC 4422 Appendix A
28974 (&url(https://tools.ietf.org/html/rfc4422)).
28975 It is only a transport and negotiation mechanism;
28976 the process of authentication is entirely controlled
28977 by the server configuration.
28978
28979 The client presents an identity in-clear.
28980 It is probably wise for a server to only advertise,
28981 and for clients to only attempt,
28982 this authentication method on a secure (eg. under TLS) connection.
28983
28984 One possible use, compatible with the
28985 K-9 Mail Android client (&url(https://k9mail.github.io/)),
28986 is for using X509 client certificates.
28987
28988 It thus overlaps in function with the TLS authenticator
28989 (see &<<CHAPtlsauth>>&)
28990 but is a full SMTP SASL authenticator
28991 rather than being implicit for TLS-connection carried
28992 client certificates only.
28993
28994 The examples and discussion in this chapter assume that
28995 client-certificate authentication is being done.
28996
28997 The client must present a certificate,
28998 for which it must have been requested via the
28999 &%tls_verify_hosts%& or &%tls_try_verify_hosts%& main options
29000 (see &<<CHAPTLS>>&).
29001 For authentication to be effective the certificate should be
29002 verifiable against a trust-anchor certificate known to the server.
29003
29004 .section "External options" "SECTexternsoptions"
29005 .cindex "options" "&(external)& authenticator (server)"
29006 The &(external)& authenticator has two server options:
29007
29008 .option server_param2 external string&!! unset
29009 .option server_param3 external string&!! unset
29010 .cindex "variables (&$auth1$& &$auth2$& etc)" "in &(external)& authenticator"
29011 These options are expanded before the &%server_condition%& option
29012 and the result are placed in &$auth2$& and &$auth3$& resectively.
29013 If the expansion is forced to fail, authentication fails. Any other expansion
29014 failure causes a temporary error code to be returned.
29015
29016 They can be used to clarify the coding of a complex &%server_condition%&.
29017
29018 .section "Using external in a server" "SECTexternserver"
29019 .cindex "AUTH" "in &(external)& authenticator"
29020 .cindex "numerical variables (&$1$& &$2$& etc)" &&&
29021         "in &(external)& authenticator"
29022 .vindex "&$auth1$&, &$auth2$&, etc"
29023 .cindex "base64 encoding" "in &(external)& authenticator"
29024
29025 When running as a server, &(external)& performs the authentication test by
29026 expanding a string. The data sent by the client with the AUTH command, or in
29027 response to subsequent prompts, is base64 encoded, and so may contain any byte
29028 values when decoded. The decoded value is treated as
29029 an identity for authentication and
29030 placed in the expansion variable &$auth1$&.
29031
29032 For compatibility with previous releases of Exim, the value is also placed in
29033 the expansion variable &$1$&. However, the use of this
29034 variable for this purpose is now deprecated, as it can lead to confusion in
29035 string expansions that also use them for other things.
29036
29037 .vindex "&$authenticated_id$&"
29038 Once an identity has been received,
29039 &%server_condition%& is expanded. If the expansion is forced to fail,
29040 authentication fails. Any other expansion failure causes a temporary error code
29041 to be returned. If the result of a successful expansion is an empty string,
29042 &"0"&, &"no"&, or &"false"&, authentication fails. If the result of the
29043 expansion is &"1"&, &"yes"&, or &"true"&, authentication succeeds and the
29044 generic &%server_set_id%& option is expanded and saved in &$authenticated_id$&.
29045 For any other result, a temporary error code is returned, with the expanded
29046 string as the error text.
29047
29048 Example:
29049 .code
29050 ext_ccert_san_mail:
29051   driver =            external
29052   public_name =       EXTERNAL
29053
29054   server_advertise_condition = $tls_in_certificate_verified
29055   server_param2 =     ${certextract {subj_altname,mail,>:} \
29056                                     {$tls_in_peercert}}
29057   server_condition =  ${if forany {$auth2} \
29058                             {eq {$item}{$auth1}}}
29059   server_set_id =     $auth1
29060 .endd
29061 This accepts a client certificate that is verifiable against any
29062 of your configured trust-anchors
29063 (which usually means the full set of public CAs)
29064 and which has a mail-SAN matching the claimed identity sent by the client.
29065
29066 &*Note*&: up to TLS1.2, the client cert is on the wire in-clear, including the SAN.
29067 The account name is therefore guessable by an opponent.
29068 TLS 1.3 protects both server and client certificates, and is not vulnerable
29069 in this way.
29070
29071
29072 .section "Using external in a client" "SECTexternclient"
29073 .cindex "options" "&(external)& authenticator (client)"
29074 The &(external)& authenticator has one client option:
29075
29076 .option client_send external string&!! unset
29077 This option is expanded and sent with the AUTH command as the
29078 identity being asserted.
29079
29080 Example:
29081 .code
29082 ext_ccert:
29083   driver =      external
29084   public_name = EXTERNAL
29085
29086   client_condition = ${if !eq{$tls_out_cipher}{}}
29087   client_send = myaccount@smarthost.example.net
29088 .endd
29089
29090
29091 .ecindex IIDexternauth1
29092 .ecindex IIDexternauth2
29093
29094
29095
29096
29097
29098 . ////////////////////////////////////////////////////////////////////////////
29099 . ////////////////////////////////////////////////////////////////////////////
29100
29101 .chapter "The tls authenticator" "CHAPtlsauth"
29102 .scindex IIDtlsauth1 "&(tls)& authenticator"
29103 .scindex IIDtlsauth2 "authenticators" "&(tls)&"
29104 .cindex "authentication" "Client Certificate"
29105 .cindex "authentication" "X509"
29106 .cindex "Certificate-based authentication"
29107 The &(tls)& authenticator provides server support for
29108 authentication based on client certificates.
29109
29110 It is not an SMTP authentication mechanism and is not
29111 advertised by the server as part of the SMTP EHLO response.
29112 It is an Exim authenticator in the sense that it affects
29113 the protocol element of the log line, can be tested for
29114 by the &%authenticated%& ACL condition, and can set
29115 the &$authenticated_id$& variable.
29116
29117 The client must present a verifiable certificate,
29118 for which it must have been requested via the
29119 &%tls_verify_hosts%& or &%tls_try_verify_hosts%& main options
29120 (see &<<CHAPTLS>>&).
29121
29122 If an authenticator of this type is configured it is
29123 run immediately after a TLS connection being negotiated
29124 (due to either STARTTLS or TLS-on-connect)
29125 and can authenticate the connection.
29126 If it does, SMTP authentication is not subsequently offered.
29127
29128 A maximum of one authenticator of this type may be present.
29129
29130
29131 .cindex "options" "&(tls)& authenticator (server)"
29132 The &(tls)& authenticator has three server options:
29133
29134 .option server_param1 tls string&!! unset
29135 .cindex "variables (&$auth1$& &$auth2$& etc)" "in &(tls)& authenticator"
29136 This option is expanded after the TLS negotiation and
29137 the result is placed in &$auth1$&.
29138 If the expansion is forced to fail, authentication fails. Any other expansion
29139 failure causes a temporary error code to be returned.
29140
29141 .option server_param2 tls string&!! unset
29142 .option server_param3 tls string&!! unset
29143 As above, for &$auth2$& and &$auth3$&.
29144
29145 &%server_param1%& may also be spelled &%server_param%&.
29146
29147
29148 Example:
29149 .code
29150 tls:
29151   driver = tls
29152   server_param1 =     ${certextract {subj_altname,mail,>:} \
29153                                     {$tls_in_peercert}}
29154   server_condition =  ${if and { {eq{$tls_in_certificate_verified}{1}} \
29155                                  {forany {$auth1} \
29156                             {!= {0} \
29157                                 {${lookup ldap{ldap:///\
29158                          mailname=${quote_ldap_dn:${lc:$item}},\
29159                          ou=users,LDAP_DC?mailid} {$value}{0} \
29160                        }    }  } }}}
29161   server_set_id =     ${if = {1}{${listcount:$auth1}} {$auth1}{}}
29162 .endd
29163 This accepts a client certificate that is verifiable against any
29164 of your configured trust-anchors
29165 (which usually means the full set of public CAs)
29166 and which has a SAN with a good account name.
29167
29168 Note that, up to TLS1.2, the client cert is on the wire in-clear, including the SAN,
29169 The account name is therefore guessable by an opponent.
29170 TLS 1.3 protects both server and client certificates, and is not vulnerable
29171 in this way.
29172 Likewise, a traditional plaintext SMTP AUTH done inside TLS is not.
29173
29174 . An alternative might use
29175 . .code
29176 .   server_param1 = ${sha256:$tls_in_peercert}
29177 . .endd
29178 . to require one of a set of specific certs that define a given account
29179 . (the verification is still required, but mostly irrelevant).
29180 . This would help for per-device use.
29181 .
29182 . However, for the future we really need support for checking a
29183 . user cert in LDAP - which probably wants a base-64 DER.
29184
29185 .ecindex IIDtlsauth1
29186 .ecindex IIDtlsauth2
29187
29188
29189 Note that because authentication is traditionally an SMTP operation,
29190 the &%authenticated%& ACL condition cannot be used in
29191 a connect- or helo-ACL.
29192
29193
29194
29195 . ////////////////////////////////////////////////////////////////////////////
29196 . ////////////////////////////////////////////////////////////////////////////
29197
29198 .chapter "Encrypted SMTP connections using TLS/SSL" "CHAPTLS" &&&
29199          "Encrypted SMTP connections"
29200 .scindex IIDencsmtp1 "encryption" "on SMTP connection"
29201 .scindex IIDencsmtp2 "SMTP" "encryption"
29202 .cindex "TLS" "on SMTP connection"
29203 .cindex "OpenSSL"
29204 .cindex "GnuTLS"
29205 Support for TLS (Transport Layer Security), formerly known as SSL (Secure
29206 Sockets Layer), is implemented by making use of the OpenSSL library or the
29207 GnuTLS library (Exim requires GnuTLS release 1.0 or later). There is no
29208 cryptographic code in the Exim distribution itself for implementing TLS. In
29209 order to use this feature you must install OpenSSL or GnuTLS, and then build a
29210 version of Exim that includes TLS support (see section &<<SECTinctlsssl>>&).
29211 You also need to understand the basic concepts of encryption at a managerial
29212 level, and in particular, the way that public keys, private keys, and
29213 certificates are used.
29214
29215 RFC 3207 defines how SMTP connections can make use of encryption. Once a
29216 connection is established, the client issues a STARTTLS command. If the
29217 server accepts this, the client and the server negotiate an encryption
29218 mechanism. If the negotiation succeeds, the data that subsequently passes
29219 between them is encrypted.
29220
29221 Exim's ACLs can detect whether the current SMTP session is encrypted or not,
29222 and if so, what cipher suite is in use, whether the client supplied a
29223 certificate, and whether or not that certificate was verified. This makes it
29224 possible for an Exim server to deny or accept certain commands based on the
29225 encryption state.
29226
29227 &*Warning*&: Certain types of firewall and certain anti-virus products can
29228 disrupt TLS connections. You need to turn off SMTP scanning for these products
29229 in order to get TLS to work.
29230
29231
29232
29233 .section "Support for the &""submissions""& (aka &""ssmtp""& and &""smtps""&) protocol" &&&
29234          "SECID284"
29235 .cindex "submissions protocol"
29236 .cindex "ssmtp protocol"
29237 .cindex "smtps protocol"
29238 .cindex "SMTP" "submissions protocol"
29239 .cindex "SMTP" "ssmtp protocol"
29240 .cindex "SMTP" "smtps protocol"
29241 The history of port numbers for TLS in SMTP is a little messy and has been
29242 contentious.  As of RFC 8314, the common practice of using the historically
29243 allocated port 465 for "email submission but with TLS immediately upon connect
29244 instead of using STARTTLS" is officially blessed by the IETF, and recommended
29245 by them in preference to STARTTLS.
29246
29247 The name originally assigned to the port was &"ssmtp"& or &"smtps"&, but as
29248 clarity emerged over the dual roles of SMTP, for MX delivery and Email
29249 Submission, nomenclature has shifted.  The modern name is now &"submissions"&.
29250
29251 This approach was, for a while, officially abandoned when encrypted SMTP was
29252 standardized, but many clients kept using it, even as the TCP port number was
29253 reassigned for other use.
29254 Thus you may encounter guidance claiming that you shouldn't enable use of
29255 this port.
29256 In practice, a number of mail-clients have only ever supported submissions,
29257 not submission with STARTTLS upgrade.
29258 Ideally, offer both submission (587) and submissions (465) service.
29259
29260 Exim supports TLS-on-connect by means of the &%tls_on_connect_ports%&
29261 global option. Its value must be a list of port numbers;
29262 the most common use is expected to be:
29263 .code
29264 tls_on_connect_ports = 465
29265 .endd
29266 The port numbers specified by this option apply to all SMTP connections, both
29267 via the daemon and via &'inetd'&. You still need to specify all the ports that
29268 the daemon uses (by setting &%daemon_smtp_ports%& or &%local_interfaces%& or
29269 the &%-oX%& command line option) because &%tls_on_connect_ports%& does not add
29270 an extra port &-- rather, it specifies different behaviour on a port that is
29271 defined elsewhere.
29272
29273 There is also a &%-tls-on-connect%& command line option. This overrides
29274 &%tls_on_connect_ports%&; it forces the TLS-only behaviour for all ports.
29275
29276
29277
29278
29279
29280
29281 .section "OpenSSL vs GnuTLS" "SECTopenvsgnu"
29282 .cindex "TLS" "OpenSSL &'vs'& GnuTLS"
29283 TLS is supported in Exim using either the OpenSSL or GnuTLS library.
29284 To build Exim to use OpenSSL you need to set
29285 .code
29286 USE_OPENSSL=yes
29287 .endd
29288 in Local/Makefile.
29289
29290 To build Exim to use GnuTLS, you need to set
29291 .code
29292 USE_GNUTLS=yes
29293 .endd
29294 in Local/Makefile.
29295
29296 You must also set TLS_LIBS and TLS_INCLUDE appropriately, so that the
29297 include files and libraries for GnuTLS can be found.
29298
29299 There are some differences in usage when using GnuTLS instead of OpenSSL:
29300
29301 .ilist
29302 The &%tls_verify_certificates%& option
29303 cannot be the path of a directory
29304 for GnuTLS versions before 3.3.6
29305 (for later versions, or OpenSSL, it can be either).
29306 .next
29307 The default value for &%tls_dhparam%& differs for historical reasons.
29308 .next
29309 .vindex "&$tls_in_peerdn$&"
29310 .vindex "&$tls_out_peerdn$&"
29311 Distinguished Name (DN) strings reported by the OpenSSL library use a slash for
29312 separating fields; GnuTLS uses commas, in accordance with RFC 2253. This
29313 affects the value of the &$tls_in_peerdn$& and &$tls_out_peerdn$& variables.
29314 .next
29315 OpenSSL identifies cipher suites using hyphens as separators, for example:
29316 DES-CBC3-SHA. GnuTLS historically used underscores, for example:
29317 RSA_ARCFOUR_SHA. What is more, OpenSSL complains if underscores are present
29318 in a cipher list. To make life simpler, Exim changes underscores to hyphens
29319 for OpenSSL and passes the string unchanged to GnuTLS (expecting the library
29320 to handle its own older variants) when processing lists of cipher suites in the
29321 &%tls_require_ciphers%& options (the global option and the &(smtp)& transport
29322 option).
29323 .next
29324 The &%tls_require_ciphers%& options operate differently, as described in the
29325 sections &<<SECTreqciphssl>>& and &<<SECTreqciphgnu>>&.
29326 .next
29327 The &%tls_dh_min_bits%& SMTP transport option is only honoured by GnuTLS.
29328 When using OpenSSL, this option is ignored.
29329 (If an API is found to let OpenSSL be configured in this way,
29330 let the Exim Maintainers know and we'll likely use it).
29331 .next
29332 With GnuTLS, if an explicit list is used for the &%tls_privatekey%& main option,
29333 it must be ordered to match the &%tls_certificate%& list.
29334 .next
29335 Some other recently added features may only be available in one or the other.
29336 This should be documented with the feature.  If the documentation does not
29337 explicitly state that the feature is infeasible in the other TLS
29338 implementation, then patches are welcome.
29339 .next
29340 The output from "exim -bV" will show which (if any) support was included
29341 in the build.
29342 Also, the macro "_HAVE_OPENSSL" or "_HAVE_GNUTLS" will be defined.
29343 .endlist
29344
29345
29346 .section "GnuTLS parameter computation" "SECTgnutlsparam"
29347 This section only applies if &%tls_dhparam%& is set to &`historic`& or to
29348 an explicit path; if the latter, then the text about generation still applies,
29349 but not the chosen filename.
29350 By default, as of Exim 4.80 a hard-coded D-H prime is used.
29351 See the documentation of &%tls_dhparam%& for more information.
29352
29353 GnuTLS uses D-H parameters that may take a substantial amount of time
29354 to compute. It is unreasonable to re-compute them for every TLS session.
29355 Therefore, Exim keeps this data in a file in its spool directory, called
29356 &_gnutls-params-NNNN_& for some value of NNNN, corresponding to the number
29357 of bits requested.
29358 The file is owned by the Exim user and is readable only by
29359 its owner. Every Exim process that start up GnuTLS reads the D-H
29360 parameters from this file. If the file does not exist, the first Exim process
29361 that needs it computes the data and writes it to a temporary file which is
29362 renamed once it is complete. It does not matter if several Exim processes do
29363 this simultaneously (apart from wasting a few resources). Once a file is in
29364 place, new Exim processes immediately start using it.
29365
29366 For maximum security, the parameters that are stored in this file should be
29367 recalculated periodically, the frequency depending on your paranoia level.
29368 If you are avoiding using the fixed D-H primes published in RFCs, then you
29369 are concerned about some advanced attacks and will wish to do this; if you do
29370 not regenerate then you might as well stick to the standard primes.
29371
29372 Arranging this is easy in principle; just delete the file when you want new
29373 values to be computed. However, there may be a problem. The calculation of new
29374 parameters needs random numbers, and these are obtained from &_/dev/random_&.
29375 If the system is not very active, &_/dev/random_& may delay returning data
29376 until enough randomness (entropy) is available. This may cause Exim to hang for
29377 a substantial amount of time, causing timeouts on incoming connections.
29378
29379 The solution is to generate the parameters externally to Exim. They are stored
29380 in &_gnutls-params-N_& in PEM format, which means that they can be
29381 generated externally using the &(certtool)& command that is part of GnuTLS.
29382
29383 To replace the parameters with new ones, instead of deleting the file
29384 and letting Exim re-create it, you can generate new parameters using
29385 &(certtool)& and, when this has been done, replace Exim's cache file by
29386 renaming. The relevant commands are something like this:
29387 .code
29388 # ls
29389 [ look for file; assume gnutls-params-2236 is the most recent ]
29390 # rm -f new-params
29391 # touch new-params
29392 # chown exim:exim new-params
29393 # chmod 0600 new-params
29394 # certtool --generate-dh-params --bits 2236 >>new-params
29395 # openssl dhparam -noout -text -in new-params | head
29396 [ check the first line, make sure it's not more than 2236;
29397   if it is, then go back to the start ("rm") and repeat
29398   until the size generated is at most the size requested ]
29399 # chmod 0400 new-params
29400 # mv new-params gnutls-params-2236
29401 .endd
29402 If Exim never has to generate the parameters itself, the possibility of
29403 stalling is removed.
29404
29405 The filename changed in Exim 4.80, to gain the -bits suffix.  The value which
29406 Exim will choose depends upon the version of GnuTLS in use.  For older GnuTLS,
29407 the value remains hard-coded in Exim as 1024.  As of GnuTLS 2.12.x, there is
29408 a way for Exim to ask for the "normal" number of bits for D-H public-key usage,
29409 and Exim does so.  This attempt to remove Exim from TLS policy decisions
29410 failed, as GnuTLS 2.12 returns a value higher than the current hard-coded limit
29411 of the NSS library.  Thus Exim gains the &%tls_dh_max_bits%& global option,
29412 which applies to all D-H usage, client or server.  If the value returned by
29413 GnuTLS is greater than &%tls_dh_max_bits%& then the value will be clamped down
29414 to &%tls_dh_max_bits%&.  The default value has been set at the current NSS
29415 limit, which is still much higher than Exim historically used.
29416
29417 The filename and bits used will change as the GnuTLS maintainers change the
29418 value for their parameter &`GNUTLS_SEC_PARAM_NORMAL`&, as clamped by
29419 &%tls_dh_max_bits%&.  At the time of writing (mid 2012), GnuTLS 2.12 recommends
29420 2432 bits, while NSS is limited to 2236 bits.
29421
29422 In fact, the requested value will be *lower* than &%tls_dh_max_bits%&, to
29423 increase the chance of the generated prime actually being within acceptable
29424 bounds, as GnuTLS has been observed to overshoot.  Note the check step in the
29425 procedure above.  There is no sane procedure available to Exim to double-check
29426 the size of the generated prime, so it might still be too large.
29427
29428
29429 .section "Requiring specific ciphers in OpenSSL" "SECTreqciphssl"
29430 .cindex "TLS" "requiring specific ciphers (OpenSSL)"
29431 .oindex "&%tls_require_ciphers%&" "OpenSSL"
29432 There is a function in the OpenSSL library that can be passed a list of cipher
29433 suites before the cipher negotiation takes place. This specifies which ciphers
29434 are acceptable for TLS versions prior to 1.3.
29435 The list is colon separated and may contain names like
29436 DES-CBC3-SHA. Exim passes the expanded value of &%tls_require_ciphers%&
29437 directly to this function call.
29438 Many systems will install the OpenSSL manual-pages, so you may have
29439 &'ciphers(1)'& available to you.
29440 The following quotation from the OpenSSL
29441 documentation specifies what forms of item are allowed in the cipher string:
29442
29443 .ilist
29444 It can consist of a single cipher suite such as RC4-SHA.
29445 .next
29446 It can represent a list of cipher suites containing a certain algorithm,
29447 or cipher suites of a certain type. For example SHA1 represents all
29448 ciphers suites using the digest algorithm SHA1 and SSLv3 represents all
29449 SSL v3 algorithms.
29450 .next
29451 Lists of cipher suites can be combined in a single cipher string using
29452 the + character. This is used as a logical and operation. For example
29453 SHA1+DES represents all cipher suites containing the SHA1 and the DES
29454 algorithms.
29455 .endlist
29456
29457 Each cipher string can be optionally preceded by one of the characters &`!`&,
29458 &`-`& or &`+`&.
29459 .ilist
29460 If &`!`& is used, the ciphers are permanently deleted from the list. The
29461 ciphers deleted can never reappear in the list even if they are explicitly
29462 stated.
29463 .next
29464 If &`-`& is used, the ciphers are deleted from the list, but some or all
29465 of the ciphers can be added again by later options.
29466 .next
29467 If &`+`& is used, the ciphers are moved to the end of the list. This
29468 option does not add any new ciphers; it just moves matching existing ones.
29469 .endlist
29470
29471 If none of these characters is present, the string is interpreted as
29472 a list of ciphers to be appended to the current preference list. If the list
29473 includes any ciphers already present they will be ignored: that is, they will
29474 not be moved to the end of the list.
29475 .endlist
29476
29477 The OpenSSL &'ciphers(1)'& command may be used to test the results of a given
29478 string:
29479 .code
29480 # note single-quotes to get ! past any shell history expansion
29481 $ openssl ciphers 'HIGH:!MD5:!SHA1'
29482 .endd
29483
29484 This example will let the library defaults be permitted on the MX port, where
29485 there's probably no identity verification anyway, but ups the ante on the
29486 submission ports where the administrator might have some influence on the
29487 choice of clients used:
29488 .code
29489 # OpenSSL variant; see man ciphers(1)
29490 tls_require_ciphers = ${if =={$received_port}{25}\
29491                            {DEFAULT}\
29492                            {HIGH:!MD5:!SHA1}}
29493 .endd
29494
29495 This example will prefer ECDSA-authenticated ciphers over RSA ones:
29496 .code
29497 tls_require_ciphers = ECDSA:RSA:!COMPLEMENTOFDEFAULT
29498 .endd
29499
29500 For TLS version 1.3 the control available is less fine-grained
29501 and Exim does not provide access to it at present.
29502 The value of the &%tls_require_ciphers%& option is ignored when
29503 TLS version 1.3 is negotiated.
29504
29505 As of writing the library default cipher suite list for TLSv1.3 is
29506 .code
29507 TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256
29508 .endd
29509
29510
29511 .section "Requiring specific ciphers or other parameters in GnuTLS" &&&
29512          "SECTreqciphgnu"
29513 .cindex "GnuTLS" "specifying parameters for"
29514 .cindex "TLS" "specifying ciphers (GnuTLS)"
29515 .cindex "TLS" "specifying key exchange methods (GnuTLS)"
29516 .cindex "TLS" "specifying MAC algorithms (GnuTLS)"
29517 .cindex "TLS" "specifying protocols (GnuTLS)"
29518 .cindex "TLS" "specifying priority string (GnuTLS)"
29519 .oindex "&%tls_require_ciphers%&" "GnuTLS"
29520 The GnuTLS library allows the caller to provide a "priority string", documented
29521 as part of the &[gnutls_priority_init]& function.  This is very similar to the
29522 ciphersuite specification in OpenSSL.
29523
29524 The &%tls_require_ciphers%& option is treated as the GnuTLS priority string
29525 and controls both protocols and ciphers.
29526
29527 The &%tls_require_ciphers%& option is available both as an global option,
29528 controlling how Exim behaves as a server, and also as an option of the
29529 &(smtp)& transport, controlling how Exim behaves as a client.  In both cases
29530 the value is string expanded.  The resulting string is not an Exim list and
29531 the string is given to the GnuTLS library, so that Exim does not need to be
29532 aware of future feature enhancements of GnuTLS.
29533
29534 Documentation of the strings accepted may be found in the GnuTLS manual, under
29535 "Priority strings".  This is online as
29536 &url(https://www.gnutls.org/manual/html_node/Priority-Strings.html),
29537 but beware that this relates to GnuTLS 3, which may be newer than the version
29538 installed on your system.  If you are using GnuTLS 3,
29539 then the example code
29540 &url(https://www.gnutls.org/manual/gnutls.html#Listing-the-ciphersuites-in-a-priority-string)
29541 on that site can be used to test a given string.
29542
29543 For example:
29544 .code
29545 # Disable older versions of protocols
29546 tls_require_ciphers = NORMAL:%LATEST_RECORD_VERSION:-VERS-SSL3.0
29547 .endd
29548
29549 Prior to Exim 4.80, an older API of GnuTLS was used, and Exim supported three
29550 additional options, "&%gnutls_require_kx%&", "&%gnutls_require_mac%&" and
29551 "&%gnutls_require_protocols%&".  &%tls_require_ciphers%& was an Exim list.
29552
29553 This example will let the library defaults be permitted on the MX port, where
29554 there's probably no identity verification anyway, and lowers security further
29555 by increasing compatibility; but this ups the ante on the submission ports
29556 where the administrator might have some influence on the choice of clients
29557 used:
29558 .code
29559 # GnuTLS variant
29560 tls_require_ciphers = ${if =={$received_port}{25}\
29561                            {NORMAL:%COMPAT}\
29562                            {SECURE128}}
29563 .endd
29564
29565
29566 .section "Configuring an Exim server to use TLS" "SECID182"
29567 .cindex "TLS" "configuring an Exim server"
29568 .cindex "ESMTP extensions" STARTTLS
29569 When Exim has been built with TLS support, it advertises the availability of
29570 the STARTTLS command to client hosts that match &%tls_advertise_hosts%&,
29571 but not to any others. The default value of this option is *, which means
29572 that STARTTLS is always advertised.  Set it to blank to never advertise;
29573 this is reasonable for systems that want to use TLS only as a client.
29574
29575 If STARTTLS is to be used you
29576 need to set some other options in order to make TLS available.
29577
29578 If a client issues a STARTTLS command and there is some configuration
29579 problem in the server, the command is rejected with a 454 error. If the client
29580 persists in trying to issue SMTP commands, all except QUIT are rejected
29581 with the error
29582 .code
29583 554 Security failure
29584 .endd
29585 If a STARTTLS command is issued within an existing TLS session, it is
29586 rejected with a 554 error code.
29587
29588 To enable TLS operations on a server, the &%tls_advertise_hosts%& option
29589 must be set to match some hosts. The default is * which matches all hosts.
29590
29591 If this is all you do, TLS encryption will be enabled but not authentication -
29592 meaning that the peer has no assurance it is actually you he is talking to.
29593 You gain protection from a passive sniffer listening on the wire but not
29594 from someone able to intercept the communication.
29595
29596 Further protection requires some further configuration at the server end.
29597
29598 To make TLS work you need to set, in the server,
29599 .code
29600 tls_certificate = /some/file/name
29601 tls_privatekey = /some/file/name
29602 .endd
29603 These options are, in fact, expanded strings, so you can make them depend on
29604 the identity of the client that is connected if you wish. The first file
29605 contains the server's X509 certificate, and the second contains the private key
29606 that goes with it. These files need to be
29607 PEM format and readable by the Exim user, and must
29608 always be given as full path names.
29609 The key must not be password-protected.
29610 They can be the same file if both the
29611 certificate and the key are contained within it. If &%tls_privatekey%& is not
29612 set, or if its expansion is forced to fail or results in an empty string, this
29613 is assumed to be the case. The certificate file may also contain intermediate
29614 certificates that need to be sent to the client to enable it to authenticate
29615 the server's certificate.
29616
29617 For dual-stack (eg. RSA and ECDSA) configurations, these options can be
29618 colon-separated lists of file paths.  Ciphers using given authentication
29619 algorithms require the presence of a suitable certificate to supply the
29620 public-key.  The server selects among the certificates to present to the
29621 client depending on the selected cipher, hence the priority ordering for
29622 ciphers will affect which certificate is used.
29623
29624 If you do not understand about certificates and keys, please try to find a
29625 source of this background information, which is not Exim-specific. (There are a
29626 few comments below in section &<<SECTcerandall>>&.)
29627
29628 &*Note*&: These options do not apply when Exim is operating as a client &--
29629 they apply only in the case of a server. If you need to use a certificate in an
29630 Exim client, you must set the options of the same names in an &(smtp)&
29631 transport.
29632
29633 With just these options, an Exim server will be able to use TLS. It does not
29634 require the client to have a certificate (but see below for how to insist on
29635 this). There is one other option that may be needed in other situations. If
29636 .code
29637 tls_dhparam = /some/file/name
29638 .endd
29639 is set, the SSL library is initialized for the use of Diffie-Hellman ciphers
29640 with the parameters contained in the file.
29641 Set this to &`none`& to disable use of DH entirely, by making no prime
29642 available:
29643 .code
29644 tls_dhparam = none
29645 .endd
29646 This may also be set to a string identifying a standard prime to be used for
29647 DH; if it is set to &`default`& or, for OpenSSL, is unset, then the prime
29648 used is &`ike23`&.  There are a few standard primes available, see the
29649 documentation for &%tls_dhparam%& for the complete list.
29650
29651 See the command
29652 .code
29653 openssl dhparam
29654 .endd
29655 for a way of generating file data.
29656
29657 The strings supplied for these three options are expanded every time a client
29658 host connects. It is therefore possible to use different certificates and keys
29659 for different hosts, if you so wish, by making use of the client's IP address
29660 in &$sender_host_address$& to control the expansion. If a string expansion is
29661 forced to fail, Exim behaves as if the option is not set.
29662
29663 .cindex "cipher" "logging"
29664 .cindex "log" "TLS cipher"
29665 .vindex "&$tls_in_cipher$&"
29666 The variable &$tls_in_cipher$& is set to the cipher suite that was negotiated for
29667 an incoming TLS connection. It is included in the &'Received:'& header of an
29668 incoming message (by default &-- you can, of course, change this), and it is
29669 also included in the log line that records a message's arrival, keyed by
29670 &"X="&, unless the &%tls_cipher%& log selector is turned off. The &%encrypted%&
29671 condition can be used to test for specific cipher suites in ACLs.
29672
29673 Once TLS has been established, the ACLs that run for subsequent SMTP commands
29674 can check the name of the cipher suite and vary their actions accordingly. The
29675 cipher suite names vary, depending on which TLS library is being used. For
29676 example, OpenSSL uses the name DES-CBC3-SHA for the cipher suite which in other
29677 contexts is known as TLS_RSA_WITH_3DES_EDE_CBC_SHA. Check the OpenSSL or GnuTLS
29678 documentation for more details.
29679
29680 For outgoing SMTP deliveries, &$tls_out_cipher$& is used and logged
29681 (again depending on the &%tls_cipher%& log selector).
29682
29683
29684 .subsection "Requesting and verifying client certificates"
29685 .cindex "certificate" "verification of client"
29686 .cindex "TLS" "client certificate verification"
29687 If you want an Exim server to request a certificate when negotiating a TLS
29688 session with a client, you must set either &%tls_verify_hosts%& or
29689 &%tls_try_verify_hosts%&. You can, of course, set either of them to * to
29690 apply to all TLS connections. For any host that matches one of these options,
29691 Exim requests a certificate as part of the setup of the TLS session. The
29692 contents of the certificate are verified by comparing it with a list of
29693 expected trust-anchors or certificates.
29694 These may be the system default set (depending on library version),
29695 an explicit file or,
29696 depending on library version, a directory, identified by
29697 &%tls_verify_certificates%&.
29698
29699 A file can contain multiple certificates, concatenated end to end. If a
29700 directory is used
29701 (OpenSSL only),
29702 each certificate must be in a separate file, with a name (or a symbolic link)
29703 of the form <&'hash'&>.0, where <&'hash'&> is a hash value constructed from the
29704 certificate. You can compute the relevant hash by running the command
29705 .code
29706 openssl x509 -hash -noout -in /cert/file
29707 .endd
29708 where &_/cert/file_& contains a single certificate.
29709
29710 There is no checking of names of the client against the certificate
29711 Subject Name or Subject Alternate Names.
29712
29713 The difference between &%tls_verify_hosts%& and &%tls_try_verify_hosts%& is
29714 what happens if the client does not supply a certificate, or if the certificate
29715 does not match any of the certificates in the collection named by
29716 &%tls_verify_certificates%&. If the client matches &%tls_verify_hosts%&, the
29717 attempt to set up a TLS session is aborted, and the incoming connection is
29718 dropped. If the client matches &%tls_try_verify_hosts%&, the (encrypted) SMTP
29719 session continues. ACLs that run for subsequent SMTP commands can detect the
29720 fact that no certificate was verified, and vary their actions accordingly. For
29721 example, you can insist on a certificate before accepting a message for
29722 relaying, but not when the message is destined for local delivery.
29723
29724 .vindex "&$tls_in_peerdn$&"
29725 When a client supplies a certificate (whether it verifies or not), the value of
29726 the Distinguished Name of the certificate is made available in the variable
29727 &$tls_in_peerdn$& during subsequent processing of the message.
29728
29729 .cindex "log" "distinguished name"
29730 Because it is often a long text string, it is not included in the log line or
29731 &'Received:'& header by default. You can arrange for it to be logged, keyed by
29732 &"DN="&, by setting the &%tls_peerdn%& log selector, and you can use
29733 &%received_header_text%& to change the &'Received:'& header. When no
29734 certificate is supplied, &$tls_in_peerdn$& is empty.
29735
29736
29737 .subsection "Caching of static server configuration items" "SSECTserverTLScache"
29738 .cindex certificate caching
29739 .cindex privatekey caching
29740 .cindex crl caching
29741 .cindex ocsp caching
29742 .cindex ciphers caching
29743 .cindex "CA bundle" caching
29744 .cindex "certificate authorities" caching
29745 .cindex tls_certificate caching
29746 .cindex tls_privatekey caching
29747 .cindex tls_crl caching
29748 .cindex tls_ocsp_file caching
29749 .cindex tls_require_ciphers caching
29750 .cindex tls_verify_certificate caching
29751 .cindex caching certificate
29752 .cindex caching privatekey
29753 .cindex caching crl
29754 .cindex caching ocsp
29755 .cindex caching ciphers
29756 .cindex caching "certificate authorities
29757 If any of the main configuration options &%tls_certificate%&, &%tls_privatekey%&,
29758 &%tls_crl%& and &%tls_ocsp_file%& have values with no
29759 expandable elements,
29760 then the associated information is loaded at daemon startup.
29761 It is made available
29762 to child processes forked for handling received SMTP connections.
29763
29764 This caching is currently only supported under Linux and FreeBSD.
29765
29766 If caching is not possible, for example if an item has to be dependent
29767 on the peer host so contains a &$sender_host_name$& expansion, the load
29768 of the associated information is done at the startup of the TLS connection.
29769
29770 The cache is invalidated and reloaded after any changes to the directories
29771 containing files specified by these options.
29772
29773 The information specified by the main option &%tls_verify_certificates%&
29774 is similarly cached so long as it specifies files explicitly
29775 or (under GnuTLS) is the string &"system,cache"&.
29776 The latter case is not automatically invalidated;
29777 it is the operator's responsibility to arrange for a daemon restart
29778 any time the system certificate authority bundle is updated.
29779 A HUP signal is sufficient for this.
29780 The value &"system"& results in no caching under GnuTLS.
29781
29782 The macro _HAVE_TLS_CA_CACHE will be defined if the suffix for "system"
29783 is acceptable in configurations for the Exim executable.
29784
29785 Caching of the system Certificate Authorities bundle can
29786 save significant time and processing on every TLS connection
29787 accepted by Exim.
29788
29789
29790
29791
29792 .section "Configuring an Exim client to use TLS" "SECTclientTLS"
29793 .cindex "cipher" "logging"
29794 .cindex "log" "TLS cipher"
29795 .cindex "log" "distinguished name"
29796 .cindex "TLS" "configuring an Exim client"
29797 The &%tls_cipher%& and &%tls_peerdn%& log selectors apply to outgoing SMTP
29798 deliveries as well as to incoming, the latter one causing logging of the
29799 server certificate's DN. The remaining client configuration for TLS is all
29800 within the &(smtp)& transport.
29801
29802 .cindex "ESMTP extensions" STARTTLS
29803 It is not necessary to set any options to have TLS work in the &(smtp)&
29804 transport. If Exim is built with TLS support, and TLS is advertised by a
29805 server, the &(smtp)& transport always tries to start a TLS session. However,
29806 this can be prevented by setting &%hosts_avoid_tls%& (an option of the
29807 transport) to a list of server hosts for which TLS should not be used.
29808
29809 If you do not want Exim to attempt to send messages unencrypted when an attempt
29810 to set up an encrypted connection fails in any way, you can set
29811 &%hosts_require_tls%& to a list of hosts for which encryption is mandatory. For
29812 those hosts, delivery is always deferred if an encrypted connection cannot be
29813 set up. If there are any other hosts for the address, they are tried in the
29814 usual way.
29815
29816 When the server host is not in &%hosts_require_tls%&, Exim may try to deliver
29817 the message unencrypted. It always does this if the response to STARTTLS is
29818 a 5&'xx'& code. For a temporary error code, or for a failure to negotiate a TLS
29819 session after a success response code, what happens is controlled by the
29820 &%tls_tempfail_tryclear%& option of the &(smtp)& transport. If it is false,
29821 delivery to this host is deferred, and other hosts (if available) are tried. If
29822 it is true, Exim attempts to deliver unencrypted after a 4&'xx'& response to
29823 STARTTLS, and if STARTTLS is accepted, but the subsequent TLS
29824 negotiation fails, Exim closes the current connection (because it is in an
29825 unknown state), opens a new one to the same host, and then tries the delivery
29826 unencrypted.
29827
29828 The &%tls_certificate%& and &%tls_privatekey%& options of the &(smtp)&
29829 transport provide the client with a certificate, which is passed to the server
29830 if it requests it.
29831 This is an optional thing for TLS connections, although either end
29832 may insist on it.
29833 If the server is Exim, it will request a certificate only if
29834 &%tls_verify_hosts%& or &%tls_try_verify_hosts%& matches the client.
29835
29836 &*Note*&: Do not use a certificate which has the OCSP-must-staple extension,
29837 for client use (they are usable for server use).
29838 As the TLS protocol has no means for the client to staple before TLS 1.3 it will result
29839 in failed connections.
29840
29841 If the &%tls_verify_certificates%& option is set on the &(smtp)& transport, it
29842 specifies a collection of expected server certificates.
29843 These may be
29844 the system default set (depending on library version),
29845 a file,
29846 or (depending on library version) a directory.
29847 The client verifies the server's certificate
29848 against this collection, taking into account any revoked certificates that are
29849 in the list defined by &%tls_crl%&.
29850 Failure to verify fails the TLS connection unless either of the
29851 &%tls_verify_hosts%& or &%tls_try_verify_hosts%& options are set.
29852
29853 The &%tls_verify_hosts%& and &%tls_try_verify_hosts%& options restrict
29854 certificate verification to the listed servers.  Verification either must
29855 or need not succeed respectively.
29856
29857 The &%tls_verify_cert_hostnames%& option lists hosts for which additional
29858 name checks are made on the server certificate.
29859 The match against this list is, as per other Exim usage, the
29860 IP for the host.  That is most closely associated with the
29861 name on the DNS A (or AAAA) record for the host.
29862 However, the name that needs to be in the certificate
29863 is the one at the head of any CNAME chain leading to the A record.
29864 The option defaults to always checking.
29865
29866 The &(smtp)& transport has two OCSP-related options:
29867 &%hosts_require_ocsp%&; a host-list for which a Certificate Status
29868 is requested and required for the connection to proceed.  The default
29869 value is empty.
29870 &%hosts_request_ocsp%&; a host-list for which (additionally)
29871 a Certificate Status is requested (but not necessarily verified).  The default
29872 value is "*" meaning that requests are made unless configured
29873 otherwise.
29874
29875 The host(s) should also be in &%hosts_require_tls%&, and
29876 &%tls_verify_certificates%& configured for the transport,
29877 for OCSP to be relevant.
29878
29879 If
29880 &%tls_require_ciphers%& is set on the &(smtp)& transport, it must contain a
29881 list of permitted cipher suites. If either of these checks fails, delivery to
29882 the current host is abandoned, and the &(smtp)& transport tries to deliver to
29883 alternative hosts, if any.
29884
29885  &*Note*&:
29886 These options must be set in the &(smtp)& transport for Exim to use TLS when it
29887 is operating as a client. Exim does not assume that a server certificate (set
29888 by the global options of the same name) should also be used when operating as a
29889 client.
29890
29891 .vindex "&$host$&"
29892 .vindex "&$host_address$&"
29893 All the TLS options in the &(smtp)& transport are expanded before use, with
29894 &$host$& and &$host_address$& containing the name and address of the server to
29895 which the client is connected. Forced failure of an expansion causes Exim to
29896 behave as if the relevant option were unset.
29897
29898 .vindex &$tls_out_bits$&
29899 .vindex &$tls_out_cipher$&
29900 .vindex &$tls_out_peerdn$&
29901 .vindex &$tls_out_sni$&
29902 Before an SMTP connection is established, the
29903 &$tls_out_bits$&, &$tls_out_cipher$&, &$tls_out_peerdn$& and &$tls_out_sni$&
29904 variables are emptied. (Until the first connection, they contain the values
29905 that were set when the message was received.) If STARTTLS is subsequently
29906 successfully obeyed, these variables are set to the relevant values for the
29907 outgoing connection.
29908
29909
29910
29911 .subsection "Caching of static client configuration items" SECTclientTLScache
29912 .cindex certificate caching
29913 .cindex privatekey caching
29914 .cindex crl caching
29915 .cindex ciphers caching
29916 .cindex "CA bundle" caching
29917 .cindex "certificate authorities" caching
29918 .cindex tls_certificate caching
29919 .cindex tls_privatekey caching
29920 .cindex tls_crl caching
29921 .cindex tls_require_ciphers caching
29922 .cindex tls_verify_certificate caching
29923 .cindex caching certificate
29924 .cindex caching privatekey
29925 .cindex caching crl
29926 .cindex caching ciphers
29927 .cindex caching "certificate authorities
29928 If any of the transport configuration options &%tls_certificate%&, &%tls_privatekey%&
29929 and &%tls_crl%& have values with no
29930 expandable elements,
29931 then the associated information is loaded per smtp transport
29932 at daemon startup, at the start of a queue run, or on a
29933 command-line specified message delivery.
29934 It is made available
29935 to child processes forked for handling making SMTP connections.
29936
29937 This caching is currently only supported under Linux.
29938
29939 If caching is not possible, the load
29940 of the associated information is done at the startup of the TLS connection.
29941
29942 The cache is invalidated in the daemon
29943 and reloaded after any changes to the directories
29944 containing files specified by these options.
29945
29946 The information specified by the main option &%tls_verify_certificates%&
29947 is similarly cached so long as it specifies files explicitly
29948 or (under GnuTLS) is the string &"system,cache"&.
29949 The latter case is not automatically invaludated;
29950 it is the operator's responsibility to arrange for a daemon restart
29951 any time the system certificate authority bundle is updated.
29952 A HUP signal is sufficient for this.
29953 The value &"system"& results in no caching under GnuTLS.
29954
29955 The macro _HAVE_TLS_CA_CACHE will be defined if the suffix for "system"
29956 is acceptable in configurations for the Exim executable.
29957
29958 Caching of the system Certificate Authorities bundle can
29959 save significant time and processing on every TLS connection
29960 initiated by Exim.
29961
29962
29963
29964
29965 .section "Use of TLS Server Name Indication" "SECTtlssni"
29966 .cindex "TLS" "Server Name Indication"
29967 .cindex "TLS" SNI
29968 .cindex SNI
29969 .vindex "&$tls_in_sni$&"
29970 .oindex "&%tls_in_sni%&"
29971 With TLS1.0 or above, there is an extension mechanism by which extra
29972 information can be included at various points in the protocol.  One of these
29973 extensions, documented in RFC 6066 (and before that RFC 4366) is
29974 &"Server Name Indication"&, commonly &"SNI"&.  This extension is sent by the
29975 client in the initial handshake, so that the server can examine the servername
29976 within and possibly choose to use different certificates and keys (and more)
29977 for this session.
29978
29979 This is analogous to HTTP's &"Host:"& header, and is the main mechanism by
29980 which HTTPS-enabled web-sites can be virtual-hosted, many sites to one IP
29981 address.
29982
29983 With SMTP to MX, there are the same problems here as in choosing the identity
29984 against which to validate a certificate: you can't rely on insecure DNS to
29985 provide the identity which you then cryptographically verify.  So this will
29986 be of limited use in that environment.
29987
29988 With SMTP to Submission, there is a well-defined hostname which clients are
29989 connecting to and can validate certificates against.  Thus clients &*can*&
29990 choose to include this information in the TLS negotiation.  If this becomes
29991 wide-spread, then hosters can choose to present different certificates to
29992 different clients.  Or even negotiate different cipher suites.
29993
29994 The &%tls_sni%& option on an SMTP transport is an expanded string; the result,
29995 if not empty, will be sent on a TLS session as part of the handshake.  There's
29996 nothing more to it.  Choosing a sensible value not derived insecurely is the
29997 only point of caution.  The &$tls_out_sni$& variable will be set to this string
29998 for the lifetime of the client connection (including during authentication).
29999
30000 If DANE validated the connection attempt then the value of the &%tls_sni%& option
30001 is forced to the name of the destination host, after any MX- or CNAME-following.
30002
30003 Except during SMTP client sessions, if &$tls_in_sni$& is set then it is a string
30004 received from a client.
30005 It can be logged with the &%log_selector%& item &`+tls_sni`&.
30006
30007 If the string &`tls_in_sni`& appears in the main section's &%tls_certificate%&
30008 option (prior to expansion) then the following options will be re-expanded
30009 during TLS session handshake, to permit alternative values to be chosen:
30010
30011 .ilist
30012 &%tls_certificate%&
30013 .next
30014 &%tls_crl%&
30015 .next
30016 &%tls_privatekey%&
30017 .next
30018 &%tls_verify_certificates%&
30019 .next
30020 &%tls_ocsp_file%&
30021 .endlist
30022
30023 Great care should be taken to deal with matters of case, various injection
30024 attacks in the string (&`../`& or SQL), and ensuring that a valid filename
30025 can always be referenced; it is important to remember that &$tls_in_sni$& is
30026 arbitrary unverified data provided prior to authentication.
30027 Further, the initial certificate is loaded before SNI has arrived, so
30028 an expansion for &%tls_certificate%& must have a default which is used
30029 when &$tls_in_sni$& is empty.
30030
30031 The Exim developers are proceeding cautiously and so far no other TLS options
30032 are re-expanded.
30033
30034 When Exim is built against OpenSSL, OpenSSL must have been built with support
30035 for TLS Extensions.  This holds true for OpenSSL 1.0.0+ and 0.9.8+ with
30036 enable-tlsext in EXTRACONFIGURE.  If you invoke &(openssl s_client -h)& and
30037 see &`-servername`& in the output, then OpenSSL has support.
30038
30039 When Exim is built against GnuTLS, SNI support is available as of GnuTLS
30040 0.5.10.  (Its presence predates the current API which Exim uses, so if Exim
30041 built, then you have SNI support).
30042
30043 .subsection ALPN
30044 .cindex TLS ALPN
30045 .cindex ALPN "general information"
30046 .cindex TLS "Application Layer Protocol Names"
30047 There is a TLS feature related to SNI
30048 called Application Layer Protocol Name (ALPN).
30049 This is intended to declare, or select, what protocol layer will be using a TLS
30050 connection.
30051 The client for the connection proposes a set of protocol names, and
30052 the server responds with a selected one.
30053 It is not, as of 2021, commonly used for SMTP connections.
30054 However, to guard against misdirected or malicious use of web clients
30055 (which often do use ALPN) against MTA ports, Exim by default check that
30056 there is no incompatible ALPN specified by a client for a TLS connection.
30057 If there is, the connection is rejected.
30058
30059 As a client Exim does not supply ALPN by default.
30060 The behaviour of both client and server can be configured using the options
30061 &%tls_alpn%& and &%hosts_require_alpn%&.
30062 There are no variables providing observability.
30063 Some feature-specific logging may appear on denied connections, but this
30064 depends on the behaviour of the peer
30065 (not all peers can send a feature-specific TLS Alert).
30066
30067 This feature is available when Exim is built with
30068 OpenSSL 1.1.0 or later or GnuTLS 3.2.0 or later;
30069 the macro _HAVE_TLS_ALPN will be defined when this is so.
30070
30071
30072
30073 .section "Multiple messages on the same encrypted TCP/IP connection" &&&
30074          "SECTmulmessam"
30075 .cindex "multiple SMTP deliveries with TLS"
30076 .cindex "TLS" "multiple message deliveries"
30077 Exim sends multiple messages down the same TCP/IP connection by starting up
30078 an entirely new delivery process for each message, passing the socket from
30079 one process to the next. This implementation does not fit well with the use
30080 of TLS, because there is quite a lot of state information associated with a TLS
30081 connection, not just a socket identification. Passing all the state information
30082 to a new process is not feasible. Consequently, for sending using TLS Exim
30083 starts an additional proxy process for handling the encryption, piping the
30084 unencrypted data stream from and to the delivery processes.
30085
30086 An older mode of operation can be enabled on a per-host basis by the
30087 &%hosts_noproxy_tls%& option on the &(smtp)& transport.  If the host matches
30088 this list the proxy process described above is not used; instead Exim
30089 shuts down an existing TLS session being run by the delivery process
30090 before passing the socket to a new process. The new process may then
30091 try to start a new TLS session, and if successful, may try to re-authenticate
30092 if AUTH is in use, before sending the next message.
30093
30094 The RFC is not clear as to whether or not an SMTP session continues in clear
30095 after TLS has been shut down, or whether TLS may be restarted again later, as
30096 just described. However, if the server is Exim, this shutdown and
30097 reinitialization works. It is not known which (if any) other servers operate
30098 successfully if the client closes a TLS session and continues with unencrypted
30099 SMTP, but there are certainly some that do not work. For such servers, Exim
30100 should not pass the socket to another process, because the failure of the
30101 subsequent attempt to use it would cause Exim to record a temporary host error,
30102 and delay other deliveries to that host.
30103
30104 To test for this case, Exim sends an EHLO command to the server after
30105 closing down the TLS session. If this fails in any way, the connection is
30106 closed instead of being passed to a new delivery process, but no retry
30107 information is recorded.
30108
30109 There is also a manual override; you can set &%hosts_nopass_tls%& on the
30110 &(smtp)& transport to match those hosts for which Exim should not pass
30111 connections to new processes if TLS has been used.
30112
30113
30114
30115
30116 .section "Certificates and all that" "SECTcerandall"
30117 .cindex "certificate" "references to discussion"
30118 In order to understand fully how TLS works, you need to know about
30119 certificates, certificate signing, and certificate authorities.
30120 This is a large topic and an introductory guide is unsuitable for the Exim
30121 reference manual, so instead we provide pointers to existing documentation.
30122
30123 The Apache web-server was for a long time the canonical guide, so their
30124 documentation is a good place to start; their SSL module's Introduction
30125 document is currently at
30126 .display
30127 &url(https://httpd.apache.org/docs/current/ssl/ssl_intro.html)
30128 .endd
30129 and their FAQ is at
30130 .display
30131 &url(https://httpd.apache.org/docs/current/ssl/ssl_faq.html)
30132 .endd
30133
30134 Eric Rescorla's book, &'SSL and TLS'&, published by Addison-Wesley (ISBN
30135 0-201-61598-3) in 2001, contains both introductory and more in-depth
30136 descriptions.
30137 More recently Ivan Ristić's book &'Bulletproof SSL and TLS'&,
30138 published by Feisty Duck (ISBN 978-1907117046) in 2013 is good.
30139 Ivan is the author of the popular TLS testing tools at
30140 &url(https://www.ssllabs.com/).
30141
30142
30143 .subsection "Certificate chains" SECID186
30144 A file named by &%tls_certificate%& may contain more than one
30145 certificate. This is useful in the case where the certificate that is being
30146 sent is validated by an intermediate certificate which the other end does
30147 not have. Multiple certificates must be in the correct order in the file.
30148 First the host's certificate itself, then the first intermediate
30149 certificate to validate the issuer of the host certificate, then the next
30150 intermediate certificate to validate the issuer of the first intermediate
30151 certificate, and so on, until finally (optionally) the root certificate.
30152 The root certificate must already be trusted by the recipient for
30153 validation to succeed, of course, but if it's not preinstalled, sending the
30154 root certificate along with the rest makes it available for the user to
30155 install if the receiving end is a client MUA that can interact with a user.
30156
30157 Note that certificates using MD5 are unlikely to work on today's Internet;
30158 even if your libraries allow loading them for use in Exim when acting as a
30159 server, increasingly clients will not accept such certificates.  The error
30160 diagnostics in such a case can be frustratingly vague.
30161
30162
30163
30164 .subsection "Self-signed certificates" SECID187
30165 .cindex "certificate" "self-signed"
30166 You can create a self-signed certificate using the &'req'& command provided
30167 with OpenSSL, like this:
30168 . ==== Do not shorten the duration here without reading and considering
30169 . ==== the text below.  Please leave it at 9999 days.
30170 .code
30171 openssl req -x509 -newkey rsa:1024 -keyout file1 -out file2 \
30172             -days 9999 -nodes
30173 .endd
30174 &_file1_& and &_file2_& can be the same file; the key and the certificate are
30175 delimited and so can be identified independently. The &%-days%& option
30176 specifies a period for which the certificate is valid. The &%-nodes%& option is
30177 important: if you do not set it, the key is encrypted with a passphrase
30178 that you are prompted for, and any use that is made of the key causes more
30179 prompting for the passphrase. This is not helpful if you are going to use
30180 this certificate and key in an MTA, where prompting is not possible.
30181
30182 . ==== I expect to still be working 26 years from now.  The less technical
30183 . ==== debt I create, in terms of storing up trouble for my later years, the
30184 . ==== happier I will be then.  We really have reached the point where we
30185 . ==== should start, at the very least, provoking thought and making folks
30186 . ==== pause before proceeding, instead of leaving all the fixes until two
30187 . ==== years before 2^31 seconds after the 1970 Unix epoch.
30188 . ==== -pdp, 2012
30189 NB: we are now past the point where 9999 days takes us past the 32-bit Unix
30190 epoch.  If your system uses unsigned time_t (most do) and is 32-bit, then
30191 the above command might produce a date in the past.  Think carefully about
30192 the lifetime of the systems you're deploying, and either reduce the duration
30193 of the certificate or reconsider your platform deployment.  (At time of
30194 writing, reducing the duration is the most likely choice, but the inexorable
30195 progression of time takes us steadily towards an era where this will not
30196 be a sensible resolution).
30197
30198 A self-signed certificate made in this way is sufficient for testing, and
30199 may be adequate for all your requirements if you are mainly interested in
30200 encrypting transfers, and not in secure identification.
30201
30202 However, many clients require that the certificate presented by the server be a
30203 user (also called &"leaf"& or &"site"&) certificate, and not a self-signed
30204 certificate. In this situation, the self-signed certificate described above
30205 must be installed on the client host as a trusted root &'certification
30206 authority'& (CA), and the certificate used by Exim must be a user certificate
30207 signed with that self-signed certificate.
30208
30209 For information on creating self-signed CA certificates and using them to sign
30210 user certificates, see the &'General implementation overview'& chapter of the
30211 Open-source PKI book, available online at
30212 &url(https://sourceforge.net/projects/ospkibook/).
30213
30214
30215 .subsection "Revoked certificates"
30216 .cindex "TLS" "revoked certificates"
30217 .cindex "revocation list"
30218 .cindex "certificate" "revocation list"
30219 .cindex "OCSP" "stapling"
30220 There are three ways for a certificate to be made unusable
30221 before its expiry.
30222
30223 .ilist
30224 Certificate issuing authorities issue Certificate Revocation Lists (CRLs) when
30225 certificates are revoked. If you have such a list, you can pass it to an Exim
30226 server using the global option called &%tls_crl%& and to an Exim client using
30227 an identically named option for the &(smtp)& transport. In each case, the value
30228 of the option is expanded and must then be the name of a file that contains a
30229 CRL in PEM format.
30230 The downside is that clients have to periodically re-download a potentially huge
30231 file from every certificate authority they know of.
30232
30233 .next
30234 The way with most moving parts at query time is Online Certificate
30235 Status Protocol (OCSP), where the client verifies the certificate
30236 against an OCSP server run by the CA.  This lets the CA track all
30237 usage of the certs.  It requires running software with access to the
30238 private key of the CA, to sign the responses to the OCSP queries.  OCSP
30239 is based on HTTP and can be proxied accordingly.
30240
30241 The only widespread OCSP server implementation (known to this writer)
30242 comes as part of OpenSSL and aborts on an invalid request, such as
30243 connecting to the port and then disconnecting.  This requires
30244 re-entering the passphrase each time some random client does this.
30245
30246 .next
30247 The third way is OCSP Stapling; in this, the server using a certificate
30248 issued by the CA periodically requests an OCSP proof of validity from
30249 the OCSP server, then serves it up inline as part of the TLS
30250 negotiation.   This approach adds no extra round trips, does not let the
30251 CA track users, scales well with number of certs issued by the CA and is
30252 resilient to temporary OCSP server failures, as long as the server
30253 starts retrying to fetch an OCSP proof some time before its current
30254 proof expires.  The downside is that it requires server support.
30255
30256 Unless Exim is built with the support disabled,
30257 or with GnuTLS earlier than version 3.3.16 / 3.4.8
30258 support for OCSP stapling is included.
30259
30260 There is a global option called &%tls_ocsp_file%&.
30261 The file specified therein is expected to be in DER format, and contain
30262 an OCSP proof.  Exim will serve it as part of the TLS handshake.  This
30263 option will be re-expanded for SNI, if the &%tls_certificate%& option
30264 contains &`tls_in_sni`&, as per other TLS options.
30265
30266 Exim does not at this time implement any support for fetching a new OCSP
30267 proof.  The burden is on the administrator to handle this, outside of
30268 Exim.  The file specified should be replaced atomically, so that the
30269 contents are always valid.  Exim will expand the &%tls_ocsp_file%& option
30270 on each connection, so a new file will be handled transparently on the
30271 next connection.
30272
30273 When built with OpenSSL Exim will check for a valid next update timestamp
30274 in the OCSP proof; if not present, or if the proof has expired, it will be
30275 ignored.
30276
30277 For the client to be able to verify the stapled OCSP the server must
30278 also supply, in its stapled information, any intermediate
30279 certificates for the chain leading to the OCSP proof from the signer
30280 of the server certificate.  There may be zero or one such. These
30281 intermediate certificates should be added to the server OCSP stapling
30282 file named by &%tls_ocsp_file%&.
30283
30284 Note that the proof only covers the terminal server certificate,
30285 not any of the chain from CA to it.
30286
30287 There is no current way to staple a proof for a client certificate.
30288
30289 .code
30290   A helper script "ocsp_fetch.pl" for fetching a proof from a CA
30291   OCSP server is supplied.  The server URL may be included in the
30292   server certificate, if the CA is helpful.
30293
30294   One failure mode seen was the OCSP Signer cert expiring before the end
30295   of validity of the OCSP proof. The checking done by Exim/OpenSSL
30296   noted this as invalid overall, but the re-fetch script did not.
30297 .endd
30298 .endlist
30299
30300
30301 .ecindex IIDencsmtp1
30302 .ecindex IIDencsmtp2
30303
30304
30305 .section "TLS Resumption" "SECTresumption"
30306 .cindex TLS resumption
30307 TLS Session Resumption for TLS 1.2 and TLS 1.3 connections can be used (defined
30308 in RFC 5077 for 1.2).  The support for this requires GnuTLS 3.6.3 or OpenSSL 1.1.1
30309 (or later).
30310
30311 Session resumption (this is the "stateless" variant) involves the server sending
30312 a "session ticket" to the client on one connection, which can be stored by the
30313 client and used for a later session.  The ticket contains sufficient state for
30314 the server to reconstruct the TLS session, avoiding some expensive crypto
30315 calculation and (on TLS1.2) one full packet roundtrip time.
30316
30317 .ilist
30318 Operational cost/benefit:
30319
30320  The extra data being transmitted costs a minor amount, and the client has
30321  extra costs in storing and retrieving the data.
30322
30323  In the Exim/Gnutls implementation the extra cost on an initial connection
30324  which is TLS1.2 over a loopback path is about 6ms on 2017-laptop class hardware.
30325  The saved cost on a subsequent connection is about 4ms; three or more
30326  connections become a net win.  On longer network paths, two or more
30327  connections will have an average lower startup time thanks to the one
30328  saved packet roundtrip.  TLS1.3 will save the crypto cpu costs but not any
30329  packet roundtrips.
30330
30331 .cindex "hints database" tls
30332  Since a new hints DB is used on the TLS client,
30333  the hints DB maintenance should be updated to additionally handle "tls".
30334
30335 .next
30336 Security aspects:
30337
30338  The session ticket is encrypted, but is obviously an additional security
30339  vulnarability surface.  An attacker able to decrypt it would have access
30340  all connections using the resumed session.
30341  The session ticket encryption key is not committed to storage by the server
30342  and is rotated regularly (OpenSSL: 1hr, and one previous key is used for
30343  overlap; GnuTLS 6hr but does not specify any overlap).
30344  Tickets have limited lifetime (2hr, and new ones issued after 1hr under
30345  OpenSSL.  GnuTLS 2hr, appears to not do overlap).
30346
30347  There is a question-mark over the security of the Diffie-Helman parameters
30348  used for session negotiation.
30349
30350 .next
30351 Observability:
30352
30353  The &%log_selector%& "tls_resumption" appends an asterisk to the tls_cipher "X="
30354  element.
30355
30356  The variables &$tls_in_resumption$& and &$tls_out_resumption$&
30357  have bits 0-4 indicating respectively
30358  support built, client requested ticket, client offered session,
30359  server issued ticket, resume used.  A suitable decode list is provided
30360  in the builtin macro _RESUME_DECODE for in &%listextract%& expansions.
30361
30362 .next
30363 Control:
30364
30365 The &%tls_resumption_hosts%& main option specifies a hostlist for which
30366 exim, operating as a server, will offer resumption to clients.
30367 Current best practice is to not offer the feature to MUA connection.
30368 Commonly this can be done like this:
30369 .code
30370 tls_resumption_hosts = ${if inlist {$received_port}{587:465} {:}{*}}
30371 .endd
30372 If the peer host matches the list after expansion then resumption
30373 is offered and/or accepted.
30374
30375 The &%tls_resumption_hosts%& smtp transport option performs the
30376 equivalent function for operation as a client.
30377 If the peer host matches the list after expansion then resumption
30378 is attempted (if a stored session is available) or the information
30379 stored (if supplied by the peer).
30380
30381
30382 .next
30383 Issues:
30384
30385  In a resumed session:
30386 .ilist
30387   The variables &$tls_{in,out}_cipher$& will have values different
30388  to the original (under GnuTLS).
30389 .next
30390   The variables &$tls_{in,out}_ocsp$& will be "not requested" or "no response",
30391  and the &%hosts_require_ocsp%& smtp trasnport option will fail.
30392 . XXX need to do something with that hosts_require_ocsp
30393 .endlist
30394
30395 .endlist
30396
30397
30398 .section DANE "SECDANE"
30399 .cindex DANE
30400 DNS-based Authentication of Named Entities, as applied to SMTP over TLS, provides assurance to a client that
30401 it is actually talking to the server it wants to rather than some attacker operating a Man In The Middle (MITM)
30402 operation.  The latter can terminate the TLS connection you make, and make another one to the server (so both
30403 you and the server still think you have an encrypted connection) and, if one of the "well known" set of
30404 Certificate Authorities has been suborned - something which *has* been seen already (2014), a verifiable
30405 certificate (if you're using normal root CAs, eg. the Mozilla set, as your trust anchors).
30406
30407 What DANE does is replace the CAs with the DNS as the trust anchor.  The assurance is limited to a) the possibility
30408 that the DNS has been suborned, b) mistakes made by the admins of the target server.   The attack surface presented
30409 by (a) is thought to be smaller than that of the set of root CAs.
30410
30411 It also allows the server to declare (implicitly) that connections to it should use TLS.  An MITM could simply
30412 fail to pass on a server's STARTTLS.
30413
30414 DANE scales better than having to maintain (and communicate via side-channel) copies of server certificates
30415 for every possible target server.  It also scales (slightly) better than having to maintain on an SMTP
30416 client a copy of the standard CAs bundle.  It also means not having to pay a CA for certificates.
30417
30418 DANE requires a server operator to do three things:
30419 .olist
30420 Run DNSSEC.  This provides assurance to clients
30421 that DNS lookups they do for the server have not been tampered with.  The domain MX record applying
30422 to this server, its A record, its TLSA record and any associated CNAME records must all be covered by
30423 DNSSEC.
30424 .next
30425 Add TLSA DNS records.  These say what the server certificate for a TLS connection should be.
30426 .next
30427 Offer a server certificate, or certificate chain, in TLS connections which is anchored by one of the TLSA records.
30428 .endlist
30429
30430 There are no changes to Exim specific to server-side operation of DANE.
30431 Support for client-side operation of DANE can be included at compile time by defining SUPPORT_DANE=yes
30432 in &_Local/Makefile_&.
30433 If it has been included, the macro "_HAVE_DANE" will be defined.
30434
30435 .subsection "DNS records"
30436 A TLSA record consist of 4 fields, the "Certificate Usage", the
30437 "Selector", the "Matching type", and the "Certificate Association Data".
30438 For a detailed description of the TLSA record see
30439 &url(https://tools.ietf.org/html/rfc7671#page-5,RFC 7671).
30440
30441 The TLSA record for the server may have "Certificate Usage" (1st) field of DANE-TA(2) or DANE-EE(3).
30442 These are the "Trust Anchor" and "End Entity" variants.
30443 The latter specifies the End Entity directly, i.e. the certificate involved is that of the server
30444 (and if only DANE-EE is used then it should be the sole one transmitted during the TLS handshake);
30445 this is appropriate for a single system, using a self-signed certificate.
30446 DANE-TA usage is effectively declaring a specific CA to be used; this might be a private CA or a public,
30447 well-known one.
30448 A private CA at simplest is just a self-signed certificate (with certain
30449 attributes) which is used to sign server certificates, but running one securely
30450 does require careful arrangement.
30451 With DANE-TA, as implemented in Exim and commonly in other MTAs,
30452 the server TLS handshake must transmit the entire certificate chain from CA to server-certificate.
30453 DANE-TA is commonly used for several services and/or servers, each having a TLSA query-domain CNAME record,
30454 all of which point to a single TLSA record.
30455 DANE-TA and DANE-EE can both be used together.
30456
30457 Our recommendation is to use DANE with a certificate from a public CA,
30458 because this enables a variety of strategies for remote clients to verify
30459 your certificate.
30460 You can then publish information both via DANE and another technology,
30461 "MTA-STS", described below.
30462
30463 When you use DANE-TA to publish trust anchor information, you ask entities
30464 outside your administrative control to trust the Certificate Authority for
30465 connections to you.
30466 If using a private CA then you should expect others to still apply the
30467 technical criteria they'd use for a public CA to your certificates.
30468 In particular, you should probably try to follow current best practices for CA
30469 operation around hash algorithms and key sizes.
30470 Do not expect other organizations to lower their security expectations just
30471 because a particular profile might be reasonable for your own internal use.
30472
30473 When this text was last updated, this in practice means to avoid use of SHA-1
30474 and MD5; if using RSA to use key sizes of at least 2048 bits (and no larger
30475 than 4096, for interoperability); to use keyUsage fields correctly; to use
30476 random serial numbers.
30477 The list of requirements is subject to change as best practices evolve.
30478 If you're not already using a private CA, or it doesn't meet these
30479 requirements, then we encourage you to avoid all these issues and use a public
30480 CA such as &url(https://letsencrypt.org/,Let's Encrypt) instead.
30481
30482 The TLSA record should have a "Selector" (2nd) field of SPKI(1) and
30483 a "Matching Type" (3rd) field of SHA2-512(2).
30484
30485 For the "Certificate Authority Data" (4th) field, commands like
30486
30487 .code
30488   openssl x509 -pubkey -noout <certificate.pem \
30489   | openssl rsa -outform der -pubin 2>/dev/null \
30490   | openssl sha512 \
30491   | awk '{print $2}'
30492 .endd
30493
30494 are workable to create a hash of the certificate's public key.
30495
30496 An example TLSA record for DANE-EE(3), SPKI(1), and SHA-512 (2) looks like
30497
30498 .code
30499   _25._tcp.mail.example.com. TLSA 3 1 2 8BA8A336E...
30500 .endd
30501
30502 At the time of writing, &url(https://www.huque.com/bin/gen_tlsa)
30503 is useful for quickly generating TLSA records.
30504
30505
30506 For use with the DANE-TA model, server certificates must have a correct name (SubjectName or SubjectAltName).
30507
30508 The Certificate issued by the CA published in the DANE-TA model should be
30509 issued using a strong hash algorithm.
30510 Exim, and importantly various other MTAs sending to you, will not
30511 re-enable hash algorithms which have been disabled by default in TLS
30512 libraries.
30513 This means no MD5 and no SHA-1.  SHA2-256 is the minimum for reliable
30514 interoperability (and probably the maximum too, in 2018).
30515
30516 .subsection "Interaction with OCSP"
30517 The use of OCSP-stapling should be considered, allowing for fast revocation of certificates (which would otherwise
30518 be limited by the DNS TTL on the TLSA records).  However, this is likely to only be usable with DANE-TA.  NOTE: the
30519 default of requesting OCSP for all hosts is modified iff DANE is in use, to:
30520
30521 .code
30522   hosts_request_ocsp = ${if or { {= {0}{$tls_out_tlsa_usage}} \
30523                                  {= {4}{$tls_out_tlsa_usage}} } \
30524                          {*}{}}
30525 .endd
30526
30527 The (new) variable &$tls_out_tlsa_usage$& is a bitfield with numbered bits set for TLSA record usage codes.
30528 The zero above means DANE was not in use, the four means that only DANE-TA usage TLSA records were
30529 found. If the definition of &%hosts_request_ocsp%& includes the
30530 string "tls_out_tlsa_usage", they are re-expanded in time to
30531 control the OCSP request.
30532
30533 This modification of hosts_request_ocsp is only done if it has the default value of "*".  Admins who change it, and
30534 those who use &%hosts_require_ocsp%&, should consider the interaction with DANE in their OCSP settings.
30535
30536
30537 .subsection "Client configuration"
30538 For client-side DANE there are three new smtp transport options, &%hosts_try_dane%&, &%hosts_require_dane%&
30539 and &%dane_require_tls_ciphers%&.
30540 The &"require"& variant will result in failure if the target host is not
30541 DNSSEC-secured. To get DNSSEC-secured hostname resolution, use
30542 the &%dnssec_request_domains%& router or transport option.
30543
30544 DANE will only be usable if the target host has DNSSEC-secured MX, A and TLSA records.
30545
30546 A TLSA lookup will be done if either of the above options match and the host-lookup succeeded using DNSSEC.
30547 If a TLSA lookup is done and succeeds, a DANE-verified TLS connection
30548 will be required for the host.  If it does not, the host will not
30549 be used; there is no fallback to non-DANE or non-TLS.
30550
30551 If DANE is requested and usable, then the TLS cipher list configuration
30552 prefers to use the option &%dane_require_tls_ciphers%& and falls
30553 back to &%tls_require_ciphers%& only if that is unset.
30554 This lets you configure "decent crypto" for DANE and "better than nothing
30555 crypto" as the default.  Note though that while GnuTLS lets the string control
30556 which versions of TLS/SSL will be negotiated, OpenSSL does not and you're
30557 limited to ciphersuite constraints.
30558
30559 If DANE is requested and useable (see above) the following transport options are ignored:
30560 .code
30561   hosts_require_tls
30562   tls_verify_hosts
30563   tls_try_verify_hosts
30564   tls_verify_certificates
30565   tls_crl
30566   tls_verify_cert_hostnames
30567   tls_sni
30568 .endd
30569
30570 If DANE is not usable, whether requested or not, and CA-anchored
30571 verification evaluation is wanted, the above variables should be set appropriately.
30572
30573 The router and transport option &%dnssec_request_domains%& must not be
30574 set to &"never"&, and &%dnssec_require_domains%& is ignored.
30575
30576 .subsection Observability
30577 If verification was successful using DANE then the "CV" item in the delivery log line will show as "CV=dane".
30578
30579 There is a new variable &$tls_out_dane$& which will have "yes" if
30580 verification succeeded using DANE and "no" otherwise (only useful
30581 in combination with events; see &<<CHAPevents>>&),
30582 and a new variable &$tls_out_tlsa_usage$& (detailed above).
30583
30584 .cindex DANE reporting
30585 An event (see &<<CHAPevents>>&) of type "dane:fail" will be raised on failures
30586 to achieve DANE-verified connection, if one was either requested and offered, or
30587 required.  This is intended to support TLS-reporting as defined in
30588 &url(https://tools.ietf.org/html/draft-ietf-uta-smtp-tlsrpt-17).
30589 The &$event_data$& will be one of the Result Types defined in
30590 Section 4.3 of that document.
30591
30592 .subsection General
30593 Under GnuTLS, DANE is only supported from version 3.0.0 onwards.
30594
30595 DANE is specified in RFC 6698. It decouples certificate authority trust
30596 selection from a "race to the bottom" of "you must trust everything for mail
30597 to get through".
30598 It does retain the need to trust the assurances provided by the DNSSEC tree.
30599
30600 There is an alternative technology called MTA-STS (RFC 8461), which
30601 instead publishes MX trust anchor information on an HTTPS website.
30602 The discovery of the address for that website does not (per standard)
30603 require DNSSEC, and could be regarded as being less secure than DANE
30604 as a result.
30605
30606 Exim has no support for MTA-STS as a client, but Exim mail server operators
30607 can choose to publish information describing their TLS configuration using
30608 MTA-STS to let those clients who do use that protocol derive trust
30609 information.
30610
30611 The MTA-STS design requires a certificate from a public Certificate Authority
30612 which is recognized by clients sending to you.
30613 That selection of which CAs are trusted by others is outside your control.
30614
30615 The most interoperable course of action is probably to use
30616 &url(https://letsencrypt.org/,Let's Encrypt), with automated certificate
30617 renewal; to publish the anchor information in DNSSEC-secured DNS via TLSA
30618 records for DANE clients (such as Exim and Postfix) and to publish anchor
30619 information for MTA-STS as well.  This is what is done for the &'exim.org'&
30620 domain itself (with caveats around occasionally broken MTA-STS because of
30621 incompatible specification changes prior to reaching RFC status).
30622
30623
30624
30625 . ////////////////////////////////////////////////////////////////////////////
30626 . ////////////////////////////////////////////////////////////////////////////
30627
30628 .chapter "Access control lists" "CHAPACL"
30629 .scindex IIDacl "&ACL;" "description"
30630 .cindex "control of incoming mail"
30631 .cindex "message" "controlling incoming"
30632 .cindex "policy control" "access control lists"
30633 Access Control Lists (ACLs) are defined in a separate section of the runtime
30634 configuration file, headed by &"begin acl"&. Each ACL definition starts with a
30635 name, terminated by a colon. Here is a complete ACL section that contains just
30636 one very small ACL:
30637 .code
30638 begin acl
30639 small_acl:
30640   accept   hosts = one.host.only
30641 .endd
30642 You can have as many lists as you like in the ACL section, and the order in
30643 which they appear does not matter. The lists are self-terminating.
30644
30645 The majority of ACLs are used to control Exim's behaviour when it receives
30646 certain SMTP commands. This applies both to incoming TCP/IP connections, and
30647 when a local process submits a message using SMTP by specifying the &%-bs%&
30648 option. The most common use is for controlling which recipients are accepted
30649 in incoming messages. In addition, you can define an ACL that is used to check
30650 local non-SMTP messages. The default configuration file contains an example of
30651 a realistic ACL for checking RCPT commands. This is discussed in chapter
30652 &<<CHAPdefconfil>>&.
30653
30654
30655 .section "Testing ACLs" "SECID188"
30656 The &%-bh%& command line option provides a way of testing your ACL
30657 configuration locally by running a fake SMTP session with which you interact.
30658
30659
30660 .section "Specifying when ACLs are used" "SECID189"
30661 .cindex "&ACL;" "options for specifying"
30662 In order to cause an ACL to be used, you have to name it in one of the relevant
30663 options in the main part of the configuration. These options are:
30664 .cindex "AUTH" "ACL for"
30665 .cindex "DATA" "ACLs for"
30666 .cindex "ETRN" "ACL for"
30667 .cindex "EXPN" "ACL for"
30668 .cindex "HELO" "ACL for"
30669 .cindex "EHLO" "ACL for"
30670 .cindex "DKIM" "ACL for"
30671 .cindex "MAIL" "ACL for"
30672 .cindex "QUIT, ACL for"
30673 .cindex "RCPT" "ACL for"
30674 .cindex "STARTTLS, ACL for"
30675 .cindex "VRFY" "ACL for"
30676 .cindex "WELLKNOWN" "ACL for"
30677 .cindex "SMTP" "connection, ACL for"
30678 .cindex "non-SMTP messages" "ACLs for"
30679 .cindex "MIME content scanning" "ACL for"
30680 .cindex "PRDR" "ACL for"
30681
30682 .table2 140pt
30683 .irow &%acl_not_smtp%&         "ACL for non-SMTP messages"
30684 .irow &%acl_not_smtp_mime%&    "ACL for non-SMTP MIME parts"
30685 .irow &%acl_not_smtp_start%&   "ACL at start of non-SMTP message"
30686 .irow &%acl_smtp_auth%&        "ACL for AUTH"
30687 .irow &%acl_smtp_connect%&     "ACL for start of SMTP connection"
30688 .irow &%acl_smtp_data%&        "ACL after DATA is complete"
30689 .irow &%acl_smtp_data_prdr%&   "ACL for each recipient, after DATA is complete"
30690 .irow &%acl_smtp_dkim%&        "ACL for each DKIM signer"
30691 .irow &%acl_smtp_etrn%&        "ACL for ETRN"
30692 .irow &%acl_smtp_expn%&        "ACL for EXPN"
30693 .irow &%acl_smtp_helo%&        "ACL for HELO or EHLO"
30694 .irow &%acl_smtp_mail%&        "ACL for MAIL"
30695 .irow &%acl_smtp_mailauth%&    "ACL for the AUTH parameter of MAIL"
30696 .irow &%acl_smtp_mime%&        "ACL for content-scanning MIME parts"
30697 .irow &%acl_smtp_notquit%&     "ACL for non-QUIT terminations"
30698 .irow &%acl_smtp_predata%&     "ACL at start of DATA command"
30699 .irow &%acl_smtp_quit%&        "ACL for QUIT"
30700 .irow &%acl_smtp_rcpt%&        "ACL for RCPT"
30701 .irow &%acl_smtp_starttls%&    "ACL for STARTTLS"
30702 .irow &%acl_smtp_vrfy%&        "ACL for VRFY"
30703 .irow &%acl_smtp_wellknown%&   "ACL for WELLKNOWN"
30704 .endtable
30705
30706 For example, if you set
30707 .code
30708 acl_smtp_rcpt = small_acl
30709 .endd
30710 the little ACL defined above is used whenever Exim receives a RCPT command
30711 in an SMTP dialogue. The majority of policy tests on incoming messages can be
30712 done when RCPT commands arrive. A rejection of RCPT should cause the
30713 sending MTA to give up on the recipient address contained in the RCPT
30714 command, whereas rejection at other times may cause the client MTA to keep on
30715 trying to deliver the message. It is therefore recommended that you do as much
30716 testing as possible at RCPT time.
30717
30718
30719 .subsection "The non-SMTP ACLs" SECnonSMTP
30720 .cindex "non-SMTP messages" "ACLs for"
30721 The non-SMTP ACLs apply to all non-interactive incoming messages, that is, they
30722 apply to batched SMTP as well as to non-SMTP messages. (Batched SMTP is not
30723 really SMTP.) Many of the ACL conditions (for example, host tests, and tests on
30724 the state of the SMTP connection such as encryption and authentication) are not
30725 relevant and are forbidden in these ACLs. However, the sender and recipients
30726 are known, so the &%senders%& and &%sender_domains%& conditions and the
30727 &$sender_address$& and &$recipients$& variables can be used. Variables such as
30728 &$authenticated_sender$& are also available. You can specify added header lines
30729 in any of these ACLs.
30730
30731 The &%acl_not_smtp_start%& ACL is run right at the start of receiving a
30732 non-SMTP message, before any of the message has been read. (This is the
30733 analogue of the &%acl_smtp_predata%& ACL for SMTP input.) In the case of
30734 batched SMTP input, it runs after the DATA command has been reached. The
30735 result of this ACL is ignored; it cannot be used to reject a message. If you
30736 really need to, you could set a value in an ACL variable here and reject based
30737 on that in the &%acl_not_smtp%& ACL. However, this ACL can be used to set
30738 controls, and in particular, it can be used to set
30739 .code
30740 control = suppress_local_fixups
30741 .endd
30742 This cannot be used in the other non-SMTP ACLs because by the time they are
30743 run, it is too late.
30744
30745 The &%acl_not_smtp_mime%& ACL is available only when Exim is compiled with the
30746 content-scanning extension. For details, see chapter &<<CHAPexiscan>>&.
30747
30748 The &%acl_not_smtp%& ACL is run just before the &[local_scan()]& function. Any
30749 kind of rejection is treated as permanent, because there is no way of sending a
30750 temporary error for these kinds of message.
30751
30752
30753 .subsection "The SMTP connect ACL" SECconnectACL
30754 .cindex "SMTP" "connection, ACL for"
30755 .oindex &%smtp_banner%&
30756 The ACL test specified by &%acl_smtp_connect%& happens at the start of an SMTP
30757 session, after the test specified by &%host_reject_connection%& (which is now
30758 an anomaly) and any TCP Wrappers testing (if configured). If the connection is
30759 accepted by an &%accept%& verb that has a &%message%& modifier, the contents of
30760 the message override the banner message that is otherwise specified by the
30761 &%smtp_banner%& option.
30762
30763 For tls-on-connect connections, the ACL is run before the TLS connection
30764 is accepted; if the ACL does not accept then the TCP connection is dropped without
30765 any TLS startup attempt and without any SMTP response being transmitted.
30766
30767
30768 .subsection "The EHLO/HELO ACL" SECheloACL
30769 .cindex "EHLO" "ACL for"
30770 .cindex "HELO" "ACL for"
30771 The ACL test specified by &%acl_smtp_helo%& happens when the client issues an
30772 EHLO or HELO command, after the tests specified by &%helo_accept_junk_hosts%&,
30773 &%helo_allow_chars%&, &%helo_verify_hosts%&, and &%helo_try_verify_hosts%&.
30774 Note that a client may issue more than one EHLO or HELO command in an SMTP
30775 session, and indeed is required to issue a new EHLO or HELO after successfully
30776 setting up encryption following a STARTTLS command.
30777
30778 Note also that a deny neither forces the client to go away nor means that
30779 mail will be refused on the connection.  Consider checking for
30780 &$sender_helo_name$& being defined in a MAIL or RCPT ACL to do that.
30781
30782 If the command is accepted by an &%accept%& verb that has a &%message%&
30783 modifier, the message may not contain more than one line (it will be truncated
30784 at the first newline and a panic logged if it does). Such a message cannot
30785 affect the EHLO options that are listed on the second and subsequent lines of
30786 an EHLO response.
30787
30788
30789 .subsection "The DATA ACLs" SECdataACLS
30790 .cindex "DATA" "ACLs for"
30791 Two ACLs are associated with the DATA command, because it is two-stage
30792 command, with two responses being sent to the client.
30793 When the DATA command is received, the ACL defined by &%acl_smtp_predata%&
30794 is obeyed. This gives you control after all the RCPT commands, but before
30795 the message itself is received. It offers the opportunity to give a negative
30796 response to the DATA command before the data is transmitted. Header lines
30797 added by MAIL or RCPT ACLs are not visible at this time, but any that
30798 are defined here are visible when the &%acl_smtp_data%& ACL is run.
30799
30800 You cannot test the contents of the message, for example, to verify addresses
30801 in the headers, at RCPT time or when the DATA command is received. Such
30802 tests have to appear in the ACL that is run after the message itself has been
30803 received, before the final response to the DATA command is sent. This is
30804 the ACL specified by &%acl_smtp_data%&, which is the second ACL that is
30805 associated with the DATA command.
30806
30807 .cindex CHUNKING "BDAT command"
30808 .cindex BDAT "SMTP command"
30809 .cindex "RFC 3030" CHUNKING
30810 If CHUNKING was advertised and a BDAT command sequence is received,
30811 the &%acl_smtp_predata%& ACL is not run.
30812 . XXX why not?  It should be possible, for the first BDAT.
30813 The &%acl_smtp_data%& is run after the last BDAT command and all of
30814 the data specified is received.
30815
30816 For both of these ACLs, it is not possible to reject individual recipients. An
30817 error response rejects the entire message. Unfortunately, it is known that some
30818 MTAs do not treat hard (5&'xx'&) responses to the DATA command (either
30819 before or after the data) correctly &-- they keep the message on their queues
30820 and try again later, but that is their problem, though it does waste some of
30821 your resources.
30822
30823 The &%acl_smtp_data%& ACL is run after
30824 the &%acl_smtp_data_prdr%&,
30825 the &%acl_smtp_dkim%&
30826 and the &%acl_smtp_mime%& ACLs.
30827
30828 .subsection "The SMTP DKIM ACL" SECTDKIMACL
30829 The &%acl_smtp_dkim%& ACL is available only when Exim is compiled with DKIM support
30830 enabled (which is the default).
30831
30832 If, for a specific message, an ACL control
30833 &*dkim_disable_verify*&
30834 has been set, this &%acl_smtp_dkim%& ACL is not called.
30835
30836 The ACL test specified by &%acl_smtp_dkim%& happens after a message has been
30837 received, and is executed for each DKIM signature found in a message.  If not
30838 otherwise specified, the default action is to accept.
30839
30840 This ACL is evaluated before &%acl_smtp_mime%& and &%acl_smtp_data%&.
30841
30842 For details on the operation of DKIM, see section &<<SECDKIM>>&.
30843
30844
30845 .subsection "The SMTP MIME ACL" SECID194
30846 The &%acl_smtp_mime%& option is available only when Exim is compiled with the
30847 content-scanning extension. For details, see chapter &<<CHAPexiscan>>&.
30848
30849 This ACL is evaluated after &%acl_smtp_dkim%& but before &%acl_smtp_data%&.
30850
30851
30852 .subsection "The SMTP PRDR ACL" SECTPRDRACL
30853 .cindex "PRDR" "ACL for"
30854 .oindex "&%prdr_enable%&"
30855 The &%acl_smtp_data_prdr%& ACL is available only when Exim is compiled
30856 with PRDR support enabled (which is the default).
30857 It becomes active only when the PRDR feature is negotiated between
30858 client and server for a message, and more than one recipient
30859 has been accepted.
30860
30861 The ACL test specified by &%acl_smtp_data_prdr%& happens after a message
30862 has been received, and is executed once for each recipient of the message
30863 with &$local_part$& and &$domain$& valid.
30864 The test may accept, defer or deny for individual recipients.
30865 The &%acl_smtp_data%& will still be called after this ACL and
30866 can reject the message overall, even if this ACL has accepted it
30867 for some or all recipients.
30868
30869 PRDR may be used to support per-user content filtering.  Without it
30870 one must defer any recipient after the first that has a different
30871 content-filter configuration.  With PRDR, the RCPT-time check
30872 .cindex "PRDR" "variable for"
30873 for this can be disabled when the variable &$prdr_requested$&
30874 is &"yes"&.
30875 Any required difference in behaviour of the main DATA-time
30876 ACL should however depend on the PRDR-time ACL having run, as Exim
30877 will avoid doing so in some situations (e.g. single-recipient mails).
30878
30879 See also the &%prdr_enable%& global option
30880 and the &%hosts_try_prdr%& smtp transport option.
30881
30882 This ACL is evaluated after &%acl_smtp_dkim%& but before &%acl_smtp_data%&.
30883 If the ACL is not defined, processing completes as if
30884 the feature was not requested by the client.
30885
30886 .subsection "The SMTP WELLKNOWN ACL" SECTWELLKNOWNACL
30887 .cindex "WELLKNOWN" "ACL for"
30888 .oindex "&%acl_smtp_wellknown%&"
30889 The &%acl_smtp_wellknown%& ACL is available only when Exim is compiled
30890 with WELLKNOWN support enabled.
30891
30892 The ACL determines the response to an SMTP WELLKNOWN command, using the normal
30893 accept/defer/deny verbs for the response code,
30894 and a new &"control=wellknown"& modifier.
30895 This modifier takes a single option, separated by a '/'
30896 character, which must be the name of a file containing the response
30897 cleartext.  The modifier is expanded before use in the usual way before
30898 it is used.  The configuration is responsible for picking a suitable file
30899 to return and, most importantly, not returning any unexpected file.
30900 The argument for the SMTP verb will be available in the &$smtp_command_argument$&
30901 variable and can be used for building the file path.
30902 If the file path given in the modifier is empty or inacessible, the control will
30903 fail.
30904
30905 For example:
30906 .code
30907  check_wellknown:
30908   accept control = wellknown/\
30909                     ${lookup {${xtextd:$smtp_command_argument}} \
30910                         dsearch,key=path,filter=file,ret=full \
30911                         {$spooldir/wellknown.d}}
30912 .endd
30913 File content will be encoded in &"xtext"& form, and line-wrapping
30914 for line-length limitation will be done before transmission.
30915 A response summary line will be prepended, with the (pre-encoding) file size.
30916
30917 The above example uses the expansion operator ${xtextd:<coded-string>}
30918 which is needed to decode the xtext-encoded key from the SMTP verb.
30919
30920 Under the util directory there is a "mailtest" utility which can be used
30921 to test/retrieve WELLKNOWN items. Syntax is
30922 .code
30923   mailtest -h host.example.com -w security.txt
30924 .endd
30925
30926 WELLKNOWN is a ESMTP extension providing access to extended
30927 information about the server.  It is modelled on the webserver
30928 facilities documented in RFC 8615 and can be used for a security.txt
30929 file and could be used for ACME handshaking (RFC 8555).
30930
30931 Exim will advertise WELLKNOWN support in the EHLO response
30932 .oindex &%wellknown_advertise_hosts%&
30933 (conditional on a new option &%wellknown_advertise_hosts%&)
30934 and service WELLKNOWN smtp verbs having a single parameter
30935 giving a key for an item of "site-wide metadata".
30936 The verb and key are separated by whitespace,
30937 and the key is xtext-encoded (per RFC 3461 section 4).
30938
30939
30940 .subsection "The QUIT ACL" SECTQUITACL
30941 .cindex "QUIT, ACL for"
30942 The ACL for the SMTP QUIT command is anomalous, in that the outcome of the ACL
30943 does not affect the response code to QUIT, which is always 221. Thus, the ACL
30944 does not in fact control any access.
30945 For this reason, it may only accept
30946 or warn as its final result.
30947
30948 This ACL can be used for tasks such as custom logging at the end of an SMTP
30949 session. For example, you can use ACL variables in other ACLs to count
30950 messages, recipients, etc., and log the totals at QUIT time using one or
30951 more &%logwrite%& modifiers on a &%warn%& verb.
30952
30953 &*Warning*&: Only the &$acl_c$&&'x'& variables can be used for this, because
30954 the &$acl_m$&&'x'& variables are reset at the end of each incoming message.
30955
30956 You do not need to have a final &%accept%&, but if you do, you can use a
30957 &%message%& modifier to specify custom text that is sent as part of the 221
30958 response to QUIT.
30959
30960 This ACL is run only for a &"normal"& QUIT. For certain kinds of disastrous
30961 failure (for example, failure to open a log file, or when Exim is bombing out
30962 because it has detected an unrecoverable error), all SMTP commands from the
30963 client are given temporary error responses until QUIT is received or the
30964 connection is closed. In these special cases, the QUIT ACL does not run.
30965
30966
30967 .subsection "The not-QUIT ACL" SECTNOTQUITACL
30968 .vindex &$acl_smtp_notquit$&
30969 The not-QUIT ACL, specified by &%acl_smtp_notquit%&, is run in most cases when
30970 an SMTP session ends without sending QUIT. However, when Exim itself is in bad
30971 trouble, such as being unable to write to its log files, this ACL is not run,
30972 because it might try to do things (such as write to log files) that make the
30973 situation even worse.
30974
30975 Like the QUIT ACL, this ACL is provided to make it possible to do customized
30976 logging or to gather statistics, and its outcome is ignored. The &%delay%&
30977 modifier is forbidden in this ACL, and the only permitted verbs are &%accept%&
30978 and &%warn%&.
30979
30980 .vindex &$smtp_notquit_reason$&
30981 When the not-QUIT ACL is running, the variable &$smtp_notquit_reason$& is set
30982 to a string that indicates the reason for the termination of the SMTP
30983 connection. The possible values are:
30984 .table2
30985 .irow &`acl-drop`&                 "Another ACL issued a &%drop%& command"
30986 .irow &`bad-commands`&             "Too many unknown or non-mail commands"
30987 .irow &`command-timeout`&          "Timeout while reading SMTP commands"
30988 .irow &`connection-lost`&          "The SMTP connection has been lost"
30989 .irow &`data-timeout`&             "Timeout while reading message data"
30990 .irow &`local-scan-error`&         "The &[local_scan()]& function crashed"
30991 .irow &`local-scan-timeout`&       "The &[local_scan()]& function timed out"
30992 .irow &`signal-exit`&              "SIGTERM or SIGINT"
30993 .irow &`synchronization-error`&    "SMTP synchronization error"
30994 .irow &`tls-failed`&               "TLS failed to start"
30995 .endtable
30996 In most cases when an SMTP connection is closed without having received QUIT,
30997 Exim sends an SMTP response message before actually closing the connection.
30998 With the exception of the &`acl-drop`& case, the default message can be
30999 overridden by the &%message%& modifier in the not-QUIT ACL. In the case of a
31000 &%drop%& verb in another ACL, it is the message from the other ACL that is
31001 used.
31002
31003
31004 .section "Finding an ACL to use" "SECID195"
31005 .cindex "&ACL;" "finding which to use"
31006 The value of an &%acl_smtp_%&&'xxx'& option is expanded before use, so
31007 you can use different ACLs in different circumstances. For example,
31008 .code
31009 acl_smtp_rcpt = ${if ={25}{$interface_port} \
31010                      {acl_check_rcpt} {acl_check_rcpt_submit} }
31011 .endd
31012 In the default configuration file there are some example settings for
31013 providing an RFC 4409 message &"submission"& service on port 587 and
31014 an RFC 8314 &"submissions"& service on port 465. You can use a string
31015 expansion like this to choose an ACL for MUAs on these ports which is
31016 more appropriate for this purpose than the default ACL on port 25.
31017
31018 The expanded string does not have to be the name of an ACL in the
31019 configuration file; there are other possibilities. Having expanded the
31020 string, Exim searches for an ACL as follows:
31021
31022 .ilist
31023 If the string begins with a slash, Exim uses it as a filename, and reads its
31024 contents as an ACL. The lines are processed in the same way as lines in the
31025 Exim configuration file. In particular, continuation lines are supported, blank
31026 lines are ignored, as are lines whose first non-whitespace character is &"#"&.
31027 If the file does not exist or cannot be read, an error occurs (typically
31028 causing a temporary failure of whatever caused the ACL to be run). For example:
31029 .code
31030 acl_smtp_data = /etc/acls/\
31031   ${lookup{$sender_host_address}lsearch\
31032   {/etc/acllist}{$value}{default}}
31033 .endd
31034 This looks up an ACL file to use on the basis of the host's IP address, falling
31035 back to a default if the lookup fails. If an ACL is successfully read from a
31036 file, it is retained in memory for the duration of the Exim process, so that it
31037 can be re-used without having to re-read the file.
31038 .next
31039 If the string does not start with a slash, and does not contain any spaces,
31040 Exim searches the ACL section of the configuration for an ACL whose name
31041 matches the string.
31042 .next
31043 If no named ACL is found, or if the string contains spaces, Exim parses
31044 the string as an inline ACL. This can save typing in cases where you just
31045 want to have something like
31046 .code
31047 acl_smtp_vrfy = accept
31048 .endd
31049 in order to allow free use of the VRFY command. Such a string may contain
31050 newlines; it is processed in the same way as an ACL that is read from a file.
31051 .endlist
31052
31053
31054
31055
31056 .section "ACL return codes" "SECID196"
31057 .cindex "&ACL;" "return codes"
31058 Except for the QUIT ACL, which does not affect the SMTP return code (see
31059 section &<<SECTQUITACL>>& above), the result of running an ACL is either
31060 &"accept"& or &"deny"&, or, if some test cannot be completed (for example, if a
31061 database is down), &"defer"&. These results cause 2&'xx'&, 5&'xx'&, and 4&'xx'&
31062 return codes, respectively, to be used in the SMTP dialogue. A fourth return,
31063 &"error"&, occurs when there is an error such as invalid syntax in the ACL.
31064 This also causes a 4&'xx'& return code.
31065
31066 For the non-SMTP ACL, &"defer"& and &"error"& are treated in the same way as
31067 &"deny"&, because there is no mechanism for passing temporary errors to the
31068 submitters of non-SMTP messages.
31069
31070
31071 ACLs that are relevant to message reception may also return &"discard"&. This
31072 has the effect of &"accept"&, but causes either the entire message or an
31073 individual recipient address to be discarded. In other words, it is a
31074 blackholing facility. Use it with care.
31075
31076 If the ACL for MAIL returns &"discard"&, all recipients are discarded, and no
31077 ACL is run for subsequent RCPT commands. The effect of &"discard"& in a
31078 RCPT ACL is to discard just the one recipient address. If there are no
31079 recipients left when the message's data is received, the DATA ACL is not
31080 run. A &"discard"& return from the DATA or the non-SMTP ACL discards all the
31081 remaining recipients. The &"discard"& return is not permitted for the
31082 &%acl_smtp_predata%& ACL.
31083
31084 If the ACL for VRFY returns &"accept"&, a recipient verify (without callout)
31085 is done on the address and the result determines the SMTP response.
31086
31087
31088 .cindex "&[local_scan()]& function" "when all recipients discarded"
31089 The &[local_scan()]& function is always run, even if there are no remaining
31090 recipients; it may create new recipients.
31091
31092
31093
31094 .section "Unset ACL options" "SECID197"
31095 .cindex "&ACL;" "unset options"
31096 The default actions when any of the &%acl_%&&'xxx'& options are unset are not
31097 all the same. &*Note*&: These defaults apply only when the relevant ACL is
31098 not defined at all. For any defined ACL, the default action when control
31099 reaches the end of the ACL statements is &"deny"&.
31100
31101 For &%acl_smtp_quit%& and &%acl_not_smtp_start%& there is no default because
31102 these two are ACLs that are used only for their side effects. They cannot be
31103 used to accept or reject anything.
31104
31105 For &%acl_not_smtp%&, &%acl_smtp_auth%&, &%acl_smtp_connect%&,
31106 &%acl_smtp_data%&, &%acl_smtp_helo%&, &%acl_smtp_mail%&, &%acl_smtp_mailauth%&,
31107 &%acl_smtp_mime%&, &%acl_smtp_predata%&, and &%acl_smtp_starttls%&, the action
31108 when the ACL is not defined is &"accept"&.
31109
31110 For the others (&%acl_smtp_etrn%&, &%acl_smtp_expn%&, &%acl_smtp_rcpt%&,
31111 &%acl_smtp_vrfy%&
31112 and &%acl_smtp_wellknown%&),
31113 the action when the ACL
31114 is not defined is &"deny"&.  This means that &%acl_smtp_rcpt%& must be
31115 defined in order to receive any messages over an SMTP connection.
31116 For an example, see the ACL in the default configuration file.
31117
31118
31119
31120 .section "Data for message ACLs" "SECID198"
31121 .cindex "&ACL;" "data for message ACL"
31122 .vindex &$domain$&
31123 .vindex &$local_part$&
31124 .vindex &$sender_address$&
31125 .vindex &$sender_host_address$&
31126 .vindex &$smtp_command$&
31127 When a MAIL or RCPT ACL, or either of the DATA ACLs, is running, the variables
31128 that contain information about the host and the message's sender (for example,
31129 &$sender_host_address$& and &$sender_address$&) are set, and can be used in ACL
31130 statements. In the case of RCPT (but not MAIL or DATA), &$domain$& and
31131 &$local_part$& are set from the argument address. The entire SMTP command
31132 is available in &$smtp_command$&.
31133
31134 When an ACL for the AUTH parameter of MAIL is running, the variables that
31135 contain information about the host are set, but &$sender_address$& is not yet
31136 set. Section &<<SECTauthparamail>>& contains a discussion of this parameter and
31137 how it is used.
31138
31139 .vindex "&$message_size$&"
31140 The &$message_size$& variable is set to the value of the SIZE parameter on
31141 the MAIL command at MAIL, RCPT and pre-data time, or to -1 if
31142 that parameter is not given. The value is updated to the true message size by
31143 the time the final DATA ACL is run (after the message data has been
31144 received).
31145
31146 .vindex "&$rcpt_count$&"
31147 .vindex "&$recipients_count$&"
31148 The &$rcpt_count$& variable increases by one for each RCPT command received.
31149 The &$recipients_count$& variable increases by one each time a RCPT command is
31150 accepted, so while an ACL for RCPT is being processed, it contains the number
31151 of previously accepted recipients. At DATA time (for both the DATA ACLs),
31152 &$rcpt_count$& contains the total number of RCPT commands, and
31153 &$recipients_count$& contains the total number of accepted recipients.
31154
31155
31156
31157
31158
31159 .section "Data for non-message ACLs" "SECTdatfornon"
31160 .cindex "&ACL;" "data for non-message ACL"
31161 .vindex &$smtp_command_argument$&
31162 .vindex &$smtp_command$&
31163 When an ACL is being run for AUTH, EHLO, ETRN, EXPN, HELO, STARTTLS, or VRFY,
31164 the remainder of the SMTP command line is placed in &$smtp_command_argument$&,
31165 and the entire SMTP command is available in &$smtp_command$&.
31166 These variables can be tested using a &%condition%& condition. For example,
31167 here is an ACL for use with AUTH, which insists that either the session is
31168 encrypted, or the CRAM-MD5 authentication method is used. In other words, it
31169 does not permit authentication methods that use cleartext passwords on
31170 unencrypted connections.
31171 .code
31172 acl_check_auth:
31173   accept encrypted = *
31174   accept condition = ${if eq{${uc:$smtp_command_argument}}\
31175                      {CRAM-MD5}}
31176   deny   message   = TLS encryption or CRAM-MD5 required
31177 .endd
31178 (Another way of applying this restriction is to arrange for the authenticators
31179 that use cleartext passwords not to be advertised when the connection is not
31180 encrypted. You can use the generic &%server_advertise_condition%& authenticator
31181 option to do this.)
31182
31183
31184
31185 .section "Format of an ACL" "SECID199"
31186 .cindex "&ACL;" "format of"
31187 .cindex "&ACL;" "verbs, definition of"
31188 An individual ACL definition consists of a number of statements.
31189 Each statement starts
31190 with a verb, optionally followed by a number of conditions and &"modifiers"&.
31191 Modifiers can change the way the verb operates, define error and log messages,
31192 set variables, insert delays, and vary the processing of accepted messages.
31193
31194 If all the conditions are met, the verb is obeyed. The same condition may be
31195 used (with different arguments) more than once in the same statement. This
31196 provides a means of specifying an &"and"& conjunction between conditions. For
31197 example:
31198 .code
31199 deny  dnslists = list1.example
31200       dnslists = list2.example
31201 .endd
31202 If there are no conditions, the verb is always obeyed. Exim stops evaluating
31203 the conditions and modifiers when it reaches a condition that fails. What
31204 happens then depends on the verb (and in one case, on a special modifier). Not
31205 all the conditions make sense at every testing point. For example, you cannot
31206 test a sender address in the ACL that is run for a VRFY command.
31207
31208 The definition of an ACL ends where another starts,
31209 or a different configuration section starts.
31210
31211
31212 .section "ACL verbs" "SECID200"
31213 The ACL verbs are as follows:
31214
31215 .ilist
31216 .cindex "&%accept%& ACL verb"
31217 &%accept%&: If all the conditions are met, the ACL returns &"accept"&. If any
31218 of the conditions are not met, what happens depends on whether &%endpass%&
31219 appears among the conditions (for syntax see below). If the failing condition
31220 is before &%endpass%&, control is passed to the next ACL statement; if it is
31221 after &%endpass%&, the ACL returns &"deny"&. Consider this statement, used to
31222 check a RCPT command:
31223 .code
31224 accept domains = +local_domains
31225        endpass
31226        verify = recipient
31227 .endd
31228 If the recipient domain does not match the &%domains%& condition, control
31229 passes to the next statement. If it does match, the recipient is verified, and
31230 the command is accepted if verification succeeds. However, if verification
31231 fails, the ACL yields &"deny"&, because the failing condition is after
31232 &%endpass%&.
31233
31234 The &%endpass%& feature has turned out to be confusing to many people, so its
31235 use is not recommended nowadays. It is always possible to rewrite an ACL so
31236 that &%endpass%& is not needed, and it is no longer used in the default
31237 configuration.
31238
31239 .cindex "&%message%& ACL modifier" "with &%accept%&"
31240 If a &%message%& modifier appears on an &%accept%& statement, its action
31241 depends on whether or not &%endpass%& is present. In the absence of &%endpass%&
31242 (when an &%accept%& verb either accepts or passes control to the next
31243 statement), &%message%& can be used to vary the message that is sent when an
31244 SMTP command is accepted. For example, in a RCPT ACL you could have:
31245 .display
31246 &`accept  `&<&'some conditions'&>
31247 &`        message = OK, I will allow you through today`&
31248 .endd
31249 You can specify an SMTP response code, optionally followed by an &"extended
31250 response code"& at the start of the message, but the first digit must be the
31251 same as would be sent by default, which is 2 for an &%accept%& verb.
31252
31253 If &%endpass%& is present in an &%accept%& statement, &%message%& specifies
31254 an error message that is used when access is denied. This behaviour is retained
31255 for backward compatibility, but current &"best practice"& is to avoid the use
31256 of &%endpass%&.
31257
31258
31259 .next
31260 .cindex "&%defer%& ACL verb"
31261 &%defer%&: If all the conditions are true, the ACL returns &"defer"& which, in
31262 an SMTP session, causes a 4&'xx'& response to be given. For a non-SMTP ACL,
31263 &%defer%& is the same as &%deny%&, because there is no way of sending a
31264 temporary error. For a RCPT command, &%defer%& is much the same as using a
31265 &(redirect)& router and &`:defer:`& while verifying, but the &%defer%& verb can
31266 be used in any ACL, and even for a recipient it might be a simpler approach.
31267
31268
31269 .next
31270 .cindex "&%deny%& ACL verb"
31271 &%deny%&: If all the conditions are met, the ACL returns &"deny"&. If any of
31272 the conditions are not met, control is passed to the next ACL statement. For
31273 example,
31274 .code
31275 deny dnslists = blackholes.mail-abuse.org
31276 .endd
31277 rejects commands from hosts that are on a DNS black list.
31278
31279
31280 .next
31281 .cindex "&%discard%& ACL verb"
31282 &%discard%&: This verb behaves like &%accept%&, except that it returns
31283 &"discard"& from the ACL instead of &"accept"&. It is permitted only on ACLs
31284 that are concerned with receiving messages. When all the conditions are true,
31285 the sending entity receives a &"success"& response. However, &%discard%& causes
31286 recipients to be discarded. If it is used in an ACL for RCPT, just the one
31287 recipient is discarded; if used for MAIL, DATA or in the non-SMTP ACL, all the
31288 message's recipients are discarded. Recipients that are discarded before DATA
31289 do not appear in the log line when the &%received_recipients%& log selector is set.
31290
31291 If the &%log_message%& modifier is set when &%discard%& operates,
31292 its contents are added to the line that is automatically written to the log.
31293 The &%message%& modifier operates exactly as it does for &%accept%&.
31294
31295
31296 .next
31297 .cindex "&%drop%& ACL verb"
31298 &%drop%&: This verb behaves like &%deny%&, except that an SMTP connection is
31299 forcibly closed after the 5&'xx'& error message has been sent. For example:
31300 .code
31301 drop   condition = ${if > {$rcpt_count}{20}}
31302        message   = I don't take more than 20 RCPTs
31303 .endd
31304 There is no difference between &%deny%& and &%drop%& for the connect-time ACL.
31305 The connection is always dropped after sending a 550 response.
31306
31307 .next
31308 .cindex "&%require%& ACL verb"
31309 &%require%&: If all the conditions are met, control is passed to the next ACL
31310 statement. If any of the conditions are not met, the ACL returns &"deny"&. For
31311 example, when checking a RCPT command,
31312 .code
31313 require message = Sender did not verify
31314         verify  = sender
31315 .endd
31316 passes control to subsequent statements only if the message's sender can be
31317 verified. Otherwise, it rejects the command. Note the positioning of the
31318 &%message%& modifier, before the &%verify%& condition. The reason for this is
31319 discussed in section &<<SECTcondmodproc>>&.
31320
31321 .next
31322 .cindex "&%warn%& ACL verb"
31323 &%warn%&: If all the conditions are true, a line specified by the
31324 &%log_message%& modifier is written to Exim's main log. Control always passes
31325 to the next ACL statement. If any condition is false, the log line is not
31326 written. If an identical log line is requested several times in the same
31327 message, only one copy is actually written to the log. If you want to force
31328 duplicates to be written, use the &%logwrite%& modifier instead.
31329
31330 If &%log_message%& is not present, a &%warn%& verb just checks its conditions
31331 and obeys any &"immediate"& modifiers (such as &%control%&, &%set%&,
31332 &%logwrite%&, &%add_header%&, and &%remove_header%&) that appear before the
31333 first failing condition. There is more about adding header lines in section
31334 &<<SECTaddheadacl>>&.
31335
31336 If any condition on a &%warn%& statement cannot be completed (that is, there is
31337 some sort of defer), the log line specified by &%log_message%& is not written.
31338 This does not include the case of a forced failure from a lookup, which
31339 is considered to be a successful completion. After a defer, no further
31340 conditions or modifiers in the &%warn%& statement are processed. The incident
31341 is logged, and the ACL continues to be processed, from the next statement
31342 onwards.
31343
31344
31345 .vindex "&$acl_verify_message$&"
31346 When one of the &%warn%& conditions is an address verification that fails, the
31347 text of the verification failure message is in &$acl_verify_message$&. If you
31348 want this logged, you must set it up explicitly. For example:
31349 .code
31350 warn   !verify = sender
31351        log_message = sender verify failed: $acl_verify_message
31352 .endd
31353 .endlist
31354
31355 At the end of each ACL there is an implicit unconditional &%deny%&.
31356
31357 As you can see from the examples above, the conditions and modifiers are
31358 written one to a line, with the first one on the same line as the verb, and
31359 subsequent ones on following lines. If you have a very long condition, you can
31360 continue it onto several physical lines by the usual backslash continuation
31361 mechanism. It is conventional to align the conditions vertically.
31362
31363
31364
31365 .section "ACL variables" "SECTaclvariables"
31366 .cindex "&ACL;" "variables"
31367 There are some special variables that can be set during ACL processing. They
31368 can be used to pass information between different ACLs, different invocations
31369 of the same ACL in the same SMTP connection, and between ACLs and the routers,
31370 transports, and filters that are used to deliver a message. The names of these
31371 variables must begin with &$acl_c$& or &$acl_m$&, followed either by a digit or
31372 an underscore, but the remainder of the name can be any sequence of
31373 alphanumeric characters and underscores that you choose. There is no limit on
31374 the number of ACL variables. The two sets act as follows:
31375 .ilist
31376 The values of those variables whose names begin with &$acl_c$& persist
31377 throughout an SMTP connection. They are never reset. Thus, a value that is set
31378 while receiving one message is still available when receiving the next message
31379 on the same SMTP connection.
31380 .next
31381 The values of those variables whose names begin with &$acl_m$& persist only
31382 while a message is being received. They are reset afterwards. They are also
31383 reset by MAIL, RSET, EHLO, HELO, and after starting up a TLS session.
31384 .endlist
31385
31386 When a message is accepted, the current values of all the ACL variables are
31387 preserved with the message and are subsequently made available at delivery
31388 time. The ACL variables are set by a modifier called &%set%&. For example:
31389 .code
31390 accept hosts = whatever
31391        set acl_m4 = some value
31392 accept authenticated = *
31393        set acl_c_auth = yes
31394 .endd
31395 &*Note*&: A leading dollar sign is not used when naming a variable that is to
31396 be set. If you want to set a variable without taking any action, you can use a
31397 &%warn%& verb without any other modifiers or conditions.
31398
31399 .oindex &%strict_acl_vars%&
31400 What happens if a syntactically valid but undefined ACL variable is
31401 referenced depends on the setting of the &%strict_acl_vars%& option. If it is
31402 false (the default), an empty string is substituted; if it is true, an
31403 error is generated.
31404
31405 Versions of Exim before 4.64 have a limited set of numbered variables, but
31406 their names are compatible, so there is no problem with upgrading.
31407
31408
31409 .section "Condition and modifier processing" "SECTcondmodproc"
31410 .cindex "&ACL;" "conditions; processing"
31411 .cindex "&ACL;" "modifiers; processing"
31412 An exclamation mark preceding a condition negates its result. For example:
31413 .code
31414 deny   domains = *.dom.example
31415       !verify  = recipient
31416 .endd
31417 causes the ACL to return &"deny"& if the recipient domain ends in
31418 &'dom.example'& and the recipient address cannot be verified. Sometimes
31419 negation can be used on the right-hand side of a condition. For example, these
31420 two statements are equivalent:
31421 .code
31422 deny  hosts = !192.168.3.4
31423 deny !hosts =  192.168.3.4
31424 .endd
31425 However, for many conditions (&%verify%& being a good example), only left-hand
31426 side negation of the whole condition is possible.
31427
31428 The arguments of conditions and modifiers are expanded. A forced failure
31429 of an expansion causes a condition to be ignored, that is, it behaves as if the
31430 condition is true. Consider these two statements:
31431 .code
31432 accept  senders = ${lookup{$host_name}lsearch\
31433                   {/some/file}{$value}fail}
31434 accept  senders = ${lookup{$host_name}lsearch\
31435                   {/some/file}{$value}{}}
31436 .endd
31437 Each attempts to look up a list of acceptable senders. If the lookup succeeds,
31438 the returned list is searched, but if the lookup fails the behaviour is
31439 different in the two cases. The &%fail%& in the first statement causes the
31440 condition to be ignored, leaving no further conditions. The &%accept%& verb
31441 therefore succeeds. The second statement, however, generates an empty list when
31442 the lookup fails. No sender can match an empty list, so the condition fails,
31443 and therefore the &%accept%& also fails.
31444
31445 ACL modifiers appear mixed in with conditions in ACL statements. Some of them
31446 specify actions that are taken as the conditions for a statement are checked;
31447 others specify text for messages that are used when access is denied or a
31448 warning is generated. The &%control%& modifier affects the way an incoming
31449 message is handled.
31450
31451 The positioning of the modifiers in an ACL statement is important, because the
31452 processing of a verb ceases as soon as its outcome is known. Only those
31453 modifiers that have already been encountered will take effect. For example,
31454 consider this use of the &%message%& modifier:
31455 .code
31456 require message = Can't verify sender
31457         verify  = sender
31458         message = Can't verify recipient
31459         verify  = recipient
31460         message = This message cannot be used
31461 .endd
31462 If sender verification fails, Exim knows that the result of the statement is
31463 &"deny"&, so it goes no further. The first &%message%& modifier has been seen,
31464 so its text is used as the error message. If sender verification succeeds, but
31465 recipient verification fails, the second message is used. If recipient
31466 verification succeeds, the third message becomes &"current"&, but is never used
31467 because there are no more conditions to cause failure.
31468
31469 For the &%deny%& verb, on the other hand, it is always the last &%message%&
31470 modifier that is used, because all the conditions must be true for rejection to
31471 happen. Specifying more than one &%message%& modifier does not make sense, and
31472 the message can even be specified after all the conditions. For example:
31473 .code
31474 deny   hosts = ...
31475       !senders = *@my.domain.example
31476        message = Invalid sender from client host
31477 .endd
31478 The &"deny"& result does not happen until the end of the statement is reached,
31479 by which time Exim has set up the message.
31480
31481
31482
31483 .section "ACL modifiers" "SECTACLmodi"
31484 .cindex "&ACL;" "modifiers; list of"
31485 The ACL modifiers are as follows:
31486
31487 .vlist
31488 .vitem &*add_header*&&~=&~<&'text'&>
31489 This modifier specifies one or more header lines that are to be added to an
31490 incoming message, assuming, of course, that the message is ultimately
31491 accepted. For details, see section &<<SECTaddheadacl>>&.
31492
31493 .vitem &*continue*&&~=&~<&'text'&>
31494 .cindex "&%continue%& ACL modifier"
31495 .cindex "database" "updating in ACL"
31496 This modifier does nothing of itself, and processing of the ACL always
31497 continues with the next condition or modifier. The value of &%continue%& is in
31498 the side effects of expanding its argument. Typically this could be used to
31499 update a database. It is really just a syntactic tidiness, to avoid having to
31500 write rather ugly lines like this:
31501 .display
31502 &`condition = ${if eq{0}{`&<&'some expansion'&>&`}{true}{true}}`&
31503 .endd
31504 Instead, all you need is
31505 .display
31506 &`continue = `&<&'some expansion'&>
31507 .endd
31508
31509 .vitem &*control*&&~=&~<&'text'&>
31510 .cindex "&%control%& ACL modifier"
31511 This modifier affects the subsequent processing of the SMTP connection or of an
31512 incoming message that is accepted. The effect of the first type of control
31513 lasts for the duration of the connection, whereas the effect of the second type
31514 lasts only until the current message has been received. The message-specific
31515 controls always apply to the whole message, not to individual recipients,
31516 even if the &%control%& modifier appears in a RCPT ACL.
31517
31518 As there are now quite a few controls that can be applied, they are described
31519 separately in section &<<SECTcontrols>>&. The &%control%& modifier can be used
31520 in several different ways. For example:
31521
31522 . ==== As this is a nested list, any displays it contains must be indented
31523 . ==== as otherwise they are too far to the left. That comment applies only
31524 . ==== when xmlto and fop are used; formatting with sdop gets it right either
31525 . ==== way.
31526
31527 .ilist
31528 It can be at the end of an &%accept%& statement:
31529 .code
31530     accept  ...some conditions
31531             control = queue
31532 .endd
31533 In this case, the control is applied when this statement yields &"accept"&, in
31534 other words, when the conditions are all true.
31535
31536 .next
31537 It can be in the middle of an &%accept%& statement:
31538 .code
31539     accept  ...some conditions...
31540             control = queue
31541             ...some more conditions...
31542 .endd
31543 If the first set of conditions are true, the control is applied, even if the
31544 statement does not accept because one of the second set of conditions is false.
31545 In this case, some subsequent statement must yield &"accept"& for the control
31546 to be relevant.
31547
31548 .next
31549 It can be used with &%warn%& to apply the control, leaving the
31550 decision about accepting or denying to a subsequent verb. For
31551 example:
31552 .code
31553     warn    ...some conditions...
31554             control = freeze
31555     accept  ...
31556 .endd
31557 This example of &%warn%& does not contain &%message%&, &%log_message%&, or
31558 &%logwrite%&, so it does not add anything to the message and does not write a
31559 log entry.
31560
31561 .next
31562 If you want to apply a control unconditionally, you can use it with a
31563 &%require%& verb. For example:
31564 .code
31565     require  control = no_multiline_responses
31566 .endd
31567 .endlist
31568
31569 .vitem &*delay*&&~=&~<&'time'&>
31570 .cindex "&%delay%& ACL modifier"
31571 .oindex "&%-bh%&"
31572 This modifier may appear in any ACL except notquit. It causes Exim to wait for
31573 the time interval before proceeding. However, when testing Exim using the
31574 &%-bh%& option, the delay is not actually imposed (an appropriate message is
31575 output instead). The time is given in the usual Exim notation, and the delay
31576 happens as soon as the modifier is processed. In an SMTP session, pending
31577 output is flushed before the delay is imposed.
31578
31579 Like &%control%&, &%delay%& can be used with &%accept%& or &%deny%&, for
31580 example:
31581 .code
31582 deny    ...some conditions...
31583         delay = 30s
31584 .endd
31585 The delay happens if all the conditions are true, before the statement returns
31586 &"deny"&. Compare this with:
31587 .code
31588 deny    delay = 30s
31589         ...some conditions...
31590 .endd
31591 which waits for 30s before processing the conditions. The &%delay%& modifier
31592 can also be used with &%warn%& and together with &%control%&:
31593 .code
31594 warn    ...some conditions...
31595         delay = 2m
31596         control = freeze
31597 accept  ...
31598 .endd
31599
31600 If &%delay%& is encountered when the SMTP PIPELINING extension is in use,
31601 responses to several commands are no longer buffered and sent in one packet (as
31602 they would normally be) because all output is flushed before imposing the
31603 delay. This optimization is disabled so that a number of small delays do not
31604 appear to the client as one large aggregated delay that might provoke an
31605 unwanted timeout. You can, however, disable output flushing for &%delay%& by
31606 using a &%control%& modifier to set &%no_delay_flush%&.
31607
31608
31609 .vitem &*endpass*&
31610 .cindex "&%endpass%& ACL modifier"
31611 This modifier, which has no argument, is recognized only in &%accept%& and
31612 &%discard%& statements. It marks the boundary between the conditions whose
31613 failure causes control to pass to the next statement, and the conditions whose
31614 failure causes the ACL to return &"deny"&. This concept has proved to be
31615 confusing to some people, so the use of &%endpass%& is no longer recommended as
31616 &"best practice"&. See the description of &%accept%& above for more details.
31617
31618
31619 .vitem &*log_message*&&~=&~<&'text'&>
31620 .cindex "&%log_message%& ACL modifier"
31621 This modifier sets up a message that is used as part of the log message if the
31622 ACL denies access or a &%warn%& statement's conditions are true. For example:
31623 .code
31624 require log_message = wrong cipher suite $tls_in_cipher
31625         encrypted   = DES-CBC3-SHA
31626 .endd
31627 &%log_message%& is also used when recipients are discarded by &%discard%&. For
31628 example:
31629 .display
31630 &`discard `&<&'some conditions'&>
31631 &`        log_message = Discarded $local_part@$domain because...`&
31632 .endd
31633 When access is denied, &%log_message%& adds to any underlying error message
31634 that may exist because of a condition failure. For example, while verifying a
31635 recipient address, a &':fail:'& redirection might have already set up a
31636 message.
31637
31638 The message may be defined before the conditions to which it applies, because
31639 the string expansion does not happen until Exim decides that access is to be
31640 denied. This means that any variables that are set by the condition are
31641 available for inclusion in the message. For example, the &$dnslist_$&<&'xxx'&>
31642 variables are set after a DNS black list lookup succeeds. If the expansion of
31643 &%log_message%& fails, or if the result is an empty string, the modifier is
31644 ignored.
31645
31646 .vindex "&$acl_verify_message$&"
31647 If you want to use a &%warn%& statement to log the result of an address
31648 verification, you can use &$acl_verify_message$& to include the verification
31649 error message.
31650
31651 If &%log_message%& is used with a &%warn%& statement, &"Warning:"& is added to
31652 the start of the logged message. If the same warning log message is requested
31653 more than once while receiving  a single email message, only one copy is
31654 actually logged. If you want to log multiple copies, use &%logwrite%& instead
31655 of &%log_message%&. In the absence of &%log_message%& and &%logwrite%&, nothing
31656 is logged for a successful &%warn%& statement.
31657
31658 If &%log_message%& is not present and there is no underlying error message (for
31659 example, from the failure of address verification), but &%message%& is present,
31660 the &%message%& text is used for logging rejections. However, if any text for
31661 logging contains newlines, only the first line is logged. In the absence of
31662 both &%log_message%& and &%message%&, a default built-in message is used for
31663 logging rejections.
31664
31665
31666 .vitem "&*log_reject_target*&&~=&~<&'log name list'&>"
31667 .cindex "&%log_reject_target%& ACL modifier"
31668 .cindex "logging in ACL" "specifying which log"
31669 This modifier makes it possible to specify which logs are used for messages
31670 about ACL rejections. Its argument is a colon-separated list of words that can
31671 be &"main"&, &"reject"&, or &"panic"&. The default is &`main:reject`&. The list
31672 may be empty, in which case a rejection is not logged at all. For example, this
31673 ACL fragment writes no logging information when access is denied:
31674 .display
31675 &`deny `&<&'some conditions'&>
31676 &`     log_reject_target =`&
31677 .endd
31678 This modifier can be used in SMTP and non-SMTP ACLs. It applies to both
31679 permanent and temporary rejections. Its effect lasts for the rest of the
31680 current ACL.
31681
31682
31683 .vitem &*logwrite*&&~=&~<&'text'&>
31684 .cindex "&%logwrite%& ACL modifier"
31685 .cindex "logging in ACL" "immediate"
31686 This modifier writes a message to a log file as soon as it is encountered when
31687 processing an ACL. (Compare &%log_message%&, which, except in the case of
31688 &%warn%& and &%discard%&, is used only if the ACL statement denies
31689 access.) The &%logwrite%& modifier can be used to log special incidents in
31690 ACLs. For example:
31691 .display
31692 &`accept `&<&'some special conditions'&>
31693 &`       control  = freeze`&
31694 &`       logwrite = froze message because ...`&
31695 .endd
31696 By default, the message is written to the main log. However, it may begin
31697 with a colon, followed by a comma-separated list of log names, and then
31698 another colon, to specify exactly which logs are to be written. For
31699 example:
31700 .code
31701 logwrite = :main,reject: text for main and reject logs
31702 logwrite = :panic: text for panic log only
31703 .endd
31704
31705
31706 .vitem &*message*&&~=&~<&'text'&>
31707 .cindex "&%message%& ACL modifier"
31708 This modifier sets up a text string that is expanded and used as a response
31709 message when an ACL statement terminates the ACL with an &"accept"&, &"deny"&,
31710 or &"defer"& response. (In the case of the &%accept%& and &%discard%& verbs,
31711 there is some complication if &%endpass%& is involved; see the description of
31712 &%accept%& for details.)
31713
31714 The expansion of the message happens at the time Exim decides that the ACL is
31715 to end, not at the time it processes &%message%&. If the expansion fails, or
31716 generates an empty string, the modifier is ignored. Here is an example where
31717 &%message%& must be specified first, because the ACL ends with a rejection if
31718 the &%hosts%& condition fails:
31719 .code
31720 require  message = Host not recognized
31721          hosts = 10.0.0.0/8
31722 .endd
31723 (Once a condition has failed, no further conditions or modifiers are
31724 processed.)
31725
31726 .cindex "SMTP" "error codes"
31727 .oindex "&%smtp_banner%&
31728 For ACLs that are triggered by SMTP commands, the message is returned as part
31729 of the SMTP response. The use of &%message%& with &%accept%& (or &%discard%&)
31730 is meaningful only for SMTP, as no message is returned when a non-SMTP message
31731 is accepted. In the case of the connect ACL, accepting with a message modifier
31732 overrides the value of &%smtp_banner%&. For the EHLO/HELO ACL, a customized
31733 accept message may not contain more than one line (otherwise it will be
31734 truncated at the first newline and a panic logged), and it cannot affect the
31735 EHLO options.
31736
31737 When SMTP is involved, the message may begin with an overriding response code,
31738 consisting of three digits optionally followed by an &"extended response code"&
31739 of the form &'n.n.n'&, each code being followed by a space. For example:
31740 .code
31741 deny  message = 599 1.2.3 Host not welcome
31742       hosts = 192.168.34.0/24
31743 .endd
31744 The first digit of the supplied response code must be the same as would be sent
31745 by default. A panic occurs if it is not. Exim uses a 550 code when it denies
31746 access, but for the predata ACL, note that the default success code is 354, not
31747 2&'xx'&.
31748
31749 Notwithstanding the previous paragraph, for the QUIT ACL, unlike the others,
31750 the message modifier cannot override the 221 response code.
31751
31752 The text in a &%message%& modifier is literal; any quotes are taken as
31753 literals, but because the string is expanded, backslash escapes are processed
31754 anyway.
31755 If the message contains newlines, this gives rise to a multi-line SMTP
31756 response.
31757 A long message line will also be split into multi-line SMTP responses,
31758 on word boundaries if possible.
31759
31760 .vindex "&$acl_verify_message$&"
31761 While the text is being expanded, the &$acl_verify_message$& variable
31762 contains any message previously set.
31763 Afterwards, &$acl_verify_message$& is cleared.
31764
31765 If &%message%& is used on a statement that verifies an address, the message
31766 specified overrides any message that is generated by the verification process.
31767 However, the original message is available in the variable
31768 &$acl_verify_message$&, so you can incorporate it into your message if you
31769 wish. In particular, if you want the text from &%:fail:%& items in &(redirect)&
31770 routers to be passed back as part of the SMTP response, you should either not
31771 use a &%message%& modifier, or make use of &$acl_verify_message$&.
31772
31773 For compatibility with previous releases of Exim, a &%message%& modifier that
31774 is used with a &%warn%& verb behaves in a similar way to the &%add_header%&
31775 modifier, but this usage is now deprecated. However, &%message%& acts only when
31776 all the conditions are true, wherever it appears in an ACL command, whereas
31777 &%add_header%& acts as soon as it is encountered. If &%message%& is used with
31778 &%warn%& in an ACL that is not concerned with receiving a message, it has no
31779 effect.
31780
31781
31782 .vitem &*queue*&&~=&~<&'text'&>
31783 .cindex "&%queue%& ACL modifier"
31784 .cindex "named queues" "selecting in ACL"
31785 This modifier specifies the use of a named queue for spool files
31786 for the message.
31787 It can only be used before the message is received (i.e. not in
31788 the DATA ACL).
31789 This could be used, for example, for known high-volume burst sources
31790 of traffic, or for quarantine of messages.
31791 Separate queue-runner processes will be needed for named queues.
31792 If the text after expansion is empty, the default queue is used.
31793
31794
31795 .vitem &*remove_header*&&~=&~<&'text'&>
31796 This modifier specifies one or more header names in a colon-separated list
31797  that are to be removed from an incoming message, assuming, of course, that
31798 the message is ultimately accepted. For details, see section &<<SECTremoveheadacl>>&.
31799
31800
31801 .vitem &*set*&&~<&'acl_name'&>&~=&~<&'value'&>
31802 .cindex "&%set%& ACL modifier"
31803 This modifier puts a value into one of the ACL variables (see section
31804 &<<SECTaclvariables>>&).
31805
31806
31807 .vitem &*udpsend*&&~=&~<&'parameters'&>
31808 .cindex "UDP communications"
31809 This modifier sends a UDP packet, for purposes such as statistics
31810 collection or behaviour monitoring. The parameters are expanded, and
31811 the result of the expansion must be a colon-separated list consisting
31812 of a destination server, port number, and the packet contents. The
31813 server can be specified as a host name or IPv4 or IPv6 address. The
31814 separator can be changed with the usual angle bracket syntax. For
31815 example, you might want to collect information on which hosts connect
31816 when:
31817 .code
31818 udpsend = <; 2001:dB8::dead:beef ; 1234 ;\
31819              $tod_zulu $sender_host_address
31820 .endd
31821 .endlist
31822
31823
31824
31825
31826 .section "Use of the control modifier" "SECTcontrols"
31827 .cindex "&%control%& ACL modifier"
31828 The &%control%& modifier supports the following settings:
31829
31830 .vlist
31831 .vitem &*control&~=&~allow_auth_unadvertised*&
31832 This modifier allows a client host to use the SMTP AUTH command even when it
31833 has not been advertised in response to EHLO. Furthermore, because there are
31834 apparently some really broken clients that do this, Exim will accept AUTH after
31835 HELO (rather than EHLO) when this control is set. It should be used only if you
31836 really need it, and you should limit its use to those broken clients that do
31837 not work without it. For example:
31838 .code
31839 warn hosts   = 192.168.34.25
31840      control = allow_auth_unadvertised
31841 .endd
31842 Normally, when an Exim server receives an AUTH command, it checks the name of
31843 the authentication mechanism that is given in the command to ensure that it
31844 matches an advertised mechanism. When this control is set, the check that a
31845 mechanism has been advertised is bypassed. Any configured mechanism can be used
31846 by the client. This control is permitted only in the connection and HELO ACLs.
31847
31848
31849 .vitem &*control&~=&~caseful_local_part*& &&&
31850        &*control&~=&~caselower_local_part*&
31851 .cindex "&ACL;" "case of local part in"
31852 .cindex "case of local parts"
31853 .vindex "&$local_part$&"
31854 These two controls are permitted only in the ACL specified by &%acl_smtp_rcpt%&
31855 (that is, during RCPT processing). By default, the contents of &$local_part$&
31856 are lower cased before ACL processing. If &"caseful_local_part"& is specified,
31857 any uppercase letters in the original local part are restored in &$local_part$&
31858 for the rest of the ACL, or until a control that sets &"caselower_local_part"&
31859 is encountered.
31860
31861 These controls affect only the current recipient. Moreover, they apply only to
31862 local part handling that takes place directly in the ACL (for example, as a key
31863 in lookups). If a test to verify the recipient is obeyed, the case-related
31864 handling of the local part during the verification is controlled by the router
31865 configuration (see the &%caseful_local_part%& generic router option).
31866
31867 This facility could be used, for example, to add a spam score to local parts
31868 containing upper case letters. For example, using &$acl_m4$& to accumulate the
31869 spam score:
31870 .code
31871 warn  control = caseful_local_part
31872       set acl_m4 = ${eval:\
31873                      $acl_m4 + \
31874                      ${if match{$local_part}{[A-Z]}{1}{0}}\
31875                     }
31876       control = caselower_local_part
31877 .endd
31878 Notice that we put back the lower cased version afterwards, assuming that
31879 is what is wanted for subsequent tests.
31880
31881
31882 .vitem &*control&~=&~cutthrough_delivery/*&<&'options'&>
31883 .cindex "&ACL;" "cutthrough routing"
31884 .cindex "cutthrough" "requesting"
31885 This option requests delivery be attempted while the item is being received.
31886
31887 The option is usable in the RCPT ACL.
31888 If enabled for a message received via smtp and routed to an smtp transport,
31889 and only one transport, interface, destination host and port combination
31890 is used for all recipients of the message,
31891 then the delivery connection is made while the receiving connection is open
31892 and data is copied from one to the other.
31893
31894 An attempt to set this option for any recipient but the first
31895 for a mail will be quietly ignored.
31896 If a recipient-verify callout
31897 (with use_sender)
31898 connection is subsequently
31899 requested in the same ACL it is held open and used for
31900 any subsequent recipients and the data,
31901 otherwise one is made after the initial RCPT ACL completes.
31902
31903 Note that routers are used in verify mode,
31904 and cannot depend on content of received headers.
31905 Note also that headers cannot be
31906 modified by any of the post-data ACLs (DATA, MIME and DKIM).
31907 Headers may be modified by routers (subject to the above) and transports.
31908 The &'Received-By:'& header is generated as soon as the body reception starts,
31909 rather than the traditional time after the full message is received;
31910 this will affect the timestamp.
31911
31912 All the usual ACLs are called; if one results in the message being
31913 rejected, all effort spent in delivery (including the costs on
31914 the ultimate destination) will be wasted.
31915 Note that in the case of data-time ACLs this includes the entire
31916 message body.
31917
31918 Cutthrough delivery is not supported via transport-filters or when DKIM signing
31919 of outgoing messages is done, because it sends data to the ultimate destination
31920 before the entire message has been received from the source.
31921 It is not supported for messages received with the SMTP PRDR
31922 or CHUNKING
31923 options in use.
31924
31925 Should the ultimate destination system positively accept or reject the mail,
31926 a corresponding indication is given to the source system and nothing is queued.
31927 If the item is successfully delivered in cutthrough mode
31928 the delivery log lines are tagged with ">>" rather than "=>" and appear
31929 before the acceptance "<=" line.
31930
31931 If there is a temporary error the item is queued for later delivery in the
31932 usual fashion.
31933 This behaviour can be adjusted by appending the option &*defer=*&<&'value'&>
31934 to the control; the default value is &"spool"& and the alternate value
31935 &"pass"& copies an SMTP defer response from the target back to the initiator
31936 and does not queue the message.
31937 Note that this is independent of any recipient verify conditions in the ACL.
31938
31939 Delivery in this mode avoids the generation of a bounce mail to a
31940 (possibly faked)
31941 sender when the destination system is doing content-scan based rejection.
31942
31943
31944 .vitem &*control&~=&~debug/*&<&'options'&>
31945 .cindex "&ACL;" "enabling debug logging"
31946 .cindex "debugging" "enabling from an ACL"
31947 This control turns on debug logging, almost as though Exim had been invoked
31948 with &`-d`&, with the output going to a new logfile in the usual logs directory,
31949 by default called &'debuglog'&.
31950
31951 Logging set up by the control will be maintained across spool residency.
31952
31953 Options are a slash-separated list.
31954 If an option takes an argument, the option name and argument are separated by
31955 an equals character.
31956 Several options are supported:
31957 .display
31958 tag=<&'suffix'&>         The filename can be adjusted with thise option.
31959                      The argument, which may access any variables already defined,
31960                      is appended to the default name.
31961
31962 opts=<&'debug&~options'&> The argument specififes what is to be logged,
31963                      using the same values as the &`-d`& command-line option.
31964
31965 stop                 Logging started with this control may be
31966                      stopped by using this option.
31967
31968 kill                 Logging started with this control may be
31969                      stopped by using this option.
31970                      Additionally the debug file will be removed,
31971                      providing one means for speculative debug tracing.
31972
31973 pretrigger=<&'size'&>    This option specifies a memory buffuer to be used
31974                      for pre-trigger debug capture.
31975                      Debug lines are recorded in the buffer until
31976                      and if) a trigger occurs; at which time they are
31977                      dumped to the debug file.  Newer lines displace the
31978                      oldest if the buffer is full.  After a trigger,
31979                      immediate writes to file are done as normal.
31980
31981 trigger=<&'reason'&>     This option selects cause for the pretrigger buffer
31982                      see above) to be copied to file.  A reason of &*now*&
31983                      take effect immediately; one of &*paniclog*& triggers
31984                      on a write to the panic log.
31985 .endd
31986
31987 Some examples (which depend on variables that don't exist in all
31988 contexts):
31989 .code
31990       control = debug
31991       control = debug/tag=.$sender_host_address
31992       control = debug/opts=+expand+acl
31993       control = debug/tag=.$message_exim_id/opts=+expand
31994       control = debug/kill
31995       control = debug/opts=+all/pretrigger=1024/trigger=paniclog
31996       control = debug/trigger=now
31997 .endd
31998
31999
32000 .vitem &*control&~=&~dkim_disable_verify*&
32001 .cindex "disable DKIM verify"
32002 .cindex "DKIM" "disable verify"
32003 This control turns off DKIM verification processing entirely.  For details on
32004 the operation and configuration of DKIM, see section &<<SECDKIM>>&.
32005
32006
32007 .vitem &*control&~=&~dmarc_disable_verify*&
32008 .cindex "disable DMARC verify"
32009 .cindex "DMARC" "disable verify"
32010 This control turns off DMARC verification processing entirely.  For details on
32011 the operation and configuration of DMARC, see section &<<SECDMARC>>&.
32012
32013
32014 .vitem &*control&~=&~dscp/*&<&'value'&>
32015 .cindex "&ACL;" "setting DSCP value"
32016 .cindex "DSCP" "inbound"
32017 This option causes the DSCP value associated with the socket for the inbound
32018 connection to be adjusted to a given value, given as one of a number of fixed
32019 strings or to numeric value.
32020 The &%-bI:dscp%& option may be used to ask Exim which names it knows of.
32021 Common values include &`throughput`&, &`mincost`&, and on newer systems
32022 &`ef`&, &`af41`&, etc.  Numeric values may be in the range 0 to 0x3F.
32023
32024 The outbound packets from Exim will be marked with this value in the header
32025 (for IPv4, the TOS field; for IPv6, the TCLASS field); there is no guarantee
32026 that these values will have any effect, not be stripped by networking
32027 equipment, or do much of anything without cooperation with your Network
32028 Engineer and those of all network operators between the source and destination.
32029
32030
32031 .vitem &*control&~=&~enforce_sync*& &&&
32032        &*control&~=&~no_enforce_sync*&
32033 .cindex "SMTP" "synchronization checking"
32034 .cindex "synchronization checking in SMTP"
32035 These controls make it possible to be selective about when SMTP synchronization
32036 is enforced. The global option &%smtp_enforce_sync%& specifies the initial
32037 state of the switch (it is true by default). See the description of this option
32038 in chapter &<<CHAPmainconfig>>& for details of SMTP synchronization checking.
32039
32040 The effect of these two controls lasts for the remainder of the SMTP
32041 connection. They can appear in any ACL except the one for the non-SMTP
32042 messages. The most straightforward place to put them is in the ACL defined by
32043 &%acl_smtp_connect%&, which is run at the start of an incoming SMTP connection,
32044 before the first synchronization check. The expected use is to turn off the
32045 synchronization checks for badly-behaved hosts that you nevertheless need to
32046 work with.
32047
32048
32049 .vitem &*control&~=&~fakedefer/*&<&'message'&>
32050 .cindex "fake defer"
32051 .cindex "defer, fake"
32052 .cindex fakedefer
32053 This control works in exactly the same way as &%fakereject%& (described below)
32054 except that it causes an SMTP 450 response after the message data instead of a
32055 550 response. You must take care when using &%fakedefer%& because it causes the
32056 messages to be duplicated when the sender retries. Therefore, you should not
32057 use &%fakedefer%& if the message is to be delivered normally.
32058
32059 .vitem &*control&~=&~fakereject/*&<&'message'&>
32060 .cindex "fake rejection"
32061 .cindex "rejection, fake"
32062 .cindex fakereject
32063 This control is permitted only for the MAIL, RCPT, and DATA ACLs, in other
32064 words, only when an SMTP message is being received. If Exim accepts the
32065 message, instead the final 250 response, a 550 rejection message is sent.
32066 However, Exim proceeds to deliver the message as normal. The control applies
32067 only to the current message, not to any subsequent ones that may be received in
32068 the same SMTP connection.
32069
32070 The text for the 550 response is taken from the &%control%& modifier. If no
32071 message is supplied, the following is used:
32072 .code
32073 550-Your message has been rejected but is being
32074 550-kept for evaluation.
32075 550-If it was a legitimate message, it may still be
32076 550 delivered to the target recipient(s).
32077 .endd
32078 This facility should be used with extreme caution.
32079
32080 .vitem &*control&~=&~freeze*&
32081 .cindex "frozen messages" "forcing in ACL"
32082 This control is permitted only for the MAIL, RCPT, DATA, and non-SMTP ACLs, in
32083 other words, only when a message is being received. If the message is accepted,
32084 it is placed on Exim's queue and frozen. The control applies only to the
32085 current message, not to any subsequent ones that may be received in the same
32086 SMTP connection.
32087
32088 This modifier can optionally be followed by &`/no_tell`&. If the global option
32089 &%freeze_tell%& is set, it is ignored for the current message (that is, nobody
32090 is told about the freezing), provided all the &*control=freeze*& modifiers that
32091 are obeyed for the current message have the &`/no_tell`& option.
32092
32093 .vitem &*control&~=&~no_delay_flush*&
32094 .cindex "SMTP" "output flushing, disabling for delay"
32095 Exim normally flushes SMTP output before implementing a delay in an ACL, to
32096 avoid unexpected timeouts in clients when the SMTP PIPELINING extension is in
32097 use. This control, as long as it is encountered before the &%delay%& modifier,
32098 disables such output flushing.
32099
32100 .vitem &*control&~=&~no_callout_flush*&
32101 .cindex "SMTP" "output flushing, disabling for callout"
32102 Exim normally flushes SMTP output before performing a callout in an ACL, to
32103 avoid unexpected timeouts in clients when the SMTP PIPELINING extension is in
32104 use. This control, as long as it is encountered before the &%verify%& condition
32105 that causes the callout, disables such output flushing.
32106
32107 .vitem &*control&~=&~no_mbox_unspool*&
32108 This control is available when Exim is compiled with the content scanning
32109 extension. Content scanning may require a copy of the current message, or parts
32110 of it, to be written in &"mbox format"& to a spool file, for passing to a virus
32111 or spam scanner. Normally, such copies are deleted when they are no longer
32112 needed. If this control is set, the copies are not deleted. The control applies
32113 only to the current message, not to any subsequent ones that may be received in
32114 the same SMTP connection. It is provided for debugging purposes and is unlikely
32115 to be useful in production.
32116
32117 .vitem &*control&~=&~no_multiline_responses*&
32118 .cindex "multiline responses, suppressing"
32119 This control is permitted for any ACL except the one for non-SMTP messages.
32120 It seems that there are broken clients in use that cannot handle multiline
32121 SMTP responses, despite the fact that RFC 821 defined them over 20 years ago.
32122
32123 If this control is set, multiline SMTP responses from ACL rejections are
32124 suppressed. One way of doing this would have been to put out these responses as
32125 one long line. However, RFC 2821 specifies a maximum of 512 bytes per response
32126 (&"use multiline responses for more"& it says &-- ha!), and some of the
32127 responses might get close to that. So this facility, which is after all only a
32128 sop to broken clients, is implemented by doing two very easy things:
32129
32130 .ilist
32131 Extra information that is normally output as part of a rejection caused by
32132 sender verification failure is omitted. Only the final line (typically &"sender
32133 verification failed"&) is sent.
32134 .next
32135 If a &%message%& modifier supplies a multiline response, only the first
32136 line is output.
32137 .endlist
32138
32139 The setting of the switch can, of course, be made conditional on the
32140 calling host. Its effect lasts until the end of the SMTP connection.
32141
32142 .vitem &*control&~=&~no_pipelining*&
32143 .cindex "PIPELINING" "suppressing advertising"
32144 .cindex "ESMTP extensions" PIPELINING
32145 This control turns off the advertising of the PIPELINING extension to SMTP in
32146 the current session. To be useful, it must be obeyed before Exim sends its
32147 response to an EHLO command. Therefore, it should normally appear in an ACL
32148 controlled by &%acl_smtp_connect%& or &%acl_smtp_helo%&. See also
32149 &%pipelining_advertise_hosts%&.
32150
32151 .vitem &*control&~=&~queue/*&<&'options'&>* &&&
32152        &*control&~=&~queue_only*&
32153 .oindex "&%queue%&"
32154 .oindex "&%queue_only%&"
32155 .cindex "queueing incoming messages"
32156 .cindex queueing "forcing in ACL"
32157 .cindex "first pass routing"
32158 This control is permitted only for the MAIL, RCPT, DATA, and non-SMTP ACLs, in
32159 other words, only when a message is being received. If the message is accepted,
32160 it is placed on Exim's queue and left there for delivery by a subsequent queue
32161 runner.
32162 If used with no options set,
32163 no immediate delivery process is started. In other words, it has the
32164 effect as the &%queue_only%& global option or &'-odq'& command-line option.
32165
32166 If the &'first_pass_route'& option is given then
32167 the behaviour is like the command-line &'-oqds'& option;
32168 a delivery process is started which stops short of making
32169 any SMTP delivery.  The benefit is that the hints database will be updated for
32170 the message being waiting for a specific host, and a later queue run will be
32171 able to send all such messages on a single connection.
32172
32173 The control only applies to the current message, not to any subsequent ones that
32174  may be received in the same SMTP connection.
32175
32176 .vitem &*control&~=&~submission/*&<&'options'&>
32177 .cindex "message" "submission"
32178 .cindex "submission mode"
32179 This control is permitted only for the MAIL, RCPT, and start of data ACLs (the
32180 latter is the one defined by &%acl_smtp_predata%&). Setting it tells Exim that
32181 the current message is a submission from a local MUA. In this case, Exim
32182 operates in &"submission mode"&, and applies certain fixups to the message if
32183 necessary. For example, it adds a &'Date:'& header line if one is not present.
32184 This control is not permitted in the &%acl_smtp_data%& ACL, because that is too
32185 late (the message has already been created).
32186
32187 Chapter &<<CHAPmsgproc>>& describes the processing that Exim applies to
32188 messages. Section &<<SECTsubmodnon>>& covers the processing that happens in
32189 submission mode; the available options for this control are described there.
32190 The control applies only to the current message, not to any subsequent ones
32191 that may be received in the same SMTP connection.
32192
32193 .vitem &*control&~=&~suppress_local_fixups*&
32194 .cindex "submission fixups, suppressing"
32195 This control applies to locally submitted (non TCP/IP) messages, and is the
32196 complement of &`control = submission`&. It disables the fixups that are
32197 normally applied to locally-submitted messages. Specifically:
32198
32199 .ilist
32200 Any &'Sender:'& header line is left alone (in this respect, it is a
32201 dynamic version of &%local_sender_retain%&).
32202 .next
32203 No &'Message-ID:'&, &'From:'&, or &'Date:'& header lines are added.
32204 .next
32205 There is no check that &'From:'& corresponds to the actual sender.
32206 .endlist ilist
32207
32208 This control may be useful when a remotely-originated message is accepted,
32209 passed to some scanning program, and then re-submitted for delivery. It can be
32210 used only in the &%acl_smtp_mail%&, &%acl_smtp_rcpt%&, &%acl_smtp_predata%&,
32211 and &%acl_not_smtp_start%& ACLs, because it has to be set before the message's
32212 data is read.
32213
32214 &*Note:*& This control applies only to the current message, not to any others
32215 that are being submitted at the same time using &%-bs%& or &%-bS%&.
32216
32217 .vitem &*control&~=&~utf8_downconvert*&
32218 This control enables conversion of UTF-8 in message envelope addresses
32219 to a-label form.
32220 For details see section &<<SECTi18nMTA>>&.
32221
32222 .vitem &*control&~=&~wellknown*&
32223 This control sets up a response data file for a WELLKNOWN SMTP command.
32224 It may only be used in an ACL servicing that command.
32225 For details see section &<<SECTWELLKNOWNACL>>&.
32226 .endlist vlist
32227
32228
32229 .section "Summary of message fixup control" "SECTsummesfix"
32230 All four possibilities for message fixups can be specified:
32231
32232 .ilist
32233 Locally submitted, fixups applied: the default.
32234 .next
32235 Locally submitted, no fixups applied: use
32236 &`control = suppress_local_fixups`&.
32237 .next
32238 Remotely submitted, no fixups applied: the default.
32239 .next
32240 Remotely submitted, fixups applied: use &`control = submission`&.
32241 .endlist
32242
32243
32244
32245 .section "Adding header lines in ACLs" "SECTaddheadacl"
32246 .cindex "header lines" "adding in an ACL"
32247 .cindex "header lines" "position of added lines"
32248 .cindex "&%add_header%& ACL modifier"
32249 The &%add_header%& modifier can be used to add one or more extra header lines
32250 to an incoming message, as in this example:
32251 .code
32252 warn dnslists = sbl.spamhaus.org : \
32253                 dialup.mail-abuse.org
32254      add_header = X-blacklisted-at: $dnslist_domain
32255 .endd
32256 The &%add_header%& modifier is permitted in the MAIL, RCPT, PREDATA, DATA,
32257 MIME, DKIM, and non-SMTP ACLs (in other words, those that are concerned with
32258 receiving a message). The message must ultimately be accepted for
32259 &%add_header%& to have any significant effect. You can use &%add_header%& with
32260 any ACL verb, including &%deny%& (though this is potentially useful only in a
32261 RCPT ACL).
32262
32263 Headers will not be added to the message if the modifier is used in
32264 DATA, MIME or DKIM ACLs for a message delivered by cutthrough routing.
32265
32266 Leading and trailing newlines are removed from
32267 the data for the &%add_header%& modifier; if it then
32268 contains one or more newlines that
32269 are not followed by a space or a tab, it is assumed to contain multiple header
32270 lines. Each one is checked for valid syntax; &`X-ACL-Warn:`& is added to the
32271 front of any line that is not a valid header line.
32272
32273 Added header lines are accumulated during the MAIL, RCPT, and predata ACLs.
32274 They are added to the message before processing the DATA and MIME ACLs.
32275 However, if an identical header line is requested more than once, only one copy
32276 is actually added to the message. Further header lines may be accumulated
32277 during the DATA and MIME ACLs, after which they are added to the message, again
32278 with duplicates suppressed. Thus, it is possible to add two identical header
32279 lines to an SMTP message, but only if one is added before DATA and one after.
32280 In the case of non-SMTP messages, new headers are accumulated during the
32281 non-SMTP ACLs, and are added to the message after all the ACLs have run. If a
32282 message is rejected after DATA or by the non-SMTP ACL, all added header lines
32283 are included in the entry that is written to the reject log.
32284
32285 .cindex "header lines" "added; visibility of"
32286 Header lines are not visible in string expansions
32287 of message headers
32288 until they are added to the
32289 message. It follows that header lines defined in the MAIL, RCPT, and predata
32290 ACLs are not visible until the DATA ACL and MIME ACLs are run. Similarly,
32291 header lines that are added by the DATA or MIME ACLs are not visible in those
32292 ACLs. Because of this restriction, you cannot use header lines as a way of
32293 passing data between (for example) the MAIL and RCPT ACLs. If you want to do
32294 this, you can use ACL variables, as described in section
32295 &<<SECTaclvariables>>&.
32296
32297 The list of headers yet to be added is given by the &%$headers_added%& variable.
32298
32299 The &%add_header%& modifier acts immediately as it is encountered during the
32300 processing of an ACL. Notice the difference between these two cases:
32301 .display
32302 &`accept add_header = ADDED: some text`&
32303 &`       `&<&'some condition'&>
32304
32305 &`accept `&<&'some condition'&>
32306 &`       add_header = ADDED: some text`&
32307 .endd
32308 In the first case, the header line is always added, whether or not the
32309 condition is true. In the second case, the header line is added only if the
32310 condition is true. Multiple occurrences of &%add_header%& may occur in the same
32311 ACL statement. All those that are encountered before a condition fails are
32312 honoured.
32313
32314 .cindex "&%warn%& ACL verb"
32315 For compatibility with previous versions of Exim, a &%message%& modifier for a
32316 &%warn%& verb acts in the same way as &%add_header%&, except that it takes
32317 effect only if all the conditions are true, even if it appears before some of
32318 them. Furthermore, only the last occurrence of &%message%& is honoured. This
32319 usage of &%message%& is now deprecated. If both &%add_header%& and &%message%&
32320 are present on a &%warn%& verb, both are processed according to their
32321 specifications.
32322
32323 By default, new header lines are added to a message at the end of the existing
32324 header lines. However, you can specify that any particular header line should
32325 be added right at the start (before all the &'Received:'& lines), immediately
32326 after the first block of &'Received:'& lines, or immediately before any line
32327 that is not a &'Received:'& or &'Resent-something:'& header.
32328
32329 This is done by specifying &":at_start:"&, &":after_received:"&, or
32330 &":at_start_rfc:"& (or, for completeness, &":at_end:"&) before the text of the
32331 header line, respectively. (Header text cannot start with a colon, as there has
32332 to be a header name first.) For example:
32333 .code
32334 warn add_header = \
32335        :after_received:X-My-Header: something or other...
32336 .endd
32337 If more than one header line is supplied in a single &%add_header%& modifier,
32338 each one is treated independently and can therefore be placed differently. If
32339 you add more than one line at the start, or after the Received: block, they end
32340 up in reverse order.
32341
32342 &*Warning*&: This facility currently applies only to header lines that are
32343 added in an ACL. It does NOT work for header lines that are added in a
32344 system filter or in a router or transport.
32345
32346
32347
32348 .section "Removing header lines in ACLs" "SECTremoveheadacl"
32349 .cindex "header lines" "removing in an ACL"
32350 .cindex "header lines" "position of removed lines"
32351 .cindex "&%remove_header%& ACL modifier"
32352 The &%remove_header%& modifier can be used to remove one or more header lines
32353 from an incoming message, as in this example:
32354 .code
32355 warn   message        = Remove internal headers
32356        remove_header  = x-route-mail1 : x-route-mail2
32357 .endd
32358 The &%remove_header%& modifier is permitted in the MAIL, RCPT, PREDATA, DATA,
32359 MIME, DKIM, and non-SMTP ACLs (in other words, those that are concerned with
32360 receiving a message). The message must ultimately be accepted for
32361 &%remove_header%& to have any significant effect. You can use &%remove_header%&
32362 with any ACL verb, including &%deny%&, though this is really not useful for
32363 any verb that doesn't result in a delivered message.
32364
32365 Headers will not be removed from the message if the modifier is used in
32366 DATA, MIME or DKIM ACLs for a message delivered by cutthrough routing.
32367
32368 More than one header can be removed at the same time by using a colon separated
32369 list of header specifiers.
32370 If a specifier does not start with a circumflex (^)
32371 then it is treated as a header name.
32372 The header name matching is case insensitive.
32373 If it does, then it is treated as a (front-anchored)
32374 regular expression applied to the whole header.
32375
32376 &*Note*&: The colon terminating a header name will need to be doubled
32377 if used in an RE, and there can legitimately be whitepace before it.
32378
32379 Example:
32380 .code
32381 remove_header = \N^(?i)Authentication-Results\s*::\s*example.org;\N
32382 .endd
32383
32384 List expansion is not performed, so you cannot use hostlists to
32385 create a list of headers, however both connection and message variable expansion
32386 are performed (&%$acl_c_*%& and &%$acl_m_*%&), illustrated in this example:
32387 .code
32388 warn   hosts           = +internal_hosts
32389        set acl_c_ihdrs = x-route-mail1 : x-route-mail2
32390 warn   message         = Remove internal headers
32391        remove_header   = $acl_c_ihdrs
32392 .endd
32393 Header specifiers for removal are accumulated during the MAIL, RCPT, and predata ACLs.
32394 Matching header lines are removed from the message before processing the DATA and MIME ACLs.
32395 If multiple header lines match, all are removed.
32396 There is no harm in attempting to remove the same header twice nor in removing
32397 a non-existent header. Further header specifiers for removal may be accumulated
32398 during the DATA and MIME ACLs, after which matching headers are removed
32399 if present. In the case of non-SMTP messages, remove specifiers are
32400 accumulated during the non-SMTP ACLs, and are acted on after
32401 all the ACLs have run. If a message is rejected after DATA or by the non-SMTP
32402 ACL, there really is no effect because there is no logging of what headers
32403 would have been removed.
32404
32405 .cindex "header lines" "removed; visibility of"
32406 Header lines are not visible in string expansions until the DATA phase when it
32407 is received. Any header lines removed in the MAIL, RCPT, and predata ACLs are
32408 not visible in the DATA ACL and MIME ACLs. Similarly, header lines that are
32409 removed by the DATA or MIME ACLs are still visible in those ACLs. Because of
32410 this restriction, you cannot use header lines as a way of controlling data
32411 passed between (for example) the MAIL and RCPT ACLs. If you want to do this,
32412 you should instead use ACL variables, as described in section
32413 &<<SECTaclvariables>>&.
32414
32415 The &%remove_header%& modifier acts immediately as it is encountered during the
32416 processing of an ACL. Notice the difference between these two cases:
32417 .display
32418 &`accept remove_header = X-Internal`&
32419 &`       `&<&'some condition'&>
32420
32421 &`accept `&<&'some condition'&>
32422 &`       remove_header = X-Internal`&
32423 .endd
32424 In the first case, the header line is always removed, whether or not the
32425 condition is true. In the second case, the header line is removed only if the
32426 condition is true. Multiple occurrences of &%remove_header%& may occur in the
32427 same ACL statement. All those that are encountered before a condition fails
32428 are honoured.
32429
32430 &*Warning*&: This facility currently applies only to header lines that are
32431 present during ACL processing. It does NOT remove header lines that are added
32432 in a system filter or in a router or transport.
32433
32434
32435
32436
32437 .section "ACL conditions" "SECTaclconditions"
32438 .cindex "&ACL;" "conditions; list of"
32439 Some of the conditions listed in this section are available only when Exim is
32440 compiled with the content-scanning extension. They are included here briefly
32441 for completeness. More detailed descriptions can be found in the discussion on
32442 content scanning in chapter &<<CHAPexiscan>>&.
32443
32444 Not all conditions are relevant in all circumstances. For example, testing
32445 senders and recipients does not make sense in an ACL that is being run as the
32446 result of the arrival of an ETRN command, and checks on message headers can be
32447 done only in the ACLs specified by &%acl_smtp_data%& and &%acl_not_smtp%&. You
32448 can use the same condition (with different parameters) more than once in the
32449 same ACL statement. This provides a way of specifying an &"and"& conjunction.
32450 The conditions are as follows:
32451
32452
32453 .vlist
32454 .vitem &*acl&~=&~*&<&'name&~of&~acl&~or&~ACL&~string&~or&~file&~name&~'&>
32455 .cindex "&ACL;" "nested"
32456 .cindex "&ACL;" "indirect"
32457 .cindex "&ACL;" "arguments"
32458 .cindex "&%acl%& ACL condition"
32459 The possible values of the argument are the same as for the
32460 &%acl_smtp_%&&'xxx'& options. The named or inline ACL is run. If it returns
32461 &"accept"& the condition is true; if it returns &"deny"& the condition is
32462 false. If it returns &"defer"&, the current ACL returns &"defer"& unless the
32463 condition is on a &%warn%& verb. In that case, a &"defer"& return makes the
32464 condition false. This means that further processing of the &%warn%& verb
32465 ceases, but processing of the ACL continues.
32466
32467 If the argument is a named ACL, up to nine space-separated optional values
32468 can be appended; they appear within the called ACL in $acl_arg1 to $acl_arg9,
32469 and $acl_narg is set to the count of values.
32470 Previous values of these variables are restored after the call returns.
32471 The name and values are expanded separately.
32472 Note that spaces in complex expansions which are used as arguments
32473 will act as argument separators.
32474
32475 If the nested &%acl%& returns &"drop"& and the outer condition denies access,
32476 the connection is dropped. If it returns &"discard"&, the verb must be
32477 &%accept%& or &%discard%&, and the action is taken immediately &-- no further
32478 conditions are tested.
32479
32480 ACLs may be nested up to 20 deep; the limit exists purely to catch runaway
32481 loops. This condition allows you to use different ACLs in different
32482 circumstances. For example, different ACLs can be used to handle RCPT commands
32483 for different local users or different local domains.
32484
32485 .vitem &*authenticated&~=&~*&<&'string&~list'&>
32486 .cindex "&%authenticated%& ACL condition"
32487 .cindex "authentication" "ACL checking"
32488 .cindex "&ACL;" "testing for authentication"
32489 If the SMTP connection is not authenticated, the condition is false. Otherwise,
32490 the name of the authenticator is tested against the list. To test for
32491 authentication by any authenticator, you can set
32492 .code
32493 authenticated = *
32494 .endd
32495
32496 .vitem &*condition&~=&~*&<&'string'&>
32497 .cindex "&%condition%& ACL condition"
32498 .cindex "customizing" "ACL condition"
32499 .cindex "&ACL;" "customized test"
32500 .cindex "&ACL;" "testing, customized"
32501 This feature allows you to make up custom conditions. If the result of
32502 expanding the string is an empty string, the number zero, or one of the strings
32503 &"no"& or &"false"&, the condition is false. If the result is any non-zero
32504 number, or one of the strings &"yes"& or &"true"&, the condition is true. For
32505 any other value, some error is assumed to have occurred, and the ACL returns
32506 &"defer"&. However, if the expansion is forced to fail, the condition is
32507 ignored. The effect is to treat it as true, whether it is positive or
32508 negative.
32509
32510 .vitem &*decode&~=&~*&<&'location'&>
32511 .cindex "&%decode%& ACL condition"
32512 This condition is available only when Exim is compiled with the
32513 content-scanning extension, and it is allowed only in the ACL defined by
32514 &%acl_smtp_mime%&. It causes the current MIME part to be decoded into a file.
32515 If all goes well, the condition is true. It is false only if there are
32516 problems such as a syntax error or a memory shortage. For more details, see
32517 chapter &<<CHAPexiscan>>&.
32518
32519 .vitem &*dnslists&~=&~*&<&'list&~of&~domain&~names&~and&~other&~data'&>
32520 .cindex "&%dnslists%& ACL condition"
32521 .cindex "DNS list" "in ACL"
32522 .cindex "black list (DNS)"
32523 .cindex "&ACL;" "testing a DNS list"
32524 This condition checks for entries in DNS black lists. These are also known as
32525 &"RBL lists"&, after the original Realtime Blackhole List, but note that the
32526 use of the lists at &'mail-abuse.org'& now carries a charge. There are too many
32527 different variants of this condition to describe briefly here. See sections
32528 &<<SECTmorednslists>>&&--&<<SECTmorednslistslast>>& for details.
32529
32530 .vitem &*domains&~=&~*&<&'domain&~list'&>
32531 .cindex "&%domains%& ACL condition"
32532 .cindex "domain" "ACL checking"
32533 .cindex "&ACL;" "testing a recipient domain"
32534 .vindex "&$domain_data$&"
32535 This condition is relevant only in a RCPT ACL. It checks that the domain
32536 of the recipient address is in the domain list. If percent-hack processing is
32537 enabled, it is done before this test is done. If the check succeeds with a
32538 lookup, the result of the lookup is placed in &$domain_data$& until the next
32539 &%domains%& test.
32540
32541 &*Note carefully*& (because many people seem to fall foul of this): you cannot
32542 use &%domains%& in a DATA ACL.
32543
32544
32545 .vitem &*encrypted&~=&~*&<&'string&~list'&>
32546 .cindex "&%encrypted%& ACL condition"
32547 .cindex "encryption" "checking in an ACL"
32548 .cindex "&ACL;" "testing for encryption"
32549 If the SMTP connection is not encrypted, the condition is false. Otherwise, the
32550 name of the cipher suite in use is tested against the list. To test for
32551 encryption without testing for any specific cipher suite(s), set
32552 .code
32553 encrypted = *
32554 .endd
32555
32556
32557 .vitem &*hosts&~=&~*&<&'host&~list'&>
32558 .cindex "&%hosts%& ACL condition"
32559 .cindex "host" "ACL checking"
32560 .cindex "&ACL;" "testing the client host"
32561 This condition tests that the calling host matches the host list. If you have
32562 name lookups or wildcarded host names and IP addresses in the same host list,
32563 you should normally put the IP addresses first. For example, you could have:
32564 .code
32565 accept hosts = 10.9.8.7 : dbm;/etc/friendly/hosts
32566 .endd
32567 The lookup in this example uses the host name for its key. This is implied by
32568 the lookup type &"dbm"&. (For a host address lookup you would use &"net-dbm"&
32569 and it wouldn't matter which way round you had these two items.)
32570
32571 The reason for the problem with host names lies in the left-to-right way that
32572 Exim processes lists. It can test IP addresses without doing any DNS lookups,
32573 but when it reaches an item that requires a host name, it fails if it cannot
32574 find a host name to compare with the pattern. If the above list is given in the
32575 opposite order, the &%accept%& statement fails for a host whose name cannot be
32576 found, even if its IP address is 10.9.8.7.
32577
32578 If you really do want to do the name check first, and still recognize the IP
32579 address even if the name lookup fails, you can rewrite the ACL like this:
32580 .code
32581 accept hosts = dbm;/etc/friendly/hosts
32582 accept hosts = 10.9.8.7
32583 .endd
32584 The default action on failing to find the host name is to assume that the host
32585 is not in the list, so the first &%accept%& statement fails. The second
32586 statement can then check the IP address.
32587
32588 .vindex "&$host_data$&"
32589 If a &%hosts%& condition is satisfied by means of a lookup, the result
32590 of the lookup is made available in the &$host_data$& variable. This
32591 allows you, for example, to set up a statement like this:
32592 .code
32593 deny  hosts = net-lsearch;/some/file
32594       message = $host_data
32595 .endd
32596 which gives a custom error message for each denied host.
32597
32598 .vitem &*local_parts&~=&~*&<&'local&~part&~list'&>
32599 .cindex "&%local_parts%& ACL condition"
32600 .cindex "local part" "ACL checking"
32601 .cindex "&ACL;" "testing a local part"
32602 .vindex "&$local_part_data$&"
32603 This condition is relevant only in a RCPT ACL. It checks that the local
32604 part of the recipient address is in the list. If percent-hack processing is
32605 enabled, it is done before this test. If the check succeeds with a lookup, the
32606 result of the lookup is placed in &$local_part_data$&, which remains set until
32607 the next &%local_parts%& test.
32608
32609 .vitem &*malware&~=&~*&<&'option'&>
32610 .cindex "&%malware%& ACL condition"
32611 .cindex "&ACL;" "virus scanning"
32612 .cindex "&ACL;" "scanning for viruses"
32613 This condition is available only when Exim is compiled with the
32614 content-scanning extension
32615 and only after a DATA command.
32616 It causes the incoming message to be scanned for
32617 viruses. For details, see chapter &<<CHAPexiscan>>&.
32618
32619 .vitem &*mime_regex&~=&~*&<&'list&~of&~regular&~expressions'&>
32620 .cindex "&%mime_regex%& ACL condition"
32621 .cindex "&ACL;" "testing by regex matching"
32622 This condition is available only when Exim is compiled with the
32623 content-scanning extension, and it is allowed only in the ACL defined by
32624 &%acl_smtp_mime%&. It causes the current MIME part to be scanned for a match
32625 with any of the regular expressions. For details, see chapter
32626 &<<CHAPexiscan>>&.
32627
32628 .vitem &*ratelimit&~=&~*&<&'parameters'&>
32629 .cindex "rate limiting"
32630 This condition can be used to limit the rate at which a user or host submits
32631 messages. Details are given in section &<<SECTratelimiting>>&.
32632
32633 .vitem &*recipients&~=&~*&<&'address&~list'&>
32634 .cindex "&%recipients%& ACL condition"
32635 .cindex "recipient" "ACL checking"
32636 .cindex "&ACL;" "testing a recipient"
32637 This condition is relevant only in a RCPT ACL. It checks the entire
32638 recipient address against a list of recipients.
32639
32640 .vitem &*regex&~=&~*&<&'list&~of&~regular&~expressions'&>
32641 .cindex "&%regex%& ACL condition"
32642 .cindex "&ACL;" "testing by regex matching"
32643 This condition is available only when Exim is compiled with the
32644 content-scanning extension, and is available only in the DATA, MIME, and
32645 non-SMTP ACLs. It causes the incoming message to be scanned for a match with
32646 any of the regular expressions. For details, see chapter &<<CHAPexiscan>>&.
32647
32648 .vitem &*seen&~=&~*&<&'parameters'&>
32649 .cindex "&%seen%& ACL condition"
32650 This condition can be used to test if a situation has been previously met,
32651 for example for greylisting.
32652 Details are given in section &<<SECTseen>>&.
32653
32654 .vitem &*sender_domains&~=&~*&<&'domain&~list'&>
32655 .cindex "&%sender_domains%& ACL condition"
32656 .cindex "sender" "ACL checking"
32657 .cindex "&ACL;" "testing a sender domain"
32658 .vindex "&$domain$&"
32659 .vindex "&$sender_address_domain$&"
32660 This condition tests the domain of the sender of the message against the given
32661 domain list. &*Note*&: The domain of the sender address is in
32662 &$sender_address_domain$&. It is &'not'& put in &$domain$& during the testing
32663 of this condition. This is an exception to the general rule for testing domain
32664 lists. It is done this way so that, if this condition is used in an ACL for a
32665 RCPT command, the recipient's domain (which is in &$domain$&) can be used to
32666 influence the sender checking.
32667
32668 &*Warning*&: It is a bad idea to use this condition on its own as a control on
32669 relaying, because sender addresses are easily, and commonly, forged.
32670
32671 .vitem &*senders&~=&~*&<&'address&~list'&>
32672 .cindex "&%senders%& ACL condition"
32673 .cindex "sender" "ACL checking"
32674 .cindex "&ACL;" "testing a sender"
32675 This condition tests the sender of the message against the given list. To test
32676 for a bounce message, which has an empty sender, set
32677 .code
32678 senders = :
32679 .endd
32680 &*Warning*&: It is a bad idea to use this condition on its own as a control on
32681 relaying, because sender addresses are easily, and commonly, forged.
32682
32683 .vitem &*spam&~=&~*&<&'username'&>
32684 .cindex "&%spam%& ACL condition"
32685 .cindex "&ACL;" "scanning for spam"
32686 This condition is available only when Exim is compiled with the
32687 content-scanning extension. It causes the incoming message to be scanned by
32688 SpamAssassin. For details, see chapter &<<CHAPexiscan>>&.
32689
32690 .vitem &*verify&~=&~certificate*&
32691 .cindex "&%verify%& ACL condition"
32692 .cindex "TLS" "client certificate verification"
32693 .cindex "certificate" "verification of client"
32694 .cindex "&ACL;" "certificate verification"
32695 .cindex "&ACL;" "testing a TLS certificate"
32696 This condition is true in an SMTP session if the session is encrypted, and a
32697 certificate was received from the client, and the certificate was verified. The
32698 server requests a certificate only if the client matches &%tls_verify_hosts%&
32699 or &%tls_try_verify_hosts%& (see chapter &<<CHAPTLS>>&).
32700
32701 .vitem &*verify&~=&~csa*&
32702 .cindex "CSA verification"
32703 This condition checks whether the sending host (the client) is authorized to
32704 send email. Details of how this works are given in section
32705 &<<SECTverifyCSA>>&.
32706
32707 .vitem &*verify&~=&~header_names_ascii*&
32708 .cindex "&%verify%& ACL condition"
32709 .cindex "&ACL;" "verifying header names only ASCII"
32710 .cindex "header lines" "verifying header names only ASCII"
32711 .cindex "verifying" "header names only ASCII"
32712 This condition is relevant only in an ACL that is run after a message has been
32713 received.
32714 This usually means an ACL specified by &%acl_smtp_data%& or &%acl_not_smtp%&.
32715 It checks all header names (not the content) to make sure
32716 there are no non-ASCII characters, also excluding control characters.  The
32717 allowable characters are decimal ASCII values 33 through 126.
32718
32719 Exim itself will handle headers with non-ASCII characters, but it can cause
32720 problems for downstream applications, so this option will allow their
32721 detection and rejection in the DATA ACL's.
32722
32723 .vitem &*verify&~=&~header_sender/*&<&'options'&>
32724 .cindex "&%verify%& ACL condition"
32725 .cindex "&ACL;" "verifying sender in the header"
32726 .cindex "header lines" "verifying the sender in"
32727 .cindex "sender" "verifying in header"
32728 .cindex "verifying" "sender in header"
32729 This condition is relevant only in an ACL that is run after a message has been
32730 received, that is, in an ACL specified by &%acl_smtp_data%& or
32731 &%acl_not_smtp%&. It checks that there is a verifiable address in at least one
32732 of the &'Sender:'&, &'Reply-To:'&, or &'From:'& header lines. Such an address
32733 is loosely thought of as a &"sender"& address (hence the name of the test).
32734 However, an address that appears in one of these headers need not be an address
32735 that accepts bounce messages; only sender addresses in envelopes are required
32736 to accept bounces. Therefore, if you use the callout option on this check, you
32737 might want to arrange for a non-empty address in the MAIL command.
32738
32739 Details of address verification and the options are given later, starting at
32740 section &<<SECTaddressverification>>& (callouts are described in section
32741 &<<SECTcallver>>&). You can combine this condition with the &%senders%&
32742 condition to restrict it to bounce messages only:
32743 .code
32744 deny    senders = :
32745        !verify  = header_sender
32746         message = A valid sender header is required for bounces
32747 .endd
32748
32749 .vitem &*verify&~=&~header_syntax*&
32750 .cindex "&%verify%& ACL condition"
32751 .cindex "&ACL;" "verifying header syntax"
32752 .cindex "header lines" "verifying syntax"
32753 .cindex "verifying" "header syntax"
32754 This condition is relevant only in an ACL that is run after a message has been
32755 received, that is, in an ACL specified by &%acl_smtp_data%& or
32756 &%acl_not_smtp%&. It checks the syntax of all header lines that can contain
32757 lists of addresses (&'Sender:'&, &'From:'&, &'Reply-To:'&, &'To:'&, &'Cc:'&,
32758 and &'Bcc:'&), returning true if there are no problems.
32759 Unqualified addresses (local parts without domains) are
32760 permitted only in locally generated messages and from hosts that match
32761 &%sender_unqualified_hosts%& or &%recipient_unqualified_hosts%&, as
32762 appropriate.
32763
32764 Note that this condition is a syntax check only. However, a common spamming
32765 ploy used to be to send syntactically invalid headers such as
32766 .code
32767 To: @
32768 .endd
32769 and this condition can be used to reject such messages, though they are not as
32770 common as they used to be.
32771
32772 .vitem &*verify&~=&~helo*&
32773 .cindex "&%verify%& ACL condition"
32774 .cindex "&ACL;" "verifying HELO/EHLO"
32775 .cindex "HELO" "verifying"
32776 .cindex "EHLO" "verifying"
32777 .cindex "verifying" "EHLO"
32778 .cindex "verifying" "HELO"
32779 This condition is true if a HELO or EHLO command has been received from the
32780 client host, and its contents have been verified. If there has been no previous
32781 attempt to verify the HELO/EHLO contents, it is carried out when this
32782 condition is encountered. See the description of the &%helo_verify_hosts%& and
32783 &%helo_try_verify_hosts%& options for details of how to request verification
32784 independently of this condition, and for detail of the verification.
32785
32786 For SMTP input that does not come over TCP/IP (the &%-bs%& command line
32787 option), this condition is always true.
32788
32789
32790 .vitem &*verify&~=&~not_blind/*&<&'options'&>
32791 .cindex "verifying" "not blind"
32792 .cindex "bcc recipients, verifying none"
32793 This condition checks that there are no blind (bcc) recipients in the message.
32794 Every envelope recipient must appear either in a &'To:'& header line or in a
32795 &'Cc:'& header line for this condition to be true. Local parts are checked
32796 case-sensitively; domains are checked case-insensitively. If &'Resent-To:'& or
32797 &'Resent-Cc:'& header lines exist, they are also checked. This condition can be
32798 used only in a DATA or non-SMTP ACL.
32799
32800 There is one possible option, &`case_insensitive`&.  If this is present then
32801 local parts are checked case-insensitively.
32802
32803 There are, of course, many legitimate messages that make use of blind (bcc)
32804 recipients. This check should not be used on its own for blocking messages.
32805
32806
32807 .vitem &*verify&~=&~recipient/*&<&'options'&>
32808 .cindex "&%verify%& ACL condition"
32809 .cindex "&ACL;" "verifying recipient"
32810 .cindex "recipient" "verifying"
32811 .cindex "verifying" "recipient"
32812 .vindex "&$address_data$&"
32813 This condition is relevant only after a RCPT command. It verifies the current
32814 recipient. Details of address verification are given later, starting at section
32815 &<<SECTaddressverification>>&. After a recipient has been verified, the value
32816 of &$address_data$& is the last value that was set while routing the address.
32817 This applies even if the verification fails. When an address that is being
32818 verified is redirected to a single address, verification continues with the new
32819 address, and in that case, the subsequent value of &$address_data$& is the
32820 value for the child address.
32821
32822 .vitem &*verify&~=&~reverse_host_lookup/*&<&'options'&>
32823 .cindex "&%verify%& ACL condition"
32824 .cindex "&ACL;" "verifying host reverse lookup"
32825 .cindex "host" "verifying reverse lookup"
32826 This condition ensures that a verified host name has been looked up from the IP
32827 address of the client host. (This may have happened already if the host name
32828 was needed for checking a host list, or if the host matched &%host_lookup%&.)
32829 Verification ensures that the host name obtained from a reverse DNS lookup, or
32830 one of its aliases, does, when it is itself looked up in the DNS, yield the
32831 original IP address.
32832
32833 There is one possible option, &`defer_ok`&.  If this is present and a
32834 DNS operation returns a temporary error, the verify condition succeeds.
32835
32836 If this condition is used for a locally generated message (that is, when there
32837 is no client host involved), it always succeeds.
32838
32839 .vitem &*verify&~=&~sender/*&<&'options'&>
32840 .cindex "&%verify%& ACL condition"
32841 .cindex "&ACL;" "verifying sender"
32842 .cindex "sender" "verifying"
32843 .cindex "verifying" "sender"
32844 This condition is relevant only after a MAIL or RCPT command, or after a
32845 message has been received (the &%acl_smtp_data%& or &%acl_not_smtp%& ACLs). If
32846 the message's sender is empty (that is, this is a bounce message), the
32847 condition is true. Otherwise, the sender address is verified.
32848
32849 .vindex "&$address_data$&"
32850 .vindex "&$sender_address_data$&"
32851 If there is data in the &$address_data$& variable at the end of routing, its
32852 value is placed in &$sender_address_data$& at the end of verification. This
32853 value can be used in subsequent conditions and modifiers in the same ACL
32854 statement. It does not persist after the end of the current statement. If you
32855 want to preserve the value for longer, you can save it in an ACL variable.
32856
32857 Details of verification are given later, starting at section
32858 &<<SECTaddressverification>>&. Exim caches the result of sender verification,
32859 to avoid doing it more than once per message.
32860
32861 .vitem &*verify&~=&~sender=*&<&'address'&>&*/*&<&'options'&>
32862 .cindex "&%verify%& ACL condition"
32863 This is a variation of the previous option, in which a modified address is
32864 verified as a sender.
32865
32866 Note that '/' is legal in local-parts; if the address may have such
32867 (eg. is generated from the received message)
32868 they must be protected from the options parsing by doubling:
32869 .code
32870 verify = sender=${listquote{/}{${address:$h_sender:}}}
32871 .endd
32872 .endlist
32873
32874
32875
32876 .section "Using DNS lists" "SECTmorednslists"
32877 .cindex "DNS list" "in ACL"
32878 .cindex "black list (DNS)"
32879 .cindex "&ACL;" "testing a DNS list"
32880 In its simplest form, the &%dnslists%& condition tests whether the calling host
32881 is on at least one of a number of DNS lists by looking up the inverted IP
32882 address in one or more DNS domains. (Note that DNS list domains are not mail
32883 domains, so the &`+`& syntax for named lists doesn't work - it is used for
32884 special options instead.) For example, if the calling host's IP
32885 address is 192.168.62.43, and the ACL statement is
32886 .code
32887 deny dnslists = blackholes.mail-abuse.org : \
32888                 dialups.mail-abuse.org
32889 .endd
32890 the following records are looked up:
32891 .code
32892 43.62.168.192.blackholes.mail-abuse.org
32893 43.62.168.192.dialups.mail-abuse.org
32894 .endd
32895 As soon as Exim finds an existing DNS record, processing of the list stops.
32896 Thus, multiple entries on the list provide an &"or"& conjunction. If you want
32897 to test that a host is on more than one list (an &"and"& conjunction), you can
32898 use two separate conditions:
32899 .code
32900 deny dnslists = blackholes.mail-abuse.org
32901      dnslists = dialups.mail-abuse.org
32902 .endd
32903 If a DNS lookup times out or otherwise fails to give a decisive answer, Exim
32904 behaves as if the host does not match the list item, that is, as if the DNS
32905 record does not exist. If there are further items in the DNS list, they are
32906 processed.
32907
32908 This is usually the required action when &%dnslists%& is used with &%deny%&
32909 (which is the most common usage), because it prevents a DNS failure from
32910 blocking mail. However, you can change this behaviour by putting one of the
32911 following special items in the list:
32912 .itable none 0 0 2 25* left 75* left
32913 .irow "+include_unknown"   "behave as if the item is on the list"
32914 .irow "+exclude_unknown"   "behave as if the item is not on the list (default)"
32915 .irow "+defer_unknown  "   "give a temporary error"
32916 .endtable
32917 .cindex "&`+include_unknown`&"
32918 .cindex "&`+exclude_unknown`&"
32919 .cindex "&`+defer_unknown`&"
32920 Each of these applies to any subsequent items on the list. For example:
32921 .code
32922 deny dnslists = +defer_unknown : foo.bar.example
32923 .endd
32924 Testing the list of domains stops as soon as a match is found. If you want to
32925 warn for one list and block for another, you can use two different statements:
32926 .code
32927 deny  dnslists = blackholes.mail-abuse.org
32928 warn  dnslists = dialups.mail-abuse.org
32929       message  = X-Warn: sending host is on dialups list
32930 .endd
32931 .cindex caching "of dns lookup"
32932 .cindex DNS TTL
32933 DNS list lookups are cached by Exim for the duration of the SMTP session
32934 (but limited by the DNS return TTL value),
32935 so a lookup based on the IP address is done at most once for any incoming
32936 connection (assuming long-enough TTL).
32937 Exim does not share information between multiple incoming
32938 connections (but your local name server cache should be active).
32939
32940 There are a number of DNS lists to choose from, some commercial, some free,
32941 or free for small deployments.  An overview can be found at
32942 &url(https://en.wikipedia.org/wiki/Comparison_of_DNS_blacklists).
32943
32944
32945
32946 .subsection "Specifying the IP address for a DNS list lookup" SECID201
32947 .cindex "DNS list" "keyed by explicit IP address"
32948 By default, the IP address that is used in a DNS list lookup is the IP address
32949 of the calling host. However, you can specify another IP address by listing it
32950 after the domain name, introduced by a slash. For example:
32951 .code
32952 deny dnslists = black.list.tld/192.168.1.2
32953 .endd
32954 This feature is not very helpful with explicit IP addresses; it is intended for
32955 use with IP addresses that are looked up, for example, the IP addresses of the
32956 MX hosts or nameservers of an email sender address. For an example, see section
32957 &<<SECTmulkeyfor>>& below.
32958
32959
32960
32961
32962 .subsection "DNS lists keyed on domain names" SECID202
32963 .cindex "DNS list" "keyed by domain name"
32964 There are some lists that are keyed on domain names rather than inverted IP
32965 addresses (see, e.g., the &'domain based zones'& link at
32966 &url(http://www.rfc-ignorant.org/)). No reversing of components is used
32967 with these lists. You can change the name that is looked up in a DNS list by
32968 listing it after the domain name, introduced by a slash. For example,
32969 .code
32970 deny  dnslists = dsn.rfc-ignorant.org/$sender_address_domain
32971       message  = Sender's domain is listed at $dnslist_domain
32972 .endd
32973 This particular example is useful only in ACLs that are obeyed after the
32974 RCPT or DATA commands, when a sender address is available. If (for
32975 example) the message's sender is &'user@tld.example'& the name that is looked
32976 up by this example is
32977 .code
32978 tld.example.dsn.rfc-ignorant.org
32979 .endd
32980 A single &%dnslists%& condition can contain entries for both names and IP
32981 addresses. For example:
32982 .code
32983 deny dnslists = sbl.spamhaus.org : \
32984                 dsn.rfc-ignorant.org/$sender_address_domain
32985 .endd
32986 The first item checks the sending host's IP address; the second checks a domain
32987 name. The whole condition is true if either of the DNS lookups succeeds.
32988
32989
32990
32991
32992 .subsection "Multiple explicit keys for a DNS list" SECTmulkeyfor
32993 .cindex "DNS list" "multiple keys for"
32994 The syntax described above for looking up explicitly-defined values (either
32995 names or IP addresses) in a DNS blacklist is a simplification. After the domain
32996 name for the DNS list, what follows the slash can in fact be a list of items.
32997 As with all lists in Exim, the default separator is a colon. However, because
32998 this is a sublist within the list of DNS blacklist domains, it is necessary
32999 either to double the separators like this:
33000 .code
33001 dnslists = black.list.tld/name.1::name.2
33002 .endd
33003 or to change the separator character, like this:
33004 .code
33005 dnslists = black.list.tld/<;name.1;name.2
33006 .endd
33007 If an item in the list is an IP address, it is inverted before the DNS
33008 blacklist domain is appended. If it is not an IP address, no inversion
33009 occurs. Consider this condition:
33010 .code
33011 dnslists = black.list.tld/<;192.168.1.2;a.domain
33012 .endd
33013 The DNS lookups that occur are:
33014 .code
33015 2.1.168.192.black.list.tld
33016 a.domain.black.list.tld
33017 .endd
33018 Once a DNS record has been found (that matches a specific IP return
33019 address, if specified &-- see section &<<SECTaddmatcon>>&), no further lookups
33020 are done. If there is a temporary DNS error, the rest of the sublist of domains
33021 or IP addresses is tried. A temporary error for the whole dnslists item occurs
33022 only if no other DNS lookup in this sublist succeeds. In other words, a
33023 successful lookup for any of the items in the sublist overrides a temporary
33024 error for a previous item.
33025
33026 The ability to supply a list of items after the slash is in some sense just a
33027 syntactic convenience. These two examples have the same effect:
33028 .code
33029 dnslists = black.list.tld/a.domain : black.list.tld/b.domain
33030 dnslists = black.list.tld/a.domain::b.domain
33031 .endd
33032 However, when the data for the list is obtained from a lookup, the second form
33033 is usually much more convenient. Consider this example:
33034 .code
33035 deny dnslists = sbl.spamhaus.org/<|${lookup dnsdb {>|a=<|\
33036                                    ${lookup dnsdb {>|mxh=\
33037                                    $sender_address_domain} }} }
33038      message  = The mail servers for the domain \
33039                 $sender_address_domain \
33040                 are listed at $dnslist_domain ($dnslist_value); \
33041                 see $dnslist_text.
33042 .endd
33043 Note the use of &`>|`& in the dnsdb lookup to specify the separator for
33044 multiple DNS records. The inner dnsdb lookup produces a list of MX hosts
33045 and the outer dnsdb lookup finds the IP addresses for these hosts. The result
33046 of expanding the condition might be something like this:
33047 .code
33048 dnslists = sbl.spamhaus.org/<|192.168.2.3|192.168.5.6|...
33049 .endd
33050 Thus, this example checks whether or not the IP addresses of the sender
33051 domain's mail servers are on the Spamhaus black list.
33052
33053 The key that was used for a successful DNS list lookup is put into the variable
33054 &$dnslist_matched$& (see section &<<SECID204>>&).
33055
33056
33057
33058
33059 .subsection "Data returned by DNS lists" SECID203
33060 .cindex "DNS list" "data returned from"
33061 DNS lists are constructed using address records in the DNS. The original RBL
33062 just used the address 127.0.0.1 on the right hand side of each record, but the
33063 RBL+ list and some other lists use a number of values with different meanings.
33064 The values used on the RBL+ list are:
33065 .itable none 0 0 2 20* left 80* left
33066 .irow 127.1.0.1  "RBL"
33067 .irow 127.1.0.2  "DUL"
33068 .irow 127.1.0.3  "DUL and RBL"
33069 .irow 127.1.0.4  "RSS"
33070 .irow 127.1.0.5  "RSS and RBL"
33071 .irow 127.1.0.6  "RSS and DUL"
33072 .irow 127.1.0.7  "RSS and DUL and RBL"
33073 .endtable
33074 Section &<<SECTaddmatcon>>& below describes how you can distinguish between
33075 different values. Some DNS lists may return more than one address record;
33076 see section &<<SECThanmuldnsrec>>& for details of how they are checked.
33077
33078 Values returned by a properly running DBSBL should be in the 127.0.0.0/8
33079 range. If a DNSBL operator loses control of the domain, lookups on it
33080 may start returning other addresses.  Because of this, Exim now ignores
33081 returned values outside the 127/8 region.
33082
33083
33084 .subsection "Variables set from DNS lists" SECID204
33085 .cindex "expansion" "variables, set from DNS list"
33086 .cindex "DNS list" "variables set from"
33087 .vindex "&$dnslist_domain$&"
33088 .vindex "&$dnslist_matched$&"
33089 .vindex "&$dnslist_text$&"
33090 .vindex "&$dnslist_value$&"
33091 When an entry is found in a DNS list, the variable &$dnslist_domain$& contains
33092 the name of the overall domain that matched (for example,
33093 &`spamhaus.example`&), &$dnslist_matched$& contains the key within that domain
33094 (for example, &`192.168.5.3`&), and &$dnslist_value$& contains the data from
33095 the DNS record. When the key is an IP address, it is not reversed in
33096 &$dnslist_matched$& (though it is, of course, in the actual lookup). In simple
33097 cases, for example:
33098 .code
33099 deny dnslists = spamhaus.example
33100 .endd
33101 the key is also available in another variable (in this case,
33102 &$sender_host_address$&). In more complicated cases, however, this is not true.
33103 For example, using a data lookup (as described in section &<<SECTmulkeyfor>>&)
33104 might generate a dnslists lookup like this:
33105 .code
33106 deny dnslists = spamhaus.example/<|192.168.1.2|192.168.6.7|...
33107 .endd
33108 If this condition succeeds, the value in &$dnslist_matched$& might be
33109 &`192.168.6.7`& (for example).
33110
33111 If more than one address record is returned by the DNS lookup, all the IP
33112 addresses are included in &$dnslist_value$&, separated by commas and spaces.
33113 The variable &$dnslist_text$& contains the contents of any associated TXT
33114 record. For lists such as RBL+ the TXT record for a merged entry is often not
33115 very meaningful. See section &<<SECTmordetinf>>& for a way of obtaining more
33116 information.
33117
33118 You can use the DNS list variables in &%message%& or &%log_message%& modifiers
33119 &-- even if these appear before the condition in the ACL, they are not
33120 expanded until after it has failed. For example:
33121 .code
33122 deny    hosts = !+local_networks
33123         message = $sender_host_address is listed \
33124                   at $dnslist_domain
33125         dnslists = rbl-plus.mail-abuse.example
33126 .endd
33127
33128
33129
33130 .subsection "Additional matching conditions for DNS lists" SECTaddmatcon
33131 .cindex "DNS list" "matching specific returned data"
33132 You can add an equals sign and an IP address after a &%dnslists%& domain name
33133 in order to restrict its action to DNS records with a matching right hand side.
33134 For example,
33135 .code
33136 deny dnslists = rblplus.mail-abuse.org=127.0.0.2
33137 .endd
33138 rejects only those hosts that yield 127.0.0.2. Without this additional data,
33139 any address record is considered to be a match. For the moment, we assume
33140 that the DNS lookup returns just one record. Section &<<SECThanmuldnsrec>>&
33141 describes how multiple records are handled.
33142
33143 More than one IP address may be given for checking, using a comma as a
33144 separator. These are alternatives &-- if any one of them matches, the
33145 &%dnslists%& condition is true. For example:
33146 .code
33147 deny  dnslists = a.b.c=127.0.0.2,127.0.0.3
33148 .endd
33149 If you want to specify a constraining address list and also specify names or IP
33150 addresses to be looked up, the constraining address list must be specified
33151 first. For example:
33152 .code
33153 deny dnslists = dsn.rfc-ignorant.org\
33154                 =127.0.0.2/$sender_address_domain
33155 .endd
33156
33157 If the character &`&&`& is used instead of &`=`&, the comparison for each
33158 listed IP address is done by a bitwise &"and"& instead of by an equality test.
33159 In other words, the listed addresses are used as bit masks. The comparison is
33160 true if all the bits in the mask are present in the address that is being
33161 tested. For example:
33162 .code
33163 dnslists = a.b.c&0.0.0.3
33164 .endd
33165 matches if the address is &'x.x.x.'&3, &'x.x.x.'&7, &'x.x.x.'&11, etc. If you
33166 want to test whether one bit or another bit is present (as opposed to both
33167 being present), you must use multiple values. For example:
33168 .code
33169 dnslists = a.b.c&0.0.0.1,0.0.0.2
33170 .endd
33171 matches if the final component of the address is an odd number or two times
33172 an odd number.
33173
33174
33175
33176 .subsection "Negated DNS matching conditions" SECID205
33177 You can supply a negative list of IP addresses as part of a &%dnslists%&
33178 condition. Whereas
33179 .code
33180 deny  dnslists = a.b.c=127.0.0.2,127.0.0.3
33181 .endd
33182 means &"deny if the host is in the black list at the domain &'a.b.c'& and the
33183 IP address yielded by the list is either 127.0.0.2 or 127.0.0.3"&,
33184 .code
33185 deny  dnslists = a.b.c!=127.0.0.2,127.0.0.3
33186 .endd
33187 means &"deny if the host is in the black list at the domain &'a.b.c'& and the
33188 IP address yielded by the list is not 127.0.0.2 and not 127.0.0.3"&. In other
33189 words, the result of the test is inverted if an exclamation mark appears before
33190 the &`=`& (or the &`&&`&) sign.
33191
33192 &*Note*&: This kind of negation is not the same as negation in a domain,
33193 host, or address list (which is why the syntax is different).
33194
33195 If you are using just one list, the negation syntax does not gain you much. The
33196 previous example is precisely equivalent to
33197 .code
33198 deny  dnslists = a.b.c
33199      !dnslists = a.b.c=127.0.0.2,127.0.0.3
33200 .endd
33201 However, if you are using multiple lists, the negation syntax is clearer.
33202 Consider this example:
33203 .code
33204 deny  dnslists = sbl.spamhaus.org : \
33205                  list.dsbl.org : \
33206                  dnsbl.njabl.org!=127.0.0.3 : \
33207                  relays.ordb.org
33208 .endd
33209 Using only positive lists, this would have to be:
33210 .code
33211 deny  dnslists = sbl.spamhaus.org : \
33212                  list.dsbl.org
33213 deny  dnslists = dnsbl.njabl.org
33214      !dnslists = dnsbl.njabl.org=127.0.0.3
33215 deny  dnslists = relays.ordb.org
33216 .endd
33217 which is less clear, and harder to maintain.
33218
33219 Negation can also be used with a bitwise-and restriction.
33220 The dnslists condition with only be trus if a result is returned
33221 by the lookup which, anded with the restriction, is all zeroes.
33222 For example:
33223 .code
33224 deny dnslists = zen.spamhaus.org!&0.255.255.0
33225 .endd
33226
33227
33228
33229
33230 .subsection "Handling multiple DNS records from a DNS list" SECThanmuldnsrec
33231 A DNS lookup for a &%dnslists%& condition may return more than one DNS record,
33232 thereby providing more than one IP address. When an item in a &%dnslists%& list
33233 is followed by &`=`& or &`&&`& and a list of IP addresses, in order to restrict
33234 the match to specific results from the DNS lookup, there are two ways in which
33235 the checking can be handled. For example, consider the condition:
33236 .code
33237 dnslists = a.b.c=127.0.0.1
33238 .endd
33239 What happens if the DNS lookup for the incoming IP address yields both
33240 127.0.0.1 and 127.0.0.2 by means of two separate DNS records? Is the
33241 condition true because at least one given value was found, or is it false
33242 because at least one of the found values was not listed? And how does this
33243 affect negated conditions? Both possibilities are provided for with the help of
33244 additional separators &`==`& and &`=&&`&.
33245
33246 .ilist
33247 If &`=`& or &`&&`& is used, the condition is true if any one of the looked up
33248 IP addresses matches one of the listed addresses. For the example above, the
33249 condition is true because 127.0.0.1 matches.
33250 .next
33251 If &`==`& or &`=&&`& is used, the condition is true only if every one of the
33252 looked up IP addresses matches one of the listed addresses. If the condition is
33253 changed to:
33254 .code
33255 dnslists = a.b.c==127.0.0.1
33256 .endd
33257 and the DNS lookup yields both 127.0.0.1 and 127.0.0.2, the condition is
33258 false because 127.0.0.2 is not listed. You would need to have:
33259 .code
33260 dnslists = a.b.c==127.0.0.1,127.0.0.2
33261 .endd
33262 for the condition to be true.
33263 .endlist
33264
33265 When &`!`& is used to negate IP address matching, it inverts the result, giving
33266 the precise opposite of the behaviour above. Thus:
33267 .ilist
33268 If &`!=`& or &`!&&`& is used, the condition is true if none of the looked up IP
33269 addresses matches one of the listed addresses. Consider:
33270 .code
33271 dnslists = a.b.c!&0.0.0.1
33272 .endd
33273 If the DNS lookup yields both 127.0.0.1 and 127.0.0.2, the condition is
33274 false because 127.0.0.1 matches.
33275 .next
33276 If &`!==`& or &`!=&&`& is used, the condition is true if there is at least one
33277 looked up IP address that does not match. Consider:
33278 .code
33279 dnslists = a.b.c!=&0.0.0.1
33280 .endd
33281 If the DNS lookup yields both 127.0.0.1 and 127.0.0.2, the condition is
33282 true, because 127.0.0.2 does not match. You would need to have:
33283 .code
33284 dnslists = a.b.c!=&0.0.0.1,0.0.0.2
33285 .endd
33286 for the condition to be false.
33287 .endlist
33288 When the DNS lookup yields only a single IP address, there is no difference
33289 between &`=`& and &`==`& and between &`&&`& and &`=&&`&.
33290
33291
33292
33293
33294 .subsection "Detailed information from merged DNS lists" SECTmordetinf
33295 .cindex "DNS list" "information from merged"
33296 When the facility for restricting the matching IP values in a DNS list is used,
33297 the text from the TXT record that is set in &$dnslist_text$& may not reflect
33298 the true reason for rejection. This happens when lists are merged and the IP
33299 address in the A record is used to distinguish them; unfortunately there is
33300 only one TXT record. One way round this is not to use merged lists, but that
33301 can be inefficient because it requires multiple DNS lookups where one would do
33302 in the vast majority of cases when the host of interest is not on any of the
33303 lists.
33304
33305 A less inefficient way of solving this problem is available. If
33306 two domain names, comma-separated, are given, the second is used first to
33307 do an initial check, making use of any IP value restrictions that are set.
33308 If there is a match, the first domain is used, without any IP value
33309 restrictions, to get the TXT record. As a byproduct of this, there is also
33310 a check that the IP being tested is indeed on the first list. The first
33311 domain is the one that is put in &$dnslist_domain$&. For example:
33312 .code
33313 deny   dnslists = \
33314          sbl.spamhaus.org,sbl-xbl.spamhaus.org=127.0.0.2 : \
33315          dul.dnsbl.sorbs.net,dnsbl.sorbs.net=127.0.0.10
33316        message  = \
33317          rejected because $sender_host_address is blacklisted \
33318          at $dnslist_domain\n$dnslist_text
33319 .endd
33320 For the first blacklist item, this starts by doing a lookup in
33321 &'sbl-xbl.spamhaus.org'& and testing for a 127.0.0.2 return. If there is a
33322 match, it then looks in &'sbl.spamhaus.org'&, without checking the return
33323 value, and as long as something is found, it looks for the corresponding TXT
33324 record. If there is no match in &'sbl-xbl.spamhaus.org'&, nothing more is done.
33325 The second blacklist item is processed similarly.
33326
33327 If you are interested in more than one merged list, the same list must be
33328 given several times, but because the results of the DNS lookups are cached,
33329 the DNS calls themselves are not repeated. For example:
33330 .code
33331 deny dnslists = \
33332          http.dnsbl.sorbs.net,dnsbl.sorbs.net=127.0.0.2 : \
33333          socks.dnsbl.sorbs.net,dnsbl.sorbs.net=127.0.0.3 : \
33334          misc.dnsbl.sorbs.net,dnsbl.sorbs.net=127.0.0.4 : \
33335          dul.dnsbl.sorbs.net,dnsbl.sorbs.net=127.0.0.10
33336 .endd
33337 In this case there is one lookup in &'dnsbl.sorbs.net'&, and if none of the IP
33338 values matches (or if no record is found), this is the only lookup that is
33339 done. Only if there is a match is one of the more specific lists consulted.
33340
33341
33342
33343 .subsection "DNS lists and IPv6" SECTmorednslistslast
33344 .cindex "IPv6" "DNS black lists"
33345 .cindex "DNS list" "IPv6 usage"
33346 If Exim is asked to do a dnslist lookup for an IPv6 address, it inverts it
33347 nibble by nibble. For example, if the calling host's IP address is
33348 3ffe:ffff:836f:0a00:000a:0800:200a:c031, Exim might look up
33349 .code
33350 1.3.0.c.a.0.0.2.0.0.8.0.a.0.0.0.0.0.a.0.f.6.3.8.
33351   f.f.f.f.e.f.f.3.blackholes.mail-abuse.org
33352 .endd
33353 (split over two lines here to fit on the page). Unfortunately, some of the DNS
33354 lists contain wildcard records, intended for IPv4, that interact badly with
33355 IPv6. For example, the DNS entry
33356 .code
33357 *.3.some.list.example.    A    127.0.0.1
33358 .endd
33359 is probably intended to put the entire 3.0.0.0/8 IPv4 network on the list.
33360 Unfortunately, it also matches the entire 3::/4 IPv6 network.
33361
33362 You can exclude IPv6 addresses from DNS lookups by making use of a suitable
33363 &%condition%& condition, as in this example:
33364 .code
33365 deny   condition = ${if isip4{$sender_host_address}}
33366        dnslists  = some.list.example
33367 .endd
33368
33369 If an explicit key is being used for a DNS lookup and it may be an IPv6
33370 address you should specify alternate list separators for both the outer
33371 (DNS list name) list and inner (lookup keys) list:
33372 .code
33373        dnslists = <; dnsbl.example.com/<|$acl_m_addrslist
33374 .endd
33375
33376
33377 .section "Previously seen user and hosts" "SECTseen"
33378 .cindex "&%seen%& ACL condition"
33379 .cindex greylisting
33380 The &%seen%& ACL condition can be used to test whether a
33381 situation has been previously met.
33382 It uses a hints database to record a timestamp against a key.
33383 The syntax of the condition is:
33384 .display
33385 &`seen =`& <&'optional flag'&><&'time interval'&> &`/`& <&'options'&>
33386 .endd
33387
33388 For example,
33389 .code
33390 defer   seen = -5m / key=${sender_host_address}_$local_part@$domain
33391 .endd
33392 in a RCPT ACL will implement simple greylisting.
33393
33394 The parameters for the condition are
33395 a possible minus sign,
33396 then an interval,
33397 then, slash-separated, a list of options.
33398 The interval is taken as an offset before the current time,
33399 and used for the test.
33400 If the interval is preceded by a minus sign then the condition returns
33401 whether a record is found which is before the test time.
33402 Otherwise, the condition returns whether one is found which is since the
33403 test time.
33404
33405 Options are read in order with later ones overriding earlier ones.
33406
33407 The default key is &$sender_host_address$&.
33408 An explicit key can be set using a &%key=value%& option.
33409
33410 If a &%readonly%& option is given then
33411 no record create or update is done.
33412 If a &%write%& option is given then
33413 a record create or update is always done.
33414 An update is done if the test is for &"since"&.
33415 If none of those hold and there was no existing record,
33416 a record is created.
33417
33418 Creates and updates are marked with the current time.
33419
33420 Finally, a &"before"& test which succeeds, and for which the record
33421 is old enough, will be refreshed with a timestamp of the test time.
33422 This can prevent tidying of the database from removing the entry.
33423 The interval for this is, by default, 10 days.
33424 An explicit interval can be set using a
33425 &%refresh=value%& option.
33426
33427 Note that &"seen"& should be added to the list of hints databases
33428 for maintenance if this ACL condition is used.
33429
33430
33431 .section "Rate limiting incoming messages" "SECTratelimiting"
33432 .cindex "rate limiting" "client sending"
33433 .cindex "limiting client sending rates"
33434 .oindex "&%smtp_ratelimit_*%&"
33435 The &%ratelimit%& ACL condition can be used to measure and control the rate at
33436 which clients can send email. This is more powerful than the
33437 &%smtp_ratelimit_*%& options, because those options control the rate of
33438 commands in a single SMTP session only, whereas the &%ratelimit%& condition
33439 works across all connections (concurrent and sequential) from the same client
33440 host. The syntax of the &%ratelimit%& condition is:
33441 .display
33442 &`ratelimit =`& <&'m'&> &`/`& <&'p'&> &`/`& <&'options'&> &`/`& <&'key'&>
33443 .endd
33444 If the average client sending rate is less than &'m'& messages per time
33445 period &'p'& then the condition is false; otherwise it is true.
33446
33447 As a side-effect, the &%ratelimit%& condition sets the expansion variable
33448 &$sender_rate$& to the client's computed rate, &$sender_rate_limit$& to the
33449 configured value of &'m'&, and &$sender_rate_period$& to the configured value
33450 of &'p'&.
33451
33452 The parameter &'p'& is the smoothing time constant, in the form of an Exim
33453 time interval, for example, &`8h`& for eight hours. A larger time constant
33454 means that it takes Exim longer to forget a client's past behaviour. The
33455 parameter &'m'& is the maximum number of messages that a client is permitted to
33456 send in each time interval. It also specifies the number of messages permitted
33457 in a fast burst. By increasing both &'m'& and &'p'& but keeping &'m/p'&
33458 constant, you can allow a client to send more messages in a burst without
33459 changing its long-term sending rate limit. Conversely, if &'m'& and &'p'& are
33460 both small, messages must be sent at an even rate.
33461
33462 There is a script in &_util/ratelimit.pl_& which extracts sending rates from
33463 log files, to assist with choosing appropriate settings for &'m'& and &'p'&
33464 when deploying the &%ratelimit%& ACL condition. The script prints usage
33465 instructions when it is run with no arguments.
33466
33467 The key is used to look up the data for calculating the client's average
33468 sending rate. This data is stored in Exim's spool directory, alongside the
33469 retry and other hints databases. The default key is &$sender_host_address$&,
33470 which means Exim computes the sending rate of each client host IP address.
33471 By changing the key you can change how Exim identifies clients for the purpose
33472 of ratelimiting. For example, to limit the sending rate of each authenticated
33473 user, independent of the computer they are sending from, set the key to
33474 &$authenticated_id$&. You must ensure that the lookup key is meaningful; for
33475 example, &$authenticated_id$& is only meaningful if the client has
33476 authenticated (which you can check with the &%authenticated%& ACL condition).
33477
33478 The lookup key does not have to identify clients: If you want to limit the
33479 rate at which a recipient receives messages, you can use the key
33480 &`$local_part@$domain`& with the &%per_rcpt%& option (see below) in a RCPT
33481 ACL.
33482
33483 Each &%ratelimit%& condition can have up to four options. A &%per_*%& option
33484 specifies what Exim measures the rate of, for example, messages or recipients
33485 or bytes. You can adjust the measurement using the &%unique=%& and/or
33486 &%count=%& options. You can also control when Exim updates the recorded rate
33487 using a &%strict%&, &%leaky%&, or &%readonly%& option. The options are
33488 separated by a slash, like the other parameters. They may appear in any order.
33489
33490 Internally, Exim appends the smoothing constant &'p'& onto the lookup key with
33491 any options that alter the meaning of the stored data. The limit &'m'& is not
33492 stored, so you can alter the configured maximum rate and Exim will still
33493 remember clients' past behaviour. If you change the &%per_*%& mode or add or
33494 remove the &%unique=%& option, the lookup key changes so Exim will forget past
33495 behaviour. The lookup key is not affected by changes to the update mode and
33496 the &%count=%& option.
33497
33498
33499 .subsection "Ratelimit options for what is being measured" ratoptmea
33500 .cindex "rate limiting" "per_* options"
33501 .vlist
33502 .vitem per_conn
33503 .cindex "rate limiting" per_conn
33504 This option limits the client's connection rate. It is not
33505 normally used in the &%acl_not_smtp%&, &%acl_not_smtp_mime%&, or
33506 &%acl_not_smtp_start%& ACLs.
33507
33508 .vitem per_mail
33509 .cindex "rate limiting" per_conn
33510 This option limits the client's rate of sending messages. This is
33511 the default if none of the &%per_*%& options is specified. It can be used in
33512 &%acl_smtp_mail%&, &%acl_smtp_rcpt%&, &%acl_smtp_predata%&, &%acl_smtp_mime%&,
33513 &%acl_smtp_data%&, or &%acl_not_smtp%&.
33514
33515 .vitem per_byte
33516 .cindex "rate limiting" per_conn
33517 This option limits the sender's email bandwidth. It can be used in
33518 the same ACLs as the &%per_mail%& option, though it is best to use this option
33519 in the &%acl_smtp_mime%&, &%acl_smtp_data%& or &%acl_not_smtp%& ACLs; if it is
33520 used in an earlier ACL, Exim relies on the SIZE parameter given by the client
33521 in its MAIL command, which may be inaccurate or completely missing. You can
33522 follow the limit &'m'& in the configuration with K, M, or G to specify limits
33523 in kilobytes, megabytes, or gigabytes, respectively.
33524
33525 .vitem per_rcpt
33526 .cindex "rate limiting" per_rcpt
33527 This option causes Exim to limit the rate at which recipients are
33528 accepted. It can be used in the &%acl_smtp_rcpt%&, &%acl_smtp_predata%&,
33529 &%acl_smtp_mime%&, or &%acl_smtp_data%& ACLs. In
33530 &%acl_smtp_rcpt%& the rate is updated one recipient at a time; in the other
33531 ACLs the rate is updated with the total (accepted) recipient count in one go. Note that
33532 in either case the rate limiting engine will see a message with many
33533 recipients as a large high-speed burst.
33534
33535 .vitem per_addr
33536 .cindex "rate limiting" per_addr
33537 This option is like the &%per_rcpt%& option, except it counts the
33538 number of different recipients that the client has sent messages to in the
33539 last time period. That is, if the client repeatedly sends messages to the same
33540 recipient, its measured rate is not increased. This option can only be used in
33541 &%acl_smtp_rcpt%&.
33542
33543 .vitem per_cmd
33544 .cindex "rate limiting" per_cmd
33545 This option causes Exim to recompute the rate every time the
33546 condition is processed. This can be used to limit the rate of any SMTP
33547 command. If it is used in multiple ACLs it can limit the aggregate rate of
33548 multiple different commands.
33549
33550 .vitem count
33551 .cindex "rate limiting" count
33552 This option can be used to alter how much Exim adds to the client's
33553 measured rate.
33554 A value is required, after an equals sign.
33555 For example, the &%per_byte%& option is equivalent to
33556 &`per_mail/count=$message_size`&.
33557 If there is no &%count=%& option, Exim
33558 increases the measured rate by one (except for the &%per_rcpt%& option in ACLs
33559 other than &%acl_smtp_rcpt%&).
33560 The count does not have to be an integer.
33561
33562 .vitem unique
33563 .cindex "rate limiting" unique
33564 This option is described in section &<<ratoptuniq>>& below.
33565 .endlist
33566
33567
33568 .subsection "Ratelimit update modes" ratoptupd
33569 .cindex "rate limiting" "reading data without updating"
33570 You can specify one of three options with the &%ratelimit%& condition to
33571 control when its database is updated. This section describes the &%readonly%&
33572 mode, and the next section describes the &%strict%& and &%leaky%& modes.
33573
33574 If the &%ratelimit%& condition is used in &%readonly%& mode, Exim looks up a
33575 previously-computed rate to check against the limit.
33576
33577 For example, you can test the client's sending rate and deny it access (when
33578 it is too fast) in the connect ACL. If the client passes this check then it
33579 can go on to send a message, in which case its recorded rate will be updated
33580 in the MAIL ACL. Subsequent connections from the same client will check this
33581 new rate.
33582 .code
33583 acl_check_connect:
33584  deny ratelimit = 100 / 5m / readonly
33585       log_message = RATE CHECK: $sender_rate/$sender_rate_period \
33586                   (max $sender_rate_limit)
33587 # ...
33588 acl_check_mail:
33589  warn ratelimit = 100 / 5m / strict
33590       log_message = RATE UPDATE: $sender_rate/$sender_rate_period \
33591                   (max $sender_rate_limit)
33592 .endd
33593
33594 If Exim encounters multiple &%ratelimit%& conditions with the same key when
33595 processing a message then it may increase the client's measured rate more than
33596 it should. For example, this will happen if you check the &%per_rcpt%& option
33597 in both &%acl_smtp_rcpt%& and &%acl_smtp_data%&. However it's OK to check the
33598 same &%ratelimit%& condition multiple times in the same ACL. You can avoid any
33599 multiple update problems by using the &%readonly%& option on later ratelimit
33600 checks.
33601
33602 The &%per_*%& options described above do not make sense in some ACLs. If you
33603 use a &%per_*%& option in an ACL where it is not normally permitted then the
33604 update mode defaults to &%readonly%& and you cannot specify the &%strict%& or
33605 &%leaky%& modes. In other ACLs the default update mode is &%leaky%& (see the
33606 next section) so you must specify the &%readonly%& option explicitly.
33607
33608
33609 .subsection "Ratelimit options for handling fast clients" ratoptfast
33610 .cindex "rate limiting" "strict and leaky modes"
33611 If a client's average rate is greater than the maximum, the rate limiting
33612 engine can react in two possible ways, depending on the presence of the
33613 &%strict%& or &%leaky%& update modes. This is independent of the other
33614 counter-measures (such as rejecting the message) that may be specified by the
33615 rest of the ACL.
33616
33617 The &%leaky%& (default) option means that the client's recorded rate is not
33618 updated if it is above the limit. The effect of this is that Exim measures the
33619 client's average rate of successfully sent email,
33620 up to the given limit.
33621 This is appropriate if the countermeasure when the condition is true
33622 consists of refusing the message, and
33623 is generally the better choice if you have clients that retry automatically.
33624 If the action when true is anything more complex then this option is
33625 likely not what is wanted.
33626
33627 The &%strict%& option means that the client's recorded rate is always
33628 updated. The effect of this is that Exim measures the client's average rate
33629 of attempts to send email, which can be much higher than the maximum it is
33630 actually allowed. If the client is over the limit it may be subjected to
33631 counter-measures by the ACL. It must slow down and allow sufficient time to
33632 pass that its computed rate falls below the maximum before it can send email
33633 again. The time (the number of smoothing periods) it must wait and not
33634 attempt to send mail can be calculated with this formula:
33635 .code
33636         ln(peakrate/maxrate)
33637 .endd
33638
33639
33640 .subsection "Limiting the rate of different events" ratoptuniq
33641 .cindex "rate limiting" "counting unique events"
33642 The &%ratelimit%& &%unique=%& option controls a mechanism for counting the
33643 rate of different events. For example, the &%per_addr%& option uses this
33644 mechanism to count the number of different recipients that the client has
33645 sent messages to in the last time period; it is equivalent to
33646 &`per_rcpt/unique=$local_part@$domain`&. You could use this feature to
33647 measure the rate that a client uses different sender addresses with the
33648 options &`per_mail/unique=$sender_address`&.
33649
33650 For each &%ratelimit%& key Exim stores the set of &%unique=%& values that it
33651 has seen for that key. The whole set is thrown away when it is older than the
33652 rate smoothing period &'p'&, so each different event is counted at most once
33653 per period. In the &%leaky%& update mode, an event that causes the client to
33654 go over the limit is not added to the set, in the same way that the client's
33655 recorded rate is not updated in the same situation.
33656
33657 When you combine the &%unique=%& and &%readonly%& options, the specific
33658 &%unique=%& value is ignored, and Exim just retrieves the client's stored
33659 rate.
33660
33661 The &%unique=%& mechanism needs more space in the ratelimit database than the
33662 other &%ratelimit%& options in order to store the event set. The number of
33663 unique values is potentially as large as the rate limit, so the extra space
33664 required increases with larger limits.
33665
33666 The uniqueification is not perfect: there is a small probability that Exim
33667 will think a new event has happened before. If the sender's rate is less than
33668 the limit, Exim should be more than 99.9% correct. However in &%strict%& mode
33669 the measured rate can go above the limit, in which case Exim may under-count
33670 events by a significant margin. Fortunately, if the rate is high enough (2.7
33671 times the limit) that the false positive rate goes above 9%, then Exim will
33672 throw away the over-full event set before the measured rate falls below the
33673 limit. Therefore the only harm should be that exceptionally high sending rates
33674 are logged incorrectly; any countermeasures you configure will be as effective
33675 as intended.
33676
33677
33678 .subsection "Using rate limiting" useratlim
33679 Exim's other ACL facilities are used to define what counter-measures are taken
33680 when the rate limit is exceeded. This might be anything from logging a warning
33681 (for example, while measuring existing sending rates in order to define
33682 policy), through time delays to slow down fast senders, up to rejecting the
33683 message. For example:
33684 .code
33685 # Log all senders' rates
33686 warn ratelimit = 0 / 1h / strict
33687      log_message = Sender rate $sender_rate / $sender_rate_period
33688
33689 # Slow down fast senders; note the need to truncate $sender_rate
33690 # at the decimal point.
33691 warn ratelimit = 100 / 1h / per_rcpt / strict
33692      delay     = ${eval: ${sg{$sender_rate}{[.].*}{}} - \
33693                    $sender_rate_limit }s
33694
33695 # Keep authenticated users under control
33696 deny authenticated = *
33697      ratelimit = 100 / 1d / strict / $authenticated_id
33698
33699 # System-wide rate limit
33700 defer ratelimit = 10 / 1s / $primary_hostname
33701       message = Sorry, too busy. Try again later.
33702
33703 # Restrict incoming rate from each host, with a default
33704 # set using a macro and special cases looked up in a table.
33705 defer ratelimit = ${lookup {$sender_host_address} \
33706                    cdb {DB/ratelimits.cdb} \
33707                    {$value} {RATELIMIT} }
33708       message = Sender rate exceeds $sender_rate_limit \
33709                messages per $sender_rate_period
33710 .endd
33711 &*Warning*&: If you have a busy server with a lot of &%ratelimit%& tests,
33712 especially with the &%per_rcpt%& option, you may suffer from a performance
33713 bottleneck caused by locking on the ratelimit hints database. Apart from
33714 making your ACLs less complicated, you can reduce the problem by using a
33715 RAM disk for Exim's hints directory (usually &_/var/spool/exim/db/_&). However
33716 this means that Exim will lose its hints data after a reboot (including retry
33717 hints, the callout cache, and ratelimit data).
33718
33719
33720
33721 .section "Address verification" "SECTaddressverification"
33722 .cindex "verifying address" "options for"
33723 .cindex "policy control" "address verification"
33724 Several of the &%verify%& conditions described in section
33725 &<<SECTaclconditions>>& cause addresses to be verified. Section
33726 &<<SECTsenaddver>>& discusses the reporting of sender verification failures.
33727 The verification conditions can be followed by options that modify the
33728 verification process. The options are separated from the keyword and from each
33729 other by slashes, and some of them contain parameters. For example:
33730 .code
33731 verify = sender/callout
33732 verify = recipient/defer_ok/callout=10s,defer_ok
33733 .endd
33734 The first stage of address verification, which always happens, is to run the
33735 address through the routers, in &"verify mode"&. Routers can detect the
33736 difference between verification and routing for delivery, and their actions can
33737 be varied by a number of generic options such as &%verify%& and &%verify_only%&
33738 (see chapter &<<CHAProutergeneric>>&). If routing fails, verification fails.
33739 The available options are as follows:
33740
33741 .ilist
33742 If the &%callout%& option is specified, successful routing to one or more
33743 remote hosts is followed by a &"callout"& to those hosts as an additional
33744 check. Callouts and their sub-options are discussed in the next section.
33745 .next
33746 If there is a defer error while doing verification routing, the ACL
33747 normally returns &"defer"&. However, if you include &%defer_ok%& in the
33748 options, the condition is forced to be true instead. Note that this is a main
33749 verification option as well as a suboption for callouts.
33750 .next
33751 The &%no_details%& option is covered in section &<<SECTsenaddver>>&, which
33752 discusses the reporting of sender address verification failures.
33753 .next
33754 The &%success_on_redirect%& option causes verification always to succeed
33755 immediately after a successful redirection. By default, if a redirection
33756 generates just one address, that address is also verified. See further
33757 discussion in section &<<SECTredirwhilveri>>&.
33758 .next
33759 If the &%quota%& option is specified for recipient verify,
33760 successful routing to an appendfile transport is followed by a call into
33761 the transport to evaluate the quota status for the recipient.
33762 No actual delivery is done, but verification will succeed if the quota
33763 is sufficient for the message (if the sender gave a message size) or
33764 not already exceeded (otherwise).
33765 .endlist
33766
33767 .cindex "verifying address" "differentiating failures"
33768 .vindex "&$recipient_verify_failure$&"
33769 .vindex "&$sender_verify_failure$&"
33770 .vindex "&$acl_verify_message$&"
33771 After an address verification failure, &$acl_verify_message$& contains the
33772 error message that is associated with the failure. It can be preserved by
33773 coding like this:
33774 .code
33775 warn  !verify = sender
33776        set acl_m0 = $acl_verify_message
33777 .endd
33778 If you are writing your own custom rejection message or log message when
33779 denying access, you can use this variable to include information about the
33780 verification failure.
33781 This variable is cleared at the end of processing the ACL verb.
33782
33783 In addition, &$sender_verify_failure$& or &$recipient_verify_failure$& (as
33784 appropriate) contains one of the following words:
33785
33786 .ilist
33787 &%qualify%&: The address was unqualified (no domain), and the message
33788 was neither local nor came from an exempted host.
33789 .next
33790 &%route%&: Routing failed.
33791 .next
33792 &%mail%&: Routing succeeded, and a callout was attempted; rejection
33793 occurred at or before the MAIL command (that is, on initial
33794 connection, HELO, or MAIL).
33795 .next
33796 &%recipient%&: The RCPT command in a callout was rejected.
33797 .next
33798 &%postmaster%&: The postmaster check in a callout was rejected.
33799 .next
33800 &%quota%&: The quota check for a local recipient did non pass.
33801 .endlist
33802
33803 The main use of these variables is expected to be to distinguish between
33804 rejections of MAIL and rejections of RCPT in callouts.
33805
33806 The above variables may also be set after a &*successful*&
33807 address verification to:
33808
33809 .ilist
33810 &%random%&: A random local-part callout succeeded
33811 .endlist
33812
33813
33814
33815
33816 .section "Callout verification" "SECTcallver"
33817 .cindex "verifying address" "by callout"
33818 .cindex "callout" "verification"
33819 .cindex "SMTP" "callout verification"
33820 For non-local addresses, routing verifies the domain, but is unable to do any
33821 checking of the local part. There are situations where some means of verifying
33822 the local part is desirable. One way this can be done is to make an SMTP
33823 &'callback'& to a delivery host for the sender address or a &'callforward'& to
33824 a subsequent host for a recipient address, to see if the host accepts the
33825 address. We use the term &'callout'& to cover both cases. Note that for a
33826 sender address, the callback is not to the client host that is trying to
33827 deliver the message, but to one of the hosts that accepts incoming mail for the
33828 sender's domain.
33829
33830 Exim does not do callouts by default. If you want them to happen, you must
33831 request them by setting appropriate options on the &%verify%& condition, as
33832 described below. This facility should be used with care, because it can add a
33833 lot of resource usage to the cost of verifying an address. However, Exim does
33834 cache the results of callouts, which helps to reduce the cost. Details of
33835 caching are in section &<<SECTcallvercache>>&.
33836
33837 Recipient callouts are usually used only between hosts that are controlled by
33838 the same administration. For example, a corporate gateway host could use
33839 callouts to check for valid recipients on an internal mailserver. A successful
33840 callout does not guarantee that a real delivery to the address would succeed;
33841 on the other hand, a failing callout does guarantee that a delivery would fail.
33842
33843 If the &%callout%& option is present on a condition that verifies an address, a
33844 second stage of verification occurs if the address is successfully routed to
33845 one or more remote hosts. The usual case is routing by a &(dnslookup)& or a
33846 &(manualroute)& router, where the router specifies the hosts. However, if a
33847 router that does not set up hosts routes to an &(smtp)& transport with a
33848 &%hosts%& setting, the transport's hosts are used. If an &(smtp)& transport has
33849 &%hosts_override%& set, its hosts are always used, whether or not the router
33850 supplies a host list.
33851 Callouts are only supported on &(smtp)& transports.
33852
33853 The port that is used is taken from the transport, if it is specified and is a
33854 remote transport. (For routers that do verification only, no transport need be
33855 specified.) Otherwise, the default SMTP port is used. If a remote transport
33856 specifies an outgoing interface, this is used; otherwise the interface is not
33857 specified. Likewise, the text that is used for the HELO command is taken from
33858 the transport's &%helo_data%& option; if there is no transport, the value of
33859 &$smtp_active_hostname$& is used.
33860
33861 For a sender callout check, Exim makes SMTP connections to the remote hosts, to
33862 test whether a bounce message could be delivered to the sender address. The
33863 following SMTP commands are sent:
33864 .display
33865 &`HELO `&<&'local host name'&>
33866 &`MAIL FROM:<>`&
33867 &`RCPT TO:`&<&'the address to be tested'&>
33868 &`QUIT`&
33869 .endd
33870 LHLO is used instead of HELO if the transport's &%protocol%& option is
33871 set to &"lmtp"&.
33872
33873 The callout may use EHLO, AUTH and/or STARTTLS given appropriate option
33874 settings.
33875
33876 A recipient callout check is similar. By default, it also uses an empty address
33877 for the sender. This default is chosen because most hosts do not make use of
33878 the sender address when verifying a recipient. Using the same address means
33879 that a single cache entry can be used for each recipient. Some sites, however,
33880 do make use of the sender address when verifying. These are catered for by the
33881 &%use_sender%& and &%use_postmaster%& options, described in the next section.
33882
33883 If the response to the RCPT command is a 2&'xx'& code, the verification
33884 succeeds. If it is 5&'xx'&, the verification fails. For any other condition,
33885 Exim tries the next host, if any. If there is a problem with all the remote
33886 hosts, the ACL yields &"defer"&, unless the &%defer_ok%& parameter of the
33887 &%callout%& option is given, in which case the condition is forced to succeed.
33888
33889 .cindex "SMTP" "output flushing, disabling for callout"
33890 A callout may take a little time. For this reason, Exim normally flushes SMTP
33891 output before performing a callout in an ACL, to avoid unexpected timeouts in
33892 clients when the SMTP PIPELINING extension is in use. The flushing can be
33893 disabled by using a &%control%& modifier to set &%no_callout_flush%&.
33894
33895 .cindex "tainted data" "de-tainting"
33896 .cindex "de-tainting" "using recipient verify"
33897 A recipient callout which gets a 2&'xx'& code
33898 will assign untainted values to the
33899 &$domain_data$& and &$local_part_data$& variables,
33900 corresponding to the domain and local parts of the recipient address.
33901
33902
33903
33904
33905 .subsection "Additional parameters for callouts" CALLaddparcall
33906 .cindex "callout" "additional parameters for"
33907 The &%callout%& option can be followed by an equals sign and a number of
33908 optional parameters, separated by commas. For example:
33909 .code
33910 verify = recipient/callout=10s,defer_ok
33911 .endd
33912 The old syntax, which had &%callout_defer_ok%& and &%check_postmaster%& as
33913 separate verify options, is retained for backwards compatibility, but is now
33914 deprecated. The additional parameters for &%callout%& are as follows:
33915
33916
33917 .vlist
33918 .vitem <&'a&~time&~interval'&>
33919 .cindex "callout" "timeout, specifying"
33920 This specifies the timeout that applies for the callout attempt to each host.
33921 For example:
33922 .code
33923 verify = sender/callout=5s
33924 .endd
33925 The default is 30 seconds. The timeout is used for each response from the
33926 remote host. It is also used for the initial connection, unless overridden by
33927 the &%connect%& parameter.
33928
33929
33930 .vitem &*connect&~=&~*&<&'time&~interval'&>
33931 .cindex "callout" "connection timeout, specifying"
33932 This parameter makes it possible to set a different (usually smaller) timeout
33933 for making the SMTP connection. For example:
33934 .code
33935 verify = sender/callout=5s,connect=1s
33936 .endd
33937 If not specified, this timeout defaults to the general timeout value.
33938
33939 .vitem &*defer_ok*&
33940 .cindex "callout" "defer, action on"
33941 When this parameter is present, failure to contact any host, or any other kind
33942 of temporary error, is treated as success by the ACL. However, the cache is not
33943 updated in this circumstance.
33944
33945 .vitem &*fullpostmaster*&
33946 .cindex "callout" "full postmaster check"
33947 This operates like the &%postmaster%& option (see below), but if the check for
33948 &'postmaster@domain'& fails, it tries just &'postmaster'&, without a domain, in
33949 accordance with the specification in RFC 2821. The RFC states that the
33950 unqualified address &'postmaster'& should be accepted.
33951
33952
33953 .vitem &*mailfrom&~=&~*&<&'email&~address'&>
33954 .cindex "callout" "sender when verifying header"
33955 When verifying addresses in header lines using the &%header_sender%&
33956 verification option, Exim behaves by default as if the addresses are envelope
33957 sender addresses from a message. Callout verification therefore tests to see
33958 whether a bounce message could be delivered, by using an empty address in the
33959 MAIL command. However, it is arguable that these addresses might never be used
33960 as envelope senders, and could therefore justifiably reject bounce messages
33961 (empty senders). The &%mailfrom%& callout parameter allows you to specify what
33962 address to use in the MAIL command. For example:
33963 .code
33964 require  verify = header_sender/callout=mailfrom=abcd@x.y.z
33965 .endd
33966 This parameter is available only for the &%header_sender%& verification option.
33967
33968
33969 .vitem &*maxwait&~=&~*&<&'time&~interval'&>
33970 .cindex "callout" "overall timeout, specifying"
33971 This parameter sets an overall timeout for performing a callout verification.
33972 For example:
33973 .code
33974 verify = sender/callout=5s,maxwait=30s
33975 .endd
33976 This timeout defaults to four times the callout timeout for individual SMTP
33977 commands. The overall timeout applies when there is more than one host that can
33978 be tried. The timeout is checked before trying the next host. This prevents
33979 very long delays if there are a large number of hosts and all are timing out
33980 (for example, when network connections are timing out).
33981
33982
33983 .vitem &*no_cache*&
33984 .cindex "callout" "cache, suppressing"
33985 .cindex "caching callout, suppressing"
33986 When this parameter is given, the callout cache is neither read nor updated.
33987
33988 .vitem &*postmaster*&
33989 .cindex "callout" "postmaster; checking"
33990 When this parameter is set, a successful callout check is followed by a similar
33991 check for the local part &'postmaster'& at the same domain. If this address is
33992 rejected, the callout fails (but see &%fullpostmaster%& above). The result of
33993 the postmaster check is recorded in a cache record; if it is a failure, this is
33994 used to fail subsequent callouts for the domain without a connection being
33995 made, until the cache record expires.
33996
33997 .vitem &*postmaster_mailfrom&~=&~*&<&'email&~address'&>
33998 The postmaster check uses an empty sender in the MAIL command by default.
33999 You can use this parameter to do a postmaster check using a different address.
34000 For example:
34001 .code
34002 require  verify = sender/callout=postmaster_mailfrom=abc@x.y.z
34003 .endd
34004 If both &%postmaster%& and &%postmaster_mailfrom%& are present, the rightmost
34005 one overrides. The &%postmaster%& parameter is equivalent to this example:
34006 .code
34007 require  verify = sender/callout=postmaster_mailfrom=
34008 .endd
34009 &*Warning*&: The caching arrangements for postmaster checking do not take
34010 account of the sender address. It is assumed that either the empty address or
34011 a fixed non-empty address will be used. All that Exim remembers is that the
34012 postmaster check for the domain succeeded or failed.
34013
34014
34015 .vitem &*random*&
34016 .cindex "callout" "&""random""& check"
34017 When this parameter is set, before doing the normal callout check, Exim does a
34018 check for a &"random"& local part at the same domain. The local part is not
34019 really random &-- it is defined by the expansion of the option
34020 &%callout_random_local_part%&, which defaults to
34021 .code
34022 $primary_hostname-$tod_epoch-testing
34023 .endd
34024 The idea here is to try to determine whether the remote host accepts all local
34025 parts without checking. If it does, there is no point in doing callouts for
34026 specific local parts. If the &"random"& check succeeds, the result is saved in
34027 a cache record, and used to force the current and subsequent callout checks to
34028 succeed without a connection being made, until the cache record expires.
34029
34030 .vitem &*use_postmaster*&
34031 .cindex "callout" "sender for recipient check"
34032 This parameter applies to recipient callouts only. For example:
34033 .code
34034 deny  !verify = recipient/callout=use_postmaster
34035 .endd
34036 .vindex "&$qualify_domain$&"
34037 It causes a non-empty postmaster address to be used in the MAIL command when
34038 performing the callout for the recipient, and also for a &"random"& check if
34039 that is configured. The local part of the address is &`postmaster`& and the
34040 domain is the contents of &$qualify_domain$&.
34041
34042 .vitem &*use_sender*&
34043 This option applies to recipient callouts only. For example:
34044 .code
34045 require  verify = recipient/callout=use_sender
34046 .endd
34047 It causes the message's actual sender address to be used in the MAIL
34048 command when performing the callout, instead of an empty address. There is no
34049 need to use this option unless you know that the called hosts make use of the
34050 sender when checking recipients. If used indiscriminately, it reduces the
34051 usefulness of callout caching.
34052
34053 .vitem &*hold*&
34054 This option applies to recipient callouts only. For example:
34055 .code
34056 require  verify = recipient/callout=use_sender,hold
34057 .endd
34058 It causes the connection to be held open and used for any further recipients
34059 and for eventual delivery (should that be done quickly).
34060 Doing this saves on TCP and SMTP startup costs, and TLS costs also
34061 when that is used for the connections.
34062 The advantage is only gained if there are no callout cache hits
34063 (which could be enforced by the no_cache option),
34064 if the use_sender option is used,
34065 if neither the random nor the use_postmaster option is used,
34066 and if no other callouts intervene.
34067 .endlist
34068
34069 If you use any of the parameters that set a non-empty sender for the MAIL
34070 command (&%mailfrom%&, &%postmaster_mailfrom%&, &%use_postmaster%&, or
34071 &%use_sender%&), you should think about possible loops. Recipient checking is
34072 usually done between two hosts that are under the same management, and the host
34073 that receives the callouts is not normally configured to do callouts itself.
34074 Therefore, it is normally safe to use &%use_postmaster%& or &%use_sender%& in
34075 these circumstances.
34076
34077 However, if you use a non-empty sender address for a callout to an arbitrary
34078 host, there is the likelihood that the remote host will itself initiate a
34079 callout check back to your host. As it is checking what appears to be a message
34080 sender, it is likely to use an empty address in MAIL, thus avoiding a
34081 callout loop. However, to be on the safe side it would be best to set up your
34082 own ACLs so that they do not do sender verification checks when the recipient
34083 is the address you use for header sender or postmaster callout checking.
34084
34085 Another issue to think about when using non-empty senders for callouts is
34086 caching. When you set &%mailfrom%& or &%use_sender%&, the cache record is keyed
34087 by the sender/recipient combination; thus, for any given recipient, many more
34088 actual callouts are performed than when an empty sender or postmaster is used.
34089
34090
34091
34092
34093 .subsection "Callout caching" SECTcallvercache
34094 .cindex "hints database" "callout cache"
34095 .cindex "callout" "cache, description of"
34096 .cindex "caching" "callout"
34097 Exim caches the results of callouts in order to reduce the amount of resources
34098 used, unless you specify the &%no_cache%& parameter with the &%callout%&
34099 option. A hints database called &"callout"& is used for the cache. Two
34100 different record types are used: one records the result of a callout check for
34101 a specific address, and the other records information that applies to the
34102 entire domain (for example, that it accepts the local part &'postmaster'&).
34103
34104 When an original callout fails, a detailed SMTP error message is given about
34105 the failure. However, for subsequent failures that use the cache data, this message
34106 is not available.
34107
34108 The expiry times for negative and positive address cache records are
34109 independent, and can be set by the global options &%callout_negative_expire%&
34110 (default 2h) and &%callout_positive_expire%& (default 24h), respectively.
34111
34112 If a host gives a negative response to an SMTP connection, or rejects any
34113 commands up to and including
34114 .code
34115 MAIL FROM:<>
34116 .endd
34117 (but not including the MAIL command with a non-empty address),
34118 any callout attempt is bound to fail. Exim remembers such failures in a
34119 domain cache record, which it uses to fail callouts for the domain without
34120 making new connections, until the domain record times out. There are two
34121 separate expiry times for domain cache records:
34122 &%callout_domain_negative_expire%& (default 3h) and
34123 &%callout_domain_positive_expire%& (default 7d).
34124
34125 Domain records expire when the negative expiry time is reached if callouts
34126 cannot be made for the domain, or if the postmaster check failed.
34127 Otherwise, they expire when the positive expiry time is reached. This
34128 ensures that, for example, a host that stops accepting &"random"& local parts
34129 will eventually be noticed.
34130
34131 The callout caching mechanism is based on the domain of the address that is
34132 being tested. If the domain routes to several hosts, it is assumed that their
34133 behaviour will be the same.
34134
34135
34136
34137 .section "Quota caching" "SECTquotacache"
34138 .cindex "hints database" "quota cache"
34139 .cindex "quota" "cache, description of"
34140 .cindex "caching" "quota"
34141 Exim caches the results of quota verification
34142 in order to reduce the amount of resources used.
34143 The &"callout"& hints database is used.
34144
34145 The default cache periods are five minutes for a positive (good) result
34146 and one hour for a negative result.
34147 To change the periods the &%quota%& option can be followed by an equals sign
34148 and a number of optional paramemters, separated by commas.
34149 For example:
34150 .code
34151 verify = recipient/quota=cachepos=1h,cacheneg=1d
34152 .endd
34153 Possible parameters are:
34154 .vlist
34155 .vitem &*cachepos&~=&~*&<&'time&~interval'&>
34156 .cindex "quota cache" "positive entry expiry, specifying"
34157 Set the lifetime for a positive cache entry.
34158 A value of zero seconds is legitimate.
34159
34160 .vitem &*cacheneg&~=&~*&<&'time&~interval'&>
34161 .cindex "quota cache" "negative entry expiry, specifying"
34162 As above, for a negative entry.
34163
34164 .vitem &*no_cache*&
34165 Set both positive and negative lifetimes to zero.
34166
34167 .section "Sender address verification reporting" "SECTsenaddver"
34168 .cindex "verifying" "suppressing error details"
34169 See section &<<SECTaddressverification>>& for a general discussion of
34170 verification. When sender verification fails in an ACL, the details of the
34171 failure are given as additional output lines before the 550 response to the
34172 relevant SMTP command (RCPT or DATA). For example, if sender callout is in use,
34173 you might see:
34174 .code
34175 MAIL FROM:<xyz@abc.example>
34176 250 OK
34177 RCPT TO:<pqr@def.example>
34178 550-Verification failed for <xyz@abc.example>
34179 550-Called:   192.168.34.43
34180 550-Sent:     RCPT TO:<xyz@abc.example>
34181 550-Response: 550 Unknown local part xyz in <xyz@abc.example>
34182 550 Sender verification failed
34183 .endd
34184 If more than one RCPT command fails in the same way, the details are given
34185 only for the first of them. However, some administrators do not want to send
34186 out this much information. You can suppress the details by adding
34187 &`/no_details`& to the ACL statement that requests sender verification. For
34188 example:
34189 .code
34190 verify = sender/no_details
34191 .endd
34192
34193 .section "Redirection while verifying" "SECTredirwhilveri"
34194 .cindex "verifying" "redirection while"
34195 .cindex "address redirection" "while verifying"
34196 A dilemma arises when a local address is redirected by aliasing or forwarding
34197 during verification: should the generated addresses themselves be verified,
34198 or should the successful expansion of the original address be enough to verify
34199 it? By default, Exim takes the following pragmatic approach:
34200
34201 .ilist
34202 When an incoming address is redirected to just one child address, verification
34203 continues with the child address, and if that fails to verify, the original
34204 verification also fails.
34205 .next
34206 When an incoming address is redirected to more than one child address,
34207 verification does not continue. A success result is returned.
34208 .endlist
34209
34210 This seems the most reasonable behaviour for the common use of aliasing as a
34211 way of redirecting different local parts to the same mailbox. It means, for
34212 example, that a pair of alias entries of the form
34213 .code
34214 A.Wol:   aw123
34215 aw123:   :fail: Gone away, no forwarding address
34216 .endd
34217 work as expected, with both local parts causing verification failure. When a
34218 redirection generates more than one address, the behaviour is more like a
34219 mailing list, where the existence of the alias itself is sufficient for
34220 verification to succeed.
34221
34222 It is possible, however, to change the default behaviour so that all successful
34223 redirections count as successful verifications, however many new addresses are
34224 generated. This is specified by the &%success_on_redirect%& verification
34225 option. For example:
34226 .code
34227 require verify = recipient/success_on_redirect/callout=10s
34228 .endd
34229 In this example, verification succeeds if a router generates a new address, and
34230 the callout does not occur, because no address was routed to a remote host.
34231
34232 When verification is being tested via the &%-bv%& option, the treatment of
34233 redirections is as just described, unless the &%-v%& or any debugging option is
34234 also specified. In that case, full verification is done for every generated
34235 address and a report is output for each of them.
34236
34237
34238
34239 .section "Client SMTP authorization (CSA)" "SECTverifyCSA"
34240 .cindex "CSA" "verifying"
34241 Client SMTP Authorization is a system that allows a site to advertise
34242 which machines are and are not permitted to send email. This is done by placing
34243 special SRV records in the DNS; these are looked up using the client's HELO
34244 domain. At the time of writing, CSA is still an Internet Draft. Client SMTP
34245 Authorization checks in Exim are performed by the ACL condition:
34246 .code
34247 verify = csa
34248 .endd
34249 This fails if the client is not authorized. If there is a DNS problem, or if no
34250 valid CSA SRV record is found, or if the client is authorized, the condition
34251 succeeds. These three cases can be distinguished using the expansion variable
34252 &$csa_status$&, which can take one of the values &"fail"&, &"defer"&,
34253 &"unknown"&, or &"ok"&. The condition does not itself defer because that would
34254 be likely to cause problems for legitimate email.
34255
34256 The error messages produced by the CSA code include slightly more
34257 detail. If &$csa_status$& is &"defer"&, this may be because of problems
34258 looking up the CSA SRV record, or problems looking up the CSA target
34259 address record. There are four reasons for &$csa_status$& being &"fail"&:
34260
34261 .ilist
34262 The client's host name is explicitly not authorized.
34263 .next
34264 The client's IP address does not match any of the CSA target IP addresses.
34265 .next
34266 The client's host name is authorized but it has no valid target IP addresses
34267 (for example, the target's addresses are IPv6 and the client is using IPv4).
34268 .next
34269 The client's host name has no CSA SRV record but a parent domain has asserted
34270 that all subdomains must be explicitly authorized.
34271 .endlist
34272
34273 The &%csa%& verification condition can take an argument which is the domain to
34274 use for the DNS query. The default is:
34275 .code
34276 verify = csa/$sender_helo_name
34277 .endd
34278 This implementation includes an extension to CSA. If the query domain
34279 is an address literal such as [192.0.2.95], or if it is a bare IP
34280 address, Exim searches for CSA SRV records in the reverse DNS as if
34281 the HELO domain was (for example) &'95.2.0.192.in-addr.arpa'&. Therefore it is
34282 meaningful to say:
34283 .code
34284 verify = csa/$sender_host_address
34285 .endd
34286 In fact, this is the check that Exim performs if the client does not say HELO.
34287 This extension can be turned off by setting the main configuration option
34288 &%dns_csa_use_reverse%& to be false.
34289
34290 If a CSA SRV record is not found for the domain itself, a search
34291 is performed through its parent domains for a record which might be
34292 making assertions about subdomains. The maximum depth of this search is limited
34293 using the main configuration option &%dns_csa_search_limit%&, which is 5 by
34294 default. Exim does not look for CSA SRV records in a top level domain, so the
34295 default settings handle HELO domains as long as seven
34296 (&'hostname.five.four.three.two.one.com'&). This encompasses the vast majority
34297 of legitimate HELO domains.
34298
34299 The &'dnsdb'& lookup also has support for CSA. Although &'dnsdb'& also supports
34300 direct SRV lookups, this is not sufficient because of the extra parent domain
34301 search behaviour of CSA, and (as with PTR lookups) &'dnsdb'& also turns IP
34302 addresses into lookups in the reverse DNS space. The result of a successful
34303 lookup such as:
34304 .code
34305 ${lookup dnsdb {csa=$sender_helo_name}}
34306 .endd
34307 has two space-separated fields: an authorization code and a target host name.
34308 The authorization code can be &"Y"& for yes, &"N"& for no, &"X"& for explicit
34309 authorization required but absent, or &"?"& for unknown.
34310
34311
34312
34313
34314 .section "Bounce address tag validation" "SECTverifyPRVS"
34315 .cindex "BATV, verifying"
34316 Bounce address tag validation (BATV) is a scheme whereby the envelope senders
34317 of outgoing messages have a cryptographic, timestamped &"tag"& added to them.
34318 Genuine incoming bounce messages should therefore always be addressed to
34319 recipients that have a valid tag. This scheme is a way of detecting unwanted
34320 bounce messages caused by sender address forgeries (often called &"collateral
34321 spam"&), because the recipients of such messages do not include valid tags.
34322
34323 There are two expansion items to help with the implementation of the BATV
34324 &"prvs"& (private signature) scheme in an Exim configuration. This scheme signs
34325 the original envelope sender address by using a simple key to add a hash of the
34326 address and some time-based randomizing information. The &%prvs%& expansion
34327 item creates a signed address, and the &%prvscheck%& expansion item checks one.
34328 The syntax of these expansion items is described in section
34329 &<<SECTexpansionitems>>&.
34330 The validity period on signed addresses is seven days.
34331
34332 As an example, suppose the secret per-address keys are stored in an MySQL
34333 database. A query to look up the key for an address could be defined as a macro
34334 like this:
34335 .code
34336 PRVSCHECK_SQL = ${lookup mysql{SELECT secret FROM batv_prvs \
34337                 WHERE sender='${quote_mysql:$prvscheck_address}'\
34338                 }{$value}}
34339 .endd
34340 Suppose also that the senders who make use of BATV are defined by an address
34341 list called &%batv_senders%&. Then, in the ACL for RCPT commands, you could
34342 use this:
34343 .code
34344 # Bounces: drop unsigned addresses for BATV senders
34345 deny senders = :
34346      recipients = +batv_senders
34347      message = This address does not send an unsigned reverse path
34348
34349 # Bounces: In case of prvs-signed address, check signature.
34350 deny senders = :
34351      condition  = ${prvscheck {$local_part@$domain}\
34352                   {PRVSCHECK_SQL}{1}}
34353      !condition = $prvscheck_result
34354      message = Invalid reverse path signature.
34355 .endd
34356 The first statement rejects recipients for bounce messages that are addressed
34357 to plain BATV sender addresses, because it is known that BATV senders do not
34358 send out messages with plain sender addresses. The second statement rejects
34359 recipients that are prvs-signed, but with invalid signatures (either because
34360 the key is wrong, or the signature has timed out).
34361
34362 A non-prvs-signed address is not rejected by the second statement, because the
34363 &%prvscheck%& expansion yields an empty string if its first argument is not a
34364 prvs-signed address, thus causing the &%condition%& condition to be false. If
34365 the first argument is a syntactically valid prvs-signed address, the yield is
34366 the third string (in this case &"1"&), whether or not the cryptographic and
34367 timeout checks succeed. The &$prvscheck_result$& variable contains the result
34368 of the checks (empty for failure, &"1"& for success).
34369
34370 There is one more issue you must consider when implementing prvs-signing:
34371 you have to ensure that the routers accept prvs-signed addresses and
34372 deliver them correctly. The easiest way to handle this is to use a &(redirect)&
34373 router to remove the signature with a configuration along these lines:
34374 .code
34375 batv_redirect:
34376   driver = redirect
34377   data = ${prvscheck {$local_part@$domain}{PRVSCHECK_SQL}}
34378 .endd
34379 This works because, if the third argument of &%prvscheck%& is empty, the result
34380 of the expansion of a prvs-signed address is the decoded value of the original
34381 address. This router should probably be the first of your routers that handles
34382 local addresses.
34383
34384 To create BATV-signed addresses in the first place, a transport of this form
34385 can be used:
34386 .code
34387 external_smtp_batv:
34388   driver = smtp
34389   return_path = ${prvs {$return_path} \
34390                        {${lookup mysql{SELECT \
34391                        secret FROM batv_prvs WHERE \
34392                        sender='${quote_mysql:$sender_address}'} \
34393                        {$value}fail}}}
34394 .endd
34395 If no key can be found for the existing return path, no signing takes place.
34396
34397
34398
34399 .section "Using an ACL to control relaying" "SECTrelaycontrol"
34400 .cindex "&ACL;" "relay control"
34401 .cindex "relaying" "control by ACL"
34402 .cindex "policy control" "relay control"
34403 An MTA is said to &'relay'& a message if it receives it from some host and
34404 delivers it directly to another host as a result of a remote address contained
34405 within it. Redirecting a local address via an alias or forward file and then
34406 passing the message on to another host is not relaying,
34407 .cindex "&""percent hack""&"
34408 but a redirection as a result of the &"percent hack"& is.
34409
34410 Two kinds of relaying exist, which are termed &"incoming"& and &"outgoing"&.
34411 A host which is acting as a gateway or an MX backup is concerned with incoming
34412 relaying from arbitrary hosts to a specific set of domains. On the other hand,
34413 a host which is acting as a smart host for a number of clients is concerned
34414 with outgoing relaying from those clients to the Internet at large. Often the
34415 same host is fulfilling both functions,
34416 . ///
34417 . as illustrated in the diagram below,
34418 . ///
34419 but in principle these two kinds of relaying are entirely independent. What is
34420 not wanted is the transmission of mail from arbitrary remote hosts through your
34421 system to arbitrary domains.
34422
34423
34424 You can implement relay control by means of suitable statements in the ACL that
34425 runs for each RCPT command. For convenience, it is often easiest to use
34426 Exim's named list facility to define the domains and hosts involved. For
34427 example, suppose you want to do the following:
34428
34429 .ilist
34430 Deliver a number of domains to mailboxes on the local host (or process them
34431 locally in some other way). Let's say these are &'my.dom1.example'& and
34432 &'my.dom2.example'&.
34433 .next
34434 Relay mail for a number of other domains for which you are the secondary MX.
34435 These might be &'friend1.example'& and &'friend2.example'&.
34436 .next
34437 Relay mail from the hosts on your local LAN, to whatever domains are involved.
34438 Suppose your LAN is 192.168.45.0/24.
34439 .endlist
34440
34441
34442 In the main part of the configuration, you put the following definitions:
34443 .code
34444 domainlist local_domains    = my.dom1.example : my.dom2.example
34445 domainlist relay_to_domains = friend1.example : friend2.example
34446 hostlist   relay_from_hosts = 192.168.45.0/24
34447 .endd
34448 Now you can use these definitions in the ACL that is run for every RCPT
34449 command:
34450 .code
34451 acl_check_rcpt:
34452   accept domains = +local_domains : +relay_to_domains
34453   accept hosts   = +relay_from_hosts
34454 .endd
34455 The first statement accepts any RCPT command that contains an address in
34456 the local or relay domains. For any other domain, control passes to the second
34457 statement, which accepts the command only if it comes from one of the relay
34458 hosts. In practice, you will probably want to make your ACL more sophisticated
34459 than this, for example, by including sender and recipient verification. The
34460 default configuration includes a more comprehensive example, which is described
34461 in chapter &<<CHAPdefconfil>>&.
34462
34463
34464
34465 .section "Checking a relay configuration" "SECTcheralcon"
34466 .cindex "relaying" "checking control of"
34467 You can check the relay characteristics of your configuration in the same way
34468 that you can test any ACL behaviour for an incoming SMTP connection, by using
34469 the &%-bh%& option to run a fake SMTP session with which you interact.
34470 .ecindex IIDacl
34471
34472
34473
34474 . ////////////////////////////////////////////////////////////////////////////
34475 . ////////////////////////////////////////////////////////////////////////////
34476
34477 .chapter "Content scanning at ACL time" "CHAPexiscan"
34478 .scindex IIDcosca "content scanning" "at ACL time"
34479 The extension of Exim to include content scanning at ACL time, formerly known
34480 as &"exiscan"&, was originally implemented as a patch by Tom Kistner. The code
34481 was integrated into the main source for Exim release 4.50, and Tom continues to
34482 maintain it. Most of the wording of this chapter is taken from Tom's
34483 specification.
34484
34485 It is also possible to scan the content of messages at other times. The
34486 &[local_scan()]& function (see chapter &<<CHAPlocalscan>>&) allows for content
34487 scanning after all the ACLs have run. A transport filter can be used to scan
34488 messages at delivery time (see the &%transport_filter%& option, described in
34489 chapter &<<CHAPtransportgeneric>>&).
34490
34491 If you want to include the ACL-time content-scanning features when you compile
34492 Exim, you need to arrange for WITH_CONTENT_SCAN to be defined in your
34493 &_Local/Makefile_&. When you do that, the Exim binary is built with:
34494
34495 .ilist
34496 Two additional ACLs (&%acl_smtp_mime%& and &%acl_not_smtp_mime%&) that are run
34497 for all MIME parts for SMTP and non-SMTP messages, respectively.
34498 .next
34499 Additional ACL conditions and modifiers: &%decode%&, &%malware%&,
34500 &%mime_regex%&, &%regex%&, and &%spam%&. These can be used in the ACL that is
34501 run at the end of message reception (the &%acl_smtp_data%& ACL).
34502 .next
34503 An additional control feature (&"no_mbox_unspool"&) that saves spooled copies
34504 of messages, or parts of messages, for debugging purposes.
34505 .next
34506 Additional expansion variables that are set in the new ACL and by the new
34507 conditions.
34508 .next
34509 Two new main configuration options: &%av_scanner%& and &%spamd_address%&.
34510 .endlist
34511
34512 Content-scanning is continually evolving, and new features are still being
34513 added. While such features are still unstable and liable to incompatible
34514 changes, they are made available in Exim by setting options whose names begin
34515 EXPERIMENTAL_ in &_Local/Makefile_&. Such features are not documented in
34516 this manual. You can find out about them by reading the file called
34517 &_doc/experimental.txt_&.
34518
34519 All the content-scanning facilities work on a MBOX copy of the message that is
34520 temporarily created in a file called:
34521 .display
34522 <&'spool_directory'&>&`/scan/`&<&'message_id'&>/<&'message_id'&>&`.eml`&
34523 .endd
34524 The &_.eml_& extension is a friendly hint to virus scanners that they can
34525 expect an MBOX-like structure inside that file. The file is created when the
34526 first content scanning facility is called. Subsequent calls to content
34527 scanning conditions open the same file again. The directory is recursively
34528 removed when the &%acl_smtp_data%& ACL has finished running, unless
34529 .code
34530 control = no_mbox_unspool
34531 .endd
34532 has been encountered. When the MIME ACL decodes files, they are put into the
34533 same directory by default.
34534
34535
34536
34537 .section "Scanning for viruses" "SECTscanvirus"
34538 .cindex "virus scanning"
34539 .cindex "content scanning" "for viruses"
34540 .cindex "content scanning" "the &%malware%& condition"
34541 The &%malware%& ACL condition lets you connect virus scanner software to Exim.
34542 It supports a &"generic"& interface to scanners called via the shell, and
34543 specialized interfaces for &"daemon"& type virus scanners, which are resident
34544 in memory and thus are much faster.
34545
34546 Since message data needs to have arrived,
34547 the condition may be only called in ACL defined by
34548 &%acl_smtp_data%&,
34549 &%acl_smtp_data_prdr%&,
34550 &%acl_smtp_mime%& or
34551 &%acl_smtp_dkim%&
34552
34553 A timeout of 2 minutes is applied to a scanner call (by default);
34554 if it expires then a defer action is taken.
34555
34556 .oindex "&%av_scanner%&"
34557 You can set the &%av_scanner%& option in the main part of the configuration
34558 to specify which scanner to use, together with any additional options that
34559 are needed. The basic syntax is as follows:
34560 .display
34561 &`av_scanner = <`&&'scanner-type'&&`>:<`&&'option1'&&`>:<`&&'option2'&&`>:[...]`&
34562 .endd
34563 If you do not set &%av_scanner%&, it defaults to
34564 .code
34565 av_scanner = sophie:/var/run/sophie
34566 .endd
34567 If the value of &%av_scanner%& starts with a dollar character, it is expanded
34568 before use.
34569 The usual list-parsing of the content (see &<<SECTlistconstruct>>&) applies.
34570 The following scanner types are supported in this release,
34571 though individual ones can be included or not at build time:
34572
34573 .vlist
34574 .vitem &%avast%&
34575 .cindex "virus scanners" "avast"
34576 This is the scanner daemon of Avast. It has been tested with Avast Core
34577 Security (currently at version 2.2.0).
34578 You can get a trial version at &url(https://www.avast.com) or for Linux
34579 at &url(https://www.avast.com/linux-server-antivirus).
34580 This scanner type takes one option,
34581 which can be either a full path to a UNIX socket,
34582 or host and port specifiers separated by white space.
34583 The host may be a name or an IP address; the port is either a
34584 single number or a pair of numbers with a dash between.
34585 A list of options may follow. These options are interpreted on the
34586 Exim's side of the malware scanner, or are given on separate lines to
34587 the daemon as options before the main scan command.
34588
34589 .cindex &`pass_unscanned`& "avast"
34590 If &`pass_unscanned`&
34591 is set, any files the Avast scanner can't scan (e.g.
34592 decompression bombs, or invalid archives) are considered clean. Use with
34593 care.
34594
34595 For example:
34596 .code
34597 av_scanner = avast:/var/run/avast/scan.sock:FLAGS -fullfiles:SENSITIVITY -pup
34598 av_scanner = avast:/var/run/avast/scan.sock:pass_unscanned:FLAGS -fullfiles:SENSITIVITY -pup
34599 av_scanner = avast:192.168.2.22 5036
34600 .endd
34601 If you omit the argument, the default path
34602 &_/var/run/avast/scan.sock_&
34603 is used.
34604 If you use a remote host,
34605 you need to make Exim's spool directory available to it,
34606 as the scanner is passed a file path, not file contents.
34607 For information about available commands and their options you may use
34608 .code
34609 $ socat UNIX:/var/run/avast/scan.sock STDIO:
34610     FLAGS
34611     SENSITIVITY
34612     PACK
34613 .endd
34614
34615 If the scanner returns a temporary failure (e.g. license issues, or
34616 permission problems), the message is deferred and a paniclog entry is
34617 written.  The usual &`defer_ok`& option is available.
34618
34619 .vitem &%aveserver%&
34620 .cindex "virus scanners" "Kaspersky"
34621 This is the scanner daemon of Kaspersky Version 5. You can get a trial version
34622 at &url(https://www.kaspersky.com/). This scanner type takes one option,
34623 which is the path to the daemon's UNIX socket. The default is shown in this
34624 example:
34625 .code
34626 av_scanner = aveserver:/var/run/aveserver
34627 .endd
34628
34629
34630 .vitem &%clamd%&
34631 .cindex "virus scanners" "clamd"
34632 This daemon-type scanner is GPL and free. You can get it at
34633 &url(https://www.clamav.net/). Some older versions of clamd do not seem to
34634 unpack MIME containers, so it used to be recommended to unpack MIME attachments
34635 in the MIME ACL. This is no longer believed to be necessary.
34636
34637 The options are a list of server specifiers, which may be
34638 a UNIX socket specification,
34639 a TCP socket specification,
34640 or a (global) option.
34641
34642 A socket specification consists of a space-separated list.
34643 For a Unix socket the first element is a full path for the socket,
34644 for a TCP socket the first element is the IP address
34645 and the second a port number,
34646 Any further elements are per-server (non-global) options.
34647 These per-server options are supported:
34648 .code
34649 retry=<timespec>        Retry on connect fail
34650 .endd
34651
34652 The &`retry`& option specifies a time after which a single retry for
34653 a failed connect is made.  The default is to not retry.
34654
34655 If a Unix socket file is specified, only one server is supported.
34656
34657 Examples:
34658 .code
34659 av_scanner = clamd:/opt/clamd/socket
34660 av_scanner = clamd:192.0.2.3 1234
34661 av_scanner = clamd:192.0.2.3 1234:local
34662 av_scanner = clamd:192.0.2.3 1234 retry=10s
34663 av_scanner = clamd:192.0.2.3 1234 : 192.0.2.4 1234
34664 .endd
34665 If the value of av_scanner points to a UNIX socket file or contains the
34666 &`local`&
34667 option, then the ClamAV interface will pass a filename containing the data
34668 to be scanned, which should normally result in less I/O happening and be
34669 more efficient.  Normally in the TCP case, the data is streamed to ClamAV as
34670 Exim does not assume that there is a common filesystem with the remote host.
34671
34672 The final example shows that multiple TCP targets can be specified.  Exim will
34673 randomly use one for each incoming email (i.e. it load balances them).  Note
34674 that only TCP targets may be used if specifying a list of scanners; a UNIX
34675 socket cannot be mixed in with TCP targets.  If one of the servers becomes
34676 unavailable, Exim will try the remaining one(s) until it finds one that works.
34677 When a clamd server becomes unreachable, Exim will log a message.  Exim does
34678 not keep track of scanner state between multiple messages, and the scanner
34679 selection is random, so the message will get logged in the mainlog for each
34680 email that the down scanner gets chosen first (message wrapped to be readable):
34681 .code
34682 2013-10-09 14:30:39 1VTumd-0000Y8-BQ malware acl condition:
34683    clamd: connection to localhost, port 3310 failed
34684    (Connection refused)
34685 .endd
34686
34687 If the option is unset, the default is &_/tmp/clamd_&. Thanks to David Saez for
34688 contributing the code for this scanner.
34689
34690 .vitem &%cmdline%&
34691 .cindex "virus scanners" "command line interface"
34692 This is the keyword for the generic command line scanner interface. It can be
34693 used to attach virus scanners that are invoked from the shell. This scanner
34694 type takes 3 mandatory options:
34695
34696 .olist
34697 The full path and name of the scanner binary, with all command line options,
34698 and a placeholder (&`%s`&) for the directory to scan.
34699
34700 .next
34701 A regular expression to match against the STDOUT and STDERR output of the
34702 virus scanner. If the expression matches, a virus was found. You must make
34703 absolutely sure that this expression matches on &"virus found"&. This is called
34704 the &"trigger"& expression.
34705
34706 .next
34707 Another regular expression, containing exactly one pair of parentheses, to
34708 match the name of the virus found in the scanners output. This is called the
34709 &"name"& expression.
34710 .endlist olist
34711
34712 For example, Sophos Sweep reports a virus on a line like this:
34713 .code
34714 Virus 'W32/Magistr-B' found in file ./those.bat
34715 .endd
34716 For the trigger expression, we can match the phrase &"found in file"&. For the
34717 name expression, we want to extract the W32/Magistr-B string, so we can match
34718 for the single quotes left and right of it. Altogether, this makes the
34719 configuration setting:
34720 .code
34721 av_scanner = cmdline:\
34722              /path/to/sweep -ss -all -rec -archive %s:\
34723              found in file:'(.+)'
34724 .endd
34725 .vitem &%drweb%&
34726 .cindex "virus scanners" "DrWeb"
34727 The DrWeb daemon scanner (&url(https://www.sald.ru/)) interface
34728 takes one option,
34729 either a full path to a UNIX socket,
34730 or host and port specifiers separated by white space.
34731 The host may be a name or an IP address; the port is either a
34732 single number or a pair of numbers with a dash between.
34733 For example:
34734 .code
34735 av_scanner = drweb:/var/run/drwebd.sock
34736 av_scanner = drweb:192.168.2.20 31337
34737 .endd
34738 If you omit the argument, the default path &_/usr/local/drweb/run/drwebd.sock_&
34739 is used. Thanks to Alex Miller for contributing the code for this scanner.
34740
34741 .vitem &%f-protd%&
34742 .cindex "virus scanners" "f-protd"
34743 The f-protd scanner is accessed via HTTP over TCP.
34744 One argument is taken, being a space-separated hostname and port number
34745 (or port-range).
34746 For example:
34747 .code
34748 av_scanner = f-protd:localhost 10200-10204
34749 .endd
34750 If you omit the argument, the default values shown above are used.
34751
34752 .vitem &%f-prot6d%&
34753 .cindex "virus scanners" "f-prot6d"
34754 The f-prot6d scanner is accessed using the FPSCAND protocol over TCP.
34755 One argument is taken, being a space-separated hostname and port number.
34756 For example:
34757 .code
34758 av_scanner = f-prot6d:localhost 10200
34759 .endd
34760 If you omit the argument, the default values show above are used.
34761
34762 .vitem &%fsecure%&
34763 .cindex "virus scanners" "F-Secure"
34764 The F-Secure daemon scanner (&url(https://www.f-secure.com/)) takes one
34765 argument which is the path to a UNIX socket. For example:
34766 .code
34767 av_scanner = fsecure:/path/to/.fsav
34768 .endd
34769 If no argument is given, the default is &_/var/run/.fsav_&. Thanks to Johan
34770 Thelmen for contributing the code for this scanner.
34771
34772 .vitem &%kavdaemon%&
34773 .cindex "virus scanners" "Kaspersky"
34774 This is the scanner daemon of Kaspersky Version 4. This version of the
34775 Kaspersky scanner is outdated. Please upgrade (see &%aveserver%& above). This
34776 scanner type takes one option, which is the path to the daemon's UNIX socket.
34777 For example:
34778 .code
34779 av_scanner = kavdaemon:/opt/AVP/AvpCtl
34780 .endd
34781 The default path is &_/var/run/AvpCtl_&.
34782
34783 .vitem &%mksd%&
34784 .cindex "virus scanners" "mksd"
34785 This was a daemon type scanner that is aimed mainly at Polish users,
34786 though some documentation was available in English.
34787 The history can be shown at &url(https://en.wikipedia.org/wiki/Mks_vir)
34788 and this appears to be a candidate for removal from Exim, unless
34789 we are informed of other virus scanners which use the same protocol
34790 to integrate.
34791 The only option for this scanner type is
34792 the maximum number of processes used simultaneously to scan the attachments,
34793 provided that mksd has
34794 been run with at least the same number of child processes. For example:
34795 .code
34796 av_scanner = mksd:2
34797 .endd
34798 You can safely omit this option (the default value is 1).
34799
34800 .vitem &%sock%&
34801 .cindex "virus scanners" "simple socket-connected"
34802 This is a general-purpose way of talking to simple scanner daemons
34803 running on the local machine.
34804 There are four options:
34805 an address (which may be an IP address and port, or the path of a Unix socket),
34806 a commandline to send (may include a single %s which will be replaced with
34807 the path to the mail file to be scanned),
34808 an RE to trigger on from the returned data,
34809 and an RE to extract malware_name from the returned data.
34810 For example:
34811 .code
34812 av_scanner = sock:127.0.0.1 6001:%s:(SPAM|VIRUS):(.*)$
34813 .endd
34814 Note that surrounding whitespace is stripped from each option, meaning
34815 there is no way to specify a trailing newline.
34816 The socket specifier and both regular-expressions are required.
34817 Default for the commandline is &_%s\n_& (note this does have a trailing newline);
34818 specify an empty element to get this.
34819
34820 .vitem &%sophie%&
34821 .cindex "virus scanners" "Sophos and Sophie"
34822 Sophie is a daemon that uses Sophos' &%libsavi%& library to scan for viruses.
34823 You can get Sophie at &url(http://sophie.sourceforge.net/). The only option
34824 for this scanner type is the path to the UNIX socket that Sophie uses for
34825 client communication. For example:
34826 .code
34827 av_scanner = sophie:/tmp/sophie
34828 .endd
34829 The default path is &_/var/run/sophie_&, so if you are using this, you can omit
34830 the option.
34831 .endlist
34832
34833 When &%av_scanner%& is correctly set, you can use the &%malware%& condition in
34834 the DATA ACL. &*Note*&: You cannot use the &%malware%& condition in the MIME
34835 ACL.
34836
34837 The &%av_scanner%& option is expanded each time &%malware%& is called. This
34838 makes it possible to use different scanners. See further below for an example.
34839 The &%malware%& condition caches its results, so when you use it multiple times
34840 for the same message, the actual scanning process is only carried out once.
34841 However, using expandable items in &%av_scanner%& disables this caching, in
34842 which case each use of the &%malware%& condition causes a new scan of the
34843 message.
34844
34845 The &%malware%& condition takes a right-hand argument that is expanded before
34846 use and taken as a list, slash-separated by default.
34847 The first element can then be one of
34848
34849 .ilist
34850 &"true"&, &"*"&, or &"1"&, in which case the message is scanned for viruses.
34851 The condition succeeds if a virus was found, and fail otherwise. This is the
34852 recommended usage.
34853 .next
34854 &"false"& or &"0"& or an empty string, in which case no scanning is done and
34855 the condition fails immediately.
34856 .next
34857 A regular expression, in which case the message is scanned for viruses. The
34858 condition succeeds if a virus is found and its name matches the regular
34859 expression. This allows you to take special actions on certain types of virus.
34860 Note that &"/"& characters in the RE must be doubled due to the list-processing,
34861 unless the separator is changed (in the usual way &<<SECTlistsepchange>>&).
34862 .endlist
34863
34864 You can append a &`defer_ok`& element to the &%malware%& argument list to accept
34865 messages even if there is a problem with the virus scanner.
34866 Otherwise, such a problem causes the ACL to defer.
34867
34868 You can append a &`tmo=<val>`& element to the &%malware%& argument list to
34869 specify a non-default timeout.  The default is two minutes.
34870 For example:
34871 .code
34872 malware = * / defer_ok / tmo=10s
34873 .endd
34874 A timeout causes the ACL to defer.
34875
34876 .vindex "&$callout_address$&"
34877 When a connection is made to the scanner the expansion variable &$callout_address$&
34878 is set to record the actual address used.
34879
34880 .vindex "&$malware_name$&"
34881 When a virus is found, the condition sets up an expansion variable called
34882 &$malware_name$& that contains the name of the virus. You can use it in a
34883 &%message%& modifier that specifies the error returned to the sender, and/or in
34884 logging data.
34885
34886 Beware the interaction of Exim's &%message_size_limit%& with any size limits
34887 imposed by your anti-virus scanner.
34888
34889 Here is a very simple scanning example:
34890 .code
34891 deny malware = *
34892      message = This message contains malware ($malware_name)
34893 .endd
34894 The next example accepts messages when there is a problem with the scanner:
34895 .code
34896 deny malware = */defer_ok
34897      message = This message contains malware ($malware_name)
34898 .endd
34899 The next example shows how to use an ACL variable to scan with both sophie and
34900 aveserver. It assumes you have set:
34901 .code
34902 av_scanner = $acl_m0
34903 .endd
34904 in the main Exim configuration.
34905 .code
34906 deny set acl_m0 = sophie
34907      malware = *
34908      message = This message contains malware ($malware_name)
34909
34910 deny set acl_m0 = aveserver
34911      malware = *
34912      message = This message contains malware ($malware_name)
34913 .endd
34914
34915
34916 .section "Scanning with SpamAssassin and Rspamd" "SECTscanspamass"
34917 .cindex "content scanning" "for spam"
34918 .cindex "spam scanning"
34919 .cindex "SpamAssassin"
34920 .cindex "Rspamd"
34921 The &%spam%& ACL condition calls SpamAssassin's &%spamd%& daemon to get a spam
34922 score and a report for the message.
34923 Support is also provided for Rspamd.
34924
34925 For more information about installation and configuration of SpamAssassin or
34926 Rspamd refer to their respective websites at
34927 &url(https://spamassassin.apache.org/) and &url(https://www.rspamd.com/)
34928
34929 SpamAssassin can be installed with CPAN by running:
34930 .code
34931 perl -MCPAN -e 'install Mail::SpamAssassin'
34932 .endd
34933 SpamAssassin has its own set of configuration files. Please review its
34934 documentation to see how you can tweak it. The default installation should work
34935 nicely, however.
34936
34937 .oindex "&%spamd_address%&"
34938 By default, SpamAssassin listens on 127.0.0.1, TCP port 783 and if you
34939 intend to use an instance running on the local host you do not need to set
34940 &%spamd_address%&. If you intend to use another host or port for SpamAssassin,
34941 you must set the &%spamd_address%& option in the global part of the Exim
34942 configuration as follows (example):
34943 .code
34944 spamd_address = 192.168.99.45 783
34945 .endd
34946 The SpamAssassin protocol relies on a TCP half-close from the client.
34947 If your SpamAssassin client side is running a Linux system with an
34948 iptables firewall, consider setting
34949 &%net.netfilter.nf_conntrack_tcp_timeout_close_wait%& to at least the
34950 timeout, Exim uses when waiting for a response from the SpamAssassin
34951 server (currently defaulting to 120s).  With a lower value the Linux
34952 connection tracking may consider your half-closed connection as dead too
34953 soon.
34954
34955
34956 To use Rspamd (which by default listens on all local addresses
34957 on TCP port 11333)
34958 you should add &%variant=rspamd%& after the address/port pair, for example:
34959 .code
34960 spamd_address = 127.0.0.1 11333 variant=rspamd
34961 .endd
34962
34963 As of version 2.60, &%SpamAssassin%& also supports communication over UNIX
34964 sockets. If you want to us these, supply &%spamd_address%& with an absolute
34965 filename instead of an address/port pair:
34966 .code
34967 spamd_address = /var/run/spamd_socket
34968 .endd
34969 You can have multiple &%spamd%& servers to improve scalability. These can
34970 reside on other hardware reachable over the network. To specify multiple
34971 &%spamd%& servers, put multiple address/port pairs in the &%spamd_address%&
34972 option, separated with colons (the separator can be changed in the usual way &<<SECTlistsepchange>>&):
34973 .code
34974 spamd_address = 192.168.2.10 783 : \
34975                 192.168.2.11 783 : \
34976                 192.168.2.12 783
34977 .endd
34978 Up to 32 &%spamd%& servers are supported.
34979 When a server fails to respond to the connection attempt, all other
34980 servers are tried until one succeeds. If no server responds, the &%spam%&
34981 condition defers.
34982
34983 Unix and TCP socket specifications may be mixed in any order.
34984 Each element of the list is a list itself, space-separated by default
34985 and changeable in the usual way (&<<SECTlistsepchange>>&);
34986 take care to not double the separator.
34987
34988 For TCP socket specifications a host name or IP (v4 or v6, but
34989 subject to list-separator quoting rules) address can be used,
34990 and the port can be one or a dash-separated pair.
34991 In the latter case, the range is tried in strict order.
34992
34993 Elements after the first for Unix sockets, or second for TCP socket,
34994 are options.
34995 The supported options are:
34996 .code
34997 pri=<priority>      Selection priority
34998 weight=<value>      Selection bias
34999 time=<start>-<end>  Use only between these times of day
35000 retry=<timespec>    Retry on connect fail
35001 tmo=<timespec>      Connection time limit
35002 variant=rspamd      Use Rspamd rather than SpamAssassin protocol
35003 .endd
35004
35005 The &`pri`& option specifies a priority for the server within the list,
35006 higher values being tried first.
35007 The default priority is 1.
35008
35009 The &`weight`& option specifies a selection bias.
35010 Within a priority set
35011 servers are queried in a random fashion, weighted by this value.
35012 The default value for selection bias is 1.
35013
35014 Time specifications for the &`time`& option are <hour>.<minute>.<second>
35015 in the local time zone; each element being one or more digits.
35016 Either the seconds or both minutes and seconds, plus the leading &`.`&
35017 characters, may be omitted and will be taken as zero.
35018
35019 Timeout specifications for the &`retry`& and &`tmo`& options
35020 are the usual Exim time interval standard, e.g. &`20s`& or &`1m`&.
35021
35022 The &`tmo`& option specifies an overall timeout for communication.
35023 The default value is two minutes.
35024
35025 The &`retry`& option specifies a time after which a single retry for
35026 a failed connect is made.
35027 The default is to not retry.
35028
35029 The &%spamd_address%& variable is expanded before use if it starts with
35030 a dollar sign. In this case, the expansion may return a string that is
35031 used as the list so that multiple spamd servers can be the result of an
35032 expansion.
35033
35034 .vindex "&$callout_address$&"
35035 When a connection is made to the server the expansion variable &$callout_address$&
35036 is set to record the actual address used.
35037
35038 .section "Calling SpamAssassin from an Exim ACL" "SECID206"
35039 Here is a simple example of the use of the &%spam%& condition in a DATA ACL:
35040 .code
35041 deny spam = joe
35042      message = This message was classified as SPAM
35043 .endd
35044 The right-hand side of the &%spam%& condition specifies a name. This is
35045 relevant if you have set up multiple SpamAssassin profiles. If you do not want
35046 to scan using a specific profile, but rather use the SpamAssassin system-wide
35047 default profile, you can scan for an unknown name, or simply use &"nobody"&.
35048 Rspamd does not use this setting. However, you must put something on the
35049 right-hand side.
35050
35051 The name allows you to use per-domain or per-user antispam profiles in
35052 principle, but this is not straightforward in practice, because a message may
35053 have multiple recipients, not necessarily all in the same domain. Because the
35054 &%spam%& condition has to be called from a DATA-time ACL in order to be able to
35055 read the contents of the message, the variables &$local_part$& and &$domain$&
35056 are not set.
35057 Careful enforcement of single-recipient messages
35058 (e.g. by responding with defer in the recipient ACL for all recipients
35059 after the first),
35060 or the use of PRDR,
35061 .cindex "PRDR" "use for per-user SpamAssassin profiles"
35062 are needed to use this feature.
35063
35064 The right-hand side of the &%spam%& condition is expanded before being used, so
35065 you can put lookups or conditions there. When the right-hand side evaluates to
35066 &"0"& or &"false"&, no scanning is done and the condition fails immediately.
35067
35068
35069 Scanning with SpamAssassin uses a lot of resources. If you scan every message,
35070 large ones may cause significant performance degradation. As most spam messages
35071 are quite small, it is recommended that you do not scan the big ones. For
35072 example:
35073 .code
35074 deny condition = ${if < {$message_size}{10K}}
35075      spam = nobody
35076      message = This message was classified as SPAM
35077 .endd
35078
35079 The &%spam%& condition returns true if the threshold specified in the user's
35080 SpamAssassin profile has been matched or exceeded. If you want to use the
35081 &%spam%& condition for its side effects (see the variables below), you can make
35082 it always return &"true"& by appending &`:true`& to the username.
35083
35084 .cindex "spam scanning" "returned variables"
35085 When the &%spam%& condition is run, it sets up a number of expansion
35086 variables.
35087 Except for &$spam_report$&,
35088 these variables are saved with the received message so are
35089 available for use at delivery time.
35090
35091 .vlist
35092 .vitem &$spam_score$&
35093 The spam score of the message, for example, &"3.4"& or &"30.5"&. This is useful
35094 for inclusion in log or reject messages.
35095
35096 .vitem &$spam_score_int$&
35097 The spam score of the message, multiplied by ten, as an integer value. For
35098 example &"34"& or &"305"&. It may appear to disagree with &$spam_score$&
35099 because &$spam_score$& is rounded and &$spam_score_int$& is truncated.
35100 The integer value is useful for numeric comparisons in conditions.
35101
35102 .vitem &$spam_bar$&
35103 A string consisting of a number of &"+"& or &"-"& characters, representing the
35104 integer part of the spam score value. A spam score of 4.4 would have a
35105 &$spam_bar$& value of &"++++"&. This is useful for inclusion in warning
35106 headers, since MUAs can match on such strings. The maximum length of the
35107 spam bar is 50 characters.
35108
35109 .vitem &$spam_report$&
35110 A multiline text table, containing the full SpamAssassin report for the
35111 message. Useful for inclusion in headers or reject messages.
35112 This variable is only usable in a DATA-time ACL.
35113 Beware that SpamAssassin may return non-ASCII characters, especially
35114 when running in country-specific locales, which are not legal
35115 unencoded in headers.
35116
35117 .vitem &$spam_action$&
35118 For SpamAssassin either 'reject' or 'no action' depending on the
35119 spam score versus threshold.
35120 For Rspamd, the recommended action.
35121
35122 .endlist
35123
35124 The &%spam%& condition caches its results unless expansion in
35125 spamd_address was used. If you call it again with the same user name, it
35126 does not scan again, but rather returns the same values as before.
35127
35128 The &%spam%& condition returns DEFER if there is any error while running
35129 the message through SpamAssassin or if the expansion of spamd_address
35130 failed. If you want to treat DEFER as FAIL (to pass on to the next ACL
35131 statement block), append &`/defer_ok`& to the right-hand side of the
35132 spam condition, like this:
35133 .code
35134 deny spam    = joe/defer_ok
35135      message = This message was classified as SPAM
35136 .endd
35137 This causes messages to be accepted even if there is a problem with &%spamd%&.
35138
35139 Here is a longer, commented example of the use of the &%spam%&
35140 condition:
35141 .code
35142 # put headers in all messages (no matter if spam or not)
35143 warn  spam = nobody:true
35144       add_header = X-Spam-Score: $spam_score ($spam_bar)
35145       add_header = X-Spam-Report: $spam_report
35146
35147 # add second subject line with *SPAM* marker when message
35148 # is over threshold
35149 warn  spam = nobody
35150       add_header = Subject: *SPAM* $h_Subject:
35151
35152 # reject spam at high scores (> 12)
35153 deny  spam = nobody:true
35154       condition = ${if >{$spam_score_int}{120}{1}{0}}
35155       message = This message scored $spam_score spam points.
35156 .endd
35157
35158
35159
35160 .section "Scanning MIME parts" "SECTscanmimepart"
35161 .cindex "content scanning" "MIME parts"
35162 .cindex "MIME content scanning"
35163 .oindex "&%acl_smtp_mime%&"
35164 .oindex "&%acl_not_smtp_mime%&"
35165 The &%acl_smtp_mime%& global option specifies an ACL that is called once for
35166 each MIME part of an SMTP message, including multipart types, in the sequence
35167 of their position in the message. Similarly, the &%acl_not_smtp_mime%& option
35168 specifies an ACL that is used for the MIME parts of non-SMTP messages. These
35169 options may both refer to the same ACL if you want the same processing in both
35170 cases.
35171
35172 These ACLs are called (possibly many times) just before the &%acl_smtp_data%&
35173 ACL in the case of an SMTP message, or just before the &%acl_not_smtp%& ACL in
35174 the case of a non-SMTP message. However, a MIME ACL is called only if the
35175 message contains a &'Content-Type:'& header line. When a call to a MIME
35176 ACL does not yield &"accept"&, ACL processing is aborted and the appropriate
35177 result code is sent to the client. In the case of an SMTP message, the
35178 &%acl_smtp_data%& ACL is not called when this happens.
35179
35180 You cannot use the &%malware%& or &%spam%& conditions in a MIME ACL; these can
35181 only be used in the DATA or non-SMTP ACLs. However, you can use the &%regex%&
35182 condition to match against the raw MIME part. You can also use the
35183 &%mime_regex%& condition to match against the decoded MIME part (see section
35184 &<<SECTscanregex>>&).
35185
35186 At the start of a MIME ACL, a number of variables are set from the header
35187 information for the relevant MIME part. These are described below. The contents
35188 of the MIME part are not by default decoded into a disk file except for MIME
35189 parts whose content-type is &"message/rfc822"&. If you want to decode a MIME
35190 part into a disk file, you can use the &%decode%& condition. The general
35191 syntax is:
35192 .display
35193 &`decode = [/`&<&'path'&>&`/]`&<&'filename'&>
35194 .endd
35195 The right hand side is expanded before use. After expansion,
35196 the value can be:
35197
35198 .olist
35199 &"0"& or &"false"&, in which case no decoding is done.
35200 .next
35201 The string &"default"&. In that case, the file is put in the temporary
35202 &"default"& directory <&'spool_directory'&>&_/scan/_&<&'message_id'&>&_/_& with
35203 a sequential filename consisting of the message id and a sequence number. The
35204 full path and name is available in &$mime_decoded_filename$& after decoding.
35205 .next
35206 A full path name starting with a slash. If the full name is an existing
35207 directory, it is used as a replacement for the default directory. The filename
35208 is then sequentially assigned. If the path does not exist, it is used as
35209 the full path and filename.
35210 .next
35211 If the string does not start with a slash, it is used as the
35212 filename, and the default path is then used.
35213 .endlist
35214 The &%decode%& condition normally succeeds. It is only false for syntax
35215 errors or unusual circumstances such as memory shortages.
35216 The variable &$mime_filename$& will have the suggested name for the file.
35217 Note however that this might contain anything, and is very difficult
35218 to safely use as all or even part of the filename.
35219 If you place files outside of the default path, they are not
35220 automatically unlinked.
35221
35222 For RFC822 attachments (these are messages attached to messages, with a
35223 content-type of &"message/rfc822"&), the ACL is called again in the same manner
35224 as for the primary message, only that the &$mime_is_rfc822$& expansion
35225 variable is set (see below). Attached messages are always decoded to disk
35226 before being checked, and the files are unlinked once the check is done.
35227
35228 The MIME ACL supports the &%regex%& and &%mime_regex%& conditions. These can be
35229 used to match regular expressions against raw and decoded MIME parts,
35230 respectively. They are described in section &<<SECTscanregex>>&.
35231
35232 .cindex "MIME content scanning" "returned variables"
35233 The following list describes all expansion variables that are
35234 available in the MIME ACL:
35235
35236 .vlist
35237 .vitem &$mime_anomaly_level$& &&&
35238        &$mime_anomaly_text$&
35239 .vindex &$mime_anomaly_level$&
35240 .vindex &$mime_anomaly_text$&
35241 If there are problems decoding, these variables contain information on
35242 the detected issue.
35243
35244 .vitem &$mime_boundary$&
35245 .vindex &$mime_boundary$&
35246 If the current part is a multipart (see &$mime_is_multipart$& below), it should
35247 have a boundary string, which is stored in this variable. If the current part
35248 has no boundary parameter in the &'Content-Type:'& header, this variable
35249 contains the empty string.
35250
35251 .vitem &$mime_charset$&
35252 .vindex &$mime_charset$&
35253 This variable contains the character set identifier, if one was found in the
35254 &'Content-Type:'& header. Examples for charset identifiers are:
35255 .code
35256 us-ascii
35257 gb2312 (Chinese)
35258 iso-8859-1
35259 .endd
35260 Please note that this value is not normalized, so you should do matches
35261 case-insensitively.
35262
35263 .vitem &$mime_content_description$&
35264 .vindex &$mime_content_description$&
35265 This variable contains the normalized content of the &'Content-Description:'&
35266 header. It can contain a human-readable description of the parts content. Some
35267 implementations repeat the filename for attachments here, but they are usually
35268 only used for display purposes.
35269
35270 .vitem &$mime_content_disposition$&
35271 .vindex &$mime_content_disposition$&
35272 This variable contains the normalized content of the &'Content-Disposition:'&
35273 header. You can expect strings like &"attachment"& or &"inline"& here.
35274
35275 .vitem &$mime_content_id$&
35276 .vindex &$mime_content_id$&
35277 This variable contains the normalized content of the &'Content-ID:'& header.
35278 This is a unique ID that can be used to reference a part from another part.
35279
35280 .vitem &$mime_content_size$&
35281 .vindex &$mime_content_size$&
35282 This variable is set only after the &%decode%& modifier (see above) has been
35283 successfully run. It contains the size of the decoded part in kilobytes. The
35284 size is always rounded up to full kilobytes, so only a completely empty part
35285 has a &$mime_content_size$& of zero.
35286
35287 .vitem &$mime_content_transfer_encoding$&
35288 .vindex &$mime_content_transfer_encoding$&
35289 This variable contains the normalized content of the
35290 &'Content-transfer-encoding:'& header. This is a symbolic name for an encoding
35291 type. Typical values are &"base64"& and &"quoted-printable"&.
35292
35293 .vitem &$mime_content_type$&
35294 .vindex &$mime_content_type$&
35295 If the MIME part has a &'Content-Type:'& header, this variable contains its
35296 value, lowercased, and without any options (like &"name"& or &"charset"&). Here
35297 are some examples of popular MIME types, as they may appear in this variable:
35298 .code
35299 text/plain
35300 text/html
35301 application/octet-stream
35302 image/jpeg
35303 audio/midi
35304 .endd
35305 If the MIME part has no &'Content-Type:'& header, this variable contains the
35306 empty string.
35307
35308 .vitem &$mime_decoded_filename$&
35309 .vindex &$mime_decoded_filename$&
35310 This variable is set only after the &%decode%& modifier (see above) has been
35311 successfully run. It contains the full path and filename of the file
35312 containing the decoded data.
35313 .endlist
35314
35315 .cindex "RFC 2047"
35316 .vlist
35317 .vitem &$mime_filename$&
35318 .vindex &$mime_filename$&
35319 This is perhaps the most important of the MIME variables. It contains a
35320 proposed filename for an attachment, if one was found in either the
35321 &'Content-Type:'& or &'Content-Disposition:'& headers. The filename will be
35322 RFC2047
35323 or RFC2231
35324 decoded, but no additional sanity checks are done.
35325  If no filename was
35326 found, this variable contains the empty string.
35327
35328 .vitem &$mime_is_coverletter$&
35329 .vindex &$mime_is_coverletter$&
35330 This variable attempts to differentiate the &"cover letter"& of an e-mail from
35331 attached data. It can be used to clamp down on flashy or unnecessarily encoded
35332 content in the cover letter, while not restricting attachments at all.
35333
35334 The variable contains 1 (true) for a MIME part believed to be part of the
35335 cover letter, and 0 (false) for an attachment. At present, the algorithm is as
35336 follows:
35337
35338 .olist
35339 The outermost MIME part of a message is always a cover letter.
35340
35341 .next
35342 If a multipart/alternative or multipart/related MIME part is a cover letter,
35343 so are all MIME subparts within that multipart.
35344
35345 .next
35346 If any other multipart is a cover letter, the first subpart is a cover letter,
35347 and the rest are attachments.
35348
35349 .next
35350 All parts contained within an attachment multipart are attachments.
35351 .endlist olist
35352
35353 As an example, the following will ban &"HTML mail"& (including that sent with
35354 alternative plain text), while allowing HTML files to be attached. HTML
35355 coverletter mail attached to non-HTML coverletter mail will also be allowed:
35356 .code
35357 deny !condition = $mime_is_rfc822
35358      condition = $mime_is_coverletter
35359      condition = ${if eq{$mime_content_type}{text/html}{1}{0}}
35360      message = HTML mail is not accepted here
35361 .endd
35362
35363 .vitem &$mime_is_multipart$&
35364 .vindex &$mime_is_multipart$&
35365 This variable has the value 1 (true) when the current part has the main type
35366 &"multipart"&, for example, &"multipart/alternative"& or &"multipart/mixed"&.
35367 Since multipart entities only serve as containers for other parts, you may not
35368 want to carry out specific actions on them.
35369
35370 .vitem &$mime_is_rfc822$&
35371 .vindex &$mime_is_rfc822$&
35372 This variable has the value 1 (true) if the current part is not a part of the
35373 checked message itself, but part of an attached message. Attached message
35374 decoding is fully recursive.
35375
35376 .vitem &$mime_part_count$&
35377 .vindex &$mime_part_count$&
35378 This variable is a counter that is raised for each processed MIME part. It
35379 starts at zero for the very first part (which is usually a multipart). The
35380 counter is per-message, so it is reset when processing RFC822 attachments (see
35381 &$mime_is_rfc822$&). The counter stays set after &%acl_smtp_mime%& is
35382 complete, so you can use it in the DATA ACL to determine the number of MIME
35383 parts of a message. For non-MIME messages, this variable contains the value -1.
35384 .endlist
35385
35386
35387
35388 .section "Scanning with regular expressions" "SECTscanregex"
35389 .cindex "content scanning" "with regular expressions"
35390 .cindex "regular expressions" "content scanning with"
35391 You can specify your own custom regular expression matches on the full body of
35392 the message, or on individual MIME parts.
35393
35394 The &%regex%& condition takes one or more regular expressions as arguments and
35395 matches them against the full message (when called in the DATA ACL) or a raw
35396 MIME part (when called in the MIME ACL). The &%regex%& condition matches
35397 linewise, with a maximum line length of 32K characters. That means you cannot
35398 have multiline matches with the &%regex%& condition.
35399
35400 The &%mime_regex%& condition can be called only in the MIME ACL. It matches up
35401 to 32K of decoded content (the whole content at once, not linewise). If the
35402 part has not been decoded with the &%decode%& modifier earlier in the ACL, it
35403 is decoded automatically when &%mime_regex%& is executed (using default path
35404 and filename values). If the decoded data is larger than  32K, only the first
35405 32K characters are checked.
35406
35407 The regular expressions are passed as a colon-separated list. To include a
35408 literal colon, you must double it. Since the whole right-hand side string is
35409 expanded before being used, you must also escape dollar signs and backslashes
35410 with more backslashes, or use the &`\N`& facility to disable expansion.
35411 Here is a simple example that contains two regular expressions:
35412 .code
35413 deny regex = [Mm]ortgage : URGENT BUSINESS PROPOSAL
35414      message = contains blacklisted regex ($regex_match_string)
35415 .endd
35416 The conditions returns true if any one of the regular expressions matches. The
35417 &$regex_match_string$& expansion variable is then set up and contains the
35418 matching regular expression.
35419 The expansion variables &$regex1$& &$regex2$& etc
35420 are set to any substrings captured by the regular expression.
35421
35422 &*Warning*&: With large messages, these conditions can be fairly
35423 CPU-intensive.
35424
35425 .ecindex IIDcosca
35426
35427
35428
35429
35430 . ////////////////////////////////////////////////////////////////////////////
35431 . ////////////////////////////////////////////////////////////////////////////
35432
35433 .chapter "Adding a local scan function to Exim" "CHAPlocalscan" &&&
35434          "Local scan function"
35435 .scindex IIDlosca "&[local_scan()]& function" "description of"
35436 .cindex "customizing" "input scan using C function"
35437 .cindex "policy control" "by local scan function"
35438 In these days of email worms, viruses, and ever-increasing spam, some sites
35439 want to apply a lot of checking to messages before accepting them.
35440
35441 The content scanning extension (chapter &<<CHAPexiscan>>&) has facilities for
35442 passing messages to external virus and spam scanning software. You can also do
35443 a certain amount in Exim itself through string expansions and the &%condition%&
35444 condition in the ACL that runs after the SMTP DATA command or the ACL for
35445 non-SMTP messages (see chapter &<<CHAPACL>>&), but this has its limitations.
35446
35447 To allow for further customization to a site's own requirements, there is the
35448 possibility of linking Exim with a private message scanning function, written
35449 in C. If you want to run code that is written in something other than C, you
35450 can of course use a little C stub to call it.
35451
35452 The local scan function is run once for every incoming message, at the point
35453 when Exim is just about to accept the message.
35454 It can therefore be used to control non-SMTP messages from local processes as
35455 well as messages arriving via SMTP.
35456
35457 Exim applies a timeout to calls of the local scan function, and there is an
35458 option called &%local_scan_timeout%& for setting it. The default is 5 minutes.
35459 Zero means &"no timeout"&.
35460 Exim also sets up signal handlers for SIGSEGV, SIGILL, SIGFPE, and SIGBUS
35461 before calling the local scan function, so that the most common types of crash
35462 are caught. If the timeout is exceeded or one of those signals is caught, the
35463 incoming message is rejected with a temporary error if it is an SMTP message.
35464 For a non-SMTP message, the message is dropped and Exim ends with a non-zero
35465 code. The incident is logged on the main and reject logs.
35466
35467
35468
35469 .section "Building Exim to use a local scan function" "SECID207"
35470 .cindex "&[local_scan()]& function" "building Exim to use"
35471 To make use of the local scan function feature, you must tell Exim where your
35472 function is before building Exim, by setting
35473 both HAVE_LOCAL_SCAN and
35474 LOCAL_SCAN_SOURCE in your
35475 &_Local/Makefile_&. A recommended place to put it is in the &_Local_&
35476 directory, so you might set
35477 .code
35478 HAVE_LOCAL_SCAN=yes
35479 LOCAL_SCAN_SOURCE=Local/local_scan.c
35480 .endd
35481 for example. The function must be called &[local_scan()]&;
35482 the source file(s) for it should first #define LOCAL_SCAN
35483 and then #include "local_scan.h".
35484 It is called by
35485 Exim after it has received a message, when the success return code is about to
35486 be sent. This is after all the ACLs have been run. The return code from your
35487 function controls whether the message is actually accepted or not. There is a
35488 commented template function (that just accepts the message) in the file
35489 _src/local_scan.c_.
35490
35491 If you want to make use of Exim's runtime configuration file to set options
35492 for your &[local_scan()]& function, you must also set
35493 .code
35494 LOCAL_SCAN_HAS_OPTIONS=yes
35495 .endd
35496 in &_Local/Makefile_& (see section &<<SECTconoptloc>>& below).
35497
35498
35499
35500
35501 .section "API for local_scan()" "SECTapiforloc"
35502 .cindex "&[local_scan()]& function" "API description"
35503 .cindex &%dlfunc%& "API description"
35504 You must include this line near the start of your code:
35505 .code
35506 #define LOCAL_SCAN
35507 #include "local_scan.h"
35508 .endd
35509 This header file defines a number of variables and other values, and the
35510 prototype for the function itself. Exim is coded to use unsigned char values
35511 almost exclusively, and one of the things this header defines is a shorthand
35512 for &`unsigned char`& called &`uschar`&.
35513 It also makes available the following macro definitions, to simplify casting character
35514 strings and pointers to character strings:
35515 .code
35516 #define CS   (char *)
35517 #define CCS  (const char *)
35518 #define CSS  (char **)
35519 #define US   (unsigned char *)
35520 #define CUS  (const unsigned char *)
35521 #define USS  (unsigned char **)
35522 .endd
35523 The function prototype for &[local_scan()]& is:
35524 .code
35525 extern int local_scan(int fd, uschar **return_text);
35526 .endd
35527 The arguments are as follows:
35528
35529 .ilist
35530 &%fd%& is a file descriptor for the file that contains the body of the message
35531 (the -D file). The file is open for reading and writing, but updating it is not
35532 recommended. &*Warning*&: You must &'not'& close this file descriptor.
35533
35534 The descriptor is positioned at character 26 of the file, which is the first
35535 character of the body itself, because the first 26 characters (19 characters
35536 before Exim  4.97) are the message id followed by &`-D`& and a newline.
35537 If you rewind the file, you should use the
35538 macro SPOOL_DATA_START_OFFSET to reset to the start of the data, just in
35539 case this changes in some future version.
35540 .next
35541 &%return_text%& is an address which you can use to return a pointer to a text
35542 string at the end of the function. The value it points to on entry is NULL.
35543 .endlist
35544
35545 The function must return an &%int%& value which is one of the following macros:
35546
35547 .vlist
35548 .vitem &`LOCAL_SCAN_ACCEPT`&
35549 .vindex "&$local_scan_data$&"
35550 The message is accepted. If you pass back a string of text, it is saved with
35551 the message, and made available in the variable &$local_scan_data$&. No
35552 newlines are permitted (if there are any, they are turned into spaces) and the
35553 maximum length of text is 1000 characters.
35554
35555 .vitem &`LOCAL_SCAN_ACCEPT_FREEZE`&
35556 This behaves as LOCAL_SCAN_ACCEPT, except that the accepted message is
35557 queued without immediate delivery, and is frozen.
35558
35559 .vitem &`LOCAL_SCAN_ACCEPT_QUEUE`&
35560 This behaves as LOCAL_SCAN_ACCEPT, except that the accepted message is
35561 queued without immediate delivery.
35562
35563 .vitem &`LOCAL_SCAN_REJECT`&
35564 The message is rejected; the returned text is used as an error message which is
35565 passed back to the sender and which is also logged. Newlines are permitted &--
35566 they cause a multiline response for SMTP rejections, but are converted to
35567 &`\n`& in log lines. If no message is given, &"Administrative prohibition"& is
35568 used.
35569
35570 .vitem &`LOCAL_SCAN_TEMPREJECT`&
35571 The message is temporarily rejected; the returned text is used as an error
35572 message as for LOCAL_SCAN_REJECT. If no message is given, &"Temporary local
35573 problem"& is used.
35574
35575 .vitem &`LOCAL_SCAN_REJECT_NOLOGHDR`&
35576 This behaves as LOCAL_SCAN_REJECT, except that the header of the rejected
35577 message is not written to the reject log. It has the effect of unsetting the
35578 &%rejected_header%& log selector for just this rejection. If
35579 &%rejected_header%& is already unset (see the discussion of the
35580 &%log_selection%& option in section &<<SECTlogselector>>&), this code is the
35581 same as LOCAL_SCAN_REJECT.
35582
35583 .vitem &`LOCAL_SCAN_TEMPREJECT_NOLOGHDR`&
35584 This code is a variation of LOCAL_SCAN_TEMPREJECT in the same way that
35585 LOCAL_SCAN_REJECT_NOLOGHDR is a variation of LOCAL_SCAN_REJECT.
35586 .endlist
35587
35588 If the message is not being received by interactive SMTP, rejections are
35589 reported by writing to &%stderr%& or by sending an email, as configured by the
35590 &%-oe%& command line options.
35591
35592
35593
35594 .section "Configuration options for local_scan()" "SECTconoptloc"
35595 .cindex "&[local_scan()]& function" "configuration options"
35596 It is possible to have option settings in the main configuration file
35597 that set values in static variables in the &[local_scan()]& module. If you
35598 want to do this, you must have the line
35599 .code
35600 LOCAL_SCAN_HAS_OPTIONS=yes
35601 .endd
35602 in your &_Local/Makefile_& when you build Exim. (This line is in
35603 &_OS/Makefile-Default_&, commented out). Then, in the &[local_scan()]& source
35604 file, you must define static variables to hold the option values, and a table
35605 to define them.
35606
35607 The table must be a vector called &%local_scan_options%&, of type
35608 &`optionlist`&. Each entry is a triplet, consisting of a name, an option type,
35609 and a pointer to the variable that holds the value. The entries must appear in
35610 alphabetical order. Following &%local_scan_options%& you must also define a
35611 variable called &%local_scan_options_count%& that contains the number of
35612 entries in the table. Here is a short example, showing two kinds of option:
35613 .code
35614 static int my_integer_option = 42;
35615 static uschar *my_string_option = US"a default string";
35616
35617 optionlist local_scan_options[] = {
35618   { "my_integer", opt_int,       &my_integer_option },
35619   { "my_string",  opt_stringptr, &my_string_option }
35620 };
35621
35622 int local_scan_options_count =
35623   sizeof(local_scan_options)/sizeof(optionlist);
35624 .endd
35625 The values of the variables can now be changed from Exim's runtime
35626 configuration file by including a local scan section as in this example:
35627 .code
35628 begin local_scan
35629 my_integer = 99
35630 my_string = some string of text...
35631 .endd
35632 The available types of option data are as follows:
35633
35634 .vlist
35635 .vitem &*opt_bool*&
35636 This specifies a boolean (true/false) option. The address should point to a
35637 variable of type &`BOOL`&, which will be set to TRUE or FALSE, which are macros
35638 that are defined as &"1"& and &"0"&, respectively. If you want to detect
35639 whether such a variable has been set at all, you can initialize it to
35640 TRUE_UNSET. (BOOL variables are integers underneath, so can hold more than two
35641 values.)
35642
35643 .vitem &*opt_fixed*&
35644 This specifies a fixed point number, such as is used for load averages.
35645 The address should point to a variable of type &`int`&. The value is stored
35646 multiplied by 1000, so, for example, 1.4142 is truncated and stored as 1414.
35647
35648 .vitem &*opt_int*&
35649 This specifies an integer; the address should point to a variable of type
35650 &`int`&. The value may be specified in any of the integer formats accepted by
35651 Exim.
35652
35653 .vitem &*opt_mkint*&
35654 This is the same as &%opt_int%&, except that when such a value is output in a
35655 &%-bP%& listing, if it is an exact number of kilobytes or megabytes, it is
35656 printed with the suffix K or M.
35657
35658 .vitem &*opt_octint*&
35659 This also specifies an integer, but the value is always interpreted as an
35660 octal integer, whether or not it starts with the digit zero, and it is
35661 always output in octal.
35662
35663 .vitem &*opt_stringptr*&
35664 This specifies a string value; the address must be a pointer to a
35665 variable that points to a string (for example, of type &`uschar *`&).
35666
35667 .vitem &*opt_time*&
35668 This specifies a time interval value. The address must point to a variable of
35669 type &`int`&. The value that is placed there is a number of seconds.
35670 .endlist
35671
35672 If the &%-bP%& command line option is followed by &`local_scan`&, Exim prints
35673 out the values of all the &[local_scan()]& options.
35674
35675
35676
35677 .section "Available Exim variables" "SECID208"
35678 .cindex "&[local_scan()]& function" "available Exim variables"
35679 The header &_local_scan.h_& gives you access to a number of C variables. These
35680 are the only ones that are guaranteed to be maintained from release to release.
35681 Note, however, that you can obtain the value of any Exim expansion variable,
35682 including &$recipients$&, by calling &'expand_string()'&. The exported
35683 C variables are as follows:
35684
35685 .vlist
35686 .vitem &*int&~body_linecount*&
35687 This variable contains the number of lines in the message's body.
35688 It is not valid if the &%spool_wireformat%& option is used.
35689
35690 .vitem &*int&~body_zerocount*&
35691 This variable contains the number of binary zero bytes in the message's body.
35692 It is not valid if the &%spool_wireformat%& option is used.
35693
35694 .vitem &*unsigned&~int&~debug_selector*&
35695 This variable is set to zero when no debugging is taking place. Otherwise, it
35696 is a bitmap of debugging selectors. Two bits are identified for use in
35697 &[local_scan()]&; they are defined as macros:
35698
35699 .ilist
35700 The &`D_v`& bit is set when &%-v%& was present on the command line. This is a
35701 testing option that is not privileged &-- any caller may set it. All the
35702 other selector bits can be set only by admin users.
35703
35704 .next
35705 The &`D_local_scan`& bit is provided for use by &[local_scan()]&; it is set
35706 by the &`+local_scan`& debug selector. It is not included in the default set
35707 of debugging bits.
35708 .endlist ilist
35709
35710 Thus, to write to the debugging output only when &`+local_scan`& has been
35711 selected, you should use code like this:
35712 .code
35713 if ((debug_selector & D_local_scan) != 0)
35714   debug_printf("xxx", ...);
35715 .endd
35716 .vitem &*uschar&~*expand_string_message*&
35717 After a failing call to &'expand_string()'& (returned value NULL), the
35718 variable &%expand_string_message%& contains the error message, zero-terminated.
35719
35720 .vitem &*header_line&~*header_list*&
35721 A pointer to a chain of header lines. The &%header_line%& structure is
35722 discussed below.
35723
35724 .vitem &*header_line&~*header_last*&
35725 A pointer to the last of the header lines.
35726
35727 .vitem &*const&~uschar&~*headers_charset*&
35728 The value of the &%headers_charset%& configuration option.
35729
35730 .vitem &*BOOL&~host_checking*&
35731 This variable is TRUE during a host checking session that is initiated by the
35732 &%-bh%& command line option.
35733
35734 .vitem &*uschar&~*interface_address*&
35735 The IP address of the interface that received the message, as a string. This
35736 is NULL for locally submitted messages.
35737
35738 .vitem &*int&~interface_port*&
35739 The port on which this message was received. When testing with the &%-bh%&
35740 command line option, the value of this variable is -1 unless a port has been
35741 specified via the &%-oMi%& option.
35742
35743 .vitem &*uschar&~*message_id*&
35744 This variable contains Exim's message id for the incoming message (the value of
35745 &$message_exim_id$&) as a zero-terminated string.
35746
35747 .vitem &*uschar&~*received_protocol*&
35748 The name of the protocol by which the message was received.
35749
35750 .vitem &*int&~recipients_count*&
35751 The number of accepted recipients.
35752
35753 .vitem &*recipient_item&~*recipients_list*&
35754 .cindex "recipient" "adding in local scan"
35755 .cindex "recipient" "removing in local scan"
35756 The list of accepted recipients, held in a vector of length
35757 &%recipients_count%&. The &%recipient_item%& structure is discussed below. You
35758 can add additional recipients by calling &'receive_add_recipient()'& (see
35759 below). You can delete recipients by removing them from the vector and
35760 adjusting the value in &%recipients_count%&. In particular, by setting
35761 &%recipients_count%& to zero you remove all recipients. If you then return the
35762 value &`LOCAL_SCAN_ACCEPT`&, the message is accepted, but immediately
35763 blackholed. To replace the recipients, you can set &%recipients_count%& to zero
35764 and then call &'receive_add_recipient()'& as often as needed.
35765
35766 .vitem &*uschar&~*sender_address*&
35767 The envelope sender address. For bounce messages this is the empty string.
35768
35769 .vitem &*uschar&~*sender_host_address*&
35770 The IP address of the sending host, as a string. This is NULL for
35771 locally-submitted messages.
35772
35773 .vitem &*uschar&~*sender_host_authenticated*&
35774 The name of the authentication mechanism that was used, or NULL if the message
35775 was not received over an authenticated SMTP connection.
35776
35777 .vitem &*uschar&~*sender_host_name*&
35778 The name of the sending host, if known.
35779
35780 .vitem &*int&~sender_host_port*&
35781 The port on the sending host.
35782
35783 .vitem &*BOOL&~smtp_input*&
35784 This variable is TRUE for all SMTP input, including BSMTP.
35785
35786 .vitem &*BOOL&~smtp_batched_input*&
35787 This variable is TRUE for BSMTP input.
35788
35789 .vitem &*int&~store_pool*&
35790 The contents of this variable control which pool of memory is used for new
35791 requests. See section &<<SECTmemhanloc>>& for details.
35792 .endlist
35793
35794
35795 .section "Structure of header lines" "SECID209"
35796 The &%header_line%& structure contains the members listed below.
35797 You can add additional header lines by calling the &'header_add()'& function
35798 (see below). You can cause header lines to be ignored (deleted) by setting
35799 their type to *.
35800
35801
35802 .vlist
35803 .vitem &*struct&~header_line&~*next*&
35804 A pointer to the next header line, or NULL for the last line.
35805
35806 .vitem &*int&~type*&
35807 A code identifying certain headers that Exim recognizes. The codes are printing
35808 characters, and are documented in chapter &<<CHAPspool>>& of this manual.
35809 Notice in particular that any header line whose type is * is not transmitted
35810 with the message. This flagging is used for header lines that have been
35811 rewritten, or are to be removed (for example, &'Envelope-sender:'& header
35812 lines.) Effectively, * means &"deleted"&.
35813
35814 .vitem &*int&~slen*&
35815 The number of characters in the header line, including the terminating and any
35816 internal newlines.
35817
35818 .vitem &*uschar&~*text*&
35819 A pointer to the text of the header. It always ends with a newline, followed by
35820 a zero byte. Internal newlines are preserved.
35821 .endlist
35822
35823
35824
35825 .section "Structure of recipient items" "SECID210"
35826 The &%recipient_item%& structure contains these members:
35827
35828 .vlist
35829 .vitem &*uschar&~*address*&
35830 This is a pointer to the recipient address as it was received.
35831
35832 .vitem &*int&~pno*&
35833 This is used in later Exim processing when top level addresses are created by
35834 the &%one_time%& option. It is not relevant at the time &[local_scan()]& is run
35835 and must always contain -1 at this stage.
35836
35837 .vitem &*uschar&~*errors_to*&
35838 If this value is not NULL, bounce messages caused by failing to deliver to the
35839 recipient are sent to the address it contains. In other words, it overrides the
35840 envelope sender for this one recipient. (Compare the &%errors_to%& generic
35841 router option.) If a &[local_scan()]& function sets an &%errors_to%& field to
35842 an unqualified address, Exim qualifies it using the domain from
35843 &%qualify_recipient%&. When &[local_scan()]& is called, the &%errors_to%& field
35844 is NULL for all recipients.
35845 .endlist
35846
35847
35848
35849 .section "Available Exim functions" "SECID211"
35850 .cindex "&[local_scan()]& function" "available Exim functions"
35851 The header &_local_scan.h_& gives you access to a number of Exim functions.
35852 These are the only ones that are guaranteed to be maintained from release to
35853 release:
35854
35855 .vlist
35856 .vitem "&*pid_t&~child_open(uschar&~**argv,&~uschar&~**envp,&~int&~newumask,&&&
35857        &~int&~*infdptr,&~int&~*outfdptr, &~&~BOOL&~make_leader)*&"
35858
35859 This function creates a child process that runs the command specified by
35860 &%argv%&. The environment for the process is specified by &%envp%&, which can
35861 be NULL if no environment variables are to be passed. A new umask is supplied
35862 for the process in &%newumask%&.
35863
35864 Pipes to the standard input and output of the new process are set up
35865 and returned to the caller via the &%infdptr%& and &%outfdptr%& arguments. The
35866 standard error is cloned to the standard output. If there are any file
35867 descriptors &"in the way"& in the new process, they are closed. If the final
35868 argument is TRUE, the new process is made into a process group leader.
35869
35870 The function returns the pid of the new process, or -1 if things go wrong.
35871
35872 .vitem &*int&~child_close(pid_t&~pid,&~int&~timeout)*&
35873 This function waits for a child process to terminate, or for a timeout (in
35874 seconds) to expire. A timeout value of zero means wait as long as it takes. The
35875 return value is as follows:
35876
35877 .ilist
35878 >= 0
35879
35880 The process terminated by a normal exit and the value is the process
35881 ending status.
35882
35883 .next
35884 < 0 and > &--256
35885
35886 The process was terminated by a signal and the value is the negation of the
35887 signal number.
35888
35889 .next
35890 &--256
35891
35892 The process timed out.
35893 .next
35894 &--257
35895
35896 The was some other error in wait(); &%errno%& is still set.
35897 .endlist
35898
35899 .vitem &*pid_t&~child_open_exim(int&~*fd)*&
35900 This function provide you with a means of submitting a new message to
35901 Exim. (Of course, you can also call &_/usr/sbin/sendmail_& yourself if you
35902 want, but this packages it all up for you.) The function creates a pipe,
35903 forks a subprocess that is running
35904 .code
35905 exim -t -oem -oi -f <>
35906 .endd
35907 and returns to you (via the &`int *`& argument) a file descriptor for the pipe
35908 that is connected to the standard input. The yield of the function is the PID
35909 of the subprocess. You can then write a message to the file descriptor, with
35910 recipients in &'To:'&, &'Cc:'&, and/or &'Bcc:'& header lines.
35911
35912 When you have finished, call &'child_close()'& to wait for the process to
35913 finish and to collect its ending status. A timeout value of zero is usually
35914 fine in this circumstance. Unless you have made a mistake with the recipient
35915 addresses, you should get a return code of zero.
35916
35917
35918 .vitem &*pid_t&~child_open_exim2(int&~*fd,&~uschar&~*sender,&~uschar&~&&&
35919        *sender_authentication)*&
35920 This function is a more sophisticated version of &'child_open()'&. The command
35921 that it runs is:
35922 .display
35923 &`exim -t -oem -oi -f `&&'sender'&&` -oMas `&&'sender_authentication'&
35924 .endd
35925 The third argument may be NULL, in which case the &%-oMas%& option is omitted.
35926
35927
35928 .vitem &*void&~debug_printf(char&~*,&~...)*&
35929 This is Exim's debugging function, with arguments as for &'(printf()'&. The
35930 output is written to the standard error stream. If no debugging is selected,
35931 calls to &'debug_printf()'& have no effect. Normally, you should make calls
35932 conditional on the &`local_scan`& debug selector by coding like this:
35933 .code
35934 if ((debug_selector & D_local_scan) != 0)
35935   debug_printf("xxx", ...);
35936 .endd
35937
35938 .vitem &*uschar&~*expand_string(uschar&~*string)*&
35939 This is an interface to Exim's string expansion code. The return value is the
35940 expanded string, or NULL if there was an expansion failure.
35941 The C variable &%expand_string_message%& contains an error message after an
35942 expansion failure. If expansion does not change the string, the return value is
35943 the pointer to the input string. Otherwise, the return value points to a new
35944 block of memory that was obtained by a call to &'store_get()'&. See section
35945 &<<SECTmemhanloc>>& below for a discussion of memory handling.
35946
35947 .vitem &*void&~header_add(int&~type,&~char&~*format,&~...)*&
35948 This function allows you to an add additional header line at the end of the
35949 existing ones. The first argument is the type, and should normally be a space
35950 character. The second argument is a format string and any number of
35951 substitution arguments as for &[sprintf()]&. You may include internal newlines
35952 if you want, and you must ensure that the string ends with a newline.
35953
35954 .vitem "&*void&~header_add_at_position(BOOL&~after,&~uschar&~*name,&~&&&
35955         BOOL&~topnot,&~int&~type,&~char&~*format, &~&~...)*&"
35956 This function adds a new header line at a specified point in the header
35957 chain. The header itself is specified as for &'header_add()'&.
35958
35959 If &%name%& is NULL, the new header is added at the end of the chain if
35960 &%after%& is true, or at the start if &%after%& is false. If &%name%& is not
35961 NULL, the header lines are searched for the first non-deleted header that
35962 matches the name. If one is found, the new header is added before it if
35963 &%after%& is false. If &%after%& is true, the new header is added after the
35964 found header and any adjacent subsequent ones with the same name (even if
35965 marked &"deleted"&). If no matching non-deleted header is found, the &%topnot%&
35966 option controls where the header is added. If it is true, addition is at the
35967 top; otherwise at the bottom. Thus, to add a header after all the &'Received:'&
35968 headers, or at the top if there are no &'Received:'& headers, you could use
35969 .code
35970 header_add_at_position(TRUE, US"Received", TRUE,
35971   ' ', "X-xxx: ...");
35972 .endd
35973 Normally, there is always at least one non-deleted &'Received:'& header, but
35974 there may not be if &%received_header_text%& expands to an empty string.
35975
35976
35977 .vitem &*void&~header_remove(int&~occurrence,&~uschar&~*name)*&
35978 This function removes header lines. If &%occurrence%& is zero or negative, all
35979 occurrences of the header are removed. If occurrence is greater than zero, that
35980 particular instance of the header is removed. If no header(s) can be found that
35981 match the specification, the function does nothing.
35982
35983
35984 .vitem "&*BOOL&~header_testname(header_line&~*hdr,&~uschar&~*name,&~&&&
35985         int&~length,&~BOOL&~notdel)*&"
35986 This function tests whether the given header has the given name. It is not just
35987 a string comparison, because white space is permitted between the name and the
35988 colon. If the &%notdel%& argument is true, a false return is forced for all
35989 &"deleted"& headers; otherwise they are not treated specially. For example:
35990 .code
35991 if (header_testname(h, US"X-Spam", 6, TRUE)) ...
35992 .endd
35993 .vitem &*uschar&~*lss_b64encode(uschar&~*cleartext,&~int&~length)*&
35994 .cindex "base64 encoding" "functions for &[local_scan()]& use"
35995 This function base64-encodes a string, which is passed by address and length.
35996 The text may contain bytes of any value, including zero. The result is passed
35997 back in dynamic memory that is obtained by calling &'store_get()'&. It is
35998 zero-terminated.
35999
36000 .vitem &*int&~lss_b64decode(uschar&~*codetext,&~uschar&~**cleartext)*&
36001 This function decodes a base64-encoded string. Its arguments are a
36002 zero-terminated base64-encoded string and the address of a variable that is set
36003 to point to the result, which is in dynamic memory. The length of the decoded
36004 string is the yield of the function. If the input is invalid base64 data, the
36005 yield is -1. A zero byte is added to the end of the output string to make it
36006 easy to interpret as a C string (assuming it contains no zeros of its own). The
36007 added zero byte is not included in the returned count.
36008
36009 .vitem &*int&~lss_match_domain(uschar&~*domain,&~uschar&~*list)*&
36010 This function checks for a match in a domain list. Domains are always
36011 matched caselessly. The return value is one of the following:
36012 .itable none 0 0 2 15* left 85* left
36013 .irow &`OK`&    "match succeeded"
36014 .irow &`FAIL`&  "match failed"
36015 .irow &`DEFER`& "match deferred"
36016 .endtable
36017 DEFER is usually caused by some kind of lookup defer, such as the
36018 inability to contact a database.
36019
36020 .vitem "&*int&~lss_match_local_part(uschar&~*localpart,&~uschar&~*list,&~&&&
36021         BOOL&~caseless)*&"
36022 This function checks for a match in a local part list. The third argument
36023 controls case-sensitivity. The return values are as for
36024 &'lss_match_domain()'&.
36025
36026 .vitem "&*int&~lss_match_address(uschar&~*address,&~uschar&~*list,&~&&&
36027         BOOL&~caseless)*&"
36028 This function checks for a match in an address list. The third argument
36029 controls the case-sensitivity of the local part match. The domain is always
36030 matched caselessly. The return values are as for &'lss_match_domain()'&.
36031
36032 .vitem "&*int&~lss_match_host(uschar&~*host_name,&~uschar&~*host_address,&~&&&
36033         uschar&~*list)*&"
36034 This function checks for a match in a host list. The most common usage is
36035 expected to be
36036 .code
36037 lss_match_host(sender_host_name, sender_host_address, ...)
36038 .endd
36039 .vindex "&$sender_host_address$&"
36040 An empty address field matches an empty item in the host list. If the host name
36041 is NULL, the name corresponding to &$sender_host_address$& is automatically
36042 looked up if a host name is required to match an item in the list. The return
36043 values are as for &'lss_match_domain()'&, but in addition, &'lss_match_host()'&
36044 returns ERROR in the case when it had to look up a host name, but the lookup
36045 failed.
36046
36047 .vitem "&*void&~log_write(unsigned&~int&~selector,&~int&~which,&~char&~&&&
36048         *format,&~...)*&"
36049 This function writes to Exim's log files. The first argument should be zero (it
36050 is concerned with &%log_selector%&). The second argument can be &`LOG_MAIN`& or
36051 &`LOG_REJECT`& or &`LOG_PANIC`& or the inclusive &"or"& of any combination of
36052 them. It specifies to which log or logs the message is written. The remaining
36053 arguments are a format and relevant insertion arguments. The string should not
36054 contain any newlines, not even at the end.
36055
36056
36057 .vitem &*void&~receive_add_recipient(uschar&~*address,&~int&~pno)*&
36058 This function adds an additional recipient to the message. The first argument
36059 is the recipient address. If it is unqualified (has no domain), it is qualified
36060 with the &%qualify_recipient%& domain. The second argument must always be -1.
36061
36062 This function does not allow you to specify a private &%errors_to%& address (as
36063 described with the structure of &%recipient_item%& above), because it pre-dates
36064 the addition of that field to the structure. However, it is easy to add such a
36065 value afterwards. For example:
36066 .code
36067  receive_add_recipient(US"monitor@mydom.example", -1);
36068  recipients_list[recipients_count-1].errors_to =
36069    US"postmaster@mydom.example";
36070 .endd
36071
36072 .vitem &*BOOL&~receive_remove_recipient(uschar&~*recipient)*&
36073 This is a convenience function to remove a named recipient from the list of
36074 recipients. It returns true if a recipient was removed, and false if no
36075 matching recipient could be found. The argument must be a complete email
36076 address.
36077 .endlist
36078
36079
36080 .cindex "RFC 2047"
36081 .vlist
36082 .vitem "&*uschar&~rfc2047_decode(uschar&~*string,&~BOOL&~lencheck,&&&
36083   &~uschar&~*target,&~int&~zeroval,&~int&~*lenptr, &~&~uschar&~**error)*&"
36084 This function decodes strings that are encoded according to RFC 2047. Typically
36085 these are the contents of header lines. First, each &"encoded word"& is decoded
36086 from the Q or B encoding into a byte-string. Then, if provided with the name of
36087 a charset encoding, and if the &[iconv()]& function is available, an attempt is
36088 made  to translate the result to the named character set. If this fails, the
36089 binary string is returned with an error message.
36090
36091 The first argument is the string to be decoded. If &%lencheck%& is TRUE, the
36092 maximum MIME word length is enforced. The third argument is the target
36093 encoding, or NULL if no translation is wanted.
36094
36095 .cindex "binary zero" "in RFC 2047 decoding"
36096 .cindex "RFC 2047" "binary zero in"
36097 If a binary zero is encountered in the decoded string, it is replaced by the
36098 contents of the &%zeroval%& argument. For use with Exim headers, the value must
36099 not be 0 because header lines are handled as zero-terminated strings.
36100
36101 The function returns the result of processing the string, zero-terminated; if
36102 &%lenptr%& is not NULL, the length of the result is set in the variable to
36103 which it points. When &%zeroval%& is 0, &%lenptr%& should not be NULL.
36104
36105 If an error is encountered, the function returns NULL and uses the &%error%&
36106 argument to return an error message. The variable pointed to by &%error%& is
36107 set to NULL if there is no error; it may be set non-NULL even when the function
36108 returns a non-NULL value if decoding was successful, but there was a problem
36109 with translation.
36110
36111
36112 .vitem &*int&~smtp_fflush(void)*&
36113 This function is used in conjunction with &'smtp_printf()'&, as described
36114 below.
36115
36116 .vitem &*void&~smtp_printf(char&~*,BOOL,&~...)*&
36117 The arguments of this function are almost like &[printf()]&; it writes to the SMTP
36118 output stream. You should use this function only when there is an SMTP output
36119 stream, that is, when the incoming message is being received via interactive
36120 SMTP. This is the case when &%smtp_input%& is TRUE and &%smtp_batched_input%&
36121 is FALSE. If you want to test for an incoming message from another host (as
36122 opposed to a local process that used the &%-bs%& command line option), you can
36123 test the value of &%sender_host_address%&, which is non-NULL when a remote host
36124 is involved.
36125
36126 If an SMTP TLS connection is established, &'smtp_printf()'& uses the TLS
36127 output function, so it can be used for all forms of SMTP connection.
36128
36129 The second argument is used to request that the data be buffered
36130 (when TRUE) or flushed (along with any previously buffered, when FALSE).
36131 This is advisory only, but likely to save on system-calls and packets
36132 sent when a sequence of calls to the function are made.
36133
36134 The argument was added in Exim version 4.90 - changing the API/ABI.
36135 Nobody noticed until 4.93 was imminent, at which point the
36136 ABI version number was incremented.
36137
36138 Strings that are written by &'smtp_printf()'& from within &[local_scan()]&
36139 must start with an appropriate response code: 550 if you are going to return
36140 LOCAL_SCAN_REJECT, 451 if you are going to return
36141 LOCAL_SCAN_TEMPREJECT, and 250 otherwise. Because you are writing the
36142 initial lines of a multi-line response, the code must be followed by a hyphen
36143 to indicate that the line is not the final response line. You must also ensure
36144 that the lines you write terminate with CRLF. For example:
36145 .code
36146 smtp_printf("550-this is some extra info\r\n");
36147 return LOCAL_SCAN_REJECT;
36148 .endd
36149 Note that you can also create multi-line responses by including newlines in
36150 the data returned via the &%return_text%& argument. The added value of using
36151 &'smtp_printf()'& is that, for instance, you could introduce delays between
36152 multiple output lines.
36153
36154 The &'smtp_printf()'& function does not return any error indication, because it
36155 does not
36156 guarantee a flush of
36157 pending output, and therefore does not test
36158 the state of the stream. (In the main code of Exim, flushing and error
36159 detection is done when Exim is ready for the next SMTP input command.) If
36160 you want to flush the output and check for an error (for example, the
36161 dropping of a TCP/IP connection), you can call &'smtp_fflush()'&, which has no
36162 arguments. It flushes the output stream, and returns a non-zero value if there
36163 is an error.
36164
36165 .vitem &*void&~*store_get(int,BOOL)*&
36166 This function accesses Exim's internal store (memory) manager. It gets a new
36167 chunk of memory whose size is given by the first argument.
36168 The second argument should be given as TRUE if the memory will be used for
36169 data possibly coming from an attacker (eg. the message content),
36170 FALSE if it is locally-sourced.
36171 Exim bombs out if it ever
36172 runs out of memory. See the next section for a discussion of memory handling.
36173
36174 .vitem &*void&~*store_get_perm(int,BOOL)*&
36175 This function is like &'store_get()'&, but it always gets memory from the
36176 permanent pool. See the next section for a discussion of memory handling.
36177
36178 .vitem &*uschar&~*string_copy(uschar&~*string)*&
36179 See below.
36180
36181 .vitem &*uschar&~*string_copyn(uschar&~*string,&~int&~length)*&
36182 See below.
36183
36184 .vitem &*uschar&~*string_sprintf(char&~*format,&~...)*&
36185 These three functions create strings using Exim's dynamic memory facilities.
36186 The first makes a copy of an entire string. The second copies up to a maximum
36187 number of characters, indicated by the second argument. The third uses a format
36188 and insertion arguments to create a new string. In each case, the result is a
36189 pointer to a new string in the current memory pool. See the next section for
36190 more discussion.
36191 .endlist
36192
36193
36194
36195 .section "More about Exim's memory handling" "SECTmemhanloc"
36196 .cindex "&[local_scan()]& function" "memory handling"
36197 No function is provided for freeing memory, because that is never needed.
36198 The dynamic memory that Exim uses when receiving a message is automatically
36199 recycled if another message is received by the same process (this applies only
36200 to incoming SMTP connections &-- other input methods can supply only one
36201 message at a time). After receiving the last message, a reception process
36202 terminates.
36203
36204 Because it is recycled, the normal dynamic memory cannot be used for holding
36205 data that must be preserved over a number of incoming messages on the same SMTP
36206 connection. However, Exim in fact uses two pools of dynamic memory; the second
36207 one is not recycled, and can be used for this purpose.
36208
36209 If you want to allocate memory that remains available for subsequent messages
36210 in the same SMTP connection, you should set
36211 .code
36212 store_pool = POOL_PERM
36213 .endd
36214 before calling the function that does the allocation. There is no need to
36215 restore the value if you do not need to; however, if you do want to revert to
36216 the normal pool, you can either restore the previous value of &%store_pool%& or
36217 set it explicitly to POOL_MAIN.
36218
36219 The pool setting applies to all functions that get dynamic memory, including
36220 &'expand_string()'&, &'store_get()'&, and the &'string_xxx()'& functions.
36221 There is also a convenience function called &'store_get_perm()'& that gets a
36222 block of memory from the permanent pool while preserving the value of
36223 &%store_pool%&.
36224 .ecindex IIDlosca
36225
36226
36227
36228
36229 . ////////////////////////////////////////////////////////////////////////////
36230 . ////////////////////////////////////////////////////////////////////////////
36231
36232 .chapter "System-wide message filtering" "CHAPsystemfilter"
36233 .scindex IIDsysfil1 "filter" "system filter"
36234 .scindex IIDsysfil2 "filtering all mail"
36235 .scindex IIDsysfil3 "system filter"
36236 The previous chapters (on ACLs and the local scan function) describe checks
36237 that can be applied to messages before they are accepted by a host. There is
36238 also a mechanism for checking messages once they have been received, but before
36239 they are delivered. This is called the &'system filter'&.
36240
36241 The system filter operates in a similar manner to users' filter files, but it
36242 is run just once per message (however many recipients the message has).
36243 It should not normally be used as a substitute for routing, because &%deliver%&
36244 commands in a system router provide new envelope recipient addresses.
36245 The system filter must be an Exim filter. It cannot be a Sieve filter.
36246
36247 The system filter is run at the start of a delivery attempt, before any routing
36248 is done. If a message fails to be completely delivered at the first attempt,
36249 the system filter is run again at the start of every retry.
36250 If you want your filter to do something only once per message, you can make use
36251 .cindex retry condition
36252 of the &%first_delivery%& condition in an &%if%& command in the filter to
36253 prevent it happening on retries.
36254
36255 .vindex "&$domain$&"
36256 .vindex "&$local_part$&"
36257 &*Warning*&: Because the system filter runs just once, variables that are
36258 specific to individual recipient addresses, such as &$local_part$& and
36259 &$domain$&, are not set, and the &"personal"& condition is not meaningful. If
36260 you want to run a centrally-specified filter for each recipient address
36261 independently, you can do so by setting up a suitable &(redirect)& router, as
36262 described in section &<<SECTperaddfil>>& below.
36263
36264
36265 .section "Specifying a system filter" "SECID212"
36266 .cindex "uid (user id)" "system filter"
36267 .cindex "gid (group id)" "system filter"
36268 The name of the file that contains the system filter must be specified by
36269 setting &%system_filter%&. If you want the filter to run under a uid and gid
36270 other than root, you must also set &%system_filter_user%& and
36271 &%system_filter_group%& as appropriate. For example:
36272 .code
36273 system_filter = /etc/mail/exim.filter
36274 system_filter_user = exim
36275 .endd
36276 If a system filter generates any deliveries directly to files or pipes (via the
36277 &%save%& or &%pipe%& commands), transports to handle these deliveries must be
36278 specified by setting &%system_filter_file_transport%& and
36279 &%system_filter_pipe_transport%&, respectively. Similarly,
36280 &%system_filter_reply_transport%& must be set to handle any messages generated
36281 by the &%reply%& command.
36282
36283
36284 .section "Testing a system filter" "SECID213"
36285 You can run simple tests of a system filter in the same way as for a user
36286 filter, but you should use &%-bF%& rather than &%-bf%&, so that features that
36287 are permitted only in system filters are recognized.
36288
36289 If you want to test the combined effect of a system filter and a user filter,
36290 you can use both &%-bF%& and &%-bf%& on the same command line.
36291
36292
36293
36294 .section "Contents of a system filter" "SECID214"
36295 The language used to specify system filters is the same as for users' filter
36296 files. It is described in the separate end-user document &'Exim's interface to
36297 mail filtering'&. However, there are some additional features that are
36298 available only in system filters; these are described in subsequent sections.
36299 If they are encountered in a user's filter file or when testing with &%-bf%&,
36300 they cause errors.
36301
36302 .cindex "frozen messages" "manual thaw; testing in filter"
36303 There are two special conditions which, though available in users' filter
36304 files, are designed for use in system filters. The condition &%first_delivery%&
36305 is true only for the first attempt at delivering a message, and
36306 &%manually_thawed%& is true only if the message has been frozen, and
36307 subsequently thawed by an admin user. An explicit forced delivery counts as a
36308 manual thaw, but thawing as a result of the &%auto_thaw%& setting does not.
36309
36310 &*Warning*&: If a system filter uses the &%first_delivery%& condition to
36311 specify an &"unseen"& (non-significant) delivery, and that delivery does not
36312 succeed, it will not be tried again.
36313 If you want Exim to retry an unseen delivery until it succeeds, you should
36314 arrange to set it up every time the filter runs.
36315
36316 When a system filter finishes running, the values of the variables &$n0$& &--
36317 &$n9$& are copied into &$sn0$& &-- &$sn9$& and are thereby made available to
36318 users' filter files. Thus a system filter can, for example, set up &"scores"&
36319 to which users' filter files can refer.
36320
36321
36322
36323 .section "Additional variable for system filters" "SECID215"
36324 .vindex "&$recipients$&"
36325 The expansion variable &$recipients$&, containing a list of all the recipients
36326 of the message (separated by commas and white space), is available in system
36327 filters. It is not available in users' filters for privacy reasons.
36328
36329
36330
36331 .section "Defer, freeze, and fail commands for system filters" "SECID216"
36332 .cindex "freezing messages"
36333 .cindex "message" "freezing"
36334 .cindex "message" "forced failure"
36335 .cindex "&%fail%&" "in system filter"
36336 .cindex "&%freeze%& in system filter"
36337 .cindex "&%defer%& in system filter"
36338 There are three extra commands (&%defer%&, &%freeze%& and &%fail%&) which are
36339 always available in system filters, but are not normally enabled in users'
36340 filters. (See the &%allow_defer%&, &%allow_freeze%& and &%allow_fail%& options
36341 for the &(redirect)& router.) These commands can optionally be followed by the
36342 word &%text%& and a string containing an error message, for example:
36343 .code
36344 fail text "this message looks like spam to me"
36345 .endd
36346 The keyword &%text%& is optional if the next character is a double quote.
36347
36348 The &%defer%& command defers delivery of the original recipients of the
36349 message. The &%fail%& command causes all the original recipients to be failed,
36350 and a bounce message to be created. The &%freeze%& command suspends all
36351 delivery attempts for the original recipients. In all cases, any new deliveries
36352 that are specified by the filter are attempted as normal after the filter has
36353 run.
36354
36355 The &%freeze%& command is ignored if the message has been manually unfrozen and
36356 not manually frozen since. This means that automatic freezing by a system
36357 filter can be used as a way of checking out suspicious messages. If a message
36358 is found to be all right, manually unfreezing it allows it to be delivered.
36359
36360 .cindex "log" "&%fail%& command log line"
36361 .cindex "&%fail%&" "log line; reducing"
36362 The text given with a fail command is used as part of the bounce message as
36363 well as being written to the log. If the message is quite long, this can fill
36364 up a lot of log space when such failures are common. To reduce the size of the
36365 log message, Exim interprets the text in a special way if it starts with the
36366 two characters &`<<`& and contains &`>>`& later. The text between these two
36367 strings is written to the log, and the rest of the text is used in the bounce
36368 message. For example:
36369 .code
36370 fail "<<filter test 1>>Your message is rejected \
36371      because it contains attachments that we are \
36372      not prepared to receive."
36373 .endd
36374
36375 .cindex "loop" "caused by &%fail%&"
36376 Take great care with the &%fail%& command when basing the decision to fail on
36377 the contents of the message, because the bounce message will of course include
36378 the contents of the original message and will therefore trigger the &%fail%&
36379 command again (causing a mail loop) unless steps are taken to prevent this.
36380 Testing the &%error_message%& condition is one way to prevent this. You could
36381 use, for example
36382 .code
36383 if $message_body contains "this is spam" and not error_message
36384 then fail text "spam is not wanted here" endif
36385 .endd
36386 though of course that might let through unwanted bounce messages. The
36387 alternative is clever checking of the body and/or headers to detect bounces
36388 generated by the filter.
36389
36390 The interpretation of a system filter file ceases after a
36391 &%defer%&,
36392 &%freeze%&, or &%fail%& command is obeyed. However, any deliveries that were
36393 set up earlier in the filter file are honoured, so you can use a sequence such
36394 as
36395 .code
36396 mail ...
36397 freeze
36398 .endd
36399 to send a specified message when the system filter is freezing (or deferring or
36400 failing) a message. The normal deliveries for the message do not, of course,
36401 take place.
36402
36403
36404
36405 .section "Adding and removing headers in a system filter" "SECTaddremheasys"
36406 .cindex "header lines" "adding; in system filter"
36407 .cindex "header lines" "removing; in system filter"
36408 .cindex "filter" "header lines; adding/removing"
36409 Two filter commands that are available only in system filters are:
36410 .code
36411 headers add <string>
36412 headers remove <string>
36413 .endd
36414 The argument for the &%headers add%& is a string that is expanded and then
36415 added to the end of the message's headers. It is the responsibility of the
36416 filter maintainer to make sure it conforms to RFC 2822 syntax. Leading white
36417 space is ignored, and if the string is otherwise empty, or if the expansion is
36418 forced to fail, the command has no effect.
36419
36420 You can use &"\n"& within the string, followed by white space, to specify
36421 continued header lines. More than one header may be added in one command by
36422 including &"\n"& within the string without any following white space. For
36423 example:
36424 .code
36425 headers add "X-header-1: ....\n  \
36426              continuation of X-header-1 ...\n\
36427              X-header-2: ...."
36428 .endd
36429 Note that the header line continuation white space after the first newline must
36430 be placed before the backslash that continues the input string, because white
36431 space after input continuations is ignored.
36432
36433 The argument for &%headers remove%& is a colon-separated list of header names.
36434 This command applies only to those headers that are stored with the message;
36435 those that are added at delivery time (such as &'Envelope-To:'& and
36436 &'Return-Path:'&) cannot be removed by this means. If there is more than one
36437 header with the same name, they are all removed.
36438
36439 The &%headers%& command in a system filter makes an immediate change to the set
36440 of header lines that was received with the message (with possible additions
36441 from ACL processing). Subsequent commands in the system filter operate on the
36442 modified set, which also forms the basis for subsequent message delivery.
36443 Unless further modified during routing or transporting, this set of headers is
36444 used for all recipients of the message.
36445
36446 During routing and transporting, the variables that refer to the contents of
36447 header lines refer only to those lines that are in this set. Thus, header lines
36448 that are added by a system filter are visible to users' filter files and to all
36449 routers and transports. This contrasts with the manipulation of header lines by
36450 routers and transports, which is not immediate, but which instead is saved up
36451 until the message is actually being written (see section
36452 &<<SECTheadersaddrem>>&).
36453
36454 If the message is not delivered at the first attempt, header lines that were
36455 added by the system filter are stored with the message, and so are still
36456 present at the next delivery attempt. Header lines that were removed are still
36457 present, but marked &"deleted"& so that they are not transported with the
36458 message. For this reason, it is usual to make the &%headers%& command
36459 conditional on &%first_delivery%& so that the set of header lines is not
36460 modified more than once.
36461
36462 Because header modification in a system filter acts immediately, you have to
36463 use an indirect approach if you want to modify the contents of a header line.
36464 For example:
36465 .code
36466 headers add "Old-Subject: $h_subject:"
36467 headers remove "Subject"
36468 headers add "Subject: new subject (was: $h_old-subject:)"
36469 headers remove "Old-Subject"
36470 .endd
36471
36472
36473
36474 .section "Setting an errors address in a system filter" "SECID217"
36475 .cindex "envelope from"
36476 .cindex "envelope sender"
36477 In a system filter, if a &%deliver%& command is followed by
36478 .code
36479 errors_to <some address>
36480 .endd
36481 in order to change the envelope sender (and hence the error reporting) for that
36482 delivery, any address may be specified. (In a user filter, only the current
36483 user's address can be set.) For example, if some mail is being monitored, you
36484 might use
36485 .code
36486 unseen deliver monitor@spying.example errors_to root@local.example
36487 .endd
36488 to take a copy which would not be sent back to the normal error reporting
36489 address if its delivery failed.
36490
36491
36492
36493 .section "Per-address filtering" "SECTperaddfil"
36494 .vindex "&$domain_data$&"
36495 .vindex "&$local_part_data$&"
36496 In contrast to the system filter, which is run just once per message for each
36497 delivery attempt, it is also possible to set up a system-wide filtering
36498 operation that runs once for each recipient address. In this case, variables
36499 such as &$local_part_data$& and &$domain_data$& can be used,
36500 and indeed, the choice of filter file could be made dependent on them.
36501 This is an example of a router which implements such a filter:
36502 .code
36503 central_filter:
36504   check_local_user
36505   driver = redirect
36506   domains = +local_domains
36507   file = /central/filters/$local_part_data
36508   no_verify
36509   allow_filter
36510   allow_freeze
36511 .endd
36512 The filter is run in a separate process under its own uid. Therefore, either
36513 &%check_local_user%& must be set (as above), in which case the filter is run as
36514 the local user, or the &%user%& option must be used to specify which user to
36515 use. If both are set, &%user%& overrides.
36516
36517 Care should be taken to ensure that none of the commands in the filter file
36518 specify a significant delivery if the message is to go on to be delivered to
36519 its intended recipient. The router will not then claim to have dealt with the
36520 address, so it will be passed on to subsequent routers to be delivered in the
36521 normal way.
36522 .ecindex IIDsysfil1
36523 .ecindex IIDsysfil2
36524 .ecindex IIDsysfil3
36525
36526
36527
36528
36529
36530
36531 . ////////////////////////////////////////////////////////////////////////////
36532 . ////////////////////////////////////////////////////////////////////////////
36533
36534 .chapter "Message processing" "CHAPmsgproc"
36535 .scindex IIDmesproc "message" "general processing"
36536 Exim performs various transformations on the sender and recipient addresses of
36537 all messages that it handles, and also on the messages' header lines. Some of
36538 these are optional and configurable, while others always take place. All of
36539 this processing, except rewriting as a result of routing, and the addition or
36540 removal of header lines while delivering, happens when a message is received,
36541 before it is placed on Exim's queue.
36542
36543 Some of the automatic processing takes place by default only for
36544 &"locally-originated"& messages. This adjective is used to describe messages
36545 that are not received over TCP/IP, but instead are passed to an Exim process on
36546 its standard input. This includes the interactive &"local SMTP"& case that is
36547 set up by the &%-bs%& command line option.
36548
36549 &*Note*&: Messages received over TCP/IP on the loopback interface (127.0.0.1
36550 or ::1) are not considered to be locally-originated. Exim does not treat the
36551 loopback interface specially in any way.
36552
36553 If you want the loopback interface to be treated specially, you must ensure
36554 that there are appropriate entries in your ACLs.
36555
36556
36557
36558
36559 .section "Submission mode for non-local messages" "SECTsubmodnon"
36560 .cindex "message" "submission"
36561 .cindex "submission mode"
36562 Processing that happens automatically for locally-originated messages (unless
36563 &%suppress_local_fixups%& is set) can also be requested for messages that are
36564 received over TCP/IP. The term &"submission mode"& is used to describe this
36565 state. Submission mode is set by the modifier
36566 .code
36567 control = submission
36568 .endd
36569 in a MAIL, RCPT, or pre-data ACL for an incoming message (see sections
36570 &<<SECTACLmodi>>& and &<<SECTcontrols>>&). This makes Exim treat the message as
36571 a local submission, and is normally used when the source of the message is
36572 known to be an MUA running on a client host (as opposed to an MTA). For
36573 example, to set submission mode for messages originating on the IPv4 loopback
36574 interface, you could include the following in the MAIL ACL:
36575 .code
36576 warn  hosts = 127.0.0.1
36577       control = submission
36578 .endd
36579 .cindex "&%sender_retain%& submission option"
36580 There are some options that can be used when setting submission mode. A slash
36581 is used to separate options. For example:
36582 .code
36583 control = submission/sender_retain
36584 .endd
36585 Specifying &%sender_retain%& has the effect of setting &%local_sender_retain%&
36586 true and &%local_from_check%& false for the current incoming message. The first
36587 of these allows an existing &'Sender:'& header in the message to remain, and
36588 the second suppresses the check to ensure that &'From:'& matches the
36589 authenticated sender. With this setting, Exim still fixes up messages by adding
36590 &'Date:'& and &'Message-ID:'& header lines if they are missing, but makes no
36591 attempt to check sender authenticity in header lines.
36592
36593 When &%sender_retain%& is not set, a submission mode setting may specify a
36594 domain to be used when generating a &'From:'& or &'Sender:'& header line. For
36595 example:
36596 .code
36597 control = submission/domain=some.domain
36598 .endd
36599 The domain may be empty. How this value is used is described in sections
36600 &<<SECTthefrohea>>& and &<<SECTthesenhea>>&. There is also a &%name%& option
36601 that allows you to specify the user's full name for inclusion in a created
36602 &'Sender:'& or &'From:'& header line. For example:
36603 .code
36604 accept authenticated = *
36605        control = submission/domain=wonderland.example/\
36606                             name=${lookup {$authenticated_id} \
36607                                    lsearch {/etc/exim/namelist}}
36608 .endd
36609 Because the name may contain any characters, including slashes, the &%name%&
36610 option must be given last. The remainder of the string is used as the name. For
36611 the example above, if &_/etc/exim/namelist_& contains:
36612 .code
36613 bigegg:  Humpty Dumpty
36614 .endd
36615 then when the sender has authenticated as &'bigegg'&, the generated &'Sender:'&
36616 line would be:
36617 .code
36618 Sender: Humpty Dumpty <bigegg@wonderland.example>
36619 .endd
36620 .cindex "return path" "in submission mode"
36621 By default, submission mode forces the return path to the same address as is
36622 used to create the &'Sender:'& header. However, if &%sender_retain%& is
36623 specified, the return path is also left unchanged.
36624
36625 &*Note*&: The changes caused by submission mode take effect after the predata
36626 ACL. This means that any sender checks performed before the fix-ups use the
36627 untrusted sender address specified by the user, not the trusted sender address
36628 specified by submission mode. Although this might be slightly unexpected, it
36629 does mean that you can configure ACL checks to spot that a user is trying to
36630 spoof another's address.
36631
36632 .section "Line endings" "SECTlineendings"
36633 .cindex "line endings"
36634 .cindex "carriage return"
36635 .cindex "linefeed"
36636 RFC 2821 specifies that CRLF (two characters: carriage-return, followed by
36637 linefeed) is the line ending for messages transmitted over the Internet using
36638 SMTP over TCP/IP. However, within individual operating systems, different
36639 conventions are used. For example, Unix-like systems use just LF, but others
36640 use CRLF or just CR.
36641
36642 Exim was designed for Unix-like systems, and internally, it stores messages
36643 using the system's convention of a single LF as a line terminator. When
36644 receiving a message, all line endings are translated to this standard format.
36645 Originally, it was thought that programs that passed messages directly to an
36646 MTA within an operating system would use that system's convention. Experience
36647 has shown that this is not the case; for example, there are Unix applications
36648 that use CRLF in this circumstance. For this reason, and for compatibility with
36649 other MTAs, the way Exim handles line endings for all messages is now as
36650 follows:
36651
36652 .ilist
36653 CR is treated as a line ending; if it is immediately followed by LF, the LF
36654 is ignored.
36655 .next
36656 The sequence &"CR, dot, CR"& does not terminate an incoming SMTP message,
36657 nor a local message in the state where a line containing only a dot is a
36658 terminator.
36659 .next
36660 If a bare CR is encountered within a header line, an extra space is added after
36661 the line terminator so as not to end the header line. The reasoning behind this
36662 is that bare CRs in header lines are most likely either to be mistakes, or
36663 people trying to play silly games.
36664 .next
36665 If the first header line received in a message ends with CRLF, a subsequent
36666 bare LF in a header line is treated in the same way as a bare CR in a header
36667 line and a bare LF in a body line is replaced with a space.
36668 .next
36669 If the first header line received in a message does not end with CRLF, a subsequent
36670 LF not preceded by CR is treated as a line ending.
36671 .endlist
36672
36673
36674
36675
36676
36677 .section "Unqualified addresses" "SECID218"
36678 .cindex "unqualified addresses"
36679 .cindex "address" "qualification"
36680 By default, Exim expects every envelope address it receives from an external
36681 host to be fully qualified. Unqualified addresses cause negative responses to
36682 SMTP commands. However, because SMTP is used as a means of transporting
36683 messages from MUAs running on personal workstations, there is sometimes a
36684 requirement to accept unqualified addresses from specific hosts or IP networks.
36685
36686 Exim has two options that separately control which hosts may send unqualified
36687 sender or recipient addresses in SMTP commands, namely
36688 &%sender_unqualified_hosts%& and &%recipient_unqualified_hosts%&. In both
36689 cases, if an unqualified address is accepted, it is qualified by adding the
36690 value of &%qualify_domain%& or &%qualify_recipient%&, as appropriate.
36691
36692 .oindex "&%qualify_domain%&"
36693 .oindex "&%qualify_recipient%&"
36694 Unqualified addresses in header lines are automatically qualified for messages
36695 that are locally originated, unless the &%-bnq%& option is given on the command
36696 line. For messages received over SMTP, unqualified addresses in header lines
36697 are qualified only if unqualified addresses are permitted in SMTP commands. In
36698 other words, such qualification is also controlled by
36699 &%sender_unqualified_hosts%& and &%recipient_unqualified_hosts%&,
36700
36701
36702
36703
36704 .section "The UUCP From line" "SECID219"
36705 .cindex "&""From""& line"
36706 .cindex "UUCP" "&""From""& line"
36707 .cindex "sender" "address"
36708 .oindex "&%uucp_from_pattern%&"
36709 .oindex "&%uucp_from_sender%&"
36710 .cindex "envelope from"
36711 .cindex "envelope sender"
36712 .cindex "Sendmail compatibility" "&""From""& line"
36713 Messages that have come from UUCP (and some other applications) often begin
36714 with a line containing the envelope sender and a timestamp, following the word
36715 &"From"&. Examples of two common formats are:
36716 .code
36717 From a.oakley@berlin.mus Fri Jan  5 12:35 GMT 1996
36718 From f.butler@berlin.mus Fri, 7 Jan 97 14:00:00 GMT
36719 .endd
36720 This line precedes the RFC 2822 header lines. For compatibility with Sendmail,
36721 Exim recognizes such lines at the start of messages that are submitted to it
36722 via the command line (that is, on the standard input). It does not recognize
36723 such lines in incoming SMTP messages, unless the sending host matches
36724 &%ignore_fromline_hosts%& or the &%-bs%& option was used for a local message
36725 and &%ignore_fromline_local%& is set. The recognition is controlled by a
36726 regular expression that is defined by the &%uucp_from_pattern%& option, whose
36727 default value matches the two common cases shown above and puts the address
36728 that follows &"From"& into &$1$&.
36729
36730 .cindex "numerical variables (&$1$& &$2$& etc)" "in &""From ""& line handling"
36731 When the caller of Exim for a non-SMTP message that contains a &"From"& line is
36732 a trusted user, the message's sender address is constructed by expanding the
36733 contents of &%uucp_sender_address%&, whose default value is &"$1"&. This is
36734 then parsed as an RFC 2822 address. If there is no domain, the local part is
36735 qualified with &%qualify_domain%& unless it is the empty string. However, if
36736 the command line &%-f%& option is used, it overrides the &"From"& line.
36737
36738 If the caller of Exim is not trusted, the &"From"& line is recognized, but the
36739 sender address is not changed. This is also the case for incoming SMTP messages
36740 that are permitted to contain &"From"& lines.
36741
36742 Only one &"From"& line is recognized. If there is more than one, the second is
36743 treated as a data line that starts the body of the message, as it is not valid
36744 as a header line. This also happens if a &"From"& line is present in an
36745 incoming SMTP message from a source that is not permitted to send them.
36746
36747
36748
36749 .section "Header lines"
36750 .subsection "Resent- header lines" SECID220
36751 .chindex Resent-
36752 RFC 2822 makes provision for sets of header lines starting with the string
36753 &`Resent-`& to be added to a message when it is resent by the original
36754 recipient to somebody else. These headers are &'Resent-Date:'&,
36755 &'Resent-From:'&, &'Resent-Sender:'&, &'Resent-To:'&, &'Resent-Cc:'&,
36756 &'Resent-Bcc:'& and &'Resent-Message-ID:'&. The RFC says:
36757
36758 .blockquote
36759 &'Resent fields are strictly informational. They MUST NOT be used in the normal
36760 processing of replies or other such automatic actions on messages.'&
36761 .endblockquote
36762
36763 This leaves things a bit vague as far as other processing actions such as
36764 address rewriting are concerned. Exim treats &%Resent-%& header lines as
36765 follows:
36766
36767 .ilist
36768 A &'Resent-From:'& line that just contains the login id of the submitting user
36769 is automatically rewritten in the same way as &'From:'& (see below).
36770 .next
36771 If there's a rewriting rule for a particular header line, it is also applied to
36772 &%Resent-%& header lines of the same type. For example, a rule that rewrites
36773 &'From:'& also rewrites &'Resent-From:'&.
36774 .next
36775 For local messages, if &'Sender:'& is removed on input, &'Resent-Sender:'& is
36776 also removed.
36777 .next
36778 For a locally-submitted message,
36779 if there are any &%Resent-%& header lines but no &'Resent-Date:'&,
36780 &'Resent-From:'&, or &'Resent-Message-Id:'&, they are added as necessary. It is
36781 the contents of &'Resent-Message-Id:'& (rather than &'Message-Id:'&) which are
36782 included in log lines in this case.
36783 .next
36784 The logic for adding &'Sender:'& is duplicated for &'Resent-Sender:'& when any
36785 &%Resent-%& header lines are present.
36786 .endlist
36787
36788
36789
36790
36791 .subsection Auto-Submitted: SECID221
36792 Whenever Exim generates an autoreply, a bounce, or a delay warning message, it
36793 includes the header line:
36794 .code
36795 Auto-Submitted: auto-replied
36796 .endd
36797
36798 .subsection Bcc: SECID222
36799 .cindex "&'Bcc:'& header line"
36800 If Exim is called with the &%-t%& option, to take recipient addresses from a
36801 message's header, it removes any &'Bcc:'& header line that may exist (after
36802 extracting its addresses). If &%-t%& is not present on the command line, any
36803 existing &'Bcc:'& is not removed.
36804
36805
36806 .subsection Date: SECID223
36807 .cindex Date:
36808 If a locally-generated or submission-mode message has no &'Date:'& header line,
36809 Exim adds one, using the current date and time, unless the
36810 &%suppress_local_fixups%& control has been specified.
36811
36812 .subsection Delivery-date: SECID224
36813 .cindex "&'Delivery-date:'& header line"
36814 .oindex "&%delivery_date_remove%&"
36815 &'Delivery-date:'& header lines are not part of the standard RFC 2822 header
36816 set. Exim can be configured to add them to the final delivery of messages. (See
36817 the generic &%delivery_date_add%& transport option.) They should not be present
36818 in messages in transit. If the &%delivery_date_remove%& configuration option is
36819 set (the default), Exim removes &'Delivery-date:'& header lines from incoming
36820 messages.
36821
36822
36823 .subsection Envelope-to: SECID225
36824 .chindex Envelope-to:
36825 .oindex "&%envelope_to_remove%&"
36826 &'Envelope-to:'& header lines are not part of the standard RFC 2822 header set.
36827 Exim can be configured to add them to the final delivery of messages. (See the
36828 generic &%envelope_to_add%& transport option.) They should not be present in
36829 messages in transit. If the &%envelope_to_remove%& configuration option is set
36830 (the default), Exim removes &'Envelope-to:'& header lines from incoming
36831 messages.
36832
36833
36834 .subsection From: SECTthefrohea
36835 .chindex From:
36836 .cindex "Sendmail compatibility" "&""From""& line"
36837 .cindex "message" "submission"
36838 .cindex "submission mode"
36839 If a submission-mode message does not contain a &'From:'& header line, Exim
36840 adds one if either of the following conditions is true:
36841
36842 .ilist
36843 The envelope sender address is not empty (that is, this is not a bounce
36844 message). The added header line copies the envelope sender address.
36845 .next
36846 .vindex "&$authenticated_id$&"
36847 The SMTP session is authenticated and &$authenticated_id$& is not empty.
36848 .olist
36849 .vindex "&$qualify_domain$&"
36850 If no domain is specified by the submission control, the local part is
36851 &$authenticated_id$& and the domain is &$qualify_domain$&.
36852 .next
36853 If a non-empty domain is specified by the submission control, the local
36854 part is &$authenticated_id$&, and the domain is the specified domain.
36855 .next
36856 If an empty domain is specified by the submission control,
36857 &$authenticated_id$& is assumed to be the complete address.
36858 .endlist
36859 .endlist
36860
36861 A non-empty envelope sender takes precedence.
36862
36863 If a locally-generated incoming message does not contain a &'From:'& header
36864 line, and the &%suppress_local_fixups%& control is not set, Exim adds one
36865 containing the sender's address. The calling user's login name and full name
36866 are used to construct the address, as described in section &<<SECTconstr>>&.
36867 They are obtained from the password data by calling &[getpwuid()]& (but see the
36868 &%unknown_login%& configuration option). The address is qualified with
36869 &%qualify_domain%&.
36870
36871 For compatibility with Sendmail, if an incoming, non-SMTP message has a
36872 &'From:'& header line containing just the unqualified login name of the calling
36873 user, this is replaced by an address containing the user's login name and full
36874 name as described in section &<<SECTconstr>>&.
36875
36876
36877 .subsection Message-ID: SECID226
36878 .chindex Message-ID:
36879 .cindex "message" "submission"
36880 .oindex "&%message_id_header_text%&"
36881 If a locally-generated or submission-mode incoming message does not contain a
36882 &'Message-ID:'& or &'Resent-Message-ID:'& header line, and the
36883 &%suppress_local_fixups%& control is not set, Exim adds a suitable header line
36884 to the message. If there are any &'Resent-:'& headers in the message, it
36885 creates &'Resent-Message-ID:'&. The id is constructed from Exim's internal
36886 message id, preceded by the letter E to ensure it starts with a letter, and
36887 followed by @ and the primary host name. Additional information can be included
36888 in this header line by setting the &%message_id_header_text%& and/or
36889 &%message_id_header_domain%& options.
36890
36891
36892 .subsection Received: SECID227
36893 .chindex Received:
36894 A &'Received:'& header line is added at the start of every message. The
36895 contents are defined by the &%received_header_text%& configuration option, and
36896 Exim automatically adds a semicolon and a timestamp to the configured string.
36897
36898 The &'Received:'& header is generated as soon as the message's header lines
36899 have been received. At this stage, the timestamp in the &'Received:'& header
36900 line is the time that the message started to be received. This is the value
36901 that is seen by the DATA ACL and by the &[local_scan()]& function.
36902
36903 Once a message is accepted, the timestamp in the &'Received:'& header line is
36904 changed to the time of acceptance, which is (apart from a small delay while the
36905 -H spool file is written) the earliest time at which delivery could start.
36906
36907
36908 .subsection References: SECID228
36909 .chindex References:
36910 Messages created by the &(autoreply)& transport include a &'References:'&
36911 header line. This is constructed according to the rules that are described in
36912 section 3.64 of RFC 2822 (which states that replies should contain such a
36913 header line), and section 3.14 of RFC 3834 (which states that automatic
36914 responses are not different in this respect). However, because some mail
36915 processing software does not cope well with very long header lines, no more
36916 than 12 message IDs are copied from the &'References:'& header line in the
36917 incoming message. If there are more than 12, the first one and then the final
36918 11 are copied, before adding the message ID of the incoming message.
36919
36920
36921
36922 .subsection Return-path: SECID229
36923 .chindex Return-path:
36924 .oindex "&%return_path_remove%&"
36925 &'Return-path:'& header lines are defined as something an MTA may insert when
36926 it does the final delivery of messages. (See the generic &%return_path_add%&
36927 transport option.) Therefore, they should not be present in messages in
36928 transit. If the &%return_path_remove%& configuration option is set (the
36929 default), Exim removes &'Return-path:'& header lines from incoming messages.
36930
36931
36932
36933 .subsection Sender: SECTthesenhea
36934 .cindex "&'Sender:'& header line"
36935 .cindex "message" "submission"
36936 .chindex Sender:
36937 For a locally-originated message from an untrusted user, Exim may remove an
36938 existing &'Sender:'& header line, and it may add a new one. You can modify
36939 these actions by setting the &%local_sender_retain%& option true, the
36940 &%local_from_check%& option false, or by using the &%suppress_local_fixups%&
36941 control setting.
36942
36943 When a local message is received from an untrusted user and
36944 &%local_from_check%& is true (the default), and the &%suppress_local_fixups%&
36945 control has not been set, a check is made to see if the address given in the
36946 &'From:'& header line is the correct (local) sender of the message. The address
36947 that is expected has the login name as the local part and the value of
36948 &%qualify_domain%& as the domain. Prefixes and suffixes for the local part can
36949 be permitted by setting &%local_from_prefix%& and &%local_from_suffix%&
36950 appropriately. If &'From:'& does not contain the correct sender, a &'Sender:'&
36951 line is added to the message.
36952
36953 If you set &%local_from_check%& false, this checking does not occur. However,
36954 the removal of an existing &'Sender:'& line still happens, unless you also set
36955 &%local_sender_retain%& to be true. It is not possible to set both of these
36956 options true at the same time.
36957
36958 .cindex "submission mode"
36959 By default, no processing of &'Sender:'& header lines is done for messages
36960 received over TCP/IP or for messages submitted by trusted users. However, when
36961 a message is received over TCP/IP in submission mode, and &%sender_retain%& is
36962 not specified on the submission control, the following processing takes place:
36963
36964 .vindex "&$authenticated_id$&"
36965 First, any existing &'Sender:'& lines are removed. Then, if the SMTP session is
36966 authenticated, and &$authenticated_id$& is not empty, a sender address is
36967 created as follows:
36968
36969 .ilist
36970 .vindex "&$qualify_domain$&"
36971 If no domain is specified by the submission control, the local part is
36972 &$authenticated_id$& and the domain is &$qualify_domain$&.
36973 .next
36974 If a non-empty domain is specified by the submission control, the local part
36975 is &$authenticated_id$&, and the domain is the specified domain.
36976 .next
36977 If an empty domain is specified by the submission control,
36978 &$authenticated_id$& is assumed to be the complete address.
36979 .endlist
36980
36981 This address is compared with the address in the &'From:'& header line. If they
36982 are different, a &'Sender:'& header line containing the created address is
36983 added. Prefixes and suffixes for the local part in &'From:'& can be permitted
36984 by setting &%local_from_prefix%& and &%local_from_suffix%& appropriately.
36985
36986 .cindex "return path" "created from &'Sender:'&"
36987 &*Note*&: Whenever a &'Sender:'& header line is created, the return path for
36988 the message (the envelope sender address) is changed to be the same address,
36989 except in the case of submission mode when &%sender_retain%& is specified.
36990
36991
36992
36993 .section "Adding and removing header lines in routers and transports" &&&
36994          "SECTheadersaddrem"
36995 .cindex "header lines" "adding; in router or transport"
36996 .cindex "header lines" "removing; in router or transport"
36997 When a message is delivered, the addition and removal of header lines can be
36998 specified in a system filter, or on any of the routers and transports that
36999 process the message. Section &<<SECTaddremheasys>>& contains details about
37000 modifying headers in a system filter. Header lines can also be added in an ACL
37001 as a message is received (see section &<<SECTaddheadacl>>&).
37002
37003 In contrast to what happens in a system filter, header modifications that are
37004 specified on routers and transports apply only to the particular recipient
37005 addresses that are being processed by those routers and transports. These
37006 changes do not actually take place until a copy of the message is being
37007 transported. Therefore, they do not affect the basic set of header lines, and
37008 they do not affect the values of the variables that refer to header lines.
37009
37010 &*Note*&: In particular, this means that any expansions in the configuration of
37011 the transport cannot refer to the modified header lines, because such
37012 expansions all occur before the message is actually transported.
37013
37014 For both routers and transports, the argument of a &%headers_add%&
37015 option must be in the form of one or more RFC 2822 header lines, separated by
37016 newlines (coded as &"\n"&). For example:
37017 .code
37018 headers_add = X-added-header: added by $primary_hostname\n\
37019               X-added-second: another added header line
37020 .endd
37021 Exim does not check the syntax of these added header lines.
37022
37023 Multiple &%headers_add%& options for a single router or transport can be
37024 specified; the values will append to a single list of header lines.
37025 Each header-line is separately expanded.
37026
37027 The argument of a &%headers_remove%& option must consist of a colon-separated
37028 list of header names. This is confusing, because header names themselves are
37029 often terminated by colons. In this case, the colons are the list separators,
37030 not part of the names. For example:
37031 .code
37032 headers_remove = return-receipt-to:acknowledge-to
37033 .endd
37034
37035 Multiple &%headers_remove%& options for a single router or transport can be
37036 specified; the arguments will append to a single header-names list.
37037 Each item is separately expanded.
37038 Note that colons in complex expansions which are used to
37039 form all or part of a &%headers_remove%& list
37040 will act as list separators.
37041
37042 When &%headers_add%& or &%headers_remove%& is specified on a router,
37043 items are expanded at routing time,
37044 and then associated with all addresses that are
37045 accepted by that router, and also with any new addresses that it generates. If
37046 an address passes through several routers as a result of aliasing or
37047 forwarding, the changes are cumulative.
37048
37049 .oindex "&%unseen%&"
37050 However, this does not apply to multiple routers that result from the use of
37051 the &%unseen%& option. Any header modifications that were specified by the
37052 &"unseen"& router or its predecessors apply only to the &"unseen"& delivery.
37053
37054 Addresses that end up with different &%headers_add%& or &%headers_remove%&
37055 settings cannot be delivered together in a batch, so a transport is always
37056 dealing with a set of addresses that have the same header-processing
37057 requirements.
37058
37059 The transport starts by writing the original set of header lines that arrived
37060 with the message, possibly modified by the system filter. As it writes out
37061 these lines, it consults the list of header names that were attached to the
37062 recipient address(es) by &%headers_remove%& options in routers, and it also
37063 consults the transport's own &%headers_remove%& option. Header lines whose
37064 names are on either of these lists are not written out. If there are multiple
37065 instances of any listed header, they are all skipped.
37066
37067 After the remaining original header lines have been written, new header
37068 lines that were specified by routers' &%headers_add%& options are written, in
37069 the order in which they were attached to the address. These are followed by any
37070 header lines specified by the transport's &%headers_add%& option.
37071
37072 This way of handling header line modifications in routers and transports has
37073 the following consequences:
37074
37075 .ilist
37076 The original set of header lines, possibly modified by the system filter,
37077 remains &"visible"&, in the sense that the &$header_$&&'xxx'& variables refer
37078 to it, at all times.
37079 .next
37080 Header lines that are added by a router's
37081 &%headers_add%& option are not accessible by means of the &$header_$&&'xxx'&
37082 expansion syntax in subsequent routers or the transport.
37083 .next
37084 Conversely, header lines that are specified for removal by &%headers_remove%&
37085 in a router remain visible to subsequent routers and the transport.
37086 .next
37087 Headers added to an address by &%headers_add%& in a router cannot be removed by
37088 a later router or by a transport.
37089 .next
37090 An added header can refer to the contents of an original header that is to be
37091 removed, even it has the same name as the added header. For example:
37092 .code
37093 headers_remove = subject
37094 headers_add = Subject: new subject (was: $h_subject:)
37095 .endd
37096 .endlist
37097
37098 &*Warning*&: The &%headers_add%& and &%headers_remove%& options cannot be used
37099 for a &(redirect)& router that has the &%one_time%& option set.
37100
37101
37102
37103
37104
37105 .section "Constructed addresses" "SECTconstr"
37106 .cindex "address" "constructed"
37107 .cindex "constructed address"
37108 When Exim constructs a sender address for a locally-generated message, it uses
37109 the form
37110 .display
37111 <&'user name'&>&~&~<&'login'&&`@`&&'qualify_domain'&>
37112 .endd
37113 For example:
37114 .code
37115 Zaphod Beeblebrox <zaphod@end.univ.example>
37116 .endd
37117 The user name is obtained from the &%-F%& command line option if set, or
37118 otherwise by looking up the calling user by &[getpwuid()]& and extracting the
37119 &"gecos"& field from the password entry. If the &"gecos"& field contains an
37120 ampersand character, this is replaced by the login name with the first letter
37121 upper cased, as is conventional in a number of operating systems. See the
37122 &%gecos_name%& option for a way to tailor the handling of the &"gecos"& field.
37123 The &%unknown_username%& option can be used to specify user names in cases when
37124 there is no password file entry.
37125
37126 .cindex "RFC 2047"
37127 In all cases, the user name is made to conform to RFC 2822 by quoting all or
37128 parts of it if necessary. In addition, if it contains any non-printing
37129 characters, it is encoded as described in RFC 2047, which defines a way of
37130 including non-ASCII characters in header lines. The value of the
37131 &%headers_charset%& option specifies the name of the encoding that is used (the
37132 characters are assumed to be in this encoding). The setting of
37133 &%print_topbitchars%& controls whether characters with the top bit set (that
37134 is, with codes greater than 127) count as printing characters or not.
37135
37136
37137
37138 .section "Case of local parts" "SECID230"
37139 .cindex "case of local parts"
37140 .cindex "local part" "case of"
37141 RFC 2822 states that the case of letters in the local parts of addresses cannot
37142 be assumed to be non-significant. Exim preserves the case of local parts of
37143 addresses, but by default it uses a lower-cased form when it is routing,
37144 because on most Unix systems, usernames are in lower case and case-insensitive
37145 routing is required. However, any particular router can be made to use the
37146 original case for local parts by setting the &%caseful_local_part%& generic
37147 router option.
37148
37149 .cindex "mixed-case login names"
37150 If you must have mixed-case user names on your system, the best way to proceed,
37151 assuming you want case-independent handling of incoming email, is to set up
37152 your first router to convert incoming local parts in your domains to the
37153 correct case by means of a file lookup. For example:
37154 .code
37155 correct_case:
37156   driver = redirect
37157   domains = +local_domains
37158   data = ${lookup{$local_part}cdb\
37159               {/etc/usercased.cdb}{$value}fail}\
37160               @$domain
37161 .endd
37162 For this router, the local part is forced to lower case by the default action
37163 (&%caseful_local_part%& is not set). The lower-cased local part is used to look
37164 up a new local part in the correct case. If you then set &%caseful_local_part%&
37165 on any subsequent routers which process your domains, they will operate on
37166 local parts with the correct case in a case-sensitive manner.
37167
37168
37169
37170 .section "Dots in local parts" "SECID231"
37171 .cindex "dot" "in local part"
37172 .cindex "local part" "dots in"
37173 RFC 2822 forbids empty components in local parts. That is, an unquoted local
37174 part may not begin or end with a dot, nor have two consecutive dots in the
37175 middle. However, it seems that many MTAs do not enforce this, so Exim permits
37176 empty components for compatibility.
37177
37178
37179
37180 .section "Rewriting addresses" "SECID232"
37181 .cindex "rewriting" "addresses"
37182 Rewriting of sender and recipient addresses, and addresses in headers, can
37183 happen automatically, or as the result of configuration options, as described
37184 in chapter &<<CHAPrewrite>>&. The headers that may be affected by this are
37185 &'Bcc:'&, &'Cc:'&, &'From:'&, &'Reply-To:'&, &'Sender:'&, and &'To:'&.
37186
37187 Automatic rewriting includes qualification, as mentioned above. The other case
37188 in which it can happen is when an incomplete non-local domain is given. The
37189 routing process may cause this to be expanded into the full domain name. For
37190 example, a header such as
37191 .code
37192 To: hare@teaparty
37193 .endd
37194 might get rewritten as
37195 .code
37196 To: hare@teaparty.wonderland.fict.example
37197 .endd
37198 Rewriting as a result of routing is the one kind of message processing that
37199 does not happen at input time, as it cannot be done until the address has
37200 been routed.
37201
37202 Strictly, one should not do &'any'& deliveries of a message until all its
37203 addresses have been routed, in case any of the headers get changed as a
37204 result of routing. However, doing this in practice would hold up many
37205 deliveries for unreasonable amounts of time, just because one address could not
37206 immediately be routed. Exim therefore does not delay other deliveries when
37207 routing of one or more addresses is deferred.
37208 .ecindex IIDmesproc
37209
37210
37211
37212 . ////////////////////////////////////////////////////////////////////////////
37213 . ////////////////////////////////////////////////////////////////////////////
37214
37215 .chapter "SMTP processing" "CHAPSMTP"
37216 .scindex IIDsmtpproc1 "SMTP" "processing details"
37217 .scindex IIDsmtpproc2 "LMTP" "processing details"
37218 Exim supports a number of different ways of using the SMTP protocol, and its
37219 LMTP variant, which is an interactive protocol for transferring messages into a
37220 closed mail store application. This chapter contains details of how SMTP is
37221 processed. For incoming mail, the following are available:
37222
37223 .ilist
37224 SMTP over TCP/IP (Exim daemon or &'inetd'&);
37225 .next
37226 SMTP over the standard input and output (the &%-bs%& option);
37227 .next
37228 Batched SMTP on the standard input (the &%-bS%& option).
37229 .endlist
37230
37231 For mail delivery, the following are available:
37232
37233 .ilist
37234 SMTP over TCP/IP (the &(smtp)& transport);
37235 .next
37236 LMTP over TCP/IP (the &(smtp)& transport with the &%protocol%& option set to
37237 &"lmtp"&);
37238 .next
37239 LMTP over a pipe to a process running in the local host (the &(lmtp)&
37240 transport);
37241 .next
37242 Batched SMTP to a file or pipe (the &(appendfile)& and &(pipe)& transports with
37243 the &%use_bsmtp%& option set).
37244 .endlist
37245
37246 &'Batched SMTP'& is the name for a process in which batches of messages are
37247 stored in or read from files (or pipes), in a format in which SMTP commands are
37248 used to contain the envelope information.
37249
37250
37251
37252 .section "Outgoing SMTP and LMTP over TCP/IP" "SECToutSMTPTCP"
37253 .cindex "SMTP" "outgoing over TCP/IP"
37254 .cindex "outgoing SMTP over TCP/IP"
37255 .cindex "LMTP" "over TCP/IP"
37256 .cindex "outgoing LMTP over TCP/IP"
37257 .cindex "EHLO"
37258 .cindex "HELO"
37259 .cindex "SIZE" "option on MAIL command"
37260 Outgoing SMTP and LMTP over TCP/IP is implemented by the &(smtp)& transport.
37261 The &%protocol%& option selects which protocol is to be used, but the actual
37262 processing is the same in both cases.
37263
37264 .cindex "ESMTP extensions" SIZE
37265 If, in response to its EHLO command, Exim is told that the SIZE
37266 extension is supported, it adds SIZE=<&'n'&> to each subsequent MAIL
37267 command. The value of <&'n'&> is the message size plus the value of the
37268 &%size_addition%& option (default 1024) to allow for additions to the message
37269 such as per-transport header lines, or changes made in a
37270 .cindex "transport" "filter"
37271 .cindex "filter" "transport filter"
37272 transport filter. If &%size_addition%& is set negative, the use of SIZE is
37273 suppressed.
37274
37275 If the remote server advertises support for PIPELINING, Exim uses the
37276 pipelining extension to SMTP (RFC 2197) to reduce the number of TCP/IP packets
37277 required for the transaction.
37278
37279 If the remote server advertises support for the STARTTLS command, and Exim
37280 was built to support TLS encryption, it tries to start a TLS session unless the
37281 server matches &%hosts_avoid_tls%&. See chapter &<<CHAPTLS>>& for more details.
37282 Either a match in that or &%hosts_verify_avoid_tls%& apply when the transport
37283 is called for verification.
37284
37285 If the remote server advertises support for the AUTH command, Exim scans
37286 the authenticators configuration for any suitable client settings, as described
37287 in chapter &<<CHAPSMTPAUTH>>&.
37288
37289 .cindex "carriage return"
37290 .cindex "linefeed"
37291 Responses from the remote host are supposed to be terminated by CR followed by
37292 LF. However, there are known to be hosts that do not send CR characters, so in
37293 order to be able to interwork with such hosts, Exim treats LF on its own as a
37294 line terminator.
37295
37296 If a message contains a number of different addresses, all those with the same
37297 characteristics (for example, the same envelope sender) that resolve to the
37298 same set of hosts, in the same order, are sent in a single SMTP transaction,
37299 even if they are for different domains, unless there are more than the setting
37300 of the &%max_rcpt%&s option in the &(smtp)& transport allows, in which case
37301 they are split into groups containing no more than &%max_rcpt%&s addresses
37302 each. If &%remote_max_parallel%& is greater than one, such groups may be sent
37303 in parallel sessions. The order of hosts with identical MX values is not
37304 significant when checking whether addresses can be batched in this way.
37305
37306 When the &(smtp)& transport suffers a temporary failure that is not
37307 message-related, Exim updates its transport-specific database, which contains
37308 records indexed by host name that remember which messages are waiting for each
37309 particular host. It also updates the retry database with new retry times.
37310
37311 .cindex "hints database" "retry keys"
37312 Exim's retry hints are based on host name plus IP address, so if one address of
37313 a multi-homed host is broken, it will soon be skipped most of the time.
37314 See the next section for more detail about error handling.
37315
37316 .cindex "SMTP" "passed connection"
37317 .cindex "SMTP" "batching over TCP/IP"
37318 When a message is successfully delivered over a TCP/IP SMTP connection, Exim
37319 looks in the hints database for the transport to see if there are any queued
37320 messages waiting for the host to which it is connected. If it finds one, it
37321 creates a new Exim process using the &%-MC%& option (which can only be used by
37322 a process running as root or the Exim user) and passes the TCP/IP socket to it
37323 so that it can deliver another message using the same socket. The new process
37324 does only those deliveries that are routed to the connected host, and may in
37325 turn pass the socket on to a third process, and so on.
37326
37327 The &%connection_max_messages%& option of the &(smtp)& transport can be used to
37328 limit the number of messages sent down a single TCP/IP connection.
37329
37330 .cindex "asterisk" "after IP address"
37331 The second and subsequent messages delivered down an existing connection are
37332 identified in the main log by the addition of an asterisk after the closing
37333 square bracket of the IP address.
37334
37335
37336
37337
37338 .subsection "Errors in outgoing SMTP" SECToutSMTPerr
37339 .cindex "error" "in outgoing SMTP"
37340 .cindex "SMTP" "errors in outgoing"
37341 .cindex "host" "error"
37342 Three different kinds of error are recognized for outgoing SMTP: host errors,
37343 message errors, and recipient errors.
37344
37345 .vlist
37346 .vitem "&*Host errors*&"
37347 A host error is not associated with a particular message or with a
37348 particular recipient of a message. The host errors are:
37349
37350 .ilist
37351 Connection refused or timed out,
37352 .next
37353 Any error response code on connection,
37354 .next
37355 Any error response code to EHLO or HELO,
37356 .next
37357 Loss of connection at any time, except after &"."&,
37358 .next
37359 I/O errors at any time,
37360 .next
37361 Timeouts during the session, other than in response to MAIL, RCPT or
37362 the &"."& at the end of the data.
37363 .endlist ilist
37364
37365 For a host error, a permanent error response on connection, or in response to
37366 EHLO, causes all addresses routed to the host to be failed. Any other host
37367 error causes all addresses to be deferred, and retry data to be created for the
37368 host. It is not tried again, for any message, until its retry time arrives. If
37369 the current set of addresses are not all delivered in this run (to some
37370 alternative host), the message is added to the list of those waiting for this
37371 host, so if it is still undelivered when a subsequent successful delivery is
37372 made to the host, it will be sent down the same SMTP connection.
37373
37374 .vitem "&*Message errors*&"
37375 .cindex "message" "error"
37376 A message error is associated with a particular message when sent to a
37377 particular host, but not with a particular recipient of the message. The
37378 message errors are:
37379
37380 .ilist
37381 Any error response code to MAIL, DATA, or the &"."& that terminates
37382 the data,
37383 .next
37384 Timeout after MAIL,
37385 .next
37386 Timeout or loss of connection after the &"."& that terminates the data. A
37387 timeout after the DATA command itself is treated as a host error, as is loss of
37388 connection at any other time.
37389 .endlist ilist
37390
37391 For a message error, a permanent error response (5&'xx'&) causes all addresses
37392 to be failed, and a delivery error report to be returned to the sender. A
37393 temporary error response (4&'xx'&), or one of the timeouts, causes all
37394 addresses to be deferred. Retry data is not created for the host, but instead,
37395 a retry record for the combination of host plus message id is created. The
37396 message is not added to the list of those waiting for this host. This ensures
37397 that the failing message will not be sent to this host again until the retry
37398 time arrives. However, other messages that are routed to the host are not
37399 affected, so if it is some property of the message that is causing the error,
37400 it will not stop the delivery of other mail.
37401
37402 If the remote host specified support for the SIZE parameter in its response
37403 to EHLO, Exim adds SIZE=&'nnn'& to the MAIL command, so an
37404 over-large message will cause a message error because the error arrives as a
37405 response to MAIL.
37406
37407 .vitem "&*Recipient errors*&"
37408 .cindex "recipient" "error"
37409 A recipient error is associated with a particular recipient of a message. The
37410 recipient errors are:
37411
37412 .ilist
37413 Any error response to RCPT,
37414 .next
37415 Timeout after RCPT.
37416 .endlist
37417
37418 For a recipient error, a permanent error response (5&'xx'&) causes the
37419 recipient address to be failed, and a bounce message to be returned to the
37420 sender. A temporary error response (4&'xx'&) or a timeout causes the failing
37421 address to be deferred, and routing retry data to be created for it. This is
37422 used to delay processing of the address in subsequent queue runs, until its
37423 routing retry time arrives. This applies to all messages, but because it
37424 operates only in queue runs, one attempt will be made to deliver a new message
37425 to the failing address before the delay starts to operate. This ensures that,
37426 if the failure is really related to the message rather than the recipient
37427 (&"message too big for this recipient"& is a possible example), other messages
37428 have a chance of getting delivered. If a delivery to the address does succeed,
37429 the retry information gets cleared, so all stuck messages get tried again, and
37430 the retry clock is reset.
37431
37432 The message is not added to the list of those waiting for this host. Use of the
37433 host for other messages is unaffected, and except in the case of a timeout,
37434 other recipients are processed independently, and may be successfully delivered
37435 in the current SMTP session. After a timeout it is of course impossible to
37436 proceed with the session, so all addresses get deferred. However, those other
37437 than the one that failed do not suffer any subsequent retry delays. Therefore,
37438 if one recipient is causing trouble, the others have a chance of getting
37439 through when a subsequent delivery attempt occurs before the failing
37440 recipient's retry time.
37441 .endlist
37442
37443 In all cases, if there are other hosts (or IP addresses) available for the
37444 current set of addresses (for example, from multiple MX records), they are
37445 tried in this run for any undelivered addresses, subject of course to their
37446 own retry data. In other words, recipient error retry data does not take effect
37447 until the next delivery attempt.
37448
37449 Some hosts have been observed to give temporary error responses to every
37450 MAIL command at certain times (&"insufficient space"& has been seen). It
37451 would be nice if such circumstances could be recognized, and defer data for the
37452 host itself created, but this is not possible within the current Exim design.
37453 What actually happens is that retry data for every (host, message) combination
37454 is created.
37455
37456 The reason that timeouts after MAIL and RCPT are treated specially is that
37457 these can sometimes arise as a result of the remote host's verification
37458 procedures. Exim makes this assumption, and treats them as if a temporary error
37459 response had been received. A timeout after &"."& is treated specially because
37460 it is known that some broken implementations fail to recognize the end of the
37461 message if the last character of the last line is a binary zero. Thus, it is
37462 helpful to treat this case as a message error.
37463
37464 Timeouts at other times are treated as host errors, assuming a problem with the
37465 host, or the connection to it. If a timeout after MAIL, RCPT,
37466 or &"."& is really a connection problem, the assumption is that at the next try
37467 the timeout is likely to occur at some other point in the dialogue, causing it
37468 then to be treated as a host error.
37469
37470 There is experimental evidence that some MTAs drop the connection after the
37471 terminating &"."& if they do not like the contents of the message for some
37472 reason, in contravention of the RFC, which indicates that a 5&'xx'& response
37473 should be given. That is why Exim treats this case as a message rather than a
37474 host error, in order not to delay other messages to the same host.
37475
37476
37477
37478
37479 .section "Incoming SMTP messages over TCP/IP" "SECID233"
37480 .cindex "SMTP" "incoming over TCP/IP"
37481 .cindex "incoming SMTP over TCP/IP"
37482 .cindex "inetd"
37483 .cindex "daemon"
37484 Incoming SMTP messages can be accepted in one of two ways: by running a
37485 listening daemon, or by using &'inetd'&. In the latter case, the entry in
37486 &_/etc/inetd.conf_& should be like this:
37487 .code
37488 smtp stream tcp nowait exim /opt/exim/bin/exim in.exim -bs
37489 .endd
37490 Exim distinguishes between this case and the case of a locally running user
37491 agent using the &%-bs%& option by checking whether or not the standard input is
37492 a socket. When it is, either the port must be privileged (less than 1024), or
37493 the caller must be root or the Exim user. If any other user passes a socket
37494 with an unprivileged port number, Exim prints a message on the standard error
37495 stream and exits with an error code.
37496
37497 By default, Exim does not make a log entry when a remote host connects or
37498 disconnects (either via the daemon or &'inetd'&), unless the disconnection is
37499 unexpected. It can be made to write such log entries by setting the
37500 &%smtp_connection%& log selector.
37501
37502 .cindex "carriage return"
37503 .cindex "linefeed"
37504 Commands from the remote host are supposed to be terminated by CR followed by
37505 LF. However, there are known to be hosts that do not send CR characters. In
37506 order to be able to interwork with such hosts, Exim treats LF on its own as a
37507 line terminator.
37508 Furthermore, because common code is used for receiving messages from all
37509 sources, a CR on its own is also interpreted as a line terminator. However, the
37510 sequence &"CR, dot, CR"& does not terminate incoming SMTP data.
37511
37512 .cindex "EHLO" "invalid data"
37513 .cindex "HELO" "invalid data"
37514 One area that sometimes gives rise to problems concerns the EHLO or
37515 HELO commands. Some clients send syntactically invalid versions of these
37516 commands, which Exim rejects by default. (This is nothing to do with verifying
37517 the data that is sent, so &%helo_verify_hosts%& is not relevant.) You can tell
37518 Exim not to apply a syntax check by setting &%helo_accept_junk_hosts%& to
37519 match the broken hosts that send invalid commands.
37520
37521 .cindex "SIZE option on MAIL command"
37522 .cindex "MAIL" "SIZE option"
37523 The amount of disk space available is checked whenever SIZE is received on
37524 a MAIL command, independently of whether &%message_size_limit%& or
37525 &%check_spool_space%& is configured, unless &%smtp_check_spool_space%& is set
37526 false. A temporary error is given if there is not enough space. If
37527 &%check_spool_space%& is set, the check is for that amount of space plus the
37528 value given with SIZE, that is, it checks that the addition of the incoming
37529 message will not reduce the space below the threshold.
37530
37531 When a message is successfully received, Exim includes the local message id in
37532 its response to the final &"."& that terminates the data. If the remote host
37533 logs this text it can help with tracing what has happened to a message.
37534
37535 The Exim daemon can limit the number of simultaneous incoming connections it is
37536 prepared to handle (see the &%smtp_accept_max%& option). It can also limit the
37537 number of simultaneous incoming connections from a single remote host (see the
37538 &%smtp_accept_max_per_host%& option). Additional connection attempts are
37539 rejected using the SMTP temporary error code 421.
37540
37541 The Exim daemon does not rely on the SIGCHLD signal to detect when a
37542 subprocess has finished, as this can get lost at busy times. Instead, it looks
37543 for completed subprocesses every time it wakes up. Provided there are other
37544 things happening (new incoming calls, starts of queue runs), completed
37545 processes will be noticed and tidied away. On very quiet systems you may
37546 sometimes see a &"defunct"& Exim process hanging about. This is not a problem;
37547 it will be noticed when the daemon next wakes up.
37548
37549 When running as a daemon, Exim can reserve some SMTP slots for specific hosts,
37550 and can also be set up to reject SMTP calls from non-reserved hosts at times of
37551 high system load &-- for details see the &%smtp_accept_reserve%&,
37552 &%smtp_load_reserve%&, and &%smtp_reserve_hosts%& options. The load check
37553 applies in both the daemon and &'inetd'& cases.
37554
37555 Exim normally starts a delivery process for each message received, though this
37556 can be varied by means of the &%-odq%& command line option and the
37557 &%queue_only%&, &%queue_only_file%&, and &%queue_only_load%& options. The
37558 number of simultaneously running delivery processes started in this way from
37559 SMTP input can be limited by the &%smtp_accept_queue%& and
37560 &%smtp_accept_queue_per_connection%& options. When either limit is reached,
37561 subsequently received messages are just put on the input queue without starting
37562 a delivery process.
37563
37564 The controls that involve counts of incoming SMTP calls (&%smtp_accept_max%&,
37565 &%smtp_accept_queue%&, &%smtp_accept_reserve%&) are not available when Exim is
37566 started up from the &'inetd'& daemon, because in that case each connection is
37567 handled by an entirely independent Exim process. Control by load average is,
37568 however, available with &'inetd'&.
37569
37570 Exim can be configured to verify addresses in incoming SMTP commands as they
37571 are received. See chapter &<<CHAPACL>>& for details. It can also be configured
37572 to rewrite addresses at this time &-- before any syntax checking is done. See
37573 section &<<SSECTrewriteS>>&.
37574
37575 Exim can also be configured to limit the rate at which a client host submits
37576 MAIL and RCPT commands in a single SMTP session. See the
37577 &%smtp_ratelimit_hosts%& option.
37578
37579
37580
37581 .subsection "Unrecognized SMTP commands" SECID234
37582 .cindex "SMTP" "unrecognized commands"
37583 If Exim receives more than &%smtp_max_unknown_commands%& unrecognized SMTP
37584 commands during a single SMTP connection, it drops the connection after sending
37585 the error response to the last command. The default value for
37586 &%smtp_max_unknown_commands%& is 3. This is a defence against some kinds of
37587 abuse that subvert web servers into making connections to SMTP ports; in these
37588 circumstances, a number of non-SMTP lines are sent first.
37589
37590
37591 .subsection "Syntax and protocol errors in SMTP commands" SECID235
37592 .cindex "SMTP" "syntax errors"
37593 .cindex "SMTP" "protocol errors"
37594 A syntax error is detected if an SMTP command is recognized, but there is
37595 something syntactically wrong with its data, for example, a malformed email
37596 address in a RCPT command. Protocol errors include invalid command
37597 sequencing such as RCPT before MAIL. If Exim receives more than
37598 &%smtp_max_synprot_errors%& such commands during a single SMTP connection, it
37599 drops the connection after sending the error response to the last command. The
37600 default value for &%smtp_max_synprot_errors%& is 3. This is a defence against
37601 broken clients that loop sending bad commands (yes, it has been seen).
37602
37603
37604
37605 .subsection "Use of non-mail SMTP commands" SECID236
37606 .cindex "SMTP" "non-mail commands"
37607 The &"non-mail"& SMTP commands are those other than MAIL, RCPT, and
37608 DATA. Exim counts such commands, and drops the connection if there are too
37609 many of them in a single SMTP session. This action catches some
37610 denial-of-service attempts and things like repeated failing AUTHs, or a mad
37611 client looping sending EHLO. The global option &%smtp_accept_max_nonmail%&
37612 defines what &"too many"& means. Its default value is 10.
37613
37614 When a new message is expected, one occurrence of RSET is not counted. This
37615 allows a client to send one RSET between messages (this is not necessary,
37616 but some clients do it). Exim also allows one uncounted occurrence of HELO
37617 or EHLO, and one occurrence of STARTTLS between messages. After
37618 starting up a TLS session, another EHLO is expected, and so it too is not
37619 counted.
37620
37621 The first occurrence of AUTH in a connection, or immediately following
37622 STARTTLS is also not counted. Otherwise, all commands other than MAIL,
37623 RCPT, DATA, and QUIT are counted.
37624
37625 You can control which hosts are subject to the limit set by
37626 &%smtp_accept_max_nonmail%& by setting
37627 &%smtp_accept_max_nonmail_hosts%&. The default value is &`*`&, which makes
37628 the limit apply to all hosts. This option means that you can exclude any
37629 specific badly-behaved hosts that you have to live with.
37630
37631
37632
37633
37634 .subsection "The VRFY and EXPN commands" SECID237
37635 When Exim receives a VRFY or EXPN command on a TCP/IP connection, it
37636 runs the ACL specified by &%acl_smtp_vrfy%& or &%acl_smtp_expn%& (as
37637 appropriate) in order to decide whether the command should be accepted or not.
37638
37639 .cindex "VRFY" "processing"
37640 When no ACL is defined for VRFY, or if it rejects without
37641 setting an explicit response code, the command is accepted
37642 (with a 252 SMTP response code)
37643 in order to support awkward clients that do a VRFY before every RCPT.
37644 When VRFY is accepted, it runs exactly the same code as when Exim is
37645 called with the &%-bv%& option, and returns 250/451/550
37646 SMTP response codes.
37647
37648 .cindex "EXPN" "processing"
37649 If no ACL for EXPN is defined, the command is rejected.
37650 When EXPN is accepted, a single-level expansion of the address is done.
37651 EXPN is treated as an &"address test"& (similar to the &%-bt%& option) rather
37652 than a verification (the &%-bv%& option). If an unqualified local part is given
37653 as the argument to EXPN, it is qualified with &%qualify_domain%&. Rejections
37654 of VRFY and EXPN commands are logged on the main and reject logs, and
37655 VRFY verification failures are logged in the main log for consistency with
37656 RCPT failures.
37657
37658
37659
37660 .subsection "The ETRN command" SECTETRN
37661 .cindex "ETRN" "processing"
37662 .cindex "ESMTP extensions" ETRN
37663 RFC 1985 describes an ESMTP command called ETRN that is designed to
37664 overcome the security problems of the TURN command (which has fallen into
37665 disuse). When Exim receives an ETRN command on a TCP/IP connection, it runs
37666 the ACL specified by &%acl_smtp_etrn%& in order to decide whether the command
37667 should be accepted or not. If no ACL is defined, the command is rejected.
37668
37669 The ETRN command is concerned with &"releasing"& messages that are awaiting
37670 delivery to certain hosts. As Exim does not organize its message queue by host,
37671 the only form of ETRN that is supported by default is the one where the
37672 text starts with the &"#"& prefix, in which case the remainder of the text is
37673 specific to the SMTP server. A valid ETRN command causes a run of Exim with
37674 the &%-R%& option to happen, with the remainder of the ETRN text as its
37675 argument. For example,
37676 .code
37677 ETRN #brigadoon
37678 .endd
37679 runs the command
37680 .code
37681 exim -R brigadoon
37682 .endd
37683 which causes a delivery attempt on all messages with undelivered addresses
37684 containing the text &"brigadoon"&. When &%smtp_etrn_serialize%& is set (the
37685 default), Exim prevents the simultaneous execution of more than one queue run
37686 for the same argument string as a result of an ETRN command. This stops
37687 a misbehaving client from starting more than one queue runner at once.
37688
37689 .cindex "hints database" "ETRN serialization"
37690 Exim implements the serialization by means of a hints database in which a
37691 record is written whenever a process is started by ETRN, and deleted when
37692 the process completes. However, Exim does not keep the SMTP session waiting for
37693 the ETRN process to complete. Once ETRN is accepted, the client is sent
37694 a &"success"& return code. Obviously there is scope for hints records to get
37695 left lying around if there is a system or program crash. To guard against this,
37696 Exim ignores any records that are more than six hours old.
37697
37698 .oindex "&%smtp_etrn_command%&"
37699 For more control over what ETRN does, the &%smtp_etrn_command%& option can
37700 used. This specifies a command that is run whenever ETRN is received,
37701 whatever the form of its argument. For
37702 example:
37703 .code
37704 smtp_etrn_command = /etc/etrn_command $domain \
37705                     $sender_host_address
37706 .endd
37707 .vindex "&$domain$&"
37708 The string is split up into arguments which are independently expanded. The
37709 expansion variable &$domain$& is set to the argument of the ETRN command,
37710 and no syntax checking is done on the contents of this argument. Exim does not
37711 wait for the command to complete, so its status code is not checked. Exim runs
37712 under its own uid and gid when receiving incoming SMTP, so it is not possible
37713 for it to change them before running the command.
37714
37715
37716
37717 .section "Incoming local SMTP" "SECID238"
37718 .cindex "SMTP" "local incoming"
37719 Some user agents use SMTP to pass messages to their local MTA using the
37720 standard input and output, as opposed to passing the envelope on the command
37721 line and writing the message to the standard input. This is supported by the
37722 &%-bs%& option. This form of SMTP is handled in the same way as incoming
37723 messages over TCP/IP (including the use of ACLs), except that the envelope
37724 sender given in a MAIL command is ignored unless the caller is trusted. In
37725 an ACL you can detect this form of SMTP input by testing for an empty host
37726 identification. It is common to have this as the first line in the ACL that
37727 runs for RCPT commands:
37728 .code
37729 accept hosts = :
37730 .endd
37731 This accepts SMTP messages from local processes without doing any other tests.
37732
37733
37734
37735 .section "Outgoing batched SMTP" "SECTbatchSMTP"
37736 .cindex "SMTP" "batched outgoing"
37737 .cindex "batched SMTP output"
37738 Both the &(appendfile)& and &(pipe)& transports can be used for handling
37739 batched SMTP. Each has an option called &%use_bsmtp%& which causes messages to
37740 be output in BSMTP format. No SMTP responses are possible for this form of
37741 delivery. All it is doing is using SMTP commands as a way of transmitting the
37742 envelope along with the message.
37743
37744 The message is written to the file or pipe preceded by the SMTP commands
37745 MAIL and RCPT, and followed by a line containing a single dot. Lines in
37746 the message that start with a dot have an extra dot added. The SMTP command
37747 HELO is not normally used. If it is required, the &%message_prefix%& option
37748 can be used to specify it.
37749
37750 Because &(appendfile)& and &(pipe)& are both local transports, they accept only
37751 one recipient address at a time by default. However, you can arrange for them
37752 to handle several addresses at once by setting the &%batch_max%& option. When
37753 this is done for BSMTP, messages may contain multiple RCPT commands. See
37754 chapter &<<CHAPbatching>>& for more details.
37755
37756 .vindex "&$host$&"
37757 When one or more addresses are routed to a BSMTP transport by a router that
37758 sets up a host list, the name of the first host on the list is available to the
37759 transport in the variable &$host$&. Here is an example of such a transport and
37760 router:
37761 .code
37762 begin routers
37763 route_append:
37764   driver = manualroute
37765   transport = smtp_appendfile
37766   route_list = domain.example  batch.host.example
37767
37768 begin transports
37769 smtp_appendfile:
37770   driver = appendfile
37771   directory = /var/bsmtp/$host
37772   batch_max = 1000
37773   use_bsmtp
37774   user = exim
37775 .endd
37776 This causes messages addressed to &'domain.example'& to be written in BSMTP
37777 format to &_/var/bsmtp/batch.host.example_&, with only a single copy of each
37778 message (unless there are more than 1000 recipients).
37779
37780
37781
37782 .section "Incoming batched SMTP" "SECTincomingbatchedSMTP"
37783 .cindex "SMTP" "batched incoming"
37784 .cindex "batched SMTP input"
37785 The &%-bS%& command line option causes Exim to accept one or more messages by
37786 reading SMTP on the standard input, but to generate no responses. If the caller
37787 is trusted, the senders in the MAIL commands are believed; otherwise the
37788 sender is always the caller of Exim. Unqualified senders and receivers are not
37789 rejected (there seems little point) but instead just get qualified. HELO
37790 and EHLO act as RSET; VRFY, EXPN, ETRN and  HELP, act
37791 as NOOP; QUIT quits.
37792
37793 Minimal policy checking is done for BSMTP input. Only the non-SMTP
37794 ACL is run in the same way as for non-SMTP local input.
37795
37796 If an error is detected while reading a message, including a missing &"."& at
37797 the end, Exim gives up immediately. It writes details of the error to the
37798 standard output in a stylized way that the calling program should be able to
37799 make some use of automatically, for example:
37800 .code
37801 554 Unexpected end of file
37802 Transaction started in line 10
37803 Error detected in line 14
37804 .endd
37805 It writes a more verbose version, for human consumption, to the standard error
37806 file, for example:
37807 .code
37808 An error was detected while processing a file of BSMTP input.
37809 The error message was:
37810
37811 501 '>' missing at end of address
37812
37813 The SMTP transaction started in line 10.
37814 The error was detected in line 12.
37815 The SMTP command at fault was:
37816
37817 rcpt to:<malformed@in.com.plete
37818
37819 1 previous message was successfully processed.
37820 The rest of the batch was abandoned.
37821 .endd
37822 The return code from Exim is zero only if there were no errors. It is 1 if some
37823 messages were accepted before an error was detected, and 2 if no messages were
37824 accepted.
37825 .ecindex IIDsmtpproc1
37826 .ecindex IIDsmtpproc2
37827
37828
37829
37830 . ////////////////////////////////////////////////////////////////////////////
37831 . ////////////////////////////////////////////////////////////////////////////
37832
37833 .chapter "Customizing bounce and warning messages" "CHAPemsgcust" &&&
37834          "Customizing messages"
37835 When a message fails to be delivered, or remains in the queue for more than a
37836 configured amount of time, Exim sends a message to the original sender, or
37837 to an alternative configured address. The text of these messages is built into
37838 the code of Exim, but it is possible to change it, either by adding a single
37839 string, or by replacing each of the paragraphs by text supplied in a file.
37840
37841 The &'From:'& and &'To:'& header lines are automatically generated; you can
37842 cause a &'Reply-To:'& line to be added by setting the &%errors_reply_to%&
37843 option. Exim also adds the line
37844 .code
37845 Auto-Submitted: auto-generated
37846 .endd
37847 to all warning and bounce messages,
37848
37849
37850 .section "Customizing bounce messages" "SECID239"
37851 .cindex "customizing" "bounce message"
37852 .cindex "bounce message" "customizing"
37853 If &%bounce_message_text%& is set, its contents are included in the default
37854 message immediately after &"This message was created automatically by mail
37855 delivery software."& The string is not expanded. It is not used if
37856 &%bounce_message_file%& is set.
37857
37858 When &%bounce_message_file%& is set, it must point to a template file for
37859 constructing error messages. The file consists of a series of text items,
37860 separated by lines consisting of exactly four asterisks. If the file cannot be
37861 opened, default text is used and a message is written to the main and panic
37862 logs. If any text item in the file is empty, default text is used for that
37863 item.
37864
37865 .vindex "&$bounce_recipient$&"
37866 .vindex "&$bounce_return_size_limit$&"
37867 Each item of text that is read from the file is expanded, and there are two
37868 expansion variables which can be of use here: &$bounce_recipient$& is set to
37869 the recipient of an error message while it is being created, and
37870 &$bounce_return_size_limit$& contains the value of the &%return_size_limit%&
37871 option, rounded to a whole number.
37872
37873 The items must appear in the file in the following order:
37874
37875 .ilist
37876 The first item is included in the headers, and should include at least a
37877 &'Subject:'& header. Exim does not check the syntax of these headers.
37878 .next
37879 The second item forms the start of the error message. After it, Exim lists the
37880 failing addresses with their error messages.
37881 .next
37882 The third item is used to introduce any text from pipe transports that is to be
37883 returned to the sender. It is omitted if there is no such text.
37884 .next
37885 The fourth, fifth and sixth items will be ignored and may be empty.
37886 The fields exist for back-compatibility
37887 .endlist
37888
37889 The default state (&%bounce_message_file%& unset) is equivalent to the
37890 following file, in which the sixth item is empty. The &'Subject:'& and some
37891 other lines have been split in order to fit them on the page:
37892 .code
37893 Subject: Mail delivery failed
37894   ${if eq{$sender_address}{$bounce_recipient}
37895   {: returning message to sender}}
37896 ****
37897 This message was created automatically by mail delivery software.
37898
37899 A message ${if eq{$sender_address}{$bounce_recipient}
37900   {that you sent }{sent by
37901
37902 <$sender_address>
37903
37904 }}could not be delivered to all of its recipients.
37905 This is a permanent error. The following address(es) failed:
37906 ****
37907 The following text was generated during the delivery attempt(s):
37908 ****
37909 ------ This is a copy of the message, including all the headers.
37910   ------
37911 ****
37912 ------ The body of the message is $message_size characters long;
37913   only the first
37914 ------ $bounce_return_size_limit or so are included here.
37915 ****
37916 .endd
37917 .section "Customizing warning messages" "SECTcustwarn"
37918 .cindex "customizing" "warning message"
37919 .cindex "warning of delay" "customizing the message"
37920 The option &%warn_message_file%& can be pointed at a template file for use when
37921 warnings about message delays are created. In this case there are only three
37922 text sections:
37923
37924 .ilist
37925 The first item is included in the headers, and should include at least a
37926 &'Subject:'& header. Exim does not check the syntax of these headers.
37927 .next
37928 The second item forms the start of the warning message. After it, Exim lists
37929 the delayed addresses.
37930 .next
37931 The third item then ends the message.
37932 .endlist
37933
37934 The default state is equivalent to the following file, except that some lines
37935 have been split here, in order to fit them on the page:
37936 .code
37937 Subject: Warning: message $message_exim_id delayed
37938   $warn_message_delay
37939 ****
37940 This message was created automatically by mail delivery software.
37941
37942 A message ${if eq{$sender_address}{$warn_message_recipients}
37943 {that you sent }{sent by
37944
37945 <$sender_address>
37946
37947 }}has not been delivered to all of its recipients after
37948 more than $warn_message_delay in the queue on $primary_hostname.
37949
37950 The message identifier is:     $message_exim_id
37951 The subject of the message is: $h_subject
37952 The date of the message is:    $h_date
37953
37954 The following address(es) have not yet been delivered:
37955 ****
37956 No action is required on your part. Delivery attempts will
37957 continue for some time, and this warning may be repeated at
37958 intervals if the message remains undelivered. Eventually the
37959 mail delivery software will give up, and when that happens,
37960 the message will be returned to you.
37961 .endd
37962 .vindex "&$warn_message_delay$&"
37963 .vindex "&$warn_message_recipients$&"
37964 However, in the default state the subject and date lines are omitted if no
37965 appropriate headers exist. During the expansion of this file,
37966 &$warn_message_delay$& is set to the delay time in one of the forms &"<&'n'&>
37967 minutes"& or &"<&'n'&> hours"&, and &$warn_message_recipients$& contains a list
37968 of recipients for the warning message. There may be more than one if there are
37969 multiple addresses with different &%errors_to%& settings on the routers that
37970 handled them.
37971
37972
37973
37974
37975 . ////////////////////////////////////////////////////////////////////////////
37976 . ////////////////////////////////////////////////////////////////////////////
37977
37978 .chapter "Some common configuration settings" "CHAPcomconreq"
37979 This chapter discusses some configuration settings that seem to be fairly
37980 common. More examples and discussion can be found in the Exim book.
37981
37982
37983
37984 .section "Sending mail to a smart host" "SECID240"
37985 .cindex "smart host" "example router"
37986 If you want to send all mail for non-local domains to a &"smart host"&, you
37987 should replace the default &(dnslookup)& router with a router which does the
37988 routing explicitly:
37989 .code
37990 send_to_smart_host:
37991   driver = manualroute
37992   route_list = !+local_domains smart.host.name
37993   transport = remote_smtp
37994 .endd
37995 You can use the smart host's IP address instead of the name if you wish.
37996 If you are using Exim only to submit messages to a smart host, and not for
37997 receiving incoming messages, you can arrange for it to do the submission
37998 synchronously by setting the &%mua_wrapper%& option (see chapter
37999 &<<CHAPnonqueueing>>&).
38000
38001
38002
38003
38004 .section "Using Exim to handle mailing lists" "SECTmailinglists"
38005 .cindex "mailing lists"
38006 Exim can be used to run simple mailing lists, but for large and/or complicated
38007 requirements, the use of additional specialized mailing list software such as
38008 Majordomo or Mailman is recommended.
38009
38010 The &(redirect)& router can be used to handle mailing lists where each list
38011 is maintained in a separate file, which can therefore be managed by an
38012 independent manager. The &%domains%& router option can be used to run these
38013 lists in a separate domain from normal mail. For example:
38014 .code
38015 lists:
38016   driver = redirect
38017   domains = lists.example
38018   file = ${lookup {$local_part} dsearch,ret=full {/usr/lists}}
38019   forbid_pipe
38020   forbid_file
38021   errors_to = ${quote_local_part:$local_part-request}@lists.example
38022   no_more
38023 .endd
38024 This router is skipped for domains other than &'lists.example'&. For addresses
38025 in that domain, it looks for a file that matches the local part. If there is no
38026 such file, the router declines, but because &%no_more%& is set, no subsequent
38027 routers are tried, and so the whole delivery fails.
38028
38029 The &%forbid_pipe%& and &%forbid_file%& options prevent a local part from being
38030 expanded into a filename or a pipe delivery, which is usually inappropriate in
38031 a mailing list.
38032
38033 .oindex "&%errors_to%&"
38034 The &%errors_to%& option specifies that any delivery errors caused by addresses
38035 taken from a mailing list are to be sent to the given address rather than the
38036 original sender of the message. However, before acting on this, Exim verifies
38037 the error address, and ignores it if verification fails.
38038
38039 For example, using the configuration above, mail sent to
38040 &'dicts@lists.example'& is passed on to those addresses contained in
38041 &_/usr/lists/dicts_&, with error reports directed to
38042 &'dicts-request@lists.example'&, provided that this address can be verified.
38043 There could be a file called &_/usr/lists/dicts-request_& containing
38044 the address(es) of this particular list's manager(s), but other approaches,
38045 such as setting up an earlier router (possibly using the &%local_part_prefix%&
38046 or &%local_part_suffix%& options) to handle addresses of the form
38047 &%owner-%&&'xxx'& or &%xxx-%&&'request'&, are also possible.
38048
38049
38050
38051 .section "Syntax errors in mailing lists" "SECID241"
38052 .cindex "mailing lists" "syntax errors in"
38053 If an entry in redirection data contains a syntax error, Exim normally defers
38054 delivery of the original address. That means that a syntax error in a mailing
38055 list holds up all deliveries to the list. This may not be appropriate when a
38056 list is being maintained automatically from data supplied by users, and the
38057 addresses are not rigorously checked.
38058
38059 If the &%skip_syntax_errors%& option is set, the &(redirect)& router just skips
38060 entries that fail to parse, noting the incident in the log. If in addition
38061 &%syntax_errors_to%& is set to a verifiable address, a message is sent to it
38062 whenever a broken address is skipped. It is usually appropriate to set
38063 &%syntax_errors_to%& to the same address as &%errors_to%&.
38064
38065
38066
38067 .section "Re-expansion of mailing lists" "SECID242"
38068 .cindex "mailing lists" "re-expansion of"
38069 Exim remembers every individual address to which a message has been delivered,
38070 in order to avoid duplication, but it normally stores only the original
38071 recipient addresses with a message. If all the deliveries to a mailing list
38072 cannot be done at the first attempt, the mailing list is re-expanded when the
38073 delivery is next tried. This means that alterations to the list are taken into
38074 account at each delivery attempt, so addresses that have been added to
38075 the list since the message arrived will therefore receive a copy of the
38076 message, even though it pre-dates their subscription.
38077
38078 If this behaviour is felt to be undesirable, the &%one_time%& option can be set
38079 on the &(redirect)& router. If this is done, any addresses generated by the
38080 router that fail to deliver at the first attempt are added to the message as
38081 &"top level"& addresses, and the parent address that generated them is marked
38082 &"delivered"&. Thus, expansion of the mailing list does not happen again at the
38083 subsequent delivery attempts. The disadvantage of this is that if any of the
38084 failing addresses are incorrect, correcting them in the file has no effect on
38085 pre-existing messages.
38086
38087 The original top-level address is remembered with each of the generated
38088 addresses, and is output in any log messages. However, any intermediate parent
38089 addresses are not recorded. This makes a difference to the log only if the
38090 &%all_parents%& selector is set, but for mailing lists there is normally only
38091 one level of expansion anyway.
38092
38093
38094
38095 .section "Closed mailing lists" "SECID243"
38096 .cindex "mailing lists" "closed"
38097 The examples so far have assumed open mailing lists, to which anybody may
38098 send mail. It is also possible to set up closed lists, where mail is accepted
38099 from specified senders only. This is done by making use of the generic
38100 &%senders%& option to restrict the router that handles the list.
38101
38102 The following example uses the same file as a list of recipients and as a list
38103 of permitted senders. It requires three routers:
38104 .code
38105 lists_request:
38106   driver = redirect
38107   domains = lists.example
38108   local_part_suffix = -request
38109   local_parts = ${lookup {$local_part} dsearch,filter=file {/usr/lists}}
38110   file = /usr/lists/${local_part_data}-request
38111   no_more
38112
38113 lists_post:
38114   driver = redirect
38115   domains = lists.example
38116   local_parts = ${lookup {$local_part} dsearch,filter=file,ret=full {/usr/lists}}
38117   senders = ${if exists {$local_part_data} {lsearch;$local_part_data}{*}}
38118   file = ${lookup {$local_part} dsearch,ret=full {/usr/lists}}
38119   forbid_pipe
38120   forbid_file
38121   errors_to = ${quote_local_part:$local_part-request}@lists.example
38122   no_more
38123
38124 lists_closed:
38125   driver = redirect
38126   domains = lists.example
38127   allow_fail
38128   data = :fail: $local_part@lists.example is a closed mailing list
38129 .endd
38130 All three routers have the same &%domains%& setting, so for any other domains,
38131 they are all skipped. The first router runs only if the local part ends in
38132 &%-request%&. It handles messages to the list manager(s) by means of an open
38133 mailing list.
38134
38135 The second router runs only if the &%senders%& precondition is satisfied. It
38136 checks for the existence of a list that corresponds to the local part, and then
38137 checks that the sender is on the list by means of a linear search. It is
38138 necessary to check for the existence of the file before trying to search it,
38139 because otherwise Exim thinks there is a configuration error. If the file does
38140 not exist, the expansion of &%senders%& is *, which matches all senders. This
38141 means that the router runs, but because there is no list, declines, and
38142 &%no_more%& ensures that no further routers are run. The address fails with an
38143 &"unrouteable address"& error.
38144
38145 The third router runs only if the second router is skipped, which happens when
38146 a mailing list exists, but the sender is not on it. This router forcibly fails
38147 the address, giving a suitable error message.
38148
38149
38150
38151
38152 .section "Variable Envelope Return Paths (VERP)" "SECTverp"
38153 .cindex "VERP"
38154 .cindex "Variable Envelope Return Paths"
38155 .cindex "envelope from"
38156 .cindex "envelope sender"
38157 Variable Envelope Return Paths &-- see &url(https://cr.yp.to/proto/verp.txt) &--
38158 are a way of helping mailing list administrators discover which subscription
38159 address is the cause of a particular delivery failure. The idea is to encode
38160 the original recipient address in the outgoing envelope sender address, so that
38161 if the message is forwarded by another host and then subsequently bounces, the
38162 original recipient can be extracted from the recipient address of the bounce.
38163
38164 .oindex &%errors_to%&
38165 .oindex &%return_path%&
38166 Envelope sender addresses can be modified by Exim using two different
38167 facilities: the &%errors_to%& option on a router (as shown in previous mailing
38168 list examples), or the &%return_path%& option on a transport. The second of
38169 these is effective only if the message is successfully delivered to another
38170 host; it is not used for errors detected on the local host (see the description
38171 of &%return_path%& in chapter &<<CHAPtransportgeneric>>&). Here is an example
38172 of the use of &%return_path%& to implement VERP on an &(smtp)& transport:
38173 .code
38174 verp_smtp:
38175   driver = smtp
38176   max_rcpt = 1
38177   return_path = \
38178     ${if match {$return_path}{^(.+?)-request@your.dom.example\$}\
38179       {${quote_local_part:$1-request+$local_part=$domain}@your.dom.example}fail}
38180 .endd
38181 This has the effect of rewriting the return path (envelope sender) on outgoing
38182 SMTP messages, if the local part of the original return path ends in
38183 &"-request"&, and the domain is &'your.dom.example'&. The rewriting inserts the
38184 local part and domain of the recipient into the return path. Suppose, for
38185 example, that a message whose return path has been set to
38186 &'somelist-request@your.dom.example'& is sent to
38187 &'subscriber@other.dom.example'&. In the transport, the return path is
38188 rewritten as
38189 .code
38190 somelist-request+subscriber=other.dom.example@your.dom.example
38191 .endd
38192 .vindex "&$local_part$&"
38193 For this to work, you must tell Exim to send multiple copies of messages that
38194 have more than one recipient, so that each copy has just one recipient. This is
38195 achieved by setting &%max_rcpt%& to 1. Without this, a single copy of a message
38196 might be sent to several different recipients in the same domain, in which case
38197 &$local_part$& is not available in the transport, because it is not unique.
38198
38199 Unless your host is doing nothing but mailing list deliveries, you should
38200 probably use a separate transport for the VERP deliveries, so as not to use
38201 extra resources in making one-per-recipient copies for other deliveries. This
38202 can easily be done by expanding the &%transport%& option in the router:
38203 .code
38204 dnslookup:
38205   driver = dnslookup
38206   domains = ! +local_domains
38207   transport = \
38208     ${if match {$return_path}{^(.+?)-request@your.dom.example\$}\
38209       {verp_smtp}{remote_smtp}}
38210   no_more
38211 .endd
38212 If you want to change the return path using &%errors_to%& in a router instead
38213 of using &%return_path%& in the transport, you need to set &%errors_to%& on all
38214 routers that handle mailing list addresses. This will ensure that all delivery
38215 errors, including those detected on the local host, are sent to the VERP
38216 address.
38217
38218 On a host that does no local deliveries and has no manual routing, only the
38219 &(dnslookup)& router needs to be changed. A special transport is not needed for
38220 SMTP deliveries. Every mailing list recipient has its own return path value,
38221 and so Exim must hand them to the transport one at a time. Here is an example
38222 of a &(dnslookup)& router that implements VERP:
38223 .code
38224 verp_dnslookup:
38225   driver = dnslookup
38226   domains = ! +local_domains
38227   transport = remote_smtp
38228   errors_to = \
38229     ${if match {$return_path}{^(.+?)-request@your.dom.example\$}}
38230      {${quote_local_part:$1-request+$local_part=$domain}@your.dom.example}fail}
38231   no_more
38232 .endd
38233 Before you start sending out messages with VERPed return paths, you must also
38234 configure Exim to accept the bounce messages that come back to those paths.
38235 Typically this is done by setting a &%local_part_suffix%& option for a
38236 router, and using this to route the messages to wherever you want to handle
38237 them.
38238
38239 The overhead incurred in using VERP depends very much on the size of the
38240 message, the number of recipient addresses that resolve to the same remote
38241 host, and the speed of the connection over which the message is being sent. If
38242 a lot of addresses resolve to the same host and the connection is slow, sending
38243 a separate copy of the message for each address may take substantially longer
38244 than sending a single copy with many recipients (for which VERP cannot be
38245 used).
38246
38247
38248
38249
38250
38251
38252 .section "Virtual domains" "SECTvirtualdomains"
38253 .cindex "virtual domains"
38254 .cindex "domain" "virtual"
38255 The phrase &'virtual domain'& is unfortunately used with two rather different
38256 meanings:
38257
38258 .ilist
38259 A domain for which there are no real mailboxes; all valid local parts are
38260 aliases for other email addresses. Common examples are organizational
38261 top-level domains and &"vanity"& domains.
38262 .next
38263 One of a number of independent domains that are all handled by the same host,
38264 with mailboxes on that host, but where the mailbox owners do not necessarily
38265 have login accounts on that host.
38266 .endlist
38267
38268 The first usage is probably more common, and does seem more &"virtual"& than
38269 the second. This kind of domain can be handled in Exim with a straightforward
38270 aliasing router. One approach is to create a separate alias file for each
38271 virtual domain. Exim can test for the existence of the alias file to determine
38272 whether the domain exists. The &(dsearch)& lookup type is useful here, leading
38273 to a router of this form:
38274 .code
38275 virtual:
38276   driver = redirect
38277   domains = dsearch;/etc/mail/virtual
38278   data = ${lookup{$local_part}lsearch{/etc/mail/virtual/$domain_data}}
38279   no_more
38280 .endd
38281 The &%domains%& option specifies that the router is to be skipped, unless there
38282 is a file in the &_/etc/mail/virtual_& directory whose name is the same as the
38283 domain that is being processed.
38284 The &(dsearch)& lookup used results in an untainted version of &$domain$&
38285 being placed into the &$domain_data$& variable.
38286
38287 When the router runs, it looks up the local
38288 part in the file to find a new address (or list of addresses). The &%no_more%&
38289 setting ensures that if the lookup fails (leading to &%data%& being an empty
38290 string), Exim gives up on the address without trying any subsequent routers.
38291
38292 This one router can handle all the virtual domains because the alias filenames
38293 follow a fixed pattern. Permissions can be arranged so that appropriate people
38294 can edit the different alias files. A successful aliasing operation results in
38295 a new envelope recipient address, which is then routed from scratch.
38296
38297 The other kind of &"virtual"& domain can also be handled in a straightforward
38298 way. One approach is to create a file for each domain containing a list of
38299 valid local parts, and use it in a router like this:
38300 .code
38301 my_domains:
38302   driver = accept
38303   domains = dsearch;/etc/mail/domains
38304   local_parts = lsearch;/etc/mail/domains/$domain
38305   transport = my_mailboxes
38306 .endd
38307 The address is accepted if there is a file for the domain, and the local part
38308 can be found in the file. The &%domains%& option is used to check for the
38309 file's existence because &%domains%& is tested before the &%local_parts%&
38310 option (see section &<<SECTrouprecon>>&). You cannot use &%require_files%&,
38311 because that option is tested after &%local_parts%&. The transport is as
38312 follows:
38313 .code
38314 my_mailboxes:
38315   driver = appendfile
38316   file = /var/mail/$domain_data/$local_part_data
38317   user = mail
38318 .endd
38319 This uses a directory of mailboxes for each domain. The &%user%& setting is
38320 required, to specify which uid is to be used for writing to the mailboxes.
38321
38322 The configuration shown here is just one example of how you might support this
38323 requirement. There are many other ways this kind of configuration can be set
38324 up, for example, by using a database instead of separate files to hold all the
38325 information about the domains.
38326
38327
38328
38329 .section "Multiple user mailboxes" "SECTmulbox"
38330 .cindex "multiple mailboxes"
38331 .cindex "mailbox" "multiple"
38332 .cindex "local part" "prefix"
38333 .cindex "local part" "suffix"
38334 Heavy email users often want to operate with multiple mailboxes, into which
38335 incoming mail is automatically sorted. A popular way of handling this is to
38336 allow users to use multiple sender addresses, so that replies can easily be
38337 identified. Users are permitted to add prefixes or suffixes to their local
38338 parts for this purpose. The wildcard facility of the generic router options
38339 &%local_part_prefix%& and &%local_part_suffix%& can be used for this. For
38340 example, consider this router:
38341 .code
38342 userforward:
38343   driver = redirect
38344   check_local_user
38345   file = $home/.forward
38346   local_part_suffix = -*
38347   local_part_suffix_optional
38348   allow_filter
38349 .endd
38350 .vindex "&$local_part_suffix$&"
38351 It runs a user's &_.forward_& file for all local parts of the form
38352 &'username-*'&. Within the filter file the user can distinguish different
38353 cases by testing the variable &$local_part_suffix$&. For example:
38354 .code
38355 if $local_part_suffix contains -special then
38356 save /home/$local_part_data/Mail/special
38357 endif
38358 .endd
38359 If the filter file does not exist, or does not deal with such addresses, they
38360 fall through to subsequent routers, and, assuming no subsequent use of the
38361 &%local_part_suffix%& option is made, they presumably fail. Thus, users have
38362 control over which suffixes are valid.
38363
38364 Alternatively, a suffix can be used to trigger the use of a different
38365 &_.forward_& file &-- which is the way a similar facility is implemented in
38366 another MTA:
38367 .code
38368 userforward:
38369   driver = redirect
38370   check_local_user
38371   local_part_suffix = -*
38372   local_part_suffix_optional
38373   file = ${lookup {.forward$local_part_suffix} dsearch,ret=full {$home} {$value}fail}
38374   allow_filter
38375 .endd
38376 If there is no suffix, &_.forward_& is used; if the suffix is &'-special'&, for
38377 example, &_.forward-special_& is used. Once again, if the appropriate file
38378 does not exist, or does not deal with the address, it is passed on to
38379 subsequent routers, which could, if required, look for an unqualified
38380 &_.forward_& file to use as a default.
38381
38382
38383
38384 .section "Simplified vacation processing" "SECID244"
38385 .cindex "vacation processing"
38386 The traditional way of running the &'vacation'& program is for a user to set up
38387 a pipe command in a &_.forward_& file
38388 (see section &<<SECTspecitredli>>& for syntax details).
38389 This is prone to error by inexperienced users. There are two features of Exim
38390 that can be used to make this process simpler for users:
38391
38392 .ilist
38393 A local part prefix such as &"vacation-"& can be specified on a router which
38394 can cause the message to be delivered directly to the &'vacation'& program, or
38395 alternatively can use Exim's &(autoreply)& transport. The contents of a user's
38396 &_.forward_& file are then much simpler. For example:
38397 .code
38398 spqr, vacation-spqr
38399 .endd
38400 .next
38401 The &%require_files%& generic router option can be used to trigger a
38402 vacation delivery by checking for the existence of a certain file in the
38403 user's home directory. The &%unseen%& generic option should also be used, to
38404 ensure that the original delivery also proceeds. In this case, all the user has
38405 to do is to create a file called, say, &_.vacation_&, containing a vacation
38406 message.
38407 .endlist
38408
38409 Another advantage of both these methods is that they both work even when the
38410 use of arbitrary pipes by users is locked out.
38411
38412
38413
38414 .section "Taking copies of mail" "SECID245"
38415 .cindex "message" "copying every"
38416 Some installations have policies that require archive copies of all messages to
38417 be made. A single copy of each message can easily be taken by an appropriate
38418 command in a system filter, which could, for example, use a different file for
38419 each day's messages.
38420
38421 There is also a shadow transport mechanism that can be used to take copies of
38422 messages that are successfully delivered by local transports, one copy per
38423 delivery. This could be used, &'inter alia'&, to implement automatic
38424 notification of delivery by sites that insist on doing such things.
38425
38426
38427
38428 .section "Intermittently connected hosts" "SECID246"
38429 .cindex "intermittently connected hosts"
38430 It has become quite common (because it is cheaper) for hosts to connect to the
38431 Internet periodically rather than remain connected all the time. The normal
38432 arrangement is that mail for such hosts accumulates on a system that is
38433 permanently connected.
38434
38435 Exim was designed for use on permanently connected hosts, and so it is not
38436 particularly well-suited to use in an intermittently connected environment.
38437 Nevertheless there are some features that can be used.
38438
38439
38440 .section "Exim on the upstream server host" "SECID247"
38441 It is tempting to arrange for incoming mail for the intermittently connected
38442 host to remain in Exim's queue until the client connects. However, this
38443 approach does not scale very well. Two different kinds of waiting message are
38444 being mixed up in the same queue &-- those that cannot be delivered because of
38445 some temporary problem, and those that are waiting for their destination host
38446 to connect. This makes it hard to manage the queue, as well as wasting
38447 resources, because each queue runner scans the entire queue.
38448
38449 A better approach is to separate off those messages that are waiting for an
38450 intermittently connected host. This can be done by delivering these messages
38451 into local files in batch SMTP, &"mailstore"&, or other envelope-preserving
38452 format, from where they are transmitted by other software when their
38453 destination connects. This makes it easy to collect all the mail for one host
38454 in a single directory, and to apply local timeout rules on a per-message basis
38455 if required.
38456
38457 On a very small scale, leaving the mail on Exim's queue can be made to work. If
38458 you are doing this, you should configure Exim with a long retry period for the
38459 intermittent host. For example:
38460 .code
38461 cheshire.wonderland.fict.example    *   F,5d,24h
38462 .endd
38463 This stops a lot of failed delivery attempts from occurring, but Exim remembers
38464 which messages it has queued up for that host. Once the intermittent host comes
38465 online, forcing delivery of one message (either by using the &%-M%& or &%-R%&
38466 options, or by using the ETRN SMTP command (see section &<<SECTETRN>>&)
38467 causes all the queued up messages to be delivered, often down a single SMTP
38468 connection. While the host remains connected, any new messages get delivered
38469 immediately.
38470
38471 If the connecting hosts do not have fixed IP addresses, that is, if a host is
38472 issued with a different IP address each time it connects, Exim's retry
38473 mechanisms on the holding host get confused, because the IP address is normally
38474 used as part of the key string for holding retry information. This can be
38475 avoided by unsetting &%retry_include_ip_address%& on the &(smtp)& transport.
38476 Since this has disadvantages for permanently connected hosts, it is best to
38477 arrange a separate transport for the intermittently connected ones.
38478
38479
38480
38481 .section "Exim on the intermittently connected client host" "SECID248"
38482 The value of &%smtp_accept_queue_per_connection%& should probably be
38483 increased, or even set to zero (that is, disabled) on the intermittently
38484 connected host, so that all incoming messages down a single connection get
38485 delivered immediately.
38486
38487 .cindex "SMTP" "passed connection"
38488 .cindex "SMTP" "multiple deliveries"
38489 .cindex "multiple SMTP deliveries"
38490 .cindex "first pass routing"
38491 Mail waiting to be sent from an intermittently connected host will probably
38492 not have been routed, because without a connection DNS lookups are not
38493 possible. This means that if a normal queue run is done at connection time,
38494 each message is likely to be sent in a separate SMTP session. This can be
38495 avoided by starting the queue run with a command line option beginning with
38496 &%-qq%& instead of &%-q%&. In this case, the queue is scanned twice. In the
38497 first pass, routing is done but no deliveries take place. The second pass is a
38498 normal queue run; since all the messages have been previously routed, those
38499 destined for the same host are likely to get sent as multiple deliveries in a
38500 single SMTP connection.
38501
38502
38503
38504 . ////////////////////////////////////////////////////////////////////////////
38505 . ////////////////////////////////////////////////////////////////////////////
38506
38507 .chapter "Using Exim as a non-queueing client" "CHAPnonqueueing" &&&
38508          "Exim as a non-queueing client"
38509 .cindex "client, non-queueing"
38510 .cindex "smart host" "suppressing queueing"
38511 On a personal computer, it is a common requirement for all
38512 email to be sent to a &"smart host"&. There are plenty of MUAs that can be
38513 configured to operate that way, for all the popular operating systems.
38514 However, there are some MUAs for Unix-like systems that cannot be so
38515 configured: they submit messages using the command line interface of
38516 &_/usr/sbin/sendmail_&. Furthermore, utility programs such as &'cron'& submit
38517 messages this way.
38518
38519 If the personal computer runs continuously, there is no problem, because it can
38520 run a conventional MTA that handles delivery to the smart host, and deal with
38521 any delays via its queueing mechanism. However, if the computer does not run
38522 continuously or runs different operating systems at different times, queueing
38523 email is not desirable.
38524
38525 There is therefore a requirement for something that can provide the
38526 &_/usr/sbin/sendmail_& interface but deliver messages to a smart host without
38527 any queueing or retrying facilities. Furthermore, the delivery to the smart
38528 host should be synchronous, so that if it fails, the sending MUA is immediately
38529 informed. In other words, we want something that extends an MUA that submits
38530 to a local MTA via the command line so that it behaves like one that submits
38531 to a remote smart host using TCP/SMTP.
38532
38533 There are a number of applications (for example, there is one called &'ssmtp'&)
38534 that do this job. However, people have found them to be lacking in various
38535 ways. For instance, you might want to allow aliasing and forwarding to be done
38536 before sending a message to the smart host.
38537
38538 Exim already had the necessary infrastructure for doing this job. Just a few
38539 tweaks were needed to make it behave as required, though it is somewhat of an
38540 overkill to use a fully-featured MTA for this purpose.
38541
38542 .oindex "&%mua_wrapper%&"
38543 There is a Boolean global option called &%mua_wrapper%&, defaulting false.
38544 Setting &%mua_wrapper%& true causes Exim to run in a special mode where it
38545 assumes that it is being used to &"wrap"& a command-line MUA in the manner
38546 just described. As well as setting &%mua_wrapper%&, you also need to provide a
38547 compatible router and transport configuration. Typically there will be just one
38548 router and one transport, sending everything to a smart host.
38549
38550 When run in MUA wrapping mode, the behaviour of Exim changes in the
38551 following ways:
38552
38553 .ilist
38554 A daemon cannot be run, nor will Exim accept incoming messages from &'inetd'&.
38555 In other words, the only way to submit messages is via the command line.
38556 .next
38557 Each message is synchronously delivered as soon as it is received (&%-odi%& is
38558 assumed). All queueing options (&%queue_only%&, &%queue_smtp_domains%&,
38559 &%control%& in an ACL, etc.) are quietly ignored. The Exim reception process
38560 does not finish until the delivery attempt is complete. If the delivery is
38561 successful, a zero return code is given.
38562 .next
38563 Address redirection is permitted, but the final routing for all addresses must
38564 be to the same remote transport, and to the same list of hosts. Furthermore,
38565 the return address (envelope sender) must be the same for all recipients, as
38566 must any added or deleted header lines. In other words, it must be possible to
38567 deliver the message in a single SMTP transaction, however many recipients there
38568 are.
38569 .next
38570 If these conditions are not met, or if routing any address results in a
38571 failure or defer status, or if Exim is unable to deliver all the recipients
38572 successfully to one of the smart hosts, delivery of the entire message fails.
38573 .next
38574 Because no queueing is allowed, all failures are treated as permanent; there
38575 is no distinction between 4&'xx'& and 5&'xx'& SMTP response codes from the
38576 smart host. Furthermore, because only a single yes/no response can be given to
38577 the caller, it is not possible to deliver to some recipients and not others. If
38578 there is an error (temporary or permanent) for any recipient, all are failed.
38579 .next
38580 If more than one smart host is listed, Exim will try another host after a
38581 connection failure or a timeout, in the normal way. However, if this kind of
38582 failure happens for all the hosts, the delivery fails.
38583 .next
38584 When delivery fails, an error message is written to the standard error stream
38585 (as well as to Exim's log), and Exim exits to the caller with a return code
38586 value 1. The message is expunged from Exim's spool files. No bounce messages
38587 are ever generated.
38588 .next
38589 No retry data is maintained, and any retry rules are ignored.
38590 .next
38591 A number of Exim options are overridden: &%deliver_drop_privilege%& is forced
38592 true, &%max_rcpt%& in the &(smtp)& transport is forced to &"unlimited"&,
38593 &%remote_max_parallel%& is forced to one, and fallback hosts are ignored.
38594 .endlist
38595
38596 The overall effect is that Exim makes a single synchronous attempt to deliver
38597 the message, failing if there is any kind of problem. Because no local
38598 deliveries are done and no daemon can be run, Exim does not need root
38599 privilege. It should be possible to run it setuid to &'exim'& instead of setuid
38600 to &'root'&. See section &<<SECTrunexiwitpri>>& for a general discussion about
38601 the advantages and disadvantages of running without root privilege.
38602
38603
38604
38605
38606 . ////////////////////////////////////////////////////////////////////////////
38607 . ////////////////////////////////////////////////////////////////////////////
38608
38609 .chapter "Log files" "CHAPlog"
38610 .scindex IIDloggen "log" "general description"
38611 .cindex "log" "types of"
38612 Exim writes three different logs, referred to as the main log, the reject log,
38613 and the panic log:
38614
38615 .ilist
38616 .cindex "main log"
38617 The main log records the arrival of each message and each delivery in a single
38618 line in each case. The format is as compact as possible, in an attempt to keep
38619 down the size of log files. Two-character flag sequences make it easy to pick
38620 out these lines. A number of other events are recorded in the main log. Some of
38621 them are optional, in which case the &%log_selector%& option controls whether
38622 they are included or not. A Perl script called &'eximstats'&, which does simple
38623 analysis of main log files, is provided in the Exim distribution (see section
38624 &<<SECTmailstat>>&).
38625 .next
38626 .cindex "reject log"
38627 The reject log records information from messages that are rejected as a result
38628 of a configuration option (that is, for policy reasons).
38629 The first line of each rejection is a copy of the line that is also written to
38630 the main log. Then, if the message's header has been read at the time the log
38631 is written, its contents are written to this log. Only the original header
38632 lines are available; header lines added by ACLs are not logged. You can use the
38633 reject log to check that your policy controls are working correctly; on a busy
38634 host this may be easier than scanning the main log for rejection messages. You
38635 can suppress the writing of the reject log by setting &%write_rejectlog%&
38636 false.
38637 .next
38638 .cindex "panic log"
38639 .cindex "system log"
38640 When certain serious errors occur, Exim writes entries to its panic log. If the
38641 error is sufficiently disastrous, Exim bombs out afterwards. Panic log entries
38642 are usually written to the main log as well, but can get lost amid the mass of
38643 other entries. The panic log should be empty under normal circumstances. It is
38644 therefore a good idea to check it (or to have a &'cron'& script check it)
38645 regularly, in order to become aware of any problems. When Exim cannot open its
38646 panic log, it tries as a last resort to write to the system log (syslog). This
38647 is opened with LOG_PID+LOG_CONS and the facility code of LOG_MAIL. The
38648 message itself is written at priority LOG_CRIT.
38649 .endlist
38650
38651 Every log line starts with a timestamp, in the format shown in the following
38652 example. Note that many of the examples shown in this chapter are line-wrapped.
38653 In the log file, this would be all on one line:
38654 .code
38655 2001-09-16 16:09:47 SMTP connection from [127.0.0.1] closed
38656   by QUIT
38657 .endd
38658 By default, the timestamps are in the local timezone. There are two
38659 ways of changing this:
38660
38661 .ilist
38662 You can set the &%timezone%& option to a different time zone; in particular, if
38663 you set
38664 .code
38665 timezone = UTC
38666 .endd
38667 the timestamps will be in UTC (aka GMT).
38668 .next
38669 If you set &%log_timezone%& true, the time zone is added to the timestamp, for
38670 example:
38671 .code
38672 2003-04-25 11:17:07 +0100 Start queue run: pid=12762
38673 .endd
38674 .endlist
38675
38676 .cindex "log" "process ids in"
38677 .cindex "pid (process id)" "in log lines"
38678 Exim does not include its process id in log lines by default, but you can
38679 request that it does so by specifying the &`pid`& log selector (see section
38680 &<<SECTlogselector>>&). When this is set, the process id is output, in square
38681 brackets, immediately after the time and date.
38682
38683
38684
38685
38686 .section "Where the logs are written" "SECTwhelogwri"
38687 .cindex "log" "destination"
38688 .cindex "log" "to file"
38689 .cindex "log" "to syslog"
38690 .cindex "syslog"
38691 The logs may be written to local files, or to syslog, or both. However, it
38692 should be noted that many syslog implementations use UDP as a transport, and
38693 are therefore unreliable in the sense that messages are not guaranteed to
38694 arrive at the loghost, nor is the ordering of messages necessarily maintained.
38695 It has also been reported that on large log files (tens of megabytes) you may
38696 need to tweak syslog to prevent it syncing the file with each write &-- on
38697 Linux this has been seen to make syslog take 90% plus of CPU time.
38698
38699 The destination for Exim's logs is configured by setting LOG_FILE_PATH in
38700 &_Local/Makefile_& or by setting &%log_file_path%& in the runtime
38701 configuration. This latter string is expanded, so it can contain, for example,
38702 references to the host name:
38703 .code
38704 log_file_path = /var/log/$primary_hostname/exim_%slog
38705 .endd
38706 It is generally advisable, however, to set the string in &_Local/Makefile_&
38707 rather than at runtime, because then the setting is available right from the
38708 start of Exim's execution. Otherwise, if there's something it wants to log
38709 before it has read the configuration file (for example, an error in the
38710 configuration file) it will not use the path you want, and may not be able to
38711 log at all.
38712
38713 The value of LOG_FILE_PATH or &%log_file_path%& is a colon-separated
38714 list, currently limited to at most two items. This is one option where the
38715 facility for changing a list separator may not be used. The list must always be
38716 colon-separated. If an item in the list is &"syslog"& then syslog is used;
38717 otherwise the item must either be an absolute path, containing &`%s`& at the
38718 point where &"main"&, &"reject"&, or &"panic"& is to be inserted, or be empty,
38719 implying the use of a default path.
38720
38721 When Exim encounters an empty item in the list, it searches the list defined by
38722 LOG_FILE_PATH, and uses the first item it finds that is neither empty nor
38723 &"syslog"&. This means that an empty item in &%log_file_path%& can be used to
38724 mean &"use the path specified at build time"&. If no such item exists, log
38725 files are written in the &_log_& subdirectory of the spool directory. This is
38726 equivalent to the configuration file setting:
38727 .code
38728 log_file_path = $spool_directory/log/%slog
38729 .endd
38730 If you do not specify anything at build time or runtime,
38731 or if you unset the option at runtime (i.e. &`log_file_path = `&),
38732 that is where the logs are written.
38733
38734 A log file path may also contain &`%D`& or &`%M`& if datestamped log filenames
38735 are in use &-- see section &<<SECTdatlogfil>>& below.
38736
38737 Here are some examples of possible Makefile settings:
38738 .display
38739 &`LOG_FILE_PATH=syslog                    `& syslog only
38740 &`LOG_FILE_PATH=:syslog                   `& syslog and default path
38741 &`LOG_FILE_PATH=syslog : /usr/log/exim_%s `& syslog and specified path
38742 &`LOG_FILE_PATH=/usr/log/exim_%s          `& specified path only
38743 .endd
38744 If there are more than two paths in the list, the first is used and a panic
38745 error is logged.
38746
38747
38748
38749 .section "Logging to local files that are periodically &""cycled""&" "SECID285"
38750 .cindex "log" "cycling local files"
38751 .cindex "cycling logs"
38752 .cindex "&'exicyclog'&"
38753 .cindex "log" "local files; writing to"
38754 Some operating systems provide centralized and standardized methods for cycling
38755 log files. For those that do not, a utility script called &'exicyclog'& is
38756 provided (see section &<<SECTcyclogfil>>&). This renames and compresses the
38757 main and reject logs each time it is called. The maximum number of old logs to
38758 keep can be set. It is suggested this script is run as a daily &'cron'& job.
38759
38760 An Exim delivery process opens the main log when it first needs to write to it,
38761 and it keeps the file open in case subsequent entries are required &-- for
38762 example, if a number of different deliveries are being done for the same
38763 message. However, remote SMTP deliveries can take a long time, and this means
38764 that the file may be kept open long after it is renamed if &'exicyclog'& or
38765 something similar is being used to rename log files on a regular basis. To
38766 ensure that a switch of log files is noticed as soon as possible, Exim calls
38767 &[stat()]& on the main log's name before reusing an open file, and if the file
38768 does not exist, or its inode has changed, the old file is closed and Exim
38769 tries to open the main log from scratch. Thus, an old log file may remain open
38770 for quite some time, but no Exim processes should write to it once it has been
38771 renamed.
38772
38773
38774
38775 .section "Datestamped log files" "SECTdatlogfil"
38776 .cindex "log" "datestamped files"
38777 Instead of cycling the main and reject log files by renaming them
38778 periodically, some sites like to use files whose names contain a datestamp,
38779 for example, &_mainlog-20031225_&. The datestamp is in the form &_yyyymmdd_& or
38780 &_yyyymm_&. Exim has support for this way of working. It is enabled by setting
38781 the &%log_file_path%& option to a path that includes &`%D`& or &`%M`& at the
38782 point where the datestamp is required. For example:
38783 .code
38784 log_file_path = /var/spool/exim/log/%slog-%D
38785 log_file_path = /var/log/exim-%s-%D.log
38786 log_file_path = /var/spool/exim/log/%D-%slog
38787 log_file_path = /var/log/exim/%s.%M
38788 .endd
38789 As before, &`%s`& is replaced by &"main"& or &"reject"&; the following are
38790 examples of names generated by the above examples:
38791 .code
38792 /var/spool/exim/log/mainlog-20021225
38793 /var/log/exim-reject-20021225.log
38794 /var/spool/exim/log/20021225-mainlog
38795 /var/log/exim/main.200212
38796 .endd
38797 When this form of log file is specified, Exim automatically switches to new
38798 files at midnight. It does not make any attempt to compress old logs; you
38799 will need to write your own script if you require this. You should not
38800 run &'exicyclog'& with this form of logging.
38801
38802 The location of the panic log is also determined by &%log_file_path%&, but it
38803 is not datestamped, because rotation of the panic log does not make sense.
38804 When generating the name of the panic log, &`%D`& or &`%M`& are removed from
38805 the string. In addition, if it immediately follows a slash, a following
38806 non-alphanumeric character is removed; otherwise a preceding non-alphanumeric
38807 character is removed. Thus, the four examples above would give these panic
38808 log names:
38809 .code
38810 /var/spool/exim/log/paniclog
38811 /var/log/exim-panic.log
38812 /var/spool/exim/log/paniclog
38813 /var/log/exim/panic
38814 .endd
38815
38816
38817 .section "Logging to syslog" "SECID249"
38818 .cindex "log" "syslog; writing to"
38819 The use of syslog does not change what Exim logs or the format of its messages,
38820 except in one respect. If &%syslog_timestamp%& is set false, the timestamps on
38821 Exim's log lines are omitted when these lines are sent to syslog. Apart from
38822 that, the same strings are written to syslog as to log files. The syslog
38823 &"facility"& is set to LOG_MAIL, and the program name to &"exim"&
38824 by default, but you can change these by setting the &%syslog_facility%& and
38825 &%syslog_processname%& options, respectively. If Exim was compiled with
38826 SYSLOG_LOG_PID set in &_Local/Makefile_& (this is the default in
38827 &_src/EDITME_&), then, on systems that permit it (all except ULTRIX), the
38828 LOG_PID flag is set so that the &[syslog()]& call adds the pid as well as
38829 the time and host name to each line.
38830 The three log streams are mapped onto syslog priorities as follows:
38831
38832 .ilist
38833 &'mainlog'& is mapped to LOG_INFO
38834 .next
38835 &'rejectlog'& is mapped to LOG_NOTICE
38836 .next
38837 &'paniclog'& is mapped to LOG_ALERT
38838 .endlist
38839
38840 Many log lines are written to both &'mainlog'& and &'rejectlog'&, and some are
38841 written to both &'mainlog'& and &'paniclog'&, so there will be duplicates if
38842 these are routed by syslog to the same place. You can suppress this duplication
38843 by setting &%syslog_duplication%& false.
38844
38845 Exim's log lines can sometimes be very long, and some of its &'rejectlog'&
38846 entries contain multiple lines when headers are included. To cope with both
38847 these cases, entries written to syslog are split into separate &[syslog()]&
38848 calls at each internal newline, and also after a maximum of
38849 870 data characters. (This allows for a total syslog line length of 1024, when
38850 additions such as timestamps are added.) If you are running a syslog
38851 replacement that can handle lines longer than the 1024 characters allowed by
38852 RFC 3164, you should set
38853 .code
38854 SYSLOG_LONG_LINES=yes
38855 .endd
38856 in &_Local/Makefile_& before building Exim. That stops Exim from splitting long
38857 lines, but it still splits at internal newlines in &'reject'& log entries.
38858
38859 To make it easy to re-assemble split lines later, each component of a split
38860 entry starts with a string of the form [<&'n'&>/<&'m'&>] or [<&'n'&>\<&'m'&>]
38861 where <&'n'&> is the component number and <&'m'&> is the total number of
38862 components in the entry. The / delimiter is used when the line was split
38863 because it was too long; if it was split because of an internal newline, the \
38864 delimiter is used. For example, supposing the length limit to be 50 instead of
38865 870, the following would be the result of a typical rejection message to
38866 &'mainlog'& (LOG_INFO), each line in addition being preceded by the time, host
38867 name, and pid as added by syslog:
38868 .code
38869 [1/5] 2002-09-16 16:09:43 16RdAL-0006pc-00 rejected from
38870 [2/5]  [127.0.0.1] (ph10): syntax error in 'From' header
38871 [3/5]  when scanning for sender: missing or malformed lo
38872 [4/5] cal part in "<>" (envelope sender is <ph10@cam.exa
38873 [5/5] mple>)
38874 .endd
38875 The same error might cause the following lines to be written to &"rejectlog"&
38876 (LOG_NOTICE):
38877 .code
38878 [1/18] 2002-09-16 16:09:43 16RdAL-0006pc-00 rejected fro
38879 [2/18] m [127.0.0.1] (ph10): syntax error in 'From' head
38880 [3/18] er when scanning for sender: missing or malformed
38881 [4/18]  local part in "<>" (envelope sender is <ph10@cam
38882 [5\18] .example>)
38883 [6\18] Recipients: ph10@some.domain.cam.example
38884 [7\18] P Received: from [127.0.0.1] (ident=ph10)
38885 [8\18]        by xxxxx.cam.example with smtp (Exim 4.00)
38886 [9\18]        id 16RdAL-0006pc-00
38887 [10/18]        for ph10@cam.example; Mon, 16 Sep 2002 16:
38888 [11\18] 09:43 +0100
38889 [12\18] F From: <>
38890 [13\18]   Subject: this is a test header
38891 [18\18]   X-something: this is another header
38892 [15/18] I Message-Id: <E16RdAL-0006pc-00@xxxxx.cam.examp
38893 [16\18] le>
38894 [17\18] B Bcc:
38895 [18/18]   Date: Mon, 16 Sep 2002 16:09:43 +0100
38896 .endd
38897 Log lines that are neither too long nor contain newlines are written to syslog
38898 without modification.
38899
38900 If only syslog is being used, the Exim monitor is unable to provide a log tail
38901 display, unless syslog is routing &'mainlog'& to a file on the local host and
38902 the environment variable EXIMON_LOG_FILE_PATH is set to tell the monitor
38903 where it is.
38904
38905
38906
38907 .section "Log line flags" "SECID250"
38908 One line is written to the main log for each message received, and for each
38909 successful, unsuccessful, and delayed delivery. These lines can readily be
38910 picked out by the distinctive two-character flags that immediately follow the
38911 timestamp. The flags are:
38912 .itable none 0 0 2 10* left 90* left
38913 .irow &%<=%&     "message arrival"
38914 .irow &%(=%&     "message fakereject"
38915 .irow &%=>%&     "normal message delivery"
38916 .irow &%->%&     "additional address in same delivery"
38917 .irow &%>>%&     "cutthrough message delivery"
38918 .irow &%*>%&     "delivery suppressed by &%-N%&"
38919 .irow &%**%&     "delivery failed; address bounced"
38920 .irow &%==%&     "delivery deferred; temporary problem"
38921 .endtable
38922
38923
38924 .section "Logging message reception" "SECID251"
38925 .cindex "log" "reception line"
38926 The format of the single-line entry in the main log that is written for every
38927 message received is shown in the basic example below, which is split over
38928 several lines in order to fit it on the page:
38929 .code
38930 2002-10-31 08:57:53 16ZCW1-0005MB-00 <= kryten@dwarf.fict.example
38931   H=mailer.fict.example [192.168.123.123] U=exim
38932   P=smtp S=5678 id=<incoming message id>
38933 .endd
38934 The address immediately following &"<="& is the envelope sender address. A
38935 bounce message is shown with the sender address &"<>"&, and if it is locally
38936 generated, this is followed by an item of the form
38937 .code
38938 R=<message id>
38939 .endd
38940 which is a reference to the message that caused the bounce to be sent.
38941
38942 .cindex "HELO"
38943 .cindex "EHLO"
38944 For messages from other hosts, the H and U fields identify the remote host and
38945 record the RFC 1413 identity of the user that sent the message, if one was
38946 received. The number given in square brackets is the IP address of the sending
38947 host. If there is a single, unparenthesized  host name in the H field, as
38948 above, it has been verified to correspond to the IP address (see the
38949 &%host_lookup%& option). If the name is in parentheses, it was the name quoted
38950 by the remote host in the SMTP HELO or EHLO command, and has not been
38951 verified. If verification yields a different name to that given for HELO or
38952 EHLO, the verified name appears first, followed by the HELO or EHLO
38953 name in parentheses.
38954
38955 Misconfigured hosts (and mail forgers) sometimes put an IP address, with or
38956 without brackets, in the HELO or EHLO command, leading to entries in
38957 the log containing text like these examples:
38958 .code
38959 H=(10.21.32.43) [192.168.8.34]
38960 H=([10.21.32.43]) [192.168.8.34]
38961 .endd
38962 This can be confusing. Only the final address in square brackets can be relied
38963 on.
38964
38965 For locally generated messages (that is, messages not received over TCP/IP),
38966 the H field is omitted, and the U field contains the login name of the caller
38967 of Exim.
38968
38969 .cindex "authentication" "logging"
38970 .cindex "AUTH" "logging"
38971 For all messages, the P field specifies the protocol used to receive the
38972 message. This is the value that is stored in &$received_protocol$&. In the case
38973 of incoming SMTP messages, the value indicates whether or not any SMTP
38974 extensions (ESMTP), encryption, or authentication were used. If the SMTP
38975 session was encrypted, there is an additional X field that records the cipher
38976 suite that was used.
38977
38978 .cindex log protocol
38979 The protocol is set to &"esmtpsa"& or &"esmtpa"& for messages received from
38980 hosts that have authenticated themselves using the SMTP AUTH command. The first
38981 value is used when the SMTP connection was encrypted (&"secure"&). In this case
38982 there is an additional item A= followed by the name of the authenticator that
38983 was used. If an authenticated identification was set up by the authenticator's
38984 &%server_set_id%& option, this is logged too, separated by a colon from the
38985 authenticator name.
38986
38987 .cindex "size" "of message"
38988 The id field records the existing message id, if present. The size of the
38989 received message is given by the S field. When the message is delivered,
38990 headers may be removed or added, so that the size of delivered copies of the
38991 message may not correspond with this value (and indeed may be different to each
38992 other).
38993
38994 The &%log_selector%& option can be used to request the logging of additional
38995 data when a message is received. See section &<<SECTlogselector>>& below.
38996
38997
38998
38999 .section "Logging deliveries" "SECID252"
39000 .cindex "log" "delivery line"
39001 The format of the single-line entry in the main log that is written for every
39002 delivery is shown in one of the examples below, for local and remote
39003 deliveries, respectively. Each example has been split into multiple lines in order
39004 to fit it on the page:
39005 .code
39006 2002-10-31 08:59:13 16ZCW1-0005MB-00 => marv
39007   <marv@hitch.fict.example> R=localuser T=local_delivery
39008 2002-10-31 09:00:10 16ZCW1-0005MB-00 =>
39009   monk@holistic.fict.example R=dnslookup T=remote_smtp
39010   H=holistic.fict.example [192.168.234.234]
39011 .endd
39012 For ordinary local deliveries, the original address is given in angle brackets
39013 after the final delivery address, which might be a pipe or a file. If
39014 intermediate address(es) exist between the original and the final address, the
39015 last of these is given in parentheses after the final address. The R and T
39016 fields record the router and transport that were used to process the address.
39017
39018 If SMTP AUTH was used for the delivery there is an additional item A=
39019 followed by the name of the authenticator that was used.
39020 If an authenticated identification was set up by the authenticator's &%client_set_id%&
39021 option, this is logged too, as a second colon-separated list item.
39022 Optionally (see the &%smtp_mailauth%& &%log_selector%&) there may be a third list item.
39023
39024 If a shadow transport was run after a successful local delivery, the log line
39025 for the successful delivery has an item added on the end, of the form
39026 .display
39027 &`ST=<`&&'shadow transport name'&&`>`&
39028 .endd
39029 If the shadow transport did not succeed, the error message is put in
39030 parentheses afterwards.
39031
39032 .cindex "asterisk" "after IP address"
39033 When more than one address is included in a single delivery (for example, two
39034 SMTP RCPT commands in one transaction) the second and subsequent addresses are
39035 flagged with &`->`& instead of &`=>`&. When two or more messages are delivered
39036 down a single SMTP connection, an asterisk follows the
39037 remote IP address (and port if enabled)
39038 in the log lines for the second and subsequent messages.
39039 When two or more messages are delivered down a single TLS connection, the
39040 DNS and some TLS-related information logged for the first message delivered
39041 will not be present in the log lines for the second and subsequent messages.
39042 TLS cipher information is still available.
39043
39044 .cindex "delivery" "cutthrough; logging"
39045 .cindex "cutthrough" "logging"
39046 When delivery is done in cutthrough mode it is flagged with &`>>`& and the log
39047 line precedes the reception line, since cutthrough waits for a possible
39048 rejection from the destination in case it can reject the sourced item.
39049
39050 The generation of a reply message by a filter file gets logged as a
39051 &"delivery"& to the addressee, preceded by &">"&.
39052
39053 The &%log_selector%& option can be used to request the logging of additional
39054 data when a message is delivered. See section &<<SECTlogselector>>& below.
39055
39056
39057 .section "Discarded deliveries" "SECID253"
39058 .cindex "discarded messages"
39059 .cindex "message" "discarded"
39060 .cindex "delivery" "discarded; logging"
39061 When a message is discarded as a result of the command &"seen finish"& being
39062 obeyed in a filter file which generates no deliveries, a log entry of the form
39063 .code
39064 2002-12-10 00:50:49 16auJc-0001UB-00 => discarded
39065   <low.club@bridge.example> R=userforward
39066 .endd
39067 is written, to record why no deliveries are logged. When a message is discarded
39068 because it is aliased to &":blackhole:"& the log line is like this:
39069 .code
39070 1999-03-02 09:44:33 10HmaX-0005vi-00 => :blackhole:
39071   <hole@nowhere.example> R=blackhole_router
39072 .endd
39073
39074
39075 .section "Deferred deliveries" "SECID254"
39076 When a delivery is deferred, a line of the following form is logged:
39077 .code
39078 2002-12-19 16:20:23 16aiQz-0002Q5-00 == marvin@endrest.example
39079   R=dnslookup T=smtp defer (146): Connection refused
39080 .endd
39081 In the case of remote deliveries, the error is the one that was given for the
39082 last IP address that was tried. Details of individual SMTP failures are also
39083 written to the log, so the above line would be preceded by something like
39084 .code
39085 2002-12-19 16:20:23 16aiQz-0002Q5-00 Failed to connect to
39086   mail1.endrest.example [192.168.239.239]: Connection refused
39087 .endd
39088 When a deferred address is skipped because its retry time has not been reached,
39089 a message is written to the log, but this can be suppressed by setting an
39090 appropriate value in &%log_selector%&.
39091
39092
39093
39094 .section "Delivery failures" "SECID255"
39095 .cindex "delivery" "failure; logging"
39096 If a delivery fails because an address cannot be routed, a line of the
39097 following form is logged:
39098 .code
39099 1995-12-19 16:20:23 0tRiQz-0002Q5-00 ** jim@trek99.example
39100   <jim@trek99.example>: unknown mail domain
39101 .endd
39102 If a delivery fails at transport time, the router and transport are shown, and
39103 the response from the remote host is included, as in this example:
39104 .code
39105 2002-07-11 07:14:17 17SXDU-000189-00 ** ace400@pb.example
39106   R=dnslookup T=remote_smtp: SMTP error from remote mailer
39107   after pipelined RCPT TO:<ace400@pb.example>: host
39108   pbmail3.py.example [192.168.63.111]: 553 5.3.0
39109   <ace400@pb.example>...Addressee unknown
39110 .endd
39111 The word &"pipelined"& indicates that the SMTP PIPELINING extension was being
39112 used. See &%hosts_avoid_esmtp%& in the &(smtp)& transport for a way of
39113 disabling PIPELINING. The log lines for all forms of delivery failure are
39114 flagged with &`**`&.
39115
39116
39117
39118 .section "Fake deliveries" "SECID256"
39119 .cindex "delivery" "fake; logging"
39120 If a delivery does not actually take place because the &%-N%& option has been
39121 used to suppress it, a normal delivery line is written to the log, except that
39122 &"=>"& is replaced by &"*>"&.
39123
39124
39125
39126 .section "Completion" "SECID257"
39127 A line of the form
39128 .code
39129 2002-10-31 09:00:11 16ZCW1-0005MB-00 Completed
39130 .endd
39131 is written to the main log when a message is about to be removed from the spool
39132 at the end of its processing.
39133
39134
39135
39136
39137 .section "Summary of Fields in Log Lines" "SECID258"
39138 .cindex "log" "summary of fields"
39139 A summary of the field identifiers that are used in log lines is shown in
39140 the following table:
39141 .display
39142 &`A   `&        authenticator name (and optional id and sender)
39143 &`C   `&        SMTP confirmation on delivery
39144 &`Ci  `&        connection identifier
39145 &`    `&        command list for &"no mail in SMTP session"&
39146 &`CV  `&        certificate verification status
39147 &`D   `&        duration of &"no mail in SMTP session"&
39148 &`DKIM`&        domain verified in incoming message
39149 &`DN  `&        distinguished name from peer certificate
39150 &`DS  `&        DNSSEC secured lookups
39151 &`DT  `&        on &`=>`&, &'=='& and &'**'& lines: time taken for, or to attempt, a delivery
39152 &`F   `&        sender address (on delivery lines)
39153 &`H   `&        host name and IP address
39154 &`I   `&        local interface used
39155 &`id  `&        message id (from header) for incoming message
39156 &`K   `&        CHUNKING extension used
39157 &`L   `&        on &`<=`& and &`=>`& lines: PIPELINING extension used
39158 &`M8S `&        8BITMIME status for incoming message
39159 &`P   `&        on &`<=`& lines: protocol used
39160 &`    `&        on &`=>`& and &`**`& lines: return path
39161 &`PRDR`&        PRDR extension used
39162 &`PRX `&        on &`<=`& and &`=>`& lines: proxy address
39163 &`Q   `&        alternate queue name
39164 &`QT  `&        on &`=>`& lines: time spent on queue so far
39165 &`    `&        on &"Completed"& lines: time spent on queue
39166 &`R   `&        on &`<=`& lines: reference for local bounce
39167 &`    `&        on &`=>`&  &`>>`& &`**`& and &`==`& lines: router name
39168 &`RT  `&        on &`<=`& lines: time taken for reception
39169 &`S   `&        size of message in bytes
39170 &`SNI `&        server name indication from TLS client hello
39171 &`ST  `&        shadow transport name
39172 &`T   `&        on &`<=`& lines: message subject (topic)
39173 &`TFO `&        connection took advantage of TCP Fast Open
39174 &`    `&        on &`=>`& &`**`& and &`==`& lines: transport name
39175 &`U   `&        local user or RFC 1413 identity
39176 &`X   `&        TLS cipher suite
39177 .endd
39178
39179
39180 .section "Other log entries" "SECID259"
39181 Various other types of log entry are written from time to time. Most should be
39182 self-explanatory. Among the more common are:
39183
39184 .ilist
39185 .cindex "retry" "time not reached"
39186 &'retry time not reached'&&~&~An address previously suffered a temporary error
39187 during routing or local delivery, and the time to retry has not yet arrived.
39188 This message is not written to an individual message log file unless it happens
39189 during the first delivery attempt.
39190 .next
39191 &'retry time not reached for any host'&&~&~An address previously suffered
39192 temporary errors during remote delivery, and the retry time has not yet arrived
39193 for any of the hosts to which it is routed.
39194 .next
39195 .cindex "spool directory" "file locked"
39196 &'spool file locked'&&~&~An attempt to deliver a message cannot proceed because
39197 some other Exim process is already working on the message. This can be quite
39198 common if queue running processes are started at frequent intervals. The
39199 &'exiwhat'& utility script can be used to find out what Exim processes are
39200 doing.
39201 .next
39202 .cindex "error" "ignored"
39203 &'error ignored'&&~&~There are several circumstances that give rise to this
39204 message:
39205 .olist
39206 Exim failed to deliver a bounce message whose age was greater than
39207 &%ignore_bounce_errors_after%&. The bounce was discarded.
39208 .next
39209 A filter file set up a delivery using the &"noerror"& option, and the delivery
39210 failed. The delivery was discarded.
39211 .next
39212 A delivery set up by a router configured with
39213 . ==== As this is a nested list, any displays it contains must be indented
39214 . ==== as otherwise they are too far to the left.
39215 .code
39216     errors_to = <>
39217 .endd
39218 failed. The delivery was discarded.
39219 .endlist olist
39220 .next
39221 .cindex DKIM "log line"
39222 &'DKIM: d='&&~&~Verbose results of a DKIM verification attempt, if enabled for
39223 logging and the message has a DKIM signature header.
39224 .endlist ilist
39225
39226
39227
39228
39229
39230 .section "Reducing or increasing what is logged" "SECTlogselector"
39231 .cindex "log" "selectors"
39232 By setting the &%log_selector%& global option, you can disable some of Exim's
39233 default logging to the main log, or you can request additional logging. The value of
39234 &%log_selector%& is made up of names preceded by plus or minus characters. For
39235 example:
39236 .code
39237 log_selector = +arguments -retry_defer
39238 .endd
39239 The list of optional log items is in the following table, with the default
39240 selection marked by asterisks:
39241 .itable none 0 0 3 2.8in left 10pt center 3in left
39242 .irow &`8bitmime`&                      &nbsp; "received 8BITMIME status"
39243 .irow &`acl_warn_skipped`&              *       "skipped &%warn%& statement in ACL"
39244 .irow &`address_rewrite`&               &nbsp; "address rewriting"
39245 .irow &`all_parents`&                   &nbsp; "all parents in => lines"
39246 .irow &`arguments`&                     &nbsp; "command line arguments"
39247 .irow &`connection_id`&                 &nbsp;  "connection identifier"
39248 .irow &`connection_reject`&             *       "connection rejections"
39249 .irow &`delay_delivery`&                *       "immediate delivery delayed"
39250 .irow &`deliver_time`&                  &nbsp; "time taken to attempt delivery"
39251 .irow &`delivery_size`&                 &nbsp; "add &`S=`&&'nnn'& to => lines"
39252 .irow &`dkim`&                          *       "DKIM verified domain on <= lines"
39253 .irow &`dkim_verbose`&                  &nbsp; "separate full DKIM verification result line, per signature; DKIM signing"
39254 .irow &`dnslist_defer`&                 *       "defers of DNS list (aka RBL) lookups"
39255 .irow &`dnssec`&                        &nbsp; "DNSSEC secured lookups"
39256 .irow &`etrn`&                          *       "ETRN commands"
39257 .irow &`host_lookup_failed`&            *       "as it says"
39258 .irow &`ident_timeout`&                 &nbsp; "timeout for ident connection"
39259 .irow &`incoming_interface`&            &nbsp; "local interface &amp; port on <= and => lines"
39260 .irow &`incoming_port`&                 &nbsp; "remote port on <= lines"
39261 .irow &`lost_incoming_connection`&      *       "as it says (includes timeouts)"
39262 .irow &`millisec`&                      &nbsp; "millisecond timestamps and RT,QT,DT,D times"
39263 .irow &`msg_id`&                        *       "on <= lines, Message-ID: header value"
39264 .irow &`msg_id_created`&                &nbsp; "on <= lines, Message-ID: header value when one had to be added"
39265 .irow &`outgoing_interface`&            &nbsp; "local interface on => lines"
39266 .irow &`outgoing_port`&                 &nbsp; "add remote port to => lines"
39267 .irow &`queue_run`&                     *       "start and end queue runs"
39268 .irow &`queue_time`&                    &nbsp; "time on queue for one recipient"
39269 .irow &`queue_time_exclusive`&          &nbsp; "exclude recieve time from QT times"
39270 .irow &`queue_time_overall`&            &nbsp; "time on queue for whole message"
39271 .irow &`pid`&                           &nbsp; "Exim process id"
39272 .irow &`pipelining`&                    &nbsp; "PIPELINING use, on <= and => lines"
39273 .irow &`proxy`&                         &nbsp; "proxy address on <= and => lines"
39274 .irow &`receive_time`&                  &nbsp; "time taken to receive message"
39275 .irow &`received_recipients`&           &nbsp; "recipients on <= lines"
39276 .irow &`received_sender`&               &nbsp; "sender on <= lines"
39277 .irow &`rejected_header`&               *       "header contents on reject log"
39278 .irow &`retry_defer`&                   *       "&<quote>&retry time not reached&</quote>&"
39279 .irow &`return_path_on_delivery`&       &nbsp; "put return path on => and ** lines"
39280 .irow &`sender_on_delivery`&            &nbsp; "add sender to => lines"
39281 .irow &`sender_verify_fail`&            *       "sender verification failures"
39282 .irow &`size_reject`&                   *       "rejection because too big"
39283 .irow &`skip_delivery`&                 *       "delivery skipped in a queue run"
39284 .irow &`smtp_confirmation`&             *       "SMTP confirmation on => lines"
39285 .irow &`smtp_connection`&               &nbsp; "incoming SMTP connections"
39286 .irow &`smtp_incomplete_transaction`&   &nbsp; "incomplete SMTP transactions"
39287 .irow &`smtp_mailauth`&                 &nbsp; "AUTH argument to MAIL commands"
39288 .irow &`smtp_no_mail`&                  &nbsp; "session with no MAIL commands"
39289 .irow &`smtp_protocol_error`&           &nbsp; "SMTP protocol errors"
39290 .irow &`smtp_syntax_error`&             &nbsp; "SMTP syntax errors"
39291 .irow &`subject`&                       &nbsp; "contents of &'Subject:'& on <= lines"
39292 .irow &`tls_certificate_verified`&      *       "certificate verification status"
39293 .irow &`tls_cipher`&                    *       "TLS cipher suite on <= and => lines"
39294 .irow &`tls_peerdn`&                    &nbsp; "TLS peer DN on <= and => lines"
39295 .irow &`tls_resumption`&                &nbsp; "append * to cipher field"
39296 .irow &`tls_sni`&                       &nbsp; "TLS SNI on <= lines"
39297 .irow &`unknown_in_list`&               &nbsp; "lookup failed in list match"
39298 .irow &`all`&                           &nbsp; "&*all of the above*&"
39299 .endtable
39300 See also the &%slow_lookup_log%& main configuration option,
39301 section &<<SECID99>>&
39302
39303 More details on each of these items follows:
39304
39305 .ilist
39306 .cindex "8BITMIME"
39307 .cindex "log" "8BITMIME"
39308 &%8bitmime%&: This causes Exim to log any 8BITMIME status of received messages,
39309 which may help in tracking down interoperability issues with ancient MTAs
39310 that are not 8bit clean.  This is added to the &"<="& line, tagged with
39311 &`M8S=`& and a value of &`0`&, &`7`& or &`8`&, corresponding to "not given",
39312 &`7BIT`& and &`8BITMIME`& respectively.
39313 .next
39314 .cindex "&%warn%& ACL verb" "log when skipping"
39315 &%acl_warn_skipped%&: When an ACL &%warn%& statement is skipped because one of
39316 its conditions cannot be evaluated, a log line to this effect is written if
39317 this log selector is set.
39318 .next
39319 .cindex "log" "rewriting"
39320 .cindex "rewriting" "logging"
39321 &%address_rewrite%&: This applies both to global rewrites and per-transport
39322 rewrites, but not to rewrites in filters run as an unprivileged user (because
39323 such users cannot access the log).
39324 .next
39325 .cindex "log" "full parentage"
39326 &%all_parents%&: Normally only the original and final addresses are logged on
39327 delivery lines; with this selector, intermediate parents are given in
39328 parentheses between them.
39329 .next
39330 .cindex "log" "Exim arguments"
39331 .cindex "Exim arguments, logging"
39332 &%arguments%&: This causes Exim to write the arguments with which it was called
39333 to the main log, preceded by the current working directory. This is a debugging
39334 feature, added to make it easier to find out how certain MUAs call
39335 &_/usr/sbin/sendmail_&. The logging does not happen if Exim has given up root
39336 privilege because it was called with the &%-C%& or &%-D%& options. Arguments
39337 that are empty or that contain white space are quoted. Non-printing characters
39338 are shown as escape sequences. This facility cannot log unrecognized arguments,
39339 because the arguments are checked before the configuration file is read. The
39340 only way to log such cases is to interpose a script such as &_util/logargs.sh_&
39341 between the caller and Exim.
39342 .next
39343 .cindex "log" "connection identifier"
39344 &%connection_identifier%&: An identifier for the accepted connection is added to
39345 connection start and end lines and to message accept lines.
39346 The identifier is tagged by Ci=.
39347 The value is PID-based, so will reset on reboot and will wrap.
39348 .next
39349 .cindex "log" "connection rejections"
39350 &%connection_reject%&: A log entry is written whenever an incoming SMTP
39351 connection is rejected, for whatever reason.
39352 .next
39353 .cindex "log" "delayed delivery"
39354 .cindex "delayed delivery, logging"
39355 &%delay_delivery%&: A log entry is written whenever a delivery process is not
39356 started for an incoming message because the load is too high or too many
39357 messages were received on one connection. Logging does not occur if no delivery
39358 process is started because &%queue_only%& is set or &%-odq%& was used.
39359 .next
39360 .cindex "log" "delivery duration"
39361 &%deliver_time%&: For each delivery, the amount of real time it has taken to
39362 perform the actual delivery is logged as DT=<&'time'&>, for example, &`DT=1s`&.
39363 If millisecond logging is enabled, short times will be shown with greater
39364 precision, eg. &`DT=0.304s`&.
39365 .next
39366 .cindex "log" "message size on delivery"
39367 .cindex "size" "of message"
39368 &%delivery_size%&: For each delivery, the size of message delivered is added to
39369 the &"=>"& line, tagged with S=.
39370 .next
39371 .cindex log "DKIM verification"
39372 .cindex DKIM "verification logging"
39373 &%dkim%&: For message acceptance log lines, when an DKIM signature in the header
39374 verifies successfully a tag of DKIM is added, with one of the verified domains.
39375 .next
39376 .cindex log "DKIM verification"
39377 .cindex DKIM "verification logging"
39378 &%dkim_verbose%&: A log entry is written for each attempted DKIM verification.
39379 Also, on message delivery lines signing information (domain and selector)
39380 is added, tagged with DKIM=.
39381 .next
39382 .cindex "log" "dnslist defer"
39383 .cindex "DNS list" "logging defer"
39384 .cindex "black list (DNS)"
39385 &%dnslist_defer%&: A log entry is written if an attempt to look up a host in a
39386 DNS black list suffers a temporary error.
39387 .next
39388 .cindex log dnssec
39389 .cindex dnssec logging
39390 &%dnssec%&: For message acceptance and (attempted) delivery log lines, when
39391 dns lookups gave secure results a tag of DS is added.
39392 For acceptance this covers the reverse and forward lookups for host name verification.
39393 It does not cover helo-name verification.
39394 For delivery this covers the SRV, MX, A and/or AAAA lookups.
39395 .next
39396 .cindex "log" "ETRN commands"
39397 .cindex "ETRN" "logging"
39398 &%etrn%&: Every valid ETRN command that is received is logged, before the ACL
39399 is run to determine whether or not it is actually accepted. An invalid ETRN
39400 command, or one received within a message transaction is not logged by this
39401 selector (see &%smtp_syntax_error%& and &%smtp_protocol_error%&).
39402 .next
39403 .cindex "log" "host lookup failure"
39404 &%host_lookup_failed%&: When a lookup of a host's IP addresses fails to find
39405 any addresses, or when a lookup of an IP address fails to find a host name, a
39406 log line is written. This logging does not apply to direct DNS lookups when
39407 routing email addresses, but it does apply to &"byname"& lookups.
39408 .next
39409 .cindex "log" "ident timeout"
39410 .cindex "RFC 1413" "logging timeout"
39411 &%ident_timeout%&: A log line is written whenever an attempt to connect to a
39412 client's ident port times out.
39413 .next
39414 .cindex "log" "incoming interface"
39415 .cindex "log" "outgoing interface"
39416 .cindex "log" "local interface"
39417 .cindex "log" "local address and port"
39418 .cindex "TCP/IP" "logging local address and port"
39419 .cindex "interface" "logging"
39420 &%incoming_interface%&: The interface on which a message was received is added
39421 to the &"<="& line as an IP address in square brackets, tagged by I= and
39422 followed by a colon and the port number. The local interface and port are also
39423 added to other SMTP log lines, for example, &"SMTP connection from"&, to
39424 rejection lines, and (despite the name) to outgoing
39425 &"=>"&, &"->"&, &"=="& and &"**"& lines.
39426 The latter can be disabled by turning off the &%outgoing_interface%& option.
39427 .next
39428 .cindex log "incoming proxy address"
39429 .cindex proxy "logging proxy address"
39430 .cindex "TCP/IP" "logging proxy address"
39431 &%proxy%&: The internal (closest to the system running Exim) IP address
39432 of the proxy, tagged by PRX=, on the &"<="& line for a message accepted
39433 on a proxied connection
39434 or the &"=>"& line for a message delivered on a proxied connection.
39435 See &<<SECTproxyInbound>>& for more information.
39436 .next
39437 .cindex "log" "incoming remote port"
39438 .cindex "port" "logging remote"
39439 .cindex "TCP/IP" "logging incoming remote port"
39440 .vindex "&$sender_fullhost$&"
39441 .vindex "&$sender_rcvhost$&"
39442 &%incoming_port%&: The remote port number from which a message was received is
39443 added to log entries and &'Received:'& header lines, following the IP address
39444 in square brackets, and separated from it by a colon. This is implemented by
39445 changing the value that is put in the &$sender_fullhost$& and
39446 &$sender_rcvhost$& variables. Recording the remote port number has become more
39447 important with the widening use of NAT (see RFC 2505).
39448 .next
39449 .cindex "log" "dropped connection"
39450 &%lost_incoming_connection%&: A log line is written when an incoming SMTP
39451 connection is unexpectedly dropped.
39452 .next
39453 .cindex "log" "millisecond timestamps"
39454 .cindex millisecond logging
39455 .cindex timestamps "millisecond, in logs"
39456 &%millisec%&: Timestamps have a period and three decimal places of finer granularity
39457 appended to the seconds value.
39458 .next
39459 .cindex "log" "message id"
39460 &%msg_id%&: The value of the Message-ID: header.
39461 .next
39462 &%msg_id_created%&: The value of the Message-ID: header, when one had to be created.
39463 This will be either because the message is a bounce, or was submitted locally
39464 (submission mode) without one.
39465 The field identifier will have an asterix appended: &"id*="&.
39466 .next
39467 .cindex "log" "outgoing interface"
39468 .cindex "log" "local interface"
39469 .cindex "log" "local address and port"
39470 .cindex "TCP/IP" "logging local address and port"
39471 .cindex "interface" "logging"
39472 &%outgoing_interface%&: If &%incoming_interface%& is turned on, then the
39473 interface on which a message was sent is added to delivery lines as an I= tag
39474 followed by IP address in square brackets. You can disable this by turning
39475 off the &%outgoing_interface%& option.
39476 .next
39477 .cindex "log" "outgoing remote port"
39478 .cindex "port" "logging outgoing remote"
39479 .cindex "TCP/IP" "logging outgoing remote port"
39480 &%outgoing_port%&: The remote port number is added to delivery log lines (those
39481 containing => tags) following the IP address.
39482 The local port is also added if &%incoming_interface%& and
39483 &%outgoing_interface%& are both enabled.
39484 This option is not included in the default setting, because for most ordinary
39485 configurations, the remote port number is always 25 (the SMTP port), and the
39486 local port is a random ephemeral port.
39487 .next
39488 .cindex "log" "process ids in"
39489 .cindex "pid (process id)" "in log lines"
39490 &%pid%&: The current process id is added to every log line, in square brackets,
39491 immediately after the time and date.
39492 .next
39493 .cindex log pipelining
39494 .cindex pipelining "logging outgoing"
39495 &%pipelining%&: A field is added to delivery and accept
39496 log lines when the ESMTP PIPELINING extension was used.
39497 The field is a single "L".
39498
39499 On accept lines, where PIPELINING was offered but not used by the client,
39500 the field has a minus appended.
39501
39502 .cindex "pipelining" "early connection"
39503 If Exim is built without the DISABLE_PIPE_CONNECT build option
39504 accept "L" fields have a period appended if the feature was
39505 offered but not used, or an asterisk appended if used.
39506 Delivery "L" fields have an asterisk appended if used.
39507
39508 .next
39509 .cindex "log" "queue run"
39510 .cindex "queue runner" "logging"
39511 &%queue_run%&: The start and end of every queue run are logged.
39512 .next
39513 .cindex "log" "queue time"
39514 &%queue_time%&: The amount of time the message has been in the queue on the
39515 local host is logged as QT=<&'time'&> on delivery (&`=>`&) lines, for example,
39516 &`QT=3m45s`&.
39517 If millisecond logging is enabled, short times will be shown with greater
39518 precision, eg. &`QT=1.578s`&.
39519 .next
39520 &%queue_time_overall%&: The amount of time the message has been in the queue on
39521 the local host is logged as QT=<&'time'&> on &"Completed"& lines, for
39522 example, &`QT=3m45s`&.
39523 .next
39524 .cindex "log" "receive duration"
39525 &%receive_time%&: For each message, the amount of real time it has taken to
39526 perform the reception is logged as RT=<&'time'&>, for example, &`RT=1s`&.
39527 If millisecond logging is enabled, short times will be shown with greater
39528 precision, eg. &`RT=0.204s`&.
39529 .next
39530 .cindex "log" "recipients"
39531 &%received_recipients%&: The recipients of a message are listed in the main log
39532 as soon as the message is received. The list appears at the end of the log line
39533 that is written when a message is received, preceded by the word &"for"&. The
39534 addresses are listed after they have been qualified, but before any rewriting
39535 has taken place.
39536 Recipients that were discarded by an ACL for MAIL or RCPT do not appear
39537 in the list.
39538 .next
39539 .cindex "log" "sender reception"
39540 &%received_sender%&: The unrewritten original sender of a message is added to
39541 the end of the log line that records the message's arrival, after the word
39542 &"from"& (before the recipients if &%received_recipients%& is also set).
39543 .next
39544 .cindex "log" "header lines for rejection"
39545 &%rejected_header%&: If a message's header has been received at the time a
39546 rejection is written to the reject log, the complete header is added to the
39547 log. Header logging can be turned off individually for messages that are
39548 rejected by the &[local_scan()]& function (see section &<<SECTapiforloc>>&).
39549 .next
39550 .cindex "log" "retry defer"
39551 &%retry_defer%&: A log line is written if a delivery is deferred because a
39552 retry time has not yet been reached. However, this &"retry time not reached"&
39553 message is always omitted from individual message logs after the first delivery
39554 attempt.
39555 .next
39556 .cindex "log" "return path"
39557 &%return_path_on_delivery%&: The return path that is being transmitted with
39558 the message is included in delivery and bounce lines, using the tag P=.
39559 This is omitted if no delivery actually happens, for example, if routing fails,
39560 or if delivery is to &_/dev/null_& or to &`:blackhole:`&.
39561 .next
39562 .cindex "log" "sender on delivery"
39563 &%sender_on_delivery%&: The message's sender address is added to every delivery
39564 and bounce line, tagged by F= (for &"from"&).
39565 This is the original sender that was received with the message; it is not
39566 necessarily the same as the outgoing return path.
39567 .next
39568 .cindex "log" "sender verify failure"
39569 &%sender_verify_fail%&: If this selector is unset, the separate log line that
39570 gives details of a sender verification failure is not written. Log lines for
39571 the rejection of SMTP commands contain just &"sender verify failed"&, so some
39572 detail is lost.
39573 .next
39574 .cindex "log" "size rejection"
39575 &%size_reject%&: A log line is written whenever a message is rejected because
39576 it is too big.
39577 .next
39578 .cindex "log" "frozen messages; skipped"
39579 .cindex "frozen messages" "logging skipping"
39580 &%skip_delivery%&: A log line is written whenever a message is skipped during a
39581 queue run because it another process is already delivering it or because
39582 it is frozen.
39583 .cindex "&""spool file is locked""&"
39584 .cindex "&""message is frozen""&"
39585 The message that is written is either &"spool file is locked"& or
39586 &"message is frozen"&.
39587 .next
39588 .cindex "log" "smtp confirmation"
39589 .cindex "SMTP" "logging confirmation"
39590 .cindex "LMTP" "logging confirmation"
39591 &%smtp_confirmation%&: The response to the final &"."& in the SMTP or LMTP dialogue for
39592 outgoing messages is added to delivery log lines in the form &`C=`&<&'text'&>.
39593 A number of MTAs (including Exim) return an identifying string in this
39594 response.
39595 .next
39596 .cindex "log" "SMTP connections"
39597 .cindex "SMTP" "logging connections"
39598 &%smtp_connection%&: A log line is written whenever an incoming SMTP connection is
39599 established or closed, unless the connection is from a host that matches
39600 &%hosts_connection_nolog%&. (In contrast, &%lost_incoming_connection%& applies
39601 only when the closure is unexpected.) This applies to connections from local
39602 processes that use &%-bs%& as well as to TCP/IP connections. If a connection is
39603 dropped in the middle of a message, a log line is always written, whether or
39604 not this selector is set, but otherwise nothing is written at the start and end
39605 of connections unless this selector is enabled.
39606
39607 For TCP/IP connections to an Exim daemon, the current number of connections is
39608 included in the log message for each new connection, but note that the count is
39609 reset if the daemon is restarted.
39610 Also, because connections are closed (and the closure is logged) in
39611 subprocesses, the count may not include connections that have been closed but
39612 whose termination the daemon has not yet noticed. Thus, while it is possible to
39613 match up the opening and closing of connections in the log, the value of the
39614 logged counts may not be entirely accurate.
39615 .next
39616 .cindex "log" "SMTP transaction; incomplete"
39617 .cindex "SMTP" "logging incomplete transactions"
39618 &%smtp_incomplete_transaction%&: When a mail transaction is aborted by
39619 RSET, QUIT, loss of connection, or otherwise, the incident is logged,
39620 and the message sender plus any accepted recipients are included in the log
39621 line. This can provide evidence of dictionary attacks.
39622 .next
39623 .cindex "log" "non-MAIL SMTP sessions"
39624 .cindex "MAIL" "logging session without"
39625 &%smtp_no_mail%&: A line is written to the main log whenever an accepted SMTP
39626 connection terminates without having issued a MAIL command. This includes both
39627 the case when the connection is dropped, and the case when QUIT is used. It
39628 does not include cases where the connection is rejected right at the start (by
39629 an ACL, or because there are too many connections, or whatever). These cases
39630 already have their own log lines.
39631
39632 The log line that is written contains the identity of the client in the usual
39633 way, followed by D= and a time, which records the duration of the connection.
39634 If the connection was authenticated, this fact is logged exactly as it is for
39635 an incoming message, with an A= item. If the connection was encrypted, CV=,
39636 DN=, and X= items may appear as they do for an incoming message, controlled by
39637 the same logging options.
39638
39639 Finally, if any SMTP commands were issued during the connection, a C= item
39640 is added to the line, listing the commands that were used. For example,
39641 .code
39642 C=EHLO,QUIT
39643 .endd
39644 shows that the client issued QUIT straight after EHLO. If there were fewer
39645 than 20 commands, they are all listed. If there were more than 20 commands,
39646 the last 20 are listed, preceded by &"..."&. However, with the default
39647 setting of 10 for &%smtp_accept_max_nonmail%&, the connection will in any case
39648 have been aborted before 20 non-mail commands are processed.
39649 .next
39650 &%smtp_mailauth%&: A third subfield with the authenticated sender,
39651 colon-separated, is appended to the A= item for a message arrival or delivery
39652 log line, if an AUTH argument to the SMTP MAIL command (see &<<SECTauthparamail>>&)
39653 was accepted or used.
39654 .next
39655 .cindex "log" "SMTP protocol error"
39656 .cindex "SMTP" "logging protocol error"
39657 &%smtp_protocol_error%&: A log line is written for every SMTP protocol error
39658 encountered. Exim does not have perfect detection of all protocol errors
39659 because of transmission delays and the use of pipelining. If PIPELINING has
39660 been advertised to a client, an Exim server assumes that the client will use
39661 it, and therefore it does not count &"expected"& errors (for example, RCPT
39662 received after rejecting MAIL) as protocol errors.
39663 .next
39664 .cindex "SMTP" "logging syntax errors"
39665 .cindex "SMTP" "syntax errors; logging"
39666 .cindex "SMTP" "unknown command; logging"
39667 .cindex "log" "unknown SMTP command"
39668 .cindex "log" "SMTP syntax error"
39669 &%smtp_syntax_error%&: A log line is written for every SMTP syntax error
39670 encountered. An unrecognized command is treated as a syntax error. For an
39671 external connection, the host identity is given; for an internal connection
39672 using &%-bs%& the sender identification (normally the calling user) is given.
39673 .next
39674 .cindex "log" "subject"
39675 .cindex "subject, logging"
39676 &%subject%&: The subject of the message is added to the arrival log line,
39677 preceded by &"T="& (T for &"topic"&, since S is already used for &"size"&).
39678 Any MIME &"words"& in the subject are decoded. The &%print_topbitchars%& option
39679 specifies whether characters with values greater than 127 should be logged
39680 unchanged, or whether they should be rendered as escape sequences.
39681 .next
39682 .cindex "log" "certificate verification"
39683 .cindex log DANE
39684 .cindex DANE logging
39685 &%tls_certificate_verified%&: An extra item is added to <= and => log lines
39686 when TLS is in use. The item is &`CV=yes`& if the peer's certificate was
39687 verified
39688 using a CA trust anchor,
39689 &`CV=dane`& if using a DNS trust anchor,
39690 and &`CV=no`& if not.
39691 .next
39692 .cindex "log" "TLS cipher"
39693 .cindex "TLS" "logging cipher"
39694 &%tls_cipher%&: When a message is sent or received over an encrypted
39695 connection, the cipher suite used is added to the log line, preceded by X=.
39696 .next
39697 .cindex "log" "TLS peer DN"
39698 .cindex "TLS" "logging peer DN"
39699 &%tls_peerdn%&: When a message is sent or received over an encrypted
39700 connection, and a certificate is supplied by the remote host, the peer DN is
39701 added to the log line, preceded by DN=.
39702 .next
39703 .cindex "log" "TLS resumption"
39704 .cindex "TLS" "logging session resumption"
39705 &%tls_resumption%&: When a message is sent or received over an encrypted
39706 connection and the TLS session resumed one used on a previous TCP connection,
39707 an asterisk is appended to the X= cipher field in the log line.
39708 .next
39709 .cindex "log" "TLS SNI"
39710 .cindex "TLS" "logging SNI"
39711 .cindex SNI logging
39712 &%tls_sni%&: When a message is received over an encrypted connection, and
39713 the remote host provided the Server Name Indication extension, the SNI is
39714 added to the log line, preceded by SNI=.
39715 .next
39716 .cindex "log" "DNS failure in list"
39717 &%unknown_in_list%&: This setting causes a log entry to be written when the
39718 result of a list match is failure because a DNS lookup failed, or because
39719 a bad IP address was in the list.
39720 .endlist
39721
39722
39723 .section "Message log" "SECID260"
39724 .cindex "message" "log file for"
39725 .cindex "log" "message log; description of"
39726 .cindex "&_msglog_& directory"
39727 .oindex "&%preserve_message_logs%&"
39728 In addition to the general log files, Exim writes a log file for each message
39729 that it handles. The names of these per-message logs are the message ids, and
39730 they are kept in the &_msglog_& sub-directory of the spool directory. Each
39731 message log contains copies of the log lines that apply to the message. This
39732 makes it easier to inspect the status of an individual message without having
39733 to search the main log. A message log is deleted when processing of the message
39734 is complete, unless &%preserve_message_logs%& is set, but this should be used
39735 only with great care because they can fill up your disk very quickly.
39736
39737 On a heavily loaded system, it may be desirable to disable the use of
39738 per-message logs, in order to reduce disk I/O. This can be done by setting the
39739 &%message_logs%& option false.
39740 .ecindex IIDloggen
39741
39742
39743
39744
39745 . ////////////////////////////////////////////////////////////////////////////
39746 . ////////////////////////////////////////////////////////////////////////////
39747
39748 .chapter "Exim utilities" "CHAPutils"
39749 .scindex IIDutils "utilities"
39750 A number of utility scripts and programs are supplied with Exim and are
39751 described in this chapter. There is also the Exim Monitor, which is covered in
39752 the next chapter. The utilities described here are:
39753
39754 .itable none 0 0 3  7* left  15* left  40* left
39755 .irow &<<SECTfinoutwha>>&     &'exiwhat'&       &&&
39756   "list what Exim processes are doing"
39757 .irow &<<SECTgreptheque>>&    &'exiqgrep'&      "grep the queue"
39758 .irow &<<SECTsumtheque>>&     &'exiqsumm'&      "summarize the queue"
39759 .irow &<<SECTextspeinf>>&     &'exigrep'&       "search the main log"
39760 .irow &<<SECTexipick>>&       &'exipick'&       "select messages on &&&
39761                                                 various criteria"
39762 .irow &<<SECTcyclogfil>>&     &'exicyclog'&     "cycle (rotate) log files"
39763 .irow &<<SECTmailstat>>&      &'eximstats'&     &&&
39764   "extract statistics from the log"
39765 .irow &<<SECTcheckaccess>>&   &'exim_checkaccess'& &&&
39766   "check address acceptance from given IP"
39767 .irow &<<SECTdbmbuild>>&      &'exim_dbmbuild'& "build a DBM file"
39768 .irow &<<SECTfinindret>>&     &'exinext'&       "extract retry information"
39769 .irow &<<SECTdumpdb>>&        &'exim_dumpdb'&   "dump a hints database"
39770 .irow &<<SECTtidydb>>&        &'exim_tidydb'&   "clean up a hints database"
39771 .irow &<<SECTfixdb>>&         &'exim_fixdb'&    "patch a hints database"
39772 .irow &<<SECTmailboxmaint>>&  &'exim_lock'&     "lock a mailbox file"
39773 .irow &<<SECTexim_msgdate>>&  &'exim_msgdate'&  "Message Ids for humans (exim_msgdate)"
39774 .endtable
39775
39776 Another utility that might be of use to sites with many MTAs is Tom Kistner's
39777 &'exilog'&. It provides log visualizations across multiple Exim servers. See
39778 &url(https://duncanthrax.net/exilog/) for details.
39779
39780
39781
39782
39783 .section "Finding out what Exim processes are doing (exiwhat)" "SECTfinoutwha"
39784 .cindex "&'exiwhat'&"
39785 .cindex "process, querying"
39786 .cindex "SIGUSR1"
39787 On operating systems that can restart a system call after receiving a signal
39788 (most modern OS), an Exim process responds to the SIGUSR1 signal by writing
39789 a line describing what it is doing to the file &_exim-process.info_& in the
39790 Exim spool directory. The &'exiwhat'& script sends the signal to all Exim
39791 processes it can find, having first emptied the file. It then waits for one
39792 second to allow the Exim processes to react before displaying the results. In
39793 order to run &'exiwhat'& successfully you have to have sufficient privilege to
39794 send the signal to the Exim processes, so it is normally run as root.
39795
39796 &*Warning*&: This is not an efficient process. It is intended for occasional
39797 use by system administrators. It is not sensible, for example, to set up a
39798 script that sends SIGUSR1 signals to Exim processes at short intervals.
39799
39800
39801 Unfortunately, the &'ps'& command that &'exiwhat'& uses to find Exim processes
39802 varies in different operating systems. Not only are different options used,
39803 but the format of the output is different. For this reason, there are some
39804 system configuration options that configure exactly how &'exiwhat'& works. If
39805 it doesn't seem to be working for you, check the following compile-time
39806 options:
39807 .itable none 0 0 2 30* left 70* left
39808 .irow &`EXIWHAT_PS_CMD`&        "the command for running &'ps'&"
39809 .irow &`EXIWHAT_PS_ARG`&        "the argument for &'ps'&"
39810 .irow &`EXIWHAT_EGREP_ARG`&     "the argument for &'egrep'& to select from &'ps'& output"
39811 .irow &`EXIWHAT_KILL_ARG`&      "the argument for the &'kill'& command"
39812 .endtable
39813 An example of typical output from &'exiwhat'& is
39814 .code
39815 164 daemon: -q1h, listening on port 25
39816 10483 running queue: waiting for 0tAycK-0002ij-00 (10492)
39817 10492 delivering 0tAycK-0002ij-00 to mail.ref.example
39818   [10.19.42.42] (editor@ref.example)
39819 10592 handling incoming call from [192.168.243.242]
39820 10628 accepting a local non-SMTP message
39821 .endd
39822 The first number in the output line is the process number. The third line has
39823 been split here, in order to fit it on the page.
39824
39825
39826
39827 .section "Selective queue listing (exiqgrep)" "SECTgreptheque"
39828 .cindex "&'exiqgrep'&"
39829 .cindex "queue" "grepping"
39830 This utility is a Perl script contributed by Matt Hubbard. It runs
39831 .code
39832 exim -bpu
39833 .endd
39834 or (in case &*-a*& switch is specified)
39835 .code
39836 exim -bp
39837 .endd
39838 to obtain a queue listing, and then greps the output to select messages
39839 that match given criteria. The following selection options are available:
39840
39841 .vlist
39842 .vitem &*-f*&&~<&'regex'&>
39843 Match the sender address using a case-insensitive search. The field that is
39844 tested is enclosed in angle brackets, so you can test for bounce messages with
39845 .code
39846 exiqgrep -f '^<>$'
39847 .endd
39848 .vitem &*-r*&&~<&'regex'&>
39849 Match a recipient address using a case-insensitive search. The field that is
39850 tested is not enclosed in angle brackets.
39851
39852 .vitem &*-s*&&~<&'regex'&>
39853 Match against the size field.
39854
39855 .vitem &*-y*&&~<&'seconds'&>
39856 Match messages that are younger than the given time.
39857
39858 .vitem &*-o*&&~<&'seconds'&>
39859 Match messages that are older than the given time.
39860
39861 .vitem &*-z*&
39862 Match only frozen messages.
39863
39864 .vitem &*-x*&
39865 Match only non-frozen messages.
39866
39867 .vitem &*-G*&&~<&'queuename'&>
39868 Match only messages in the given queue.  Without this, the default queue is searched.
39869 .endlist
39870
39871 The following options control the format of the output:
39872
39873 .vlist
39874 .vitem &*-c*&
39875 Display only the count of matching messages.
39876
39877 .vitem &*-l*&
39878 Long format &-- display the full message information as output by Exim. This is
39879 the default.
39880
39881 .vitem &*-i*&
39882 Display message ids only.
39883
39884 .vitem &*-b*&
39885 Brief format &-- one line per message.
39886
39887 .vitem &*-R*&
39888 Display messages in reverse order.
39889
39890 .vitem &*-a*&
39891 Include delivered recipients in queue listing.
39892 .endlist
39893
39894 The following options give alternates for configuration:
39895
39896 .vlist
39897 .vitem &*-C*&&~<&'config&~file'&>
39898 is used to specify an alternate &_exim.conf_& which might
39899 contain alternate exim configuration the queue management might be using.
39900
39901 .vitem &*-E*&&~<&'path'&>
39902 can be used to specify a path for the exim binary,
39903 overriding the built-in one.
39904 .endlist
39905
39906 There is one more option, &%-h%&, which outputs a list of options.
39907 At least one selection option, or either the &*-c*& or &*-h*& option, must be given.
39908
39909
39910
39911 .section "Summarizing the queue (exiqsumm)" "SECTsumtheque"
39912 .cindex "&'exiqsumm'&"
39913 .cindex "queue" "summary"
39914 The &'exiqsumm'& utility is a Perl script which reads the output of &`exim
39915 -bp`& and produces a summary of the messages in the queue. Thus, you use it by
39916 running a command such as
39917 .code
39918 exim -bp | exiqsumm
39919 .endd
39920 The output consists of one line for each domain that has messages waiting for
39921 it, as in the following example:
39922 .code
39923 3   2322   74m   66m  msn.com.example
39924 .endd
39925 Each line lists the number of pending deliveries for a domain, their total
39926 volume, and the length of time that the oldest and the newest messages have
39927 been waiting. Note that the number of pending deliveries is greater than the
39928 number of messages when messages have more than one recipient.
39929
39930 A summary line is output at the end. By default the output is sorted on the
39931 domain name, but &'exiqsumm'& has the options &%-a%& and &%-c%&, which cause
39932 the output to be sorted by oldest message and by count of messages,
39933 respectively. There are also three options that split the messages for each
39934 domain into two or more subcounts: &%-b%& separates bounce messages, &%-f%&
39935 separates frozen messages, and &%-s%& separates messages according to their
39936 sender.
39937
39938 The output of &'exim -bp'& contains the original addresses in the message, so
39939 this also applies to the output from &'exiqsumm'&. No domains from addresses
39940 generated by aliasing or forwarding are included (unless the &%one_time%&
39941 option of the &(redirect)& router has been used to convert them into &"top
39942 level"& addresses).
39943
39944
39945
39946
39947 .section "Extracting specific information from the log (exigrep)" &&&
39948          "SECTextspeinf"
39949 .cindex "&'exigrep'&"
39950 .cindex "log" "extracts; grepping for"
39951 The &'exigrep'& utility is a Perl script that searches one or more main log
39952 files for entries that match a given pattern. When it finds a match, it
39953 extracts all the log entries for the relevant message, not just those that
39954 match the pattern. Thus, &'exigrep'& can extract complete log entries for a
39955 given message, or all mail for a given user, or for a given host, for example.
39956 The input files can be in Exim log format or syslog format.
39957 If a matching log line is not associated with a specific message, it is
39958 included in &'exigrep'&'s output without any additional lines. The usage is:
39959 .display
39960 &`exigrep [-t<`&&'n'&&`>] [-I] [-l] [-M] [-v] <`&&'pattern'&&`> [<`&&'log file'&&`>] ...`&
39961 .endd
39962 If no log filenames are given on the command line, the standard input is read.
39963
39964 The &%-t%& argument specifies a number of seconds. It adds an additional
39965 condition for message selection. Messages that are complete are shown only if
39966 they spent more than <&'n'&> seconds in the queue.
39967
39968 By default, &'exigrep'& does case-insensitive matching. The &%-I%& option
39969 makes it case-sensitive. This may give a performance improvement when searching
39970 large log files. Without &%-I%&, the Perl pattern matches use Perl's &`/i`&
39971 option; with &%-I%& they do not. In both cases it is possible to change the
39972 case sensitivity within the pattern by using &`(?i)`& or &`(?-i)`&.
39973
39974 The &%-l%& option means &"literal"&, that is, treat all characters in the
39975 pattern as standing for themselves. Otherwise the pattern must be a Perl
39976 regular expression.
39977
39978 The &%-v%& option inverts the matching condition. That is, a line is selected
39979 if it does &'not'& match the pattern.
39980
39981 The &%-M%& options means &"related messages"&. &'exigrep'& will show messages
39982 that are generated as a result/response to a message that &'exigrep'& matched
39983 normally.
39984
39985 Example of &%-M%&:
39986 user_a sends a message to user_b, which generates a bounce back to user_b. If
39987 &'exigrep'& is used to search for &"user_a"&, only the first message will be
39988 displayed.  But if &'exigrep'& is used to search for &"user_b"&, the first and
39989 the second (bounce) message will be displayed. Using &%-M%& with &'exigrep'&
39990 when searching for &"user_a"& will show both messages since the bounce is
39991 &"related"& to or a &"result"& of the first message that was found by the
39992 search term.
39993
39994 If the location of a &'zcat'& command is known from the definition of
39995 ZCAT_COMMAND in &_Local/Makefile_&, &'exigrep'& automatically passes any file
39996 whose name ends in COMPRESS_SUFFIX through &'zcat'& as it searches it.
39997 If the ZCAT_COMMAND is not executable, &'exigrep'& tries to use
39998 autodetection of some well known compression extensions.
39999
40000
40001 .section "Selecting messages by various criteria (exipick)" "SECTexipick"
40002 .cindex "&'exipick'&"
40003 John Jetmore's &'exipick'& utility is included in the Exim distribution. It
40004 lists messages from the queue according to a variety of criteria. For details
40005 of &'exipick'&'s facilities, run &'exipick'& with
40006 the &%--help%& option.
40007
40008
40009 .section "Cycling log files (exicyclog)" "SECTcyclogfil"
40010 .cindex "log" "cycling local files"
40011 .cindex "cycling logs"
40012 .cindex "&'exicyclog'&"
40013 The &'exicyclog'& script can be used to cycle (rotate) &'mainlog'& and
40014 &'rejectlog'& files. This is not necessary if only syslog is being used, or if
40015 you are using log files with datestamps in their names (see section
40016 &<<SECTdatlogfil>>&). Some operating systems have their own standard mechanisms
40017 for log cycling, and these can be used instead of &'exicyclog'& if preferred.
40018 There are two command line options for &'exicyclog'&:
40019 .ilist
40020 &%-k%& <&'count'&> specifies the number of log files to keep, overriding the
40021 default that is set when Exim is built. The default default is 10.
40022 .next
40023 &%-l%& <&'path'&> specifies the log file path, in the same format as Exim's
40024 &%log_file_path%& option (for example, &`/var/log/exim_%slog`&), again
40025 overriding the script's default, which is to find the setting from Exim's
40026 configuration.
40027 .endlist
40028
40029 Each time &'exicyclog'& is run the filenames get &"shuffled down"& by one. If
40030 the main log filename is &_mainlog_& (the default) then when &'exicyclog'& is
40031 run &_mainlog_& becomes &_mainlog.01_&, the previous &_mainlog.01_& becomes
40032 &_mainlog.02_& and so on, up to the limit that is set in the script or by the
40033 &%-k%& option. Log files whose numbers exceed the limit are discarded. Reject
40034 logs are handled similarly.
40035
40036 If the limit is greater than 99, the script uses 3-digit numbers such as
40037 &_mainlog.001_&, &_mainlog.002_&, etc. If you change from a number less than 99
40038 to one that is greater, or &'vice versa'&, you will have to fix the names of
40039 any existing log files.
40040
40041 If no &_mainlog_& file exists, the script does nothing. Files that &"drop off"&
40042 the end are deleted. All files with numbers greater than 01 are compressed,
40043 using a compression command which is configured by the COMPRESS_COMMAND
40044 setting in &_Local/Makefile_&. It is usual to run &'exicyclog'& daily from a
40045 root &%crontab%& entry of the form
40046 .code
40047 1 0 * * * su exim -c /usr/exim/bin/exicyclog
40048 .endd
40049 assuming you have used the name &"exim"& for the Exim user. You can run
40050 &'exicyclog'& as root if you wish, but there is no need.
40051
40052
40053
40054 .section "Mail statistics (eximstats)" "SECTmailstat"
40055 .cindex "statistics"
40056 .cindex "&'eximstats'&"
40057 A Perl script called &'eximstats'& is provided for extracting statistical
40058 information from log files. The output is either plain text, or HTML.
40059 . --- 2018-09-07: LogReport's Lire appears to be dead; website is a Yahoo Japan
40060 . --- 404 error and everything else points to that.
40061
40062 The &'eximstats'& script has been hacked about quite a bit over time. The
40063 latest version is the result of some extensive revision by Steve Campbell. A
40064 lot of information is given by default, but there are options for suppressing
40065 various parts of it. Following any options, the arguments to the script are a
40066 list of files, which should be main log files. For example:
40067 .code
40068 eximstats -nr /var/spool/exim/log/mainlog.01
40069 .endd
40070 By default, &'eximstats'& extracts information about the number and volume of
40071 messages received from or delivered to various hosts. The information is sorted
40072 both by message count and by volume, and the top fifty hosts in each category
40073 are listed on the standard output. Similar information, based on email
40074 addresses or domains instead of hosts can be requested by means of various
40075 options. For messages delivered and received locally, similar statistics are
40076 also produced per user.
40077
40078 The output also includes total counts and statistics about delivery errors, and
40079 histograms showing the number of messages received and deliveries made in each
40080 hour of the day. A delivery with more than one address in its envelope (for
40081 example, an SMTP transaction with more than one RCPT command) is counted
40082 as a single delivery by &'eximstats'&.
40083
40084 Though normally more deliveries than receipts are reported (as messages may
40085 have multiple recipients), it is possible for &'eximstats'& to report more
40086 messages received than delivered, even though the queue is empty at the start
40087 and end of the period in question. If an incoming message contains no valid
40088 recipients, no deliveries are recorded for it. A bounce message is handled as
40089 an entirely separate message.
40090
40091 &'eximstats'& always outputs a grand total summary giving the volume and number
40092 of messages received and deliveries made, and the number of hosts involved in
40093 each case. It also outputs the number of messages that were delayed (that is,
40094 not completely delivered at the first attempt), and the number that had at
40095 least one address that failed.
40096
40097 The remainder of the output is in sections that can be independently disabled
40098 or modified by various options. It consists of a summary of deliveries by
40099 transport, histograms of messages received and delivered per time interval
40100 (default per hour), information about the time messages spent in the queue,
40101 a list of relayed messages, lists of the top fifty sending hosts, local
40102 senders, destination hosts, and destination local users by count and by volume,
40103 and a list of delivery errors that occurred.
40104
40105 The relay information lists messages that were actually relayed, that is, they
40106 came from a remote host and were directly delivered to some other remote host,
40107 without being processed (for example, for aliasing or forwarding) locally.
40108
40109 There are quite a few options for &'eximstats'& to control exactly what it
40110 outputs. These are documented in the Perl script itself, and can be extracted
40111 by running the command &(perldoc)& on the script. For example:
40112 .code
40113 perldoc /usr/exim/bin/eximstats
40114 .endd
40115
40116 .section "Checking access policy (exim_checkaccess)" "SECTcheckaccess"
40117 .cindex "&'exim_checkaccess'&"
40118 .cindex "policy control" "checking access"
40119 .cindex "checking access"
40120 The &%-bh%& command line argument allows you to run a fake SMTP session with
40121 debugging output, in order to check what Exim is doing when it is applying
40122 policy controls to incoming SMTP mail. However, not everybody is sufficiently
40123 familiar with the SMTP protocol to be able to make full use of &%-bh%&, and
40124 sometimes you just want to answer the question &"Does this address have
40125 access?"& without bothering with any further details.
40126
40127 The &'exim_checkaccess'& utility is a &"packaged"& version of &%-bh%&. It takes
40128 two arguments, an IP address and an email address:
40129 .code
40130 exim_checkaccess 10.9.8.7 A.User@a.domain.example
40131 .endd
40132 The utility runs a call to Exim with the &%-bh%& option, to test whether the
40133 given email address would be accepted in a RCPT command in a TCP/IP
40134 connection from the host with the given IP address. The output of the utility
40135 is either the word &"accepted"&, or the SMTP error response, for example:
40136 .code
40137 Rejected:
40138 550 Relay not permitted
40139 .endd
40140 When running this test, the utility uses &`<>`& as the envelope sender address
40141 for the MAIL command, but you can change this by providing additional
40142 options. These are passed directly to the Exim command. For example, to specify
40143 that the test is to be run with the sender address &'himself@there.example'&
40144 you can use:
40145 .code
40146 exim_checkaccess 10.9.8.7 A.User@a.domain.example \
40147                  -f himself@there.example
40148 .endd
40149 Note that these additional Exim command line items must be given after the two
40150 mandatory arguments.
40151
40152 Because the &%exim_checkaccess%& uses &%-bh%&, it does not perform callouts
40153 while running its checks. You can run checks that include callouts by using
40154 &%-bhc%&, but this is not yet available in a &"packaged"& form.
40155
40156
40157
40158 .section "Making DBM files (exim_dbmbuild)" "SECTdbmbuild"
40159 .cindex "DBM" "building dbm files"
40160 .cindex "building DBM files"
40161 .cindex "&'exim_dbmbuild'&"
40162 .cindex "lower casing"
40163 .cindex "binary zero" "in lookup key"
40164 The &'exim_dbmbuild'& program reads an input file containing keys and data in
40165 the format used by the &(lsearch)& lookup (see section
40166 &<<SECTsinglekeylookups>>&). It writes a DBM file using the lower-cased alias
40167 names as keys and the remainder of the information as data. The lower-casing
40168 can be prevented by calling the program with the &%-nolc%& option.
40169
40170 A terminating zero is included as part of the key string. This is expected by
40171 the &(dbm)& lookup type. However, if the option &%-nozero%& is given,
40172 &'exim_dbmbuild'& creates files without terminating zeroes in either the key
40173 strings or the data strings. The &(dbmnz)& lookup type can be used with such
40174 files.
40175
40176 The program requires two arguments: the name of the input file (which can be a
40177 single hyphen to indicate the standard input), and the name of the output file.
40178 It creates the output under a temporary name, and then renames it if all went
40179 well.
40180
40181 .cindex "USE_DB"
40182 If the native DB interface is in use (USE_DB is set in a compile-time
40183 configuration file &-- this is common in free versions of Unix) the two
40184 filenames must be different, because in this mode the Berkeley DB functions
40185 create a single output file using exactly the name given. For example,
40186 .code
40187 exim_dbmbuild /etc/aliases /etc/aliases.db
40188 .endd
40189 reads the system alias file and creates a DBM version of it in
40190 &_/etc/aliases.db_&.
40191
40192 In systems that use the &'ndbm'& routines (mostly proprietary versions of
40193 Unix), two files are used, with the suffixes &_.dir_& and &_.pag_&. In this
40194 environment, the suffixes are added to the second argument of
40195 &'exim_dbmbuild'&, so it can be the same as the first. This is also the case
40196 when the Berkeley functions are used in compatibility mode (though this is not
40197 recommended), because in that case it adds a &_.db_& suffix to the filename.
40198
40199 If a duplicate key is encountered, the program outputs a warning, and when it
40200 finishes, its return code is 1 rather than zero, unless the &%-noduperr%&
40201 option is used. By default, only the first of a set of duplicates is used &--
40202 this makes it compatible with &(lsearch)& lookups. There is an option
40203 &%-lastdup%& which causes it to use the data for the last duplicate instead.
40204 There is also an option &%-nowarn%&, which stops it listing duplicate keys to
40205 &%stderr%&. For other errors, where it doesn't actually make a new file, the
40206 return code is 2.
40207
40208
40209
40210
40211 .section "Finding individual retry times (exinext)" "SECTfinindret"
40212 .cindex "retry" "times"
40213 .cindex "&'exinext'&"
40214 A utility called &'exinext'& (mostly a Perl script) provides the ability to
40215 fish specific information out of the retry database. Given a mail domain (or a
40216 complete address), it looks up the hosts for that domain, and outputs any retry
40217 information for the hosts or for the domain. At present, the retry information
40218 is obtained by running &'exim_dumpdb'& (see below) and post-processing the
40219 output. For example:
40220 .code
40221 $ exinext piglet@milne.fict.example
40222 kanga.milne.example:192.168.8.1 error 146: Connection refused
40223   first failed: 21-Feb-1996 14:57:34
40224   last tried:   21-Feb-1996 14:57:34
40225   next try at:  21-Feb-1996 15:02:34
40226 roo.milne.example:192.168.8.3 error 146: Connection refused
40227   first failed: 20-Jan-1996 13:12:08
40228   last tried:   21-Feb-1996 11:42:03
40229   next try at:  21-Feb-1996 19:42:03
40230   past final cutoff time
40231 .endd
40232 You can also give &'exinext'& a local part, without a domain, and it
40233 will give any retry information for that local part in your default domain.
40234 A message id can be used to obtain retry information pertaining to a specific
40235 message. This exists only when an attempt to deliver a message to a remote host
40236 suffers a message-specific error (see section &<<SECToutSMTPerr>>&).
40237 &'exinext'& is not particularly efficient, but then it is not expected to be
40238 run very often.
40239
40240 The &'exinext'& utility calls Exim to find out information such as the location
40241 of the spool directory. The utility has &%-C%& and &%-D%& options, which are
40242 passed on to the &'exim'& commands. The first specifies an alternate Exim
40243 configuration file, and the second sets macros for use within the configuration
40244 file. These features are mainly to help in testing, but might also be useful in
40245 environments where more than one configuration file is in use.
40246
40247
40248
40249 .section "Hints database maintenance" "SECThindatmai"
40250 .cindex "hints database" "maintenance"
40251 .cindex "maintaining Exim's hints database"
40252 Three utility programs are provided for maintaining the DBM files that Exim
40253 uses to contain its delivery hint information. Each program requires two
40254 arguments. The first specifies the name of Exim's spool directory, and the
40255 second is the name of the database it is to operate on. These are as follows:
40256
40257 .ilist
40258 &'retry'&: the database of retry information
40259 .next
40260 &'wait-'&<&'transport name'&>: databases of information about messages waiting
40261 for remote hosts
40262 .next
40263 &'callout'&: the callout cache
40264 .next
40265 &'ratelimit'&: the data for implementing the ratelimit ACL condition
40266 .next
40267 &'tls'&: TLS session resumption data
40268 .next
40269 &'misc'&: other hints data
40270 .endlist
40271
40272 The &'misc'& database is used for
40273
40274 .ilist
40275 Serializing ETRN runs (when &%smtp_etrn_serialize%& is set)
40276 .next
40277 Serializing delivery to a specific host (when &%serialize_hosts%& is set in an
40278 &(smtp)& transport)
40279 .next
40280 Limiting the concurrency of specific transports (when &%max_parallel%& is set
40281 in a transport)
40282 .next
40283 Recording EHLO-time facilities advertised by hosts
40284 .endlist
40285
40286
40287
40288 .section "exim_dumpdb" "SECTdumpdb"
40289 .cindex "&'exim_dumpdb'&"
40290 The entire contents of a database are written to the standard output by the
40291 &'exim_dumpdb'& program,
40292 taking as arguments the spool and database names.
40293 An option &'-z'& may be given to request times in UTC;
40294 otherwise times are in the local timezone.
40295 An option &'-k'& may be given to dump only the record keys.
40296 For example, to dump the retry database:
40297 .code
40298 exim_dumpdb /var/spool/exim retry
40299 .endd
40300 For the retry database
40301 two lines of output are produced for each entry:
40302 .code
40303 T:mail.ref.example:192.168.242.242 146 77 Connection refused
40304 31-Oct-1995 12:00:12 02-Nov-1995 12:21:39 02-Nov-1995 20:21:39 *
40305 .endd
40306 The first item on the first line is the key of the record. It starts with one
40307 of the letters R, or T, depending on whether it refers to a routing or
40308 transport retry. For a local delivery, the next part is the local address; for
40309 a remote delivery it is the name of the remote host, followed by its failing IP
40310 address (unless &%retry_include_ip_address%& is set false on the &(smtp)&
40311 transport). If the remote port is not the standard one (port 25), it is added
40312 to the IP address. Then there follows an error code, an additional error code,
40313 and a textual description of the error.
40314
40315 The three times on the second line are the time of first failure, the time of
40316 the last delivery attempt, and the computed time for the next attempt. The line
40317 ends with an asterisk if the cutoff time for the last retry rule has been
40318 exceeded.
40319
40320 Each output line from &'exim_dumpdb'& for the &'wait-xxx'& databases
40321 consists of a host name followed by a list of ids for messages that are or were
40322 waiting to be delivered to that host. If there are a very large number for any
40323 one host, continuation records, with a sequence number added to the host name,
40324 may be seen. The data in these records is often out of date, because a message
40325 may be routed to several alternative hosts, and Exim makes no effort to keep
40326 cross-references.
40327
40328
40329
40330 .section "exim_tidydb" "SECTtidydb"
40331 .cindex "&'exim_tidydb'&"
40332 The &'exim_tidydb'& utility program is used to tidy up the contents of a hints
40333 database. If run with no options, it removes all records that are more than 30
40334 days old. The age is calculated from the date and time that the record was last
40335 updated. Note that, in the case of the retry database, it is &'not'& the time
40336 since the first delivery failure. Information about a host that has been down
40337 for more than 30 days will remain in the database, provided that the record is
40338 updated sufficiently often.
40339
40340 The cutoff date can be altered by means of the &%-t%& option, which must be
40341 followed by a time. For example, to remove all records older than a week from
40342 the retry database:
40343 .code
40344 exim_tidydb -t 7d /var/spool/exim retry
40345 .endd
40346 Both the &'wait-xxx'& and &'retry'& databases contain items that involve
40347 message ids. In the former these appear as data in records keyed by host &--
40348 they were messages that were waiting for that host &-- and in the latter they
40349 are the keys for retry information for messages that have suffered certain
40350 types of error. When &'exim_tidydb'& is run, a check is made to ensure that
40351 message ids in database records are those of messages that are still on the
40352 queue. Message ids for messages that no longer exist are removed from
40353 &'wait-xxx'& records, and if this leaves any records empty, they are deleted.
40354 For the &'retry'& database, records whose keys are non-existent message ids are
40355 removed. The &'exim_tidydb'& utility outputs comments on the standard output
40356 whenever it removes information from the database.
40357
40358 Certain records are automatically removed by Exim when they are no longer
40359 needed, but others are not. For example, if all the MX hosts for a domain are
40360 down, a retry record is created for each one. If the primary MX host comes back
40361 first, its record is removed when Exim successfully delivers to it, but the
40362 records for the others remain because Exim has not tried to use those hosts.
40363
40364 It is important, therefore, to run &'exim_tidydb'& periodically on all the
40365 hints databases. You should do this at a quiet time of day, because it requires
40366 a database to be locked (and therefore inaccessible to Exim) while it does its
40367 work. Removing records from a DBM file does not normally make the file smaller,
40368 but all the common DBM libraries are able to re-use the space that is released.
40369 After an initial phase of increasing in size, the databases normally reach a
40370 point at which they no longer get any bigger, as long as they are regularly
40371 tidied.
40372
40373 &*Warning*&: If you never run &'exim_tidydb'&, the space used by the hints
40374 databases is likely to keep on increasing.
40375
40376
40377
40378
40379 .section "exim_fixdb" "SECTfixdb"
40380 .cindex "&'exim_fixdb'&"
40381 The &'exim_fixdb'& program is a utility for interactively modifying databases.
40382 Its main use is for testing Exim, but it might also be occasionally useful for
40383 getting round problems in a live system. Its interface
40384 is somewhat crude. On entry, it prompts for input with a right angle-bracket. A
40385 key of a database record can then be entered, and the data for that record is
40386 displayed.
40387
40388 If &"d"& is typed at the next prompt, the entire record is deleted. For all
40389 except the &'retry'& database, that is the only operation that can be carried
40390 out. For the &'retry'& database, each field is output preceded by a number, and
40391 data for individual fields can be changed by typing the field number followed
40392 by new data, for example:
40393 .code
40394 > 4 951102:1000
40395 .endd
40396 resets the time of the next delivery attempt. Time values are given as a
40397 sequence of digit pairs for year, month, day, hour, and minute. Colons can be
40398 used as optional separators.
40399
40400 Both displayed and input times are in the local timezone by default.
40401 If an option &'-z'& is used on the command line, displayed times
40402 are in UTC.
40403
40404
40405
40406
40407 .section "Mailbox maintenance (exim_lock)" "SECTmailboxmaint"
40408 .cindex "mailbox" "maintenance"
40409 .cindex "&'exim_lock'&"
40410 .cindex "locking mailboxes"
40411 The &'exim_lock'& utility locks a mailbox file using the same algorithm as
40412 Exim. For a discussion of locking issues, see section &<<SECTopappend>>&.
40413 &'Exim_lock'& can be used to prevent any modification of a mailbox by Exim or
40414 a user agent while investigating a problem. The utility requires the name of
40415 the file as its first argument. If the locking is successful, the second
40416 argument is run as a command (using C's &[system()]& function); if there is no
40417 second argument, the value of the SHELL environment variable is used; if this
40418 is unset or empty, &_/bin/sh_& is run. When the command finishes, the mailbox
40419 is unlocked and the utility ends. The following options are available:
40420
40421 .vlist
40422 .vitem &%-fcntl%&
40423 Use &[fcntl()]& locking on the open mailbox.
40424
40425 .vitem &%-flock%&
40426 Use &[flock()]& locking on the open mailbox, provided the operating system
40427 supports it.
40428
40429 .vitem &%-interval%&
40430 This must be followed by a number, which is a number of seconds; it sets the
40431 interval to sleep between retries (default 3).
40432
40433 .vitem &%-lockfile%&
40434 Create a lock file before opening the mailbox.
40435
40436 .vitem &%-mbx%&
40437 Lock the mailbox using MBX rules.
40438
40439 .vitem &%-q%&
40440 Suppress verification output.
40441
40442 .vitem &%-retries%&
40443 This must be followed by a number; it sets the number of times to try to get
40444 the lock (default 10).
40445
40446 .vitem &%-restore_time%&
40447 This option causes &%exim_lock%& to restore the modified and read times to the
40448 locked file before exiting. This allows you to access a locked mailbox (for
40449 example, to take a backup copy) without disturbing the times that the user
40450 subsequently sees.
40451
40452 .vitem &%-timeout%&
40453 This must be followed by a number, which is a number of seconds; it sets a
40454 timeout to be used with a blocking &[fcntl()]& lock. If it is not set (the
40455 default), a non-blocking call is used.
40456
40457 .vitem &%-v%&
40458 Generate verbose output.
40459 .endlist
40460
40461 If none of &%-fcntl%&, &%-flock%&, &%-lockfile%& or &%-mbx%& are given, the
40462 default is to create a lock file and also to use &[fcntl()]& locking on the
40463 mailbox, which is the same as Exim's default. The use of &%-flock%& or
40464 &%-fcntl%& requires that the file be writeable; the use of &%-lockfile%&
40465 requires that the directory containing the file be writeable. Locking by lock
40466 file does not last forever; Exim assumes that a lock file is expired if it is
40467 more than 30 minutes old.
40468
40469 The &%-mbx%& option can be used with either or both of &%-fcntl%& or
40470 &%-flock%&. It assumes &%-fcntl%& by default. MBX locking causes a shared lock
40471 to be taken out on the open mailbox, and an exclusive lock on the file
40472 &_/tmp/.n.m_& where &'n'& and &'m'& are the device number and inode
40473 number of the mailbox file. When the locking is released, if an exclusive lock
40474 can be obtained for the mailbox, the file in &_/tmp_& is deleted.
40475
40476 The default output contains verification of the locking that takes place. The
40477 &%-v%& option causes some additional information to be given. The &%-q%& option
40478 suppresses all output except error messages.
40479
40480 A command such as
40481 .code
40482 exim_lock /var/spool/mail/spqr
40483 .endd
40484 runs an interactive shell while the file is locked, whereas
40485 .display
40486 &`exim_lock -q /var/spool/mail/spqr <<End`&
40487 <&'some commands'&>
40488 &`End`&
40489 .endd
40490 runs a specific non-interactive sequence of commands while the file is locked,
40491 suppressing all verification output. A single command can be run by a command
40492 such as
40493 .code
40494 exim_lock -q /var/spool/mail/spqr \
40495   "cp /var/spool/mail/spqr /some/where"
40496 .endd
40497 Note that if a command is supplied, it must be entirely contained within the
40498 second argument &-- hence the quotes.
40499
40500
40501 .section "Message Ids for humans (exim_msgdate)" "SECTexim_msgdate"
40502 .cindex "exim_msgdate"
40503 The &'exim_msgdate'& utility is written by Andrew Aitchison and included in the Exim distribution.
40504 This Perl script converts an Exim Mesage ID back into a human readable form.
40505 For details of &'exim_msgdate'&'s options, run &'exim_msgdate'& with the &%--help%& option.
40506
40507 Section &<<SECTmessiden>>& (Message identification) describes Exim Mesage IDs.
40508 .ecindex IIDutils
40509 . ////////////////////////////////////////////////////////////////////////////
40510 . ////////////////////////////////////////////////////////////////////////////
40511
40512 .chapter "The Exim monitor" "CHAPeximon"
40513 .scindex IIDeximon "Exim monitor" "description"
40514 .cindex "X-windows"
40515 .cindex "&'eximon'&"
40516 .cindex "Local/eximon.conf"
40517 .cindex "&_exim_monitor/EDITME_&"
40518 The Exim monitor is an application which displays in an X window information
40519 about the state of Exim's queue and what Exim is doing. An admin user can
40520 perform certain operations on messages from this GUI interface; however all
40521 such facilities are also available from the command line, and indeed, the
40522 monitor itself makes use of the command line to perform any actions requested.
40523
40524
40525
40526 .section "Running the monitor" "SECID264"
40527 The monitor is started by running the script called &'eximon'&. This is a shell
40528 script that sets up a number of environment variables, and then runs the
40529 binary called &_eximon.bin_&. The default appearance of the monitor window can
40530 be changed by editing the &_Local/eximon.conf_& file created by editing
40531 &_exim_monitor/EDITME_&. Comments in that file describe what the various
40532 parameters are for.
40533
40534 The parameters that get built into the &'eximon'& script can be overridden for
40535 a particular invocation by setting up environment variables of the same names,
40536 preceded by &`EXIMON_`&. For example, a shell command such as
40537 .code
40538 EXIMON_LOG_DEPTH=400 eximon
40539 .endd
40540 (in a Bourne-compatible shell) runs &'eximon'& with an overriding setting of
40541 the LOG_DEPTH parameter. If EXIMON_LOG_FILE_PATH is set in the environment, it
40542 overrides the Exim log file configuration. This makes it possible to have
40543 &'eximon'& tailing log data that is written to syslog, provided that MAIL.INFO
40544 syslog messages are routed to a file on the local host.
40545
40546 X resources can be used to change the appearance of the window in the normal
40547 way. For example, a resource setting of the form
40548 .code
40549 Eximon*background: gray94
40550 .endd
40551 changes the colour of the background to light grey rather than white. The
40552 stripcharts are drawn with both the data lines and the reference lines in
40553 black. This means that the reference lines are not visible when on top of the
40554 data. However, their colour can be changed by setting a resource called
40555 &"highlight"& (an odd name, but that's what the Athena stripchart widget uses).
40556 For example, if your X server is running Unix, you could set up lighter
40557 reference lines in the stripcharts by obeying
40558 .code
40559 xrdb -merge <<End
40560 Eximon*highlight: gray
40561 End
40562 .endd
40563 .cindex "admin user"
40564 In order to see the contents of messages in the queue, and to operate on them,
40565 &'eximon'& must either be run as root or by an admin user.
40566
40567 The command-line parameters of &'eximon'& are passed to &_eximon.bin_& and may
40568 contain X11 resource parameters interpreted by the X11 library.  In addition,
40569 if the first parameter starts with the string "gdb" then it is removed and the
40570 binary is invoked under gdb (the parameter is used as the gdb command-name, so
40571 versioned variants of gdb can be invoked).
40572
40573 The monitor's window is divided into three parts. The first contains one or
40574 more stripcharts and two action buttons, the second contains a &"tail"& of the
40575 main log file, and the third is a display of the queue of messages awaiting
40576 delivery, with two more action buttons. The following sections describe these
40577 different parts of the display.
40578
40579
40580
40581
40582 .section "The stripcharts" "SECID265"
40583 .cindex "stripchart"
40584 The first stripchart is always a count of messages in the queue. Its name can
40585 be configured by setting QUEUE_STRIPCHART_NAME in the
40586 &_Local/eximon.conf_& file. The remaining stripcharts are defined in the
40587 configuration script by regular expression matches on log file entries, making
40588 it possible to display, for example, counts of messages delivered to certain
40589 hosts or using certain transports. The supplied defaults display counts of
40590 received and delivered messages, and of local and SMTP deliveries. The default
40591 period between stripchart updates is one minute; this can be adjusted by a
40592 parameter in the &_Local/eximon.conf_& file.
40593
40594 The stripchart displays rescale themselves automatically as the value they are
40595 displaying changes. There are always 10 horizontal lines in each chart; the
40596 title string indicates the value of each division when it is greater than one.
40597 For example, &"x2"& means that each division represents a value of 2.
40598
40599 It is also possible to have a stripchart which shows the percentage fullness of
40600 a particular disk partition, which is useful when local deliveries are confined
40601 to a single partition.
40602
40603 .cindex "&%statvfs%& function"
40604 This relies on the availability of the &[statvfs()]& function or equivalent in
40605 the operating system. Most, but not all versions of Unix that support Exim have
40606 this. For this particular stripchart, the top of the chart always represents
40607 100%, and the scale is given as &"x10%"&. This chart is configured by setting
40608 SIZE_STRIPCHART and (optionally) SIZE_STRIPCHART_NAME in the
40609 &_Local/eximon.conf_& file.
40610
40611
40612
40613
40614 .section "Main action buttons" "SECID266"
40615 .cindex "size" "of monitor window"
40616 .cindex "Exim monitor" "window size"
40617 .cindex "window size"
40618 Below the stripcharts there is an action button for quitting the monitor. Next
40619 to this is another button marked &"Size"&. They are placed here so that
40620 shrinking the window to its default minimum size leaves just the queue count
40621 stripchart and these two buttons visible. Pressing the &"Size"& button causes
40622 the window to expand to its maximum size, unless it is already at the maximum,
40623 in which case it is reduced to its minimum.
40624
40625 When expanding to the maximum, if the window cannot be fully seen where it
40626 currently is, it is moved back to where it was the last time it was at full
40627 size. When it is expanding from its minimum size, the old position is
40628 remembered, and next time it is reduced to the minimum it is moved back there.
40629
40630 The idea is that you can keep a reduced window just showing one or two
40631 stripcharts at a convenient place on your screen, easily expand it to show
40632 the full window when required, and just as easily put it back to what it was.
40633 The idea is copied from what the &'twm'& window manager does for its
40634 &'f.fullzoom'& action. The minimum size of the window can be changed by setting
40635 the MIN_HEIGHT and MIN_WIDTH values in &_Local/eximon.conf_&.
40636
40637 Normally, the monitor starts up with the window at its full size, but it can be
40638 built so that it starts up with the window at its smallest size, by setting
40639 START_SMALL=yes in &_Local/eximon.conf_&.
40640
40641
40642
40643 .section "The log display" "SECID267"
40644 .cindex "log" "tail of; in monitor"
40645 The second section of the window is an area in which a display of the tail of
40646 the main log is maintained.
40647 To save space on the screen, the timestamp on each log line is shortened by
40648 removing the date and, if &%log_timezone%& is set, the timezone.
40649 The log tail is not available when the only destination for logging data is
40650 syslog, unless the syslog lines are routed to a local file whose name is passed
40651 to &'eximon'& via the EXIMON_LOG_FILE_PATH environment variable.
40652
40653 The log sub-window has a scroll bar at its lefthand side which can be used to
40654 move back to look at earlier text, and the up and down arrow keys also have a
40655 scrolling effect. The amount of log that is kept depends on the setting of
40656 LOG_BUFFER in &_Local/eximon.conf_&, which specifies the amount of memory
40657 to use. When this is full, the earlier 50% of data is discarded &-- this is
40658 much more efficient than throwing it away line by line. The sub-window also has
40659 a horizontal scroll bar for accessing the ends of long log lines. This is the
40660 only means of horizontal scrolling; the right and left arrow keys are not
40661 available. Text can be cut from this part of the window using the mouse in the
40662 normal way. The size of this subwindow is controlled by parameters in the
40663 configuration file &_Local/eximon.conf_&.
40664
40665 Searches of the text in the log window can be carried out by means of the ^R
40666 and ^S keystrokes, which default to a reverse and a forward search,
40667 respectively. The search covers only the text that is displayed in the window.
40668 It cannot go further back up the log.
40669
40670 The point from which the search starts is indicated by a caret marker. This is
40671 normally at the end of the text in the window, but can be positioned explicitly
40672 by pointing and clicking with the left mouse button, and is moved automatically
40673 by a successful search. If new text arrives in the window when it is scrolled
40674 back, the caret remains where it is, but if the window is not scrolled back,
40675 the caret is moved to the end of the new text.
40676
40677 Pressing ^R or ^S pops up a window into which the search text can be typed.
40678 There are buttons for selecting forward or reverse searching, for carrying out
40679 the search, and for cancelling. If the &"Search"& button is pressed, the search
40680 happens and the window remains so that further searches can be done. If the
40681 &"Return"& key is pressed, a single search is done and the window is closed. If
40682 ^C is typed the search is cancelled.
40683
40684 The searching facility is implemented using the facilities of the Athena text
40685 widget. By default this pops up a window containing both &"search"& and
40686 &"replace"& options. In order to suppress the unwanted &"replace"& portion for
40687 eximon, a modified version of the &%TextPop%& widget is distributed with Exim.
40688 However, the linkers in BSDI and HP-UX seem unable to handle an externally
40689 provided version of &%TextPop%& when the remaining parts of the text widget
40690 come from the standard libraries. The compile-time option EXIMON_TEXTPOP can be
40691 unset to cut out the modified &%TextPop%&, making it possible to build Eximon
40692 on these systems, at the expense of having unwanted items in the search popup
40693 window.
40694
40695
40696
40697 .section "The queue display" "SECID268"
40698 .cindex "queue" "display in monitor"
40699 The bottom section of the monitor window contains a list of all messages that
40700 are in the queue, which includes those currently being received or delivered,
40701 as well as those awaiting delivery. The size of this subwindow is controlled by
40702 parameters in the configuration file &_Local/eximon.conf_&, and the frequency
40703 at which it is updated is controlled by another parameter in the same file &--
40704 the default is 5 minutes, since queue scans can be quite expensive. However,
40705 there is an &"Update"& action button just above the display which can be used
40706 to force an update of the queue display at any time.
40707
40708 When a host is down for some time, a lot of pending mail can build up for it,
40709 and this can make it hard to deal with other messages in the queue. To help
40710 with this situation there is a button next to &"Update"& called &"Hide"&. If
40711 pressed, a dialogue box called &"Hide addresses ending with"& is put up. If you
40712 type anything in here and press &"Return"&, the text is added to a chain of
40713 such texts, and if every undelivered address in a message matches at least one
40714 of the texts, the message is not displayed.
40715
40716 If there is an address that does not match any of the texts, all the addresses
40717 are displayed as normal. The matching happens on the ends of addresses so, for
40718 example, &'cam.ac.uk'& specifies all addresses in Cambridge, while
40719 &'xxx@foo.com.example'& specifies just one specific address. When any hiding
40720 has been set up, a button called &"Unhide"& is displayed. If pressed, it
40721 cancels all hiding. Also, to ensure that hidden messages do not get forgotten,
40722 a hide request is automatically cancelled after one hour.
40723
40724 While the dialogue box is displayed, you can't press any buttons or do anything
40725 else to the monitor window. For this reason, if you want to cut text from the
40726 queue display to use in the dialogue box, you have to do the cutting before
40727 pressing the &"Hide"& button.
40728
40729 The queue display contains, for each unhidden queued message, the length of
40730 time it has been in the queue, the size of the message, the message id, the
40731 message sender, and the first undelivered recipient, all on one line. If it is
40732 a bounce message, the sender is shown as &"<>"&. If there is more than one
40733 recipient to which the message has not yet been delivered, subsequent ones are
40734 listed on additional lines, up to a maximum configured number, following which
40735 an ellipsis is displayed. Recipients that have already received the message are
40736 not shown.
40737
40738 .cindex "frozen messages" "display"
40739 If a message is frozen, an asterisk is displayed at the left-hand side.
40740
40741 The queue display has a vertical scroll bar, and can also be scrolled by means
40742 of the arrow keys. Text can be cut from it using the mouse in the normal way.
40743 The text searching facilities, as described above for the log window, are also
40744 available, but the caret is always moved to the end of the text when the queue
40745 display is updated.
40746
40747
40748
40749 .section "The queue menu" "SECID269"
40750 .cindex "queue" "menu in monitor"
40751 If the &%shift%& key is held down and the left button is clicked when the mouse
40752 pointer is over the text for any message, an action menu pops up, and the first
40753 line of the queue display for the message is highlighted. This does not affect
40754 any selected text.
40755
40756 If you want to use some other event for popping up the menu, you can set the
40757 MENU_EVENT parameter in &_Local/eximon.conf_& to change the default, or
40758 set EXIMON_MENU_EVENT in the environment before starting the monitor. The
40759 value set in this parameter is a standard X event description. For example, to
40760 run eximon using &%ctrl%& rather than &%shift%& you could use
40761 .code
40762 EXIMON_MENU_EVENT='Ctrl<Btn1Down>' eximon
40763 .endd
40764 The title of the menu is the message id, and it contains entries which act as
40765 follows:
40766
40767 .ilist
40768 &'message log'&: The contents of the message log for the message are displayed
40769 in a new text window.
40770 .next
40771 &'headers'&: Information from the spool file that contains the envelope
40772 information and headers is displayed in a new text window. See chapter
40773 &<<CHAPspool>>& for a description of the format of spool files.
40774 .next
40775 &'body'&: The contents of the spool file containing the body of the message are
40776 displayed in a new text window. There is a default limit of 20,000 bytes to the
40777 amount of data displayed. This can be changed by setting the BODY_MAX
40778 option at compile time, or the EXIMON_BODY_MAX option at runtime.
40779 .next
40780 &'deliver message'&: A call to Exim is made using the &%-M%& option to request
40781 delivery of the message. This causes an automatic thaw if the message is
40782 frozen. The &%-v%& option is also set, and the output from Exim is displayed in
40783 a new text window. The delivery is run in a separate process, to avoid holding
40784 up the monitor while the delivery proceeds.
40785 .next
40786 &'freeze message'&: A call to Exim is made using the &%-Mf%& option to request
40787 that the message be frozen.
40788 .next
40789 .cindex "thawing messages"
40790 .cindex "unfreezing messages"
40791 .cindex "frozen messages" "thawing"
40792 &'thaw message'&: A call to Exim is made using the &%-Mt%& option to request
40793 that the message be thawed.
40794 .next
40795 .cindex "delivery" "forcing failure"
40796 &'give up on msg'&: A call to Exim is made using the &%-Mg%& option to request
40797 that Exim gives up trying to deliver the message. A bounce message is generated
40798 for any remaining undelivered addresses.
40799 .next
40800 &'remove message'&: A call to Exim is made using the &%-Mrm%& option to request
40801 that the message be deleted from the system without generating a bounce
40802 message.
40803 .next
40804 &'add recipient'&: A dialog box is displayed into which a recipient address can
40805 be typed. If the address is not qualified and the QUALIFY_DOMAIN parameter
40806 is set in &_Local/eximon.conf_&, the address is qualified with that domain.
40807 Otherwise it must be entered as a fully qualified address. Pressing RETURN
40808 causes a call to Exim to be made using the &%-Mar%& option to request that an
40809 additional recipient be added to the message, unless the entry box is empty, in
40810 which case no action is taken.
40811 .next
40812 &'mark delivered'&: A dialog box is displayed into which a recipient address
40813 can be typed. If the address is not qualified and the QUALIFY_DOMAIN parameter
40814 is set in &_Local/eximon.conf_&, the address is qualified with that domain.
40815 Otherwise it must be entered as a fully qualified address. Pressing RETURN
40816 causes a call to Exim to be made using the &%-Mmd%& option to mark the given
40817 recipient address as already delivered, unless the entry box is empty, in which
40818 case no action is taken.
40819 .next
40820 &'mark all delivered'&: A call to Exim is made using the &%-Mmad%& option to
40821 mark all recipient addresses as already delivered.
40822 .next
40823 &'edit sender'&: A dialog box is displayed initialized with the current
40824 sender's address. Pressing RETURN causes a call to Exim to be made using the
40825 &%-Mes%& option to replace the sender address, unless the entry box is empty,
40826 in which case no action is taken. If you want to set an empty sender (as in
40827 bounce messages), you must specify it as &"<>"&. Otherwise, if the address is
40828 not qualified and the QUALIFY_DOMAIN parameter is set in &_Local/eximon.conf_&,
40829 the address is qualified with that domain.
40830 .endlist
40831
40832 When a delivery is forced, a window showing the &%-v%& output is displayed. In
40833 other cases when a call to Exim is made, if there is any output from Exim (in
40834 particular, if the command fails) a window containing the command and the
40835 output is displayed. Otherwise, the results of the action are normally apparent
40836 from the log and queue displays. However, if you set ACTION_OUTPUT=yes in
40837 &_Local/eximon.conf_&, a window showing the Exim command is always opened, even
40838 if no output is generated.
40839
40840 The queue display is automatically updated for actions such as freezing and
40841 thawing, unless ACTION_QUEUE_UPDATE=no has been set in
40842 &_Local/eximon.conf_&. In this case the &"Update"& button has to be used to
40843 force an update of the display after one of these actions.
40844
40845 In any text window that is displayed as result of a menu action, the normal
40846 cut-and-paste facility is available, and searching can be carried out using ^R
40847 and ^S, as described above for the log tail window.
40848 .ecindex IIDeximon
40849
40850
40851
40852
40853
40854 . ////////////////////////////////////////////////////////////////////////////
40855 . ////////////////////////////////////////////////////////////////////////////
40856
40857 .chapter "Security considerations" "CHAPsecurity"
40858 .scindex IIDsecurcon "security" "discussion of"
40859 This chapter discusses a number of issues concerned with security, some of
40860 which are also covered in other parts of this manual.
40861
40862 For reasons that this author does not understand, some people have promoted
40863 Exim as a &"particularly secure"& mailer. Perhaps it is because of the
40864 existence of this chapter in the documentation. However, the intent of the
40865 chapter is simply to describe the way Exim works in relation to certain
40866 security concerns, not to make any specific claims about the effectiveness of
40867 its security as compared with other MTAs.
40868
40869 What follows is a description of the way Exim is supposed to be. Best efforts
40870 have been made to try to ensure that the code agrees with the theory, but an
40871 absence of bugs can never be guaranteed. Any that are reported will get fixed
40872 as soon as possible.
40873
40874
40875 .section "Building a more &""hardened""& Exim" "SECID286"
40876 .cindex "security" "build-time features"
40877 There are a number of build-time options that can be set in &_Local/Makefile_&
40878 to create Exim binaries that are &"harder"& to attack, in particular by a rogue
40879 Exim administrator who does not have the root password, or by someone who has
40880 penetrated the Exim (but not the root) account. These options are as follows:
40881
40882 .ilist
40883 ALT_CONFIG_PREFIX can be set to a string that is required to match the
40884 start of any filenames used with the &%-C%& option. When it is set, these
40885 filenames are also not allowed to contain the sequence &"/../"&. (However, if
40886 the value of the &%-C%& option is identical to the value of CONFIGURE_FILE in
40887 &_Local/Makefile_&, Exim ignores &%-C%& and proceeds as usual.) There is no
40888 default setting for &%ALT_CONFIG_PREFIX%&.
40889
40890 If the permitted configuration files are confined to a directory to
40891 which only root has access, this guards against someone who has broken
40892 into the Exim account from running a privileged Exim with an arbitrary
40893 configuration file, and using it to break into other accounts.
40894 .next
40895
40896 If a non-trusted configuration file (i.e. not the default configuration file
40897 or one which is trusted by virtue of being listed in the TRUSTED_CONFIG_LIST
40898 file) is specified with &%-C%&, or if macros are given with &%-D%& (but see
40899 the next item), then root privilege is retained only if the caller of Exim is
40900 root. This locks out the possibility of testing a configuration using &%-C%&
40901 right through message reception and delivery, even if the caller is root. The
40902 reception works, but by that time, Exim is running as the Exim user, so when
40903 it re-execs to regain privilege for the delivery, the use of &%-C%& causes
40904 privilege to be lost. However, root can test reception and delivery using two
40905 separate commands.
40906
40907 .next
40908 The WHITELIST_D_MACROS build option declares some macros to be safe to override
40909 with &%-D%& if the real uid is one of root, the Exim run-time user or the
40910 CONFIGURE_OWNER, if defined.  The potential impact of this option is limited by
40911 requiring the run-time value supplied to &%-D%& to match a regex that errs on
40912 the restrictive side.  Requiring build-time selection of safe macros is onerous
40913 but this option is intended solely as a transition mechanism to permit
40914 previously-working configurations to continue to work after release 4.73.
40915 .next
40916 If DISABLE_D_OPTION is defined, the use of the &%-D%& command line option
40917 is disabled.
40918 .next
40919 FIXED_NEVER_USERS can be set to a colon-separated list of users that are
40920 never to be used for any deliveries. This is like the &%never_users%& runtime
40921 option, but it cannot be overridden; the runtime option adds additional users
40922 to the list. The default setting is &"root"&; this prevents a non-root user who
40923 is permitted to modify the runtime file from using Exim as a way to get root.
40924 .endlist
40925
40926
40927
40928 .section "Root privilege" "SECID270"
40929 .cindex "setuid"
40930 .cindex "root privilege"
40931 The Exim binary is normally setuid to root, which means that it gains root
40932 privilege (runs as root) when it starts execution. In some special cases (for
40933 example, when the daemon is not in use and there are no local deliveries), it
40934 may be possible to run Exim setuid to some user other than root. This is
40935 discussed in the next section. However, in most installations, root privilege
40936 is required for two things:
40937
40938 .ilist
40939 To set up a socket connected to the standard SMTP port (25) when initialising
40940 the listening daemon. If Exim is run from &'inetd'&, this privileged action is
40941 not required.
40942 .next
40943 To be able to change uid and gid in order to read users' &_.forward_& files and
40944 perform local deliveries as the receiving user or as specified in the
40945 configuration.
40946 .endlist
40947
40948 It is not necessary to be root to do any of the other things Exim does, such as
40949 receiving messages and delivering them externally over SMTP, and it is
40950 obviously more secure if Exim does not run as root except when necessary.
40951 For this reason, a user and group for Exim to use must be defined in
40952 &_Local/Makefile_&. These are known as &"the Exim user"& and &"the Exim
40953 group"&. Their values can be changed by the runtime configuration, though this
40954 is not recommended. Often a user called &'exim'& is used, but some sites use
40955 &'mail'& or another user name altogether.
40956
40957 Exim uses &[setuid()]& whenever it gives up root privilege. This is a permanent
40958 abdication; the process cannot regain root afterwards. Prior to release 4.00,
40959 &[seteuid()]& was used in some circumstances, but this is no longer the case.
40960
40961 After a new Exim process has interpreted its command line options, it changes
40962 uid and gid in the following cases:
40963
40964 .ilist
40965 .oindex "&%-C%&"
40966 .oindex "&%-D%&"
40967 If the &%-C%& option is used to specify an alternate configuration file, or if
40968 the &%-D%& option is used to define macro values for the configuration, and the
40969 calling process is not running as root, the uid and gid are changed to those of
40970 the calling process.
40971 However, if DISABLE_D_OPTION is defined in &_Local/Makefile_&, the &%-D%&
40972 option may not be used at all.
40973 If WHITELIST_D_MACROS is defined in &_Local/Makefile_&, then some macro values
40974 can be supplied if the calling process is running as root, the Exim run-time
40975 user or CONFIGURE_OWNER, if defined.
40976 .next
40977 .oindex "&%-be%&"
40978 .oindex "&%-bf%&"
40979 .oindex "&%-bF%&"
40980 If the expansion test option (&%-be%&) or one of the filter testing options
40981 (&%-bf%& or &%-bF%&) are used, the uid and gid are changed to those of the
40982 calling process.
40983 .next
40984 If the process is not a daemon process or a queue runner process or a delivery
40985 process or a process for testing address routing (started with &%-bt%&), the
40986 uid and gid are changed to the Exim user and group. This means that Exim always
40987 runs under its own uid and gid when receiving messages. This also applies when
40988 testing address verification
40989 .oindex "&%-bv%&"
40990 .oindex "&%-bh%&"
40991 (the &%-bv%& option) and testing incoming message policy controls (the &%-bh%&
40992 option).
40993 .next
40994 For a daemon, queue runner, delivery, or address testing process, the uid
40995 remains as root at this stage, but the gid is changed to the Exim group.
40996 .endlist
40997
40998 The processes that initially retain root privilege behave as follows:
40999
41000 .ilist
41001 A daemon process changes the gid to the Exim group and the uid to the Exim
41002 user after setting up one or more listening sockets. The &[initgroups()]&
41003 function is called, so that if the Exim user is in any additional groups, they
41004 will be used during message reception.
41005 .next
41006 A queue runner process retains root privilege throughout its execution. Its
41007 job is to fork a controlled sequence of delivery processes.
41008 .next
41009 A delivery process retains root privilege throughout most of its execution,
41010 but any actual deliveries (that is, the transports themselves) are run in
41011 subprocesses which always change to a non-root uid and gid. For local
41012 deliveries this is typically the uid and gid of the owner of the mailbox; for
41013 remote deliveries, the Exim uid and gid are used. Once all the delivery
41014 subprocesses have been run, a delivery process changes to the Exim uid and gid
41015 while doing post-delivery tidying up such as updating the retry database and
41016 generating bounce and warning messages.
41017
41018 While the recipient addresses in a message are being routed, the delivery
41019 process runs as root. However, if a user's filter file has to be processed,
41020 this is done in a subprocess that runs under the individual user's uid and
41021 gid. A system filter is run as root unless &%system_filter_user%& is set.
41022 .next
41023 A process that is testing addresses (the &%-bt%& option) runs as root so that
41024 the routing is done in the same environment as a message delivery.
41025 .endlist
41026
41027
41028
41029
41030 .section "Running Exim without privilege" "SECTrunexiwitpri"
41031 .cindex "privilege, running without"
41032 .cindex "unprivileged running"
41033 .cindex "root privilege" "running without"
41034 Some installations like to run Exim in an unprivileged state for more of its
41035 operation, for added security. Support for this mode of operation is provided
41036 by the global option &%deliver_drop_privilege%&. When this is set, the uid and
41037 gid are changed to the Exim user and group at the start of a delivery process
41038 (and also queue runner and address testing processes). This means that address
41039 routing is no longer run as root, and the deliveries themselves cannot change
41040 to any other uid.
41041
41042 .cindex SIGHUP
41043 .cindex "daemon" "restarting"
41044 Leaving the binary setuid to root, but setting &%deliver_drop_privilege%& means
41045 that the daemon can still be started in the usual way, and it can respond
41046 correctly to SIGHUP because the re-invocation regains root privilege.
41047
41048 An alternative approach is to make Exim setuid to the Exim user and also setgid
41049 to the Exim group. If you do this, the daemon must be started from a root
41050 process. (Calling Exim from a root process makes it behave in the way it does
41051 when it is setuid root.) However, the daemon cannot restart itself after a
41052 SIGHUP signal because it cannot regain privilege.
41053
41054 It is still useful to set &%deliver_drop_privilege%& in this case, because it
41055 stops Exim from trying to re-invoke itself to do a delivery after a message has
41056 been received. Such a re-invocation is a waste of resources because it has no
41057 effect.
41058
41059 If restarting the daemon is not an issue (for example, if &%mua_wrapper%& is
41060 set, or &'inetd'& is being used instead of a daemon), having the binary setuid
41061 to the Exim user seems a clean approach, but there is one complication:
41062
41063 In this style of operation, Exim is running with the real uid and gid set to
41064 those of the calling process, and the effective uid/gid set to Exim's values.
41065 Ideally, any association with the calling process' uid/gid should be dropped,
41066 that is, the real uid/gid should be reset to the effective values so as to
41067 discard any privileges that the caller may have. While some operating systems
41068 have a function that permits this action for a non-root effective uid, quite a
41069 number of them do not. Because of this lack of standardization, Exim does not
41070 address this problem at this time.
41071
41072 For this reason, the recommended approach for &"mostly unprivileged"& running
41073 is to keep the Exim binary setuid to root, and to set
41074 &%deliver_drop_privilege%&. This also has the advantage of allowing a daemon to
41075 be used in the most straightforward way.
41076
41077 If you configure Exim not to run delivery processes as root, there are a
41078 number of restrictions on what you can do:
41079
41080 .ilist
41081 You can deliver only as the Exim user/group. You should  explicitly use the
41082 &%user%& and &%group%& options to override routers or local transports that
41083 normally deliver as the recipient. This makes sure that configurations that
41084 work in this mode function the same way in normal mode. Any implicit or
41085 explicit specification of another user causes an error.
41086 .next
41087 Use of &_.forward_& files is severely restricted, such that it is usually
41088 not worthwhile to include them in the configuration.
41089 .next
41090 Users who wish to use &_.forward_& would have to make their home directory and
41091 the file itself accessible to the Exim user. Pipe and append-to-file entries,
41092 and their equivalents in Exim filters, cannot be used. While they could be
41093 enabled in the Exim user's name, that would be insecure and not very useful.
41094 .next
41095 Unless the local user mailboxes are all owned by the Exim user (possible in
41096 some POP3 or IMAP-only environments):
41097
41098 .olist
41099 They must be owned by the Exim group and be writeable by that group. This
41100 implies you must set &%mode%& in the appendfile configuration, as well as the
41101 mode of the mailbox files themselves.
41102 .next
41103 You must set &%no_check_owner%&, since most or all of the files will not be
41104 owned by the Exim user.
41105 .next
41106 You must set &%file_must_exist%&, because Exim cannot set the owner correctly
41107 on a newly created mailbox when unprivileged. This also implies that new
41108 mailboxes need to be created manually.
41109 .endlist olist
41110 .endlist ilist
41111
41112
41113 These restrictions severely restrict what can be done in local deliveries.
41114 However, there are no restrictions on remote deliveries. If you are running a
41115 gateway host that does no local deliveries, setting &%deliver_drop_privilege%&
41116 gives more security at essentially no cost.
41117
41118 If you are using the &%mua_wrapper%& facility (see chapter
41119 &<<CHAPnonqueueing>>&), &%deliver_drop_privilege%& is forced to be true.
41120
41121
41122
41123
41124 .section "Delivering to local files" "SECID271"
41125 Full details of the checks applied by &(appendfile)& before it writes to a file
41126 are given in chapter &<<CHAPappendfile>>&.
41127
41128
41129
41130 .section "Running local commands" "SECTsecconslocalcmds"
41131 .cindex "security" "local commands"
41132 .cindex "security" "command injection attacks"
41133 There are a number of ways in which an administrator can configure Exim to run
41134 commands based upon received, untrustworthy, data. Further, in some
41135 configurations a user who can control a &_.forward_& file can also arrange to
41136 run commands. Configuration to check includes, but is not limited to:
41137
41138 .ilist
41139 Use of &%use_shell%& in the pipe transport: various forms of shell command
41140 injection may be possible with this option present. It is dangerous and should
41141 be used only with considerable caution. Consider constraints which whitelist
41142 allowed characters in a variable which is to be used in a pipe transport that
41143 has &%use_shell%& enabled.
41144 .next
41145 A number of options such as &%forbid_filter_run%&, &%forbid_filter_perl%&,
41146 &%forbid_filter_dlfunc%& and so forth which restrict facilities available to
41147 &_.forward_& files in a redirect router. If Exim is running on a central mail
41148 hub to which ordinary users do not have shell access, but home directories are
41149 NFS mounted (for instance) then administrators should review the list of these
41150 forbid options available, and should bear in mind that the options that may
41151 need forbidding can change as new features are added between releases.
41152 .next
41153 The &%${run...}%& expansion item does not use a shell by default, but
41154 administrators can configure use of &_/bin/sh_& as part of the command.
41155 Such invocations should be viewed with prejudicial suspicion.
41156 .next
41157 Administrators who use embedded Perl are advised to explore how Perl's
41158 taint checking might apply to their usage.
41159 .next
41160 Use of &%${expand...}%& is somewhat analogous to shell's eval builtin and
41161 administrators are well advised to view its use with suspicion, in case (for
41162 instance) it allows a local-part to contain embedded Exim directives.
41163 .next
41164 Use of &%${match_local_part...}%& and friends becomes more dangerous if
41165 Exim was built with EXPAND_LISTMATCH_RHS defined: the second string in
41166 each can reference arbitrary lists and files, rather than just being a list
41167 of opaque strings.
41168 The EXPAND_LISTMATCH_RHS option was added and set false by default because of
41169 real-world security vulnerabilities caused by its use with untrustworthy data
41170 injected in, for SQL injection attacks.
41171 Consider the use of the &%inlisti%& expansion condition instead.
41172 .endlist
41173
41174
41175
41176
41177 .section "Trust in configuration data" "SECTsecconfdata"
41178 .cindex "security" "data sources"
41179 .cindex "security" "regular expressions"
41180 .cindex "regular expressions" "security"
41181 .cindex "PCRE2" "security"
41182 If configuration data for Exim can come from untrustworthy sources, there
41183 are some issues to be aware of:
41184
41185 .ilist
41186 Use of &%${expand...}%& may provide a path for shell injection attacks.
41187 .next
41188 Letting untrusted data provide a regular expression is unwise.
41189 .next
41190 Using &%${match...}%& to apply a fixed regular expression against untrusted
41191 data may result in pathological behaviour within PCRE2.  Be aware of what
41192 "backtracking" means and consider options for being more strict with a regular
41193 expression. Avenues to explore include limiting what can match (avoiding &`.`&
41194 when &`[a-z0-9]`& or other character class will do), use of atomic grouping and
41195 possessive quantifiers or just not using regular expressions against untrusted
41196 data.
41197 .next
41198 It can be important to correctly use &%${quote:...}%&,
41199 &%${quote_local_part:...}%& and &%${quote_%&<&'lookup-type'&>&%:...}%& expansion
41200 items to ensure that data is correctly constructed.
41201 .next
41202 Some lookups might return multiple results, even though normal usage is only
41203 expected to yield one result.
41204 .endlist
41205
41206
41207
41208
41209 .section "IPv4 source routing" "SECID272"
41210 .cindex "source routing" "in IP packets"
41211 .cindex "IP source routing"
41212 Many operating systems suppress IP source-routed packets in the kernel, but
41213 some cannot be made to do this, so Exim does its own check. It logs incoming
41214 IPv4 source-routed TCP calls, and then drops them. Things are all different in
41215 IPv6. No special checking is currently done.
41216
41217
41218
41219 .section "The VRFY, EXPN, and ETRN commands in SMTP" "SECID273"
41220 Support for these SMTP commands is disabled by default. If required, they can
41221 be enabled by defining suitable ACLs.
41222
41223
41224
41225
41226 .section "Privileged users" "SECID274"
41227 .cindex "trusted users"
41228 .cindex "admin user"
41229 .cindex "privileged user"
41230 .cindex "user" "trusted"
41231 .cindex "user" "admin"
41232 Exim recognizes two sets of users with special privileges. Trusted users are
41233 able to submit new messages to Exim locally, but supply their own sender
41234 addresses and information about a sending host. For other users submitting
41235 local messages, Exim sets up the sender address from the uid, and doesn't
41236 permit a remote host to be specified.
41237
41238 .oindex "&%-f%&"
41239 However, an untrusted user is permitted to use the &%-f%& command line option
41240 in the special form &%-f <>%& to indicate that a delivery failure for the
41241 message should not cause an error report. This affects the message's envelope,
41242 but it does not affect the &'Sender:'& header. Untrusted users may also be
41243 permitted to use specific forms of address with the &%-f%& option by setting
41244 the &%untrusted_set_sender%& option.
41245
41246 Trusted users are used to run processes that receive mail messages from some
41247 other mail domain and pass them on to Exim for delivery either locally, or over
41248 the Internet. Exim trusts a caller that is running as root, as the Exim user,
41249 as any user listed in the &%trusted_users%& configuration option, or under any
41250 group listed in the &%trusted_groups%& option.
41251
41252 Admin users are permitted to do things to the messages on Exim's queue. They
41253 can freeze or thaw messages, cause them to be returned to their senders, remove
41254 them entirely, or modify them in various ways. In addition, admin users can run
41255 the Exim monitor and see all the information it is capable of providing, which
41256 includes the contents of files on the spool.
41257
41258 .oindex "&%-M%&"
41259 .oindex "&%-q%&"
41260 By default, the use of the &%-M%& and &%-q%& options to cause Exim to attempt
41261 delivery of messages on its queue is restricted to admin users. This
41262 restriction can be relaxed by setting the &%no_prod_requires_admin%& option.
41263 Similarly, the use of &%-bp%& (and its variants) to list the contents of the
41264 queue is also restricted to admin users. This restriction can be relaxed by
41265 setting &%no_queue_list_requires_admin%&.
41266
41267 Exim recognizes an admin user if the calling process is running as root or as
41268 the Exim user or if any of the groups associated with the calling process is
41269 the Exim group. It is not necessary actually to be running under the Exim
41270 group. However, if admin users who are not root or the Exim user are to access
41271 the contents of files on the spool via the Exim monitor (which runs
41272 unprivileged), Exim must be built to allow group read access to its spool
41273 files.
41274
41275 By default, regular users are trusted to perform basic testing and
41276 introspection commands, as themselves.  This setting can be tightened by
41277 setting the &%commandline_checks_require_admin%& option.
41278 This affects most of the checking options,
41279 such as &%-be%& and anything else &%-b*%&.
41280
41281
41282 .section "Spool files" "SECID275"
41283 .cindex "spool directory" "files"
41284 Exim's spool directory and everything it contains is owned by the Exim user and
41285 set to the Exim group. The mode for spool files is defined in the
41286 &_Local/Makefile_& configuration file, and defaults to 0640. This means that
41287 any user who is a member of the Exim group can access these files.
41288
41289
41290
41291 .section "Use of argv[0]" "SECID276"
41292 Exim examines the last component of &%argv[0]%&, and if it matches one of a set
41293 of specific strings, Exim assumes certain options. For example, calling Exim
41294 with the last component of &%argv[0]%& set to &"rsmtp"& is exactly equivalent
41295 to calling it with the option &%-bS%&. There are no security implications in
41296 this.
41297
41298
41299
41300 .section "Use of %f formatting" "SECID277"
41301 The only use made of &"%f"& by Exim is in formatting load average values. These
41302 are actually stored in integer variables as 1000 times the load average.
41303 Consequently, their range is limited and so therefore is the length of the
41304 converted output.
41305
41306
41307
41308 .section "Embedded Exim path" "SECID278"
41309 Exim uses its own path name, which is embedded in the code, only when it needs
41310 to re-exec in order to regain root privilege. Therefore, it is not root when it
41311 does so. If some bug allowed the path to get overwritten, it would lead to an
41312 arbitrary program's being run as exim, not as root.
41313
41314
41315
41316 .section "Dynamic module directory" "SECTdynmoddir"
41317 Any dynamically loadable modules must be installed into the directory
41318 defined in &`LOOKUP_MODULE_DIR`& in &_Local/Makefile_& for Exim to permit
41319 loading it.
41320
41321
41322 .section "Use of sprintf()" "SECID279"
41323 .cindex "&[sprintf()]&"
41324 A large number of occurrences of &"sprintf"& in the code are actually calls to
41325 &'string_sprintf()'&, a function that returns the result in malloc'd store.
41326 The intermediate formatting is done into a large fixed buffer by a function
41327 that runs through the format string itself, and checks the length of each
41328 conversion before performing it, thus preventing buffer overruns.
41329
41330 The remaining uses of &[sprintf()]& happen in controlled circumstances where
41331 the output buffer is known to be sufficiently long to contain the converted
41332 string.
41333
41334
41335
41336 .section "Use of debug_printf() and log_write()" "SECID280"
41337 Arbitrary strings are passed to both these functions, but they do their
41338 formatting by calling the function &'string_vformat()'&, which runs through
41339 the format string itself, and checks the length of each conversion.
41340
41341
41342
41343 .section "Use of strcat() and strcpy()" "SECID281"
41344 These are used only in cases where the output buffer is known to be large
41345 enough to hold the result.
41346 .ecindex IIDsecurcon
41347
41348
41349
41350
41351 . ////////////////////////////////////////////////////////////////////////////
41352 . ////////////////////////////////////////////////////////////////////////////
41353
41354 .chapter "Format of spool files" "CHAPspool"
41355 .scindex IIDforspo1 "format" "spool files"
41356 .scindex IIDforspo2 "spool directory" "format of files"
41357 .scindex IIDforspo3 "spool files" "format of"
41358 .cindex "spool files" "editing"
41359 A message on Exim's queue consists of two files, whose names are the message id
41360 followed by -D and -H, respectively. The data portion of the message is kept in
41361 the -D file on its own. The message's envelope, status, and headers are all
41362 kept in the -H file, whose format is described in this chapter. Each of these
41363 two files contains the final component of its own name as its first line. This
41364 is insurance against disk crashes where the directory is lost but the files
41365 themselves are recoverable.
41366
41367 The file formats may be changed, or new formats added, at any release.
41368 Spool files are not intended as an interface to other programs
41369 and should not be used as such.
41370
41371 Some people are tempted into editing -D files in order to modify messages. You
41372 need to be extremely careful if you do this; it is not recommended and you are
41373 on your own if you do it. Here are some of the pitfalls:
41374
41375 .ilist
41376 You must ensure that Exim does not try to deliver the message while you are
41377 fiddling with it. The safest way is to take out a write lock on the -D file,
41378 which is what Exim itself does, using &[fcntl()]&. If you update the file in
41379 place, the lock will be retained. If you write a new file and rename it, the
41380 lock will be lost at the instant of rename.
41381 .next
41382 .vindex "&$body_linecount$&"
41383 If you change the number of lines in the file, the value of
41384 &$body_linecount$&, which is stored in the -H file, will be incorrect and can
41385 cause incomplete transmission of messages or undeliverable messages.
41386 .next
41387 If the message is in MIME format, you must take care not to break it.
41388 .next
41389 If the message is cryptographically signed, any change will invalidate the
41390 signature.
41391 .endlist
41392 All in all, modifying -D files is fraught with danger.
41393
41394 Files whose names end with -J may also be seen in the &_input_& directory (or
41395 its subdirectories when &%split_spool_directory%& is set). These are journal
41396 files, used to record addresses to which the message has been delivered during
41397 the course of a delivery attempt. If there are still undelivered recipients at
41398 the end, the -H file is updated, and the -J file is deleted. If, however, there
41399 is some kind of crash (for example, a power outage) before this happens, the -J
41400 file remains in existence. When Exim next processes the message, it notices the
41401 -J file and uses it to update the -H file before starting the next delivery
41402 attempt.
41403
41404 Files whose names end with -K or .eml may also be seen in the spool.
41405 These are temporaries used for DKIM or malware processing, when that is used.
41406 They should be tidied up by normal operations; any old ones are probably
41407 relics of crashes and can be removed.
41408
41409 .section "Format of the -H file" "SECID282"
41410 .cindex "uid (user id)" "in spool file"
41411 .cindex "gid (group id)" "in spool file"
41412 The second line of the -H file contains the login name for the uid of the
41413 process that called Exim to read the message, followed by the numerical uid and
41414 gid. For a locally generated message, this is normally the user who sent the
41415 message. For a message received over TCP/IP via the daemon, it is
41416 normally the Exim user.
41417
41418 The third line of the file contains the address of the message's sender as
41419 transmitted in the envelope, contained in angle brackets. The sender address is
41420 empty for bounce messages. For incoming SMTP mail, the sender address is given
41421 in the MAIL command. For locally generated mail, the sender address is
41422 created by Exim from the login name of the current user and the configured
41423 &%qualify_domain%&. However, this can be overridden by the &%-f%& option or a
41424 leading &"From&~"& line if the caller is trusted, or if the supplied address is
41425 &"<>"& or an address that matches &%untrusted_set_senders%&.
41426
41427 The fourth line contains two numbers. The first is the time that the message
41428 was received, in the conventional Unix form &-- the number of seconds since the
41429 start of the epoch. The second number is a count of the number of messages
41430 warning of delayed delivery that have been sent to the sender.
41431
41432 There follow a number of lines starting with a hyphen.
41433 These contain variables, can appear in any
41434 order, and are omitted when not relevant.
41435
41436 If there is a second hyphen after the first,
41437 the corresponding data is tainted.
41438 If there is a value in parentheses, the data is quoted for a lookup.
41439
41440 The following word specifies a variable,
41441 and the remainder of the item depends on the variable.
41442
41443 .vlist
41444 .vitem "&%-acl%&&~<&'number'&>&~<&'length'&>"
41445 This item is obsolete, and is not generated from Exim release 4.61 onwards;
41446 &%-aclc%& and &%-aclm%& are used instead. However, &%-acl%& is still
41447 recognized, to provide backward compatibility. In the old format, a line of
41448 this form is present for every ACL variable that is not empty. The number
41449 identifies the variable; the &%acl_c%&&*x*& variables are numbered 0&--9 and
41450 the &%acl_m%&&*x*& variables are numbered 10&--19. The length is the length of
41451 the data string for the variable. The string itself starts at the beginning of
41452 the next line, and is followed by a newline character. It may contain internal
41453 newlines.
41454
41455 .vitem "&%-aclc%&&~<&'rest-of-name'&>&~<&'length'&>"
41456 A line of this form is present for every ACL connection variable that is
41457 defined. Note that there is a space between &%-aclc%& and the rest of the name.
41458 The length is the length of the data string for the variable. The string itself
41459 starts at the beginning of the next line, and is followed by a newline
41460 character. It may contain internal newlines.
41461
41462 .vitem "&%-aclm%&&~<&'rest-of-name'&>&~<&'length'&>"
41463 A line of this form is present for every ACL message variable that is defined.
41464 Note that there is a space between &%-aclm%& and the rest of the name. The
41465 length is the length of the data string for the variable. The string itself
41466 starts at the beginning of the next line, and is followed by a newline
41467 character. It may contain internal newlines.
41468
41469 .vitem "&%-active_hostname%&&~<&'hostname'&>"
41470 This is present if, when the message was received over SMTP, the value of
41471 &$smtp_active_hostname$& was different to the value of &$primary_hostname$&.
41472
41473 .vitem &%-allow_unqualified_recipient%&
41474 This is present if unqualified recipient addresses are permitted in header
41475 lines (to stop such addresses from being qualified if rewriting occurs at
41476 transport time). Local messages that were input using &%-bnq%& and remote
41477 messages from hosts that match &%recipient_unqualified_hosts%& set this flag.
41478
41479 .vitem &%-allow_unqualified_sender%&
41480 This is present if unqualified sender addresses are permitted in header lines
41481 (to stop such addresses from being qualified if rewriting occurs at transport
41482 time). Local messages that were input using &%-bnq%& and remote messages from
41483 hosts that match &%sender_unqualified_hosts%& set this flag.
41484
41485 .vitem "&%-auth_id%&&~<&'text'&>"
41486 The id information for a message received on an authenticated SMTP connection
41487 &-- the value of the &$authenticated_id$& variable.
41488
41489 .vitem "&%-auth_sender%&&~<&'address'&>"
41490 The address of an authenticated sender &-- the value of the
41491 &$authenticated_sender$& variable.
41492
41493 .vitem "&%-body_linecount%&&~<&'number'&>"
41494 This records the number of lines in the body of the message, and is
41495 present unless &%-spool_file_wireformat%& is.
41496
41497 .vitem "&%-body_zerocount%&&~<&'number'&>"
41498 This records the number of binary zero bytes in the body of the message, and is
41499 present if the number is greater than zero.
41500
41501 .vitem &%-deliver_firsttime%&
41502 This is written when a new message is first added to the spool. When the spool
41503 file is updated after a deferral, it is omitted.
41504
41505 .vitem "&%-frozen%&&~<&'time'&>"
41506 .cindex "frozen messages" "spool data"
41507 The message is frozen, and the freezing happened at <&'time'&>.
41508
41509 .vitem "&%-helo_name%&&~<&'text'&>"
41510 This records the host name as specified by a remote host in a HELO or EHLO
41511 command.
41512
41513 .vitem "&%-host_address%&&~<&'address'&>.<&'port'&>"
41514 This records the IP address of the host from which the message was received and
41515 the remote port number that was used. It is omitted for locally generated
41516 messages.
41517
41518 .vitem "&%-host_auth%&&~<&'text'&>"
41519 If the message was received on an authenticated SMTP connection, this records
41520 the name of the authenticator &-- the value of the
41521 &$sender_host_authenticated$& variable.
41522
41523 .vitem &%-host_lookup_failed%&
41524 This is present if an attempt to look up the sending host's name from its IP
41525 address failed. It corresponds to the &$host_lookup_failed$& variable.
41526
41527 .vitem "&%-host_name%&&~<&'text'&>"
41528 .cindex "reverse DNS lookup"
41529 .cindex "DNS" "reverse lookup"
41530 This records the name of the remote host from which the message was received,
41531 if the host name was looked up from the IP address when the message was being
41532 received. It is not present if no reverse lookup was done.
41533
41534 .vitem "&%-ident%&&~<&'text'&>"
41535 For locally submitted messages, this records the login of the originating user,
41536 unless it was a trusted user and the &%-oMt%& option was used to specify an
41537 ident value. For messages received over TCP/IP, this records the ident string
41538 supplied by the remote host, if any.
41539
41540 .vitem "&%-interface_address%&&~<&'address'&>.<&'port'&>"
41541 This records the IP address of the local interface and the port number through
41542 which a message was received from a remote host. It is omitted for locally
41543 generated messages.
41544
41545 .vitem &%-local%&
41546 The message is from a local sender.
41547
41548 .vitem &%-localerror%&
41549 The message is a locally-generated bounce message.
41550
41551 .vitem "&%-local_scan%&&~<&'string'&>"
41552 This records the data string that was returned by the &[local_scan()]& function
41553 when the message was received &-- the value of the &$local_scan_data$&
41554 variable. It is omitted if no data was returned.
41555
41556 .vitem &%-manual_thaw%&
41557 The message was frozen but has been thawed manually, that is, by an explicit
41558 Exim command rather than via the auto-thaw process.
41559
41560 .vitem &%-N%&
41561 A testing delivery process was started using the &%-N%& option to suppress any
41562 actual deliveries, but delivery was deferred. At any further delivery attempts,
41563 &%-N%& is assumed.
41564
41565 .vitem &%-received_protocol%&
41566 This records the value of the &$received_protocol$& variable, which contains
41567 the name of the protocol by which the message was received.
41568
41569 .vitem &%-sender_set_untrusted%&
41570 The envelope sender of this message was set by an untrusted local caller (used
41571 to ensure that the caller is displayed in queue listings).
41572
41573 .vitem "&%-spam_score_int%&&~<&'number'&>"
41574 If a message was scanned by SpamAssassin, this is present. It records the value
41575 of &$spam_score_int$&.
41576
41577 .vitem &%-spool_file_wireformat%&
41578 The -D file for this message is in wire-format (for ESMTP CHUNKING)
41579 rather than Unix-format.
41580 The line-ending is CRLF rather than newline.
41581 There is still, however, no leading-dot-stuffing.
41582
41583 .vitem &%-tls_certificate_verified%&
41584 A TLS certificate was received from the client that sent this message, and the
41585 certificate was verified by the server.
41586
41587 .vitem "&%-tls_cipher%&&~<&'cipher name'&>"
41588 When the message was received over an encrypted connection, this records the
41589 name of the cipher suite that was used.
41590
41591 .vitem "&%-tls_peerdn%&&~<&'peer DN'&>"
41592 When the message was received over an encrypted connection, and a certificate
41593 was received from the client, this records the Distinguished Name from that
41594 certificate.
41595 .endlist
41596
41597 Following the options there is a list of those addresses to which the message
41598 is not to be delivered. This set of addresses is initialized from the command
41599 line when the &%-t%& option is used and &%extract_addresses_remove_arguments%&
41600 is set; otherwise it starts out empty. Whenever a successful delivery is made,
41601 the address is added to this set. The addresses are kept internally as a
41602 balanced binary tree, and it is a representation of that tree which is written
41603 to the spool file. If an address is expanded via an alias or forward file, the
41604 original address is added to the tree when deliveries to all its child
41605 addresses are complete.
41606
41607 If the tree is empty, there is a single line in the spool file containing just
41608 the text &"XX"&. Otherwise, each line consists of two letters, which are either
41609 Y or N, followed by an address. The address is the value for the node of the
41610 tree, and the letters indicate whether the node has a left branch and/or a
41611 right branch attached to it, respectively. If branches exist, they immediately
41612 follow. Here is an example of a three-node tree:
41613 .code
41614 YY darcy@austen.fict.example
41615 NN alice@wonderland.fict.example
41616 NN editor@thesaurus.ref.example
41617 .endd
41618 After the non-recipients tree, there is a list of the message's recipients.
41619 This is a simple list, preceded by a count. It includes all the original
41620 recipients of the message, including those to whom the message has already been
41621 delivered. In the simplest case, the list contains one address per line. For
41622 example:
41623 .code
41624 4
41625 editor@thesaurus.ref.example
41626 darcy@austen.fict.example
41627 rdo@foundation
41628 alice@wonderland.fict.example
41629 .endd
41630 However, when a child address has been added to the top-level addresses as a
41631 result of the use of the &%one_time%& option on a &(redirect)& router, each
41632 line is of the following form:
41633 .display
41634 <&'top-level address'&> <&'errors_to address'&> &&&
41635   <&'length'&>,<&'parent number'&>#<&'flag bits'&>
41636 .endd
41637 The 01 flag bit indicates the presence of the three other fields that follow
41638 the top-level address. Other bits may be used in future to support additional
41639 fields. The <&'parent number'&> is the offset in the recipients list of the
41640 original parent of the &"one time"& address. The first two fields are the
41641 envelope sender that is associated with this address and its length. If the
41642 length is zero, there is no special envelope sender (there are then two space
41643 characters in the line). A non-empty field can arise from a &(redirect)& router
41644 that has an &%errors_to%& setting.
41645
41646
41647 A blank line separates the envelope and status information from the headers
41648 which follow. A header may occupy several lines of the file, and to save effort
41649 when reading it in, each header is preceded by a number and an identifying
41650 character. The number is the number of characters in the header, including any
41651 embedded newlines and the terminating newline. The character is one of the
41652 following:
41653
41654 .table2 50pt
41655 .row <&'blank'&>         "header in which Exim has no special interest"
41656 .row &`B`&               "&'Bcc:'& header"
41657 .row &`C`&               "&'Cc:'& header"
41658 .row &`F`&               "&'From:'& header"
41659 .row &`I`&               "&'Message-id:'& header"
41660 .row &`P`&               "&'Received:'& header &-- P for &""postmark""&"
41661 .row &`R`&               "&'Reply-To:'& header"
41662 .row &`S`&               "&'Sender:'& header"
41663 .row &`T`&               "&'To:'& header"
41664 .row &`*`&               "replaced or deleted header"
41665 .endtable
41666
41667 Deleted or replaced (rewritten) headers remain in the spool file for debugging
41668 purposes. They are not transmitted when the message is delivered. Here is a
41669 typical set of headers:
41670 .code
41671 111P Received: by hobbit.fict.example with local (Exim 4.00)
41672 id 14y9EI-00026G-00; Fri, 11 May 2001 10:28:59 +0100
41673 049  Message-Id: <E14y9EI-00026G-00@hobbit.fict.example>
41674 038* X-rewrote-sender: bb@hobbit.fict.example
41675 042* From: Bilbo Baggins <bb@hobbit.fict.example>
41676 049F From: Bilbo Baggins <B.Baggins@hobbit.fict.example>
41677 099* To: alice@wonderland.fict.example, rdo@foundation,
41678 darcy@austen.fict.example, editor@thesaurus.ref.example
41679 104T To: alice@wonderland.fict.example, rdo@foundation.example,
41680 darcy@austen.fict.example, editor@thesaurus.ref.example
41681 038  Date: Fri, 11 May 2001 10:28:59 +0100
41682 .endd
41683 The asterisked headers indicate that the envelope sender, &'From:'& header, and
41684 &'To:'& header have been rewritten, the last one because routing expanded the
41685 unqualified domain &'foundation'&.
41686 .ecindex IIDforspo1
41687 .ecindex IIDforspo2
41688 .ecindex IIDforspo3
41689
41690 .section "Format of the -D file" "SECID282a"
41691 The data file is traditionally in Unix-standard format: lines are ended with
41692 an ASCII newline character.
41693 However, when the &%spool_wireformat%& main option is used some -D files
41694 can have an alternate format.
41695 This is flagged by a &%-spool_file_wireformat%& line in the corresponding -H file.
41696 The -D file lines (not including the first name-component line) are
41697 suitable for direct copying to the wire when transmitting using the
41698 ESMTP CHUNKING option, meaning lower processing overhead.
41699 Lines are terminated with an ASCII CRLF pair.
41700 There is no dot-stuffing (and no dot-termination).
41701
41702 . ////////////////////////////////////////////////////////////////////////////
41703 . ////////////////////////////////////////////////////////////////////////////
41704
41705 .chapter "DKIM, SPF, SRS and DMARC" "CHAPdkim" &&&
41706          "DKIM, SPF, SRS and DMARC Support"
41707
41708 .section "DKIM (DomainKeys Identified Mail)" SECDKIM
41709 .cindex "DKIM"
41710
41711 DKIM is a mechanism by which messages sent by some entity can be provably
41712 linked to a domain which that entity controls.  It permits reputation to
41713 be tracked on a per-domain basis, rather than merely upon source IP address.
41714 DKIM is documented in RFC 6376.
41715
41716 As DKIM relies on the message being unchanged in transit, messages handled
41717 by a mailing-list (which traditionally adds to the message) will not match
41718 any original DKIM signature.
41719
41720 DKIM support is compiled into Exim by default if TLS support is present.
41721 It can be disabled by setting DISABLE_DKIM=yes in &_Local/Makefile_&.
41722
41723 Exim's DKIM implementation allows for
41724 .olist
41725 Signing outgoing messages: This function is implemented in the SMTP transport.
41726 It can co-exist with all other Exim features
41727 (including transport filters) except cutthrough delivery.
41728 However, signing options may not depend on headers modified by
41729 routers, the transport or a transport filter.
41730 .next
41731 Verifying signatures in incoming messages: This is implemented by an additional
41732 ACL (acl_smtp_dkim), which can be called several times per message, with
41733 different signature contexts.
41734 .endlist
41735
41736 In typical Exim style, the verification implementation does not include any
41737 default "policy". Instead it enables you to build your own policy using
41738 Exim's standard controls.
41739
41740 Please note that verification of DKIM signatures in incoming mail is turned
41741 on by default for logging (in the <= line) purposes.
41742
41743 Additional log detail can be enabled using the &%dkim_verbose%& log_selector.
41744 When set, for each signature in incoming email,
41745 exim will log a line displaying the most important signature details, and the
41746 signature status. Here is an example (with line-breaks added for clarity):
41747 .code
41748 2009-09-09 10:22:28 1MlIRf-0003LU-U3 DKIM:
41749     d=facebookmail.com s=q1-2009b
41750     c=relaxed/relaxed a=rsa-sha1
41751     i=@facebookmail.com t=1252484542 [verification succeeded]
41752 .endd
41753
41754 You might want to turn off DKIM verification processing entirely for internal
41755 or relay mail sources. To do that, set the &%dkim_disable_verify%& ACL
41756 control modifier. This should typically be done in the RCPT ACL, at points
41757 where you accept mail from relay sources (internal hosts or authenticated
41758 senders).
41759
41760
41761 .subsection "Signing outgoing messages" SECDKIMSIGN
41762 .cindex DKIM signing
41763
41764 For signing to be usable you must have published a DKIM record in DNS.
41765 Note that RFC 8301 (which does not cover EC keys) says:
41766 .code
41767 rsa-sha1 MUST NOT be used for signing or verifying.
41768
41769 Signers MUST use RSA keys of at least 1024 bits for all keys.
41770 Signers SHOULD use RSA keys of at least 2048 bits.
41771 .endd
41772
41773 Note also that the key content (the 'p=' field)
41774 in the DNS record is different between RSA and EC keys;
41775 for the former it is the base64 of the ASN.1 for the RSA public key
41776 (equivalent to the private-key .pem with the header/trailer stripped)
41777 but for EC keys it is the base64 of the pure key; no ASN.1 wrapping.
41778
41779 Signing is enabled by setting private options on the SMTP transport.
41780 These options take (expandable) strings as arguments.
41781
41782 .option dkim_domain smtp "string list&!!" unset
41783 The domain(s) you want to sign with.
41784 After expansion, this can be a list.
41785 Each element in turn,
41786 lowercased,
41787 .vindex "&$dkim_domain$&"
41788 is put into the &%$dkim_domain%& expansion variable
41789 while expanding the remaining signing options.
41790 If it is empty after expansion, DKIM signing is not done,
41791 and no error will result even if &%dkim_strict%& is set.
41792
41793 .option dkim_selector smtp "string list&!!" unset
41794 This sets the key selector string.
41795 After expansion, which can use &$dkim_domain$&, this can be a list.
41796 Each element in turn is put in the expansion
41797 .vindex "&$dkim_selector$&"
41798 variable &%$dkim_selector%& which may be used in the &%dkim_private_key%&
41799 option along with &%$dkim_domain%&.
41800 If the option is empty after expansion, DKIM signing is not done for this domain,
41801 and no error will result even if &%dkim_strict%& is set.
41802
41803 To do, for example, dual-signing with RSA and EC keys
41804 this could be be used:
41805 .code
41806 dkim_selector = ec_sel : rsa_sel
41807 dkim_private_key = KEYS_DIR/$dkim_selector
41808 .endd
41809
41810 .option dkim_private_key smtp string&!! unset
41811 This sets the private key to use.
41812 You can use the &%$dkim_domain%& and
41813 &%$dkim_selector%& expansion variables to determine the private key to use.
41814 The result can either
41815 .ilist
41816 be a valid RSA private key in ASCII armor (.pem file), including line breaks
41817 .next
41818 with GnuTLS 3.6.0 or OpenSSL 1.1.1 or later,
41819 be a valid Ed25519 private key (same format as above)
41820 .next
41821 start with a slash, in which case it is treated as a file that contains
41822 the private key
41823 .next
41824 be "0", "false" or the empty string, in which case the message will not
41825 be signed. This case will not result in an error, even if &%dkim_strict%&
41826 is set.
41827 .endlist
41828
41829 To generate keys under OpenSSL:
41830 .code
41831 openssl genrsa -out dkim_rsa.private 2048
41832 openssl rsa -in dkim_rsa.private -out /dev/stdout -pubout -outform PEM
41833 .endd
41834 The result file from the first command should be retained, and
41835 this option set to use it.
41836 Take the base-64 lines from the output of the second command, concatenated,
41837 for the DNS TXT record.
41838 See section 3.6 of RFC6376 for the record specification.
41839
41840 Under GnuTLS:
41841 .code
41842 certtool --generate-privkey --rsa --bits=2048 --password='' -8 --outfile=dkim_rsa.private
41843 certtool --load-privkey=dkim_rsa.private --pubkey-info
41844 .endd
41845
41846 Note that RFC 8301 says:
41847 .code
41848 Signers MUST use RSA keys of at least 1024 bits for all keys.
41849 Signers SHOULD use RSA keys of at least 2048 bits.
41850 .endd
41851
41852 EC keys for DKIM are defined by RFC 8463.
41853 They are considerably smaller than RSA keys for equivalent protection.
41854 As they are a recent development, users should consider dual-signing
41855 (by setting a list of selectors, and an expansion for this option)
41856 for some transition period.
41857 The "_CRYPTO_SIGN_ED25519" macro will be defined if support is present
41858 for EC keys.
41859
41860 OpenSSL 1.1.1 and GnuTLS 3.6.0 can create Ed25519 private keys:
41861 .code
41862 openssl genpkey -algorithm ed25519 -out dkim_ed25519.private
41863 certtool --generate-privkey --key-type=ed25519 --outfile=dkim_ed25519.private
41864 .endd
41865
41866 To produce the required public key value for a DNS record:
41867 .code
41868 openssl pkey -outform DER -pubout -in dkim_ed25519.private | tail -c +13 | base64
41869 certtool --load_privkey=dkim_ed25519.private --pubkey_info --outder | tail -c +13 | base64
41870 .endd
41871
41872 Exim also supports an alternate format
41873 of Ed25519 keys in DNS which was a candidate during development
41874 of the standard, but not adopted.
41875 A future release will probably drop that support.
41876
41877 .option dkim_hash smtp string&!! sha256
41878 Can be set to any one of the supported hash methods, which are:
41879 .ilist
41880 &`sha1`& &-- should not be used, is old and insecure
41881 .next
41882 &`sha256`& &-- the default
41883 .next
41884 &`sha512`& &-- possibly more secure but less well supported
41885 .endlist
41886
41887 Note that RFC 8301 says:
41888 .code
41889 rsa-sha1 MUST NOT be used for signing or verifying.
41890 .endd
41891
41892 .option dkim_identity smtp string&!! unset
41893 If set after expansion, the value is used to set an "i=" tag in
41894 the signing header.  The DKIM standards restrict the permissible
41895 syntax of this optional tag to a mail address, with possibly-empty
41896 local part, an @, and a domain identical to or subdomain of the "d="
41897 tag value.  Note that Exim does not check the value.
41898
41899 .option dkim_canon smtp string&!! unset
41900 This option sets the canonicalization method used when signing a message.
41901 The DKIM RFC currently supports two methods: "simple" and "relaxed".
41902 The option defaults to "relaxed" when unset. Note: the current implementation
41903 only supports signing with the same canonicalization method for both headers and body.
41904
41905 .option dkim_strict smtp string&!! unset
41906 This  option  defines  how  Exim  behaves  when  signing a message that
41907 should be signed fails for some reason.  When the expansion evaluates to
41908 either &"1"& or &"true"&, Exim will defer. Otherwise Exim will send the message
41909 unsigned. You can use the &%$dkim_domain%& and &%$dkim_selector%& expansion
41910 variables here.
41911
41912 .option dkim_sign_headers smtp string&!! "see below"
41913 If set, this option must expand to a colon-separated
41914 list of header names.
41915 Headers with these names, or the absence of such a header, will be included
41916 in the message signature.
41917 When unspecified, the header names listed in RFC4871 will be used,
41918 whether or not each header is present in the message.
41919 The default list is available for the expansion in the macro
41920 &"_DKIM_SIGN_HEADERS"&
41921 and an oversigning variant is in &"_DKIM_OVERSIGN_HEADERS"&.
41922
41923 If a name is repeated, multiple headers by that name (or the absence thereof)
41924 will be signed.  The textually later headers in the headers part of the
41925 message are signed first, if there are multiples.
41926
41927 A name can be prefixed with either an &"="& or a &"+"& character.
41928 If an &"="& prefix is used, all headers that are present with this name
41929 will be signed.
41930 If a &"+"& prefix if used, all headers that are present with this name
41931 will be signed, and one signature added for a missing header with the
41932 name will be appended.
41933
41934 .option dkim_timestamps smtp integer&!! unset
41935 This option controls the inclusion of timestamp information in the signature.
41936 If not set, no such information will be included.
41937 Otherwise, must be an unsigned number giving an offset in seconds from the
41938 current time for the expiry tag (e.g. 1209600 for two weeks); both creation
41939 (t=) and expiry (x=) tags will be included unless the offset is 0 (no expiry).
41940
41941 RFC 6376 lists these tags as RECOMMENDED.
41942
41943
41944 .subsection "Verifying DKIM signatures in incoming mail" SECDKIMVFY
41945 .cindex DKIM verification
41946
41947 Verification of DKIM signatures in SMTP incoming email is done for all
41948 messages for which an ACL control &%dkim_disable_verify%& has not been set.
41949
41950 .cindex DKIM "selecting signature algorithms"
41951 Individual classes of DKIM signature algorithm can be ignored by changing
41952 the main options &%dkim_verify_hashes%& or &%dkim_verify_keytypes%&.
41953 The &%dkim_verify_minimal%& option can be set to cease verification
41954 processing for a message once the first passing signature is found.
41955
41956 .cindex authentication "expansion item"
41957 Performing verification sets up information used by the
41958 &%authresults%& expansion item.
41959
41960 For most purposes the default option settings suffice and the remainder
41961 of this section can be ignored.
41962
41963 The results of verification are made available to the
41964 &%acl_smtp_dkim%& ACL, which (for complex needs) can examine and modify them.
41965 A missing ACL definition defaults to accept.
41966 By default, the ACL is called once for each
41967 syntactically(!) correct signature in the incoming message.
41968 If any ACL call does not accept, the message is not accepted.
41969 If a cutthrough delivery was in progress for the message, that is
41970 summarily dropped (having wasted the transmission effort).
41971
41972 To evaluate the verification result in the ACL
41973 a large number of expansion variables
41974 containing the signature status and its details are set up during the
41975 runtime of the ACL.
41976
41977 Calling the ACL only for existing signatures is not sufficient to build
41978 more advanced policies. For that reason, the main option
41979 &%dkim_verify_signers%&, and an expansion variable
41980 &%$dkim_signers%& exist.
41981
41982 The main option &%dkim_verify_signers%& can be set to a colon-separated
41983 list of DKIM domains or identities for which the ACL &%acl_smtp_dkim%& is
41984 called. It is expanded when the message has been received. At this point,
41985 the expansion variable &%$dkim_signers%& already contains a colon-separated
41986 list of signer domains and identities for the message. When
41987 &%dkim_verify_signers%& is not specified in the main configuration,
41988 it defaults as:
41989 .code
41990 dkim_verify_signers = $dkim_signers
41991 .endd
41992 This leads to the default behaviour of calling &%acl_smtp_dkim%& for each
41993 DKIM signature in the message. Current DKIM verifiers may want to explicitly
41994 call the ACL for known domains or identities. This would be achieved as follows:
41995 .code
41996 dkim_verify_signers = paypal.com:ebay.com:$dkim_signers
41997 .endd
41998 This would result in &%acl_smtp_dkim%& always being called for "paypal.com"
41999 and "ebay.com", plus all domains and identities that have signatures in the message.
42000 You can also be more creative in constructing your policy. For example:
42001 .code
42002 dkim_verify_signers = $sender_address_domain:$dkim_signers
42003 .endd
42004
42005 If a domain or identity is listed several times in the (expanded) value of
42006 &%dkim_verify_signers%&, the ACL is only called once for that domain or identity.
42007
42008 Note that if the option is set using untrustworthy data
42009 (such as the From: header)
42010 care should be taken to force lowercase for domains
42011 and for the domain part if identities.
42012 The default setting can be regarded as trustworthy in this respect.
42013
42014 If multiple signatures match a domain (or identity), the ACL is called once
42015 for each matching signature.
42016
42017
42018 Inside the DKIM ACL, the following expansion variables are
42019 available (from most to least important):
42020
42021
42022 .vlist
42023 .vitem &%$dkim_cur_signer%&
42024 The signer that is being evaluated in this ACL run. This can be a domain or
42025 an identity. This is one of the list items from the expanded main option
42026 &%dkim_verify_signers%& (see above).
42027
42028 .vitem &%$dkim_verify_status%&
42029 So long as a DKIM ACL is defined
42030 (it need do no more than accept, which is the default),
42031 after all the DKIM ACL runs have completed, the value becomes a
42032 colon-separated list of the values after each run.
42033 The value is maintained for the MIME, PRDR and DATA ACLs.
42034
42035 Within the DKIM ACL,
42036 a string describing the general status of the signature. One of
42037 .ilist
42038 &%none%&: There is no signature in the message for the current domain or
42039 identity (as reflected by &%$dkim_cur_signer%&).
42040 .next
42041 &%invalid%&: The signature could not be verified due to a processing error.
42042 More detail is available in &%$dkim_verify_reason%&.
42043 .next
42044 &%fail%&: Verification of the signature failed.  More detail is
42045 available in &%$dkim_verify_reason%&.
42046 .next
42047 &%pass%&: The signature passed verification. It is valid.
42048 .endlist
42049
42050 This variable can be overwritten using an ACL 'set' modifier.
42051 This might, for instance, be done to enforce a policy restriction on
42052 hash-method or key-size:
42053 .code
42054   warn condition       = ${if eq {$dkim_verify_status}{pass}}
42055        condition       = ${if eq {${length_3:$dkim_algo}}{rsa}}
42056        condition       = ${if or {{eq {$dkim_algo}{rsa-sha1}} \
42057                                   {< {$dkim_key_length}{1024}}}}
42058        logwrite        = NOTE: forcing DKIM verify fail (was pass)
42059        set dkim_verify_status = fail
42060        set dkim_verify_reason = hash too weak or key too short
42061 .endd
42062
42063 .vitem &%$dkim_verify_reason%&
42064 A string giving a little bit more detail when &%$dkim_verify_status%& is either
42065 "fail" or "invalid". One of
42066 .ilist
42067 &%pubkey_unavailable%& (when &%$dkim_verify_status%&="invalid"): The public
42068 key for the domain could not be retrieved. This may be a temporary problem.
42069 .next
42070 &%pubkey_syntax%& (when &%$dkim_verify_status%&="invalid"): The public key
42071 record for the domain is syntactically invalid.
42072 .next
42073 &%bodyhash_mismatch%& (when &%$dkim_verify_status%&="fail"): The calculated
42074 body hash does not match the one specified in the signature header. This
42075 means that the message body was modified in transit.
42076 .next
42077 &%signature_incorrect%& (when &%$dkim_verify_status%&="fail"): The signature
42078 could not be verified. This may mean that headers were modified,
42079 re-written or otherwise changed in a way which is incompatible with
42080 DKIM verification. It may of course also mean that the signature is forged.
42081 .endlist
42082
42083 This variable can be overwritten, with any value, using an ACL 'set' modifier.
42084
42085 .vitem &%$dkim_domain%&
42086 The signing domain. IMPORTANT: This variable is only populated if there is
42087 an actual signature in the message for the current domain or identity (as
42088 reflected by &%$dkim_cur_signer%&).
42089
42090 .vitem &%$dkim_identity%&
42091 The signing identity, if present. IMPORTANT: This variable is only populated
42092 if there is an actual signature in the message for the current domain or
42093 identity (as reflected by &%$dkim_cur_signer%&).
42094
42095 .vitem &%$dkim_selector%&
42096 The key record selector string.
42097
42098 .vitem &%$dkim_algo%&
42099 The algorithm used. One of 'rsa-sha1' or 'rsa-sha256'.
42100 If running under GnuTLS 3.6.0 or OpenSSL 1.1.1 or later,
42101 may also be 'ed25519-sha256'.
42102 The "_CRYPTO_SIGN_ED25519" macro will be defined if support is present
42103 for EC keys.
42104
42105 Note that RFC 8301 says:
42106 .code
42107 rsa-sha1 MUST NOT be used for signing or verifying.
42108
42109 DKIM signatures identified as having been signed with historic
42110 algorithms (currently, rsa-sha1) have permanently failed evaluation
42111 .endd
42112
42113 To enforce this you must either have a DKIM ACL which checks this variable
42114 and overwrites the &$dkim_verify_status$& variable as discussed above,
42115 or have set the main option &%dkim_verify_hashes%& to exclude
42116 processing of such signatures.
42117
42118 .vitem &%$dkim_canon_body%&
42119 The body canonicalization method. One of 'relaxed' or 'simple'.
42120
42121 .vitem &%$dkim_canon_headers%&
42122 The header canonicalization method. One of 'relaxed' or 'simple'.
42123
42124 .vitem &%$dkim_copiedheaders%&
42125 A transcript of headers and their values which are included in the signature
42126 (copied from the 'z=' tag of the signature).
42127 Note that RFC6376 requires that verification fail if the From: header is
42128 not included in the signature.  Exim does not enforce this; sites wishing
42129 strict enforcement should code the check explicitly.
42130
42131 .vitem &%$dkim_bodylength%&
42132 The number of signed body bytes. If zero ("0"), the body is unsigned. If no
42133 limit was set by the signer, "9999999999999" is returned. This makes sure
42134 that this variable always expands to an integer value.
42135 &*Note:*& The presence of the signature tag specifying a signing body length
42136 is one possible route to spoofing of valid DKIM signatures.
42137 A paranoid implementation might wish to regard signature where this variable
42138 shows less than the "no limit" return as being invalid.
42139
42140 .vitem &%$dkim_created%&
42141 UNIX timestamp reflecting the date and time when the signature was created.
42142 When this was not specified by the signer, "0" is returned.
42143
42144 .vitem &%$dkim_expires%&
42145 UNIX timestamp reflecting the date and time when the signer wants the
42146 signature to be treated as "expired". When this was not specified by the
42147 signer, "9999999999999" is returned. This makes it possible to do useful
42148 integer size comparisons against this value.
42149 Note that Exim does not check this value.
42150
42151 .vitem &%$dkim_headernames%&
42152 A colon-separated list of names of headers included in the signature.
42153
42154 .vitem &%$dkim_key_testing%&
42155 "1" if the key record has the "testing" flag set, "0" if not.
42156
42157 .vitem &%$dkim_key_nosubdomains%&
42158 "1" if the key record forbids subdomaining, "0" otherwise.
42159
42160 .vitem &%$dkim_key_srvtype%&
42161 Service type (tag s=) from the key record. Defaults to "*" if not specified
42162 in the key record.
42163
42164 .vitem &%$dkim_key_granularity%&
42165 Key granularity (tag g=) from the key record. Defaults to "*" if not specified
42166 in the key record.
42167
42168 .vitem &%$dkim_key_notes%&
42169 Notes from the key record (tag n=).
42170
42171 .vitem &%$dkim_key_length%&
42172 Number of bits in the key.
42173 Valid only once the key is loaded, which is at the time the header signature
42174 is verified, which is after the body hash is.
42175
42176 Note that RFC 8301 says:
42177 .code
42178 Verifiers MUST NOT consider signatures using RSA keys of
42179 less than 1024 bits as valid signatures.
42180 .endd
42181
42182 This is enforced by the default setting for the &%dkim_verify_min_keysizes%&
42183 option.
42184
42185 .endlist
42186
42187 In addition, two ACL conditions are provided:
42188
42189 .vlist
42190 .vitem &%dkim_signers%&
42191 ACL condition that checks a colon-separated list of domains or identities
42192 for a match against the domain or identity that the ACL is currently verifying
42193 (reflected by &%$dkim_cur_signer%&).
42194 This condition is only usable in a DKIM ACL.
42195 This is typically used to restrict an ACL
42196 verb to a group of domains or identities. For example:
42197
42198 .code
42199 # Warn when Mail purportedly from GMail has no gmail signature
42200 warn sender_domains = gmail.com
42201      dkim_signers = gmail.com
42202      dkim_status = none
42203      log_message = GMail sender without gmail.com DKIM signature
42204 .endd
42205
42206 Note that the above does not check for a total lack of DKIM signing;
42207 for that check for empty &$h_DKIM-Signature:$& in the data ACL.
42208
42209 .vitem &%dkim_status%&
42210 ACL condition that checks a colon-separated list of possible DKIM verification
42211 results against the actual result of verification,
42212 given by &$dkim_verify_status$& if that is non-empty or "none" if empty.
42213 This condition may be used in DKIM, MIME, PRDR and DATA ACLs.
42214
42215 A basic verification might be:
42216 .code
42217 deny !dkim_status = pass:none:invalid
42218 .endd
42219
42220 A more complex use could be
42221 to restrict an ACL verb to a list of verification outcomes, for example:
42222
42223 .code
42224 deny sender_domains = paypal.com:paypal.de
42225      dkim_signers = paypal.com:paypal.de
42226      dkim_status = none:invalid:fail
42227      message = Mail from Paypal with invalid/missing signature
42228 .endd
42229
42230 The possible status keywords are: 'none','invalid','fail' and 'pass'. Please
42231 see the documentation of the &%$dkim_verify_status%& expansion variable above
42232 for more information of what they mean.
42233
42234 The condition is true if the status
42235 (or any of the list of status values)
42236 is any one of the supplied list.
42237 .endlist
42238
42239
42240
42241
42242 .section "SPF (Sender Policy Framework)" SECSPF
42243 .cindex SPF verification
42244
42245 SPF is a mechanism whereby a domain may assert which IP addresses may transmit
42246 messages with its domain in the envelope from, documented by RFC 7208.
42247 For more information on SPF see &url(http://www.open-spf.org), a static copy of
42248 the &url(http://openspf.org).
42249 . --- 2019-10-28: still not https, open-spf.org is told to be a
42250 . --- web-archive copy of the now dead openspf.org site
42251 . --- See https://www.mail-archive.com/mailop@mailop.org/msg08019.html for a
42252 . --- discussion.
42253
42254 Messages sent by a system not authorised will fail checking of such assertions.
42255 This includes retransmissions done by traditional forwarders.
42256
42257 SPF verification support is built into Exim if SUPPORT_SPF=yes is set in
42258 &_Local/Makefile_&.  The support uses the &_libspf2_& library
42259 &url(https://www.libspf2.org/).
42260 There is no Exim involvement in the transmission of messages;
42261 publishing certain DNS records is all that is required.
42262
42263 For verification, an ACL condition and an expansion lookup are provided.
42264 .cindex authentication "expansion item"
42265 Performing verification sets up information used by the
42266 &%authresults%& expansion item.
42267
42268
42269 .cindex SPF "ACL condition"
42270 .cindex ACL "spf condition"
42271 The ACL condition "spf" can be used at or after the MAIL ACL.
42272 It takes as an argument a list of strings giving the outcome of the SPF check,
42273 and will succeed for any matching outcome.
42274 Valid strings are:
42275 .vlist
42276 .vitem &%pass%&
42277 The SPF check passed, the sending host is positively verified by SPF.
42278
42279 .vitem &%fail%&
42280 The SPF check failed, the sending host is NOT allowed to send mail for the
42281 domain in the envelope-from address.
42282
42283 .vitem &%softfail%&
42284 The SPF check failed, but the queried domain can't absolutely confirm that this
42285 is a forgery.
42286
42287 .vitem &%none%&
42288 The queried domain does not publish SPF records.
42289
42290 .vitem &%neutral%&
42291 The SPF check returned a "neutral" state.  This means the queried domain has
42292 published a SPF record, but wants to allow outside servers to send mail under
42293 its domain as well.  This should be treated like "none".
42294
42295 .vitem &%permerror%&
42296 This indicates a syntax error in the SPF record of the queried domain.
42297 You may deny messages when this occurs.
42298
42299 .vitem &%temperror%&
42300 This indicates a temporary error during all processing, including Exim's
42301 SPF processing.  You may defer messages when this occurs.
42302
42303 .vitem &%invalid%&
42304 There was an error during processing of the SPF lookup
42305 .endlist
42306
42307 You can prefix each string with an exclamation mark to  invert
42308 its meaning,  for example  "!fail" will  match all  results but
42309 "fail".  The  string  list is  evaluated  left-to-right,  in a
42310 short-circuit fashion.
42311
42312 Example:
42313 .code
42314 deny spf = fail
42315      message = $sender_host_address is not allowed to send mail from \
42316                ${if def:sender_address_domain \
42317                     {$sender_address_domain}{$sender_helo_name}}.  \
42318                Please see http://www.open-spf.org/Why;\
42319                identity=${if def:sender_address_domain \
42320                              {$sender_address}{$sender_helo_name}};\
42321                ip=$sender_host_address
42322 .endd
42323
42324 Note: The above mentioned URL may not be as helpful as expected. You are
42325 encouraged to replace the link with a link to a site with more
42326 explanations.
42327
42328 When the spf condition has run, it sets up several expansion
42329 variables:
42330
42331 .cindex SPF "verification variables"
42332 .vlist
42333 .vitem &$spf_header_comment$&
42334 .vindex &$spf_header_comment$&
42335   This contains a human-readable string describing the outcome
42336   of the SPF check. You can add it to a custom header or use
42337   it for logging purposes.
42338
42339 .vitem &$spf_received$&
42340 .vindex &$spf_received$&
42341   This contains a complete Received-SPF: header (name and
42342   content) that can be added to the message. Please note that
42343   according to the SPF draft, this header must be added at the
42344   top of the header list, i.e. with
42345 .code
42346 add_header = :at_start:$spf_received
42347 .endd
42348   See section &<<SECTaddheadacl>>& for further details.
42349
42350   Note: in case of "Best-guess" (see below), the convention is
42351   to put this string in a header called X-SPF-Guess: instead.
42352
42353 .vitem &$spf_result$&
42354 .vindex &$spf_result$&
42355   This contains the outcome of the SPF check in string form,
42356   currently one of pass, fail, softfail, none, neutral, permerror,
42357   temperror, or &"(invalid)"&.
42358
42359 .vitem &$spf_result_guessed$&
42360 .vindex &$spf_result_guessed$&
42361   This boolean is true only if a best-guess operation was used
42362   and required in order to obtain a result.
42363
42364 .vitem &$spf_smtp_comment$&
42365 .vindex &$spf_smtp_comment$&
42366 .vindex &%spf_smtp_comment_template%&
42367   This contains a string that can be used in a SMTP response
42368   to the calling party. Useful for "fail".
42369   The string is generated by the SPF library from the template configured in the main config
42370   option &%spf_smtp_comment_template%&.
42371 .endlist
42372
42373
42374 .cindex SPF "ACL condition"
42375 .cindex ACL "spf_guess condition"
42376 .cindex SPF "best guess"
42377 In addition to SPF, you can also perform checks for so-called
42378 "Best-guess".  Strictly speaking, "Best-guess" is not standard
42379 SPF, but it is supported by the same framework that enables SPF
42380 capability.
42381 Refer to &url(http://www.open-spf.org/FAQ/Best_guess_record)
42382 for a description of what it means.
42383 . --- 2019-10-28: still not https:
42384
42385 To access this feature, simply use the spf_guess condition in place
42386 of the spf one.  For example:
42387
42388 .code
42389 deny spf_guess = fail
42390      message = $sender_host_address doesn't look trustworthy to me
42391 .endd
42392
42393 In case you decide to reject messages based on this check, you
42394 should note that although it uses the same framework, "Best-guess"
42395 is not SPF, and therefore you should not mention SPF at all in your
42396 reject message.
42397
42398 When the spf_guess condition has run, it sets up the same expansion
42399 variables as when spf condition is run, described above.
42400
42401 Additionally, since Best-guess is not standardized, you may redefine
42402 what "Best-guess" means to you by redefining the main configuration
42403 &%spf_guess%& option.
42404 For example, the following:
42405
42406 .code
42407 spf_guess = v=spf1 a/16 mx/16 ptr ?all
42408 .endd
42409
42410 would relax host matching rules to a broader network range.
42411
42412
42413 .cindex SPF "lookup expansion"
42414 .cindex lookup spf
42415 A lookup expansion is also available. It takes an email
42416 address as the key and an IP address
42417 (v4 or v6)
42418 as the database:
42419
42420 .code
42421   ${lookup {username@domain} spf {ip.ip.ip.ip}}
42422 .endd
42423
42424 The lookup will return the same result strings as can appear in
42425 &$spf_result$& (pass,fail,softfail,neutral,none,err_perm,err_temp).
42426
42427
42428
42429
42430
42431 .subsection "SRS (Sender Rewriting Scheme)" SECTSRS
42432 .cindex SRS "sender rewriting scheme"
42433 .cindex VERP "variable envelope return path"
42434
42435 SRS can be used to modify sender addresses when forwarding so that
42436 SPF verification does not object to them.
42437 It can also be used to identify a received bounce message as
42438 likely (or not) having been trigged by a message from the
42439 local system, and for identifying dead addresses in mailing lists.
42440 It is one implementation of a VERP (Variable Envelope Return Path) method.
42441
42442 SRS operates by encoding the original envelope sender in a new
42443 sender local part and using a domain run by the forwarding site
42444 as the new domain for the sender.  Any DSN message should be returned
42445 to this new sender at the forwarding site, which can extract the
42446 original sender from the coded local part and forward the DSN to
42447 the originator.
42448
42449 This is a way of avoiding the breakage that SPF does to forwarding.
42450 The constructed local-part will be longer than the original,
42451 leading to possible problems with very long addresses.
42452 The changing of the sender address also hinders the tracing of mail
42453 problems.
42454
42455 Exim can be built to include native SRS support.  To do this
42456 SUPPORT_SRS=yes must be defined in &_Local/Makefile_&.
42457 If this has been done, the macros _HAVE_SRS and _HAVE_NATIVE_SRS
42458 will be defined.
42459 The support is limited to SRS0-encoding; SRS1 is not supported.
42460
42461 .cindex SRS excoding
42462 To encode an address use this expansion item:
42463 .vlist
42464 .vitem &*${srs_encode&~{*&<&'secret'&>&*}{*&<&'return&~path'&>&*}{*&<&'original&~domain'&>&*}}*&
42465 .cindex "&%srs_encode%& expansion item"
42466 .cindex SRS "expansion item"
42467 The first argument should be a secret known and used by all systems
42468 handling the recipient domain for the original message.
42469 There is no need to periodically change this key; a timestamp is also
42470 encoded.
42471 The second argument should be given as the envelope sender address before this
42472 encoding operation.
42473 If this value is empty the the expansion result will be empty.
42474 The third argument should be the recipient domain of the message when
42475 it arrived at this system.
42476 All arguments are expanded before use.
42477
42478 The result of the expansion is the replacement envelope-from (return path)
42479 to be used.
42480 .endlist
42481
42482 .cindex SRS decoding
42483 To decode an address use this expansion condition:
42484 .vlist
42485 .vitem &*inbound_srs&~{*&<&'local&~part'&>&*}{*&<&'secret'&>&*}*&
42486 The first argument should be the recipient local part as it was received.
42487 The second argument is the site secret.
42488 Both arguments are expanded before use.
42489
42490 If the messages is not for an SRS-encoded recipient the condition will
42491 return false.
42492 If it is, the condition will return true and the variable
42493 &$srs_recipient$& will be set to the decoded (original) value.
42494
42495 If the second argument is empty then the condition returns true if
42496 the first argument is in valid SRS formet, else false.
42497 The variable &$srs_recipient$& is not set for this case.
42498 .endlist
42499
42500 Example usage:
42501 .code
42502   #macro
42503   SRS_SECRET = <pick something unique for your site for this. Use on all MXs.>
42504
42505   #routers
42506
42507   outbound:
42508     driver =    dnslookup
42509     # if outbound, and forwarding has been done, use an alternate transport
42510     domains =   ! +my_domains
42511     transport = ${if eq {$local_part@$domain} \
42512                         {$original_local_part@$original_domain} \
42513                      {remote_smtp} {remote_forwarded_smtp}}
42514
42515   inbound_srs:
42516     driver =    redirect
42517     senders =   :
42518     domains =   +my_domains
42519     # detect inbound bounces which are SRS'd, and decode them
42520     condition = ${if inbound_srs {$local_part} {SRS_SECRET}}
42521     data =      $srs_recipient
42522
42523   inbound_srs_failure:
42524     driver =    redirect
42525     senders =   :
42526     domains =   +my_domains
42527     # detect inbound bounces which look SRS'd but are invalid
42528     condition = ${if inbound_srs {$local_part} {}}
42529     allow_fail
42530     data =      :fail: Invalid SRS recipient address
42531
42532   #... further routers here get inbound_srs-redirected recipients
42533   # and any that were not SRS'd
42534
42535
42536   # transport; should look like the non-forward outbound
42537   # one, plus the max_rcpt and return_path options
42538   remote_forwarded_smtp:
42539     driver =              smtp
42540     # single-recipient so that $original_domain is valid
42541     max_rcpt =            1
42542     # modify the envelope from, for mails that we forward
42543     return_path =         ${srs_encode {SRS_SECRET} {$return_path} {$original_domain}}
42544 .endd
42545
42546
42547
42548
42549
42550 .section DMARC SECDMARC
42551 .cindex DMARC verification
42552
42553 DMARC combines feedback from SPF, DKIM, and header From: in order
42554 to attempt to provide better indicators of the authenticity of an
42555 email.  This document does not explain the fundamentals; you
42556 should read and understand how it works by visiting the website at
42557 &url(http://www.dmarc.org/).
42558
42559 If Exim is built with DMARC support,
42560 the libopendmarc library is used.
42561
42562 For building Exim yourself, obtain the library from
42563 &url(http://sourceforge.net/projects/opendmarc/)
42564 to obtain a copy, or find it in your favorite package
42565 repository.  You will need to attend to the local/Makefile feature
42566 SUPPORT_DMARC and the associated LDFLAGS addition.
42567 This description assumes
42568 that headers will be in /usr/local/include, and that the libraries
42569 are in /usr/local/lib.
42570
42571 .subsection Configuration SSECDMARCCONFIG
42572 .cindex DMARC configuration
42573
42574 There are three main-configuration options:
42575 .cindex DMARC "configuration options"
42576
42577 The &%dmarc_tld_file%& option
42578 .oindex &%dmarc_tld_file%&
42579 defines the location of a text file of valid
42580 top level domains the opendmarc library uses
42581 during domain parsing. Maintained by Mozilla,
42582 the most current version can be downloaded
42583 from a link at &url(https://publicsuffix.org/list/public_suffix_list.dat).
42584 See also the util/renew-opendmarc-tlds.sh script.
42585 The default for the option is unset.
42586 If not set, DMARC processing is disabled.
42587
42588
42589 The &%dmarc_history_file%& option, if set
42590 .oindex &%dmarc_history_file%&
42591 defines the location of a file to log results
42592 of dmarc verification on inbound emails. The
42593 contents are importable by the opendmarc tools
42594 which will manage the data, send out DMARC
42595 reports, and expire the data. Make sure the
42596 directory of this file is writable by the user
42597 exim runs as.
42598 The default is unset.
42599
42600 The &%dmarc_forensic_sender%& option
42601 .oindex &%dmarc_forensic_sender%&
42602 defines an alternate email address to use when sending a
42603 forensic report detailing alignment failures
42604 if a sender domain's dmarc record specifies it
42605 and you have configured Exim to send them.
42606 If set, this is expanded and used for the
42607 From: header line; the address is extracted
42608 from it and used for the envelope from.
42609 If not set (the default), the From: header is expanded from
42610 the dsn_from option, and <> is used for the
42611 envelope from.
42612
42613 .subsection Controls SSECDMARCCONTROLS
42614 .cindex DMARC controls
42615
42616 By default, the DMARC processing will run for any remote,
42617 non-authenticated user.  It makes sense to only verify DMARC
42618 status of messages coming from remote, untrusted sources.  You can
42619 use standard conditions such as hosts, senders, etc, to decide that
42620 DMARC verification should *not* be performed for them and disable
42621 DMARC with an ACL control modifier:
42622 .code
42623   control = dmarc_disable_verify
42624 .endd
42625 A DMARC record can also specify a "forensic address", which gives
42626 exim an email address to submit reports about failed alignment.
42627 Exim does not do this by default because in certain conditions it
42628 results in unintended information leakage (what lists a user might
42629 be subscribed to, etc).  You must configure exim to submit forensic
42630 reports to the owner of the domain.  If the DMARC record contains a
42631 forensic address and you specify the control statement below, then
42632 exim will send these forensic emails.  It is also advised that you
42633 configure a &%dmarc_forensic_sender%& because the default sender address
42634 construction might be inadequate.
42635 .code
42636   control = dmarc_enable_forensic
42637 .endd
42638 (AGAIN: You can choose not to send these forensic reports by simply
42639 not putting the dmarc_enable_forensic control line at any point in
42640 your exim config.  If you don't tell exim to send them, it will not
42641 send them.)
42642
42643 There are no options to either control.  Both must appear before
42644 the DATA acl.
42645
42646 .subsection ACL SSECDMARCACL
42647 .cindex DMARC "ACL condition"
42648
42649 DMARC checks can be run on incoming SMTP  messages by using the
42650 &"dmarc_status"& ACL condition in the DATA ACL.  You are required to
42651 call the &"spf"& condition first in the ACLs, then the &"dmarc_status"&
42652 condition.  Putting this condition in the ACLs is required in order
42653 for a DMARC check to actually occur.  All of the variables are set
42654 up before the DATA ACL, but there is no actual DMARC check that
42655 occurs until a &"dmarc_status"& condition is encountered in the ACLs.
42656
42657 The &"dmarc_status"& condition takes a list of strings on its
42658 right-hand side.  These strings describe recommended action based
42659 on the DMARC check.  To understand what the policy recommendations
42660 mean, refer to the DMARC website above.  Valid strings are:
42661 .itable none 0 0 2 20* left 80* left
42662 .irow &'accept'&        "The DMARC check passed and the library recommends accepting the email"
42663 .irow &'reject'&        "The DMARC check failed and the library recommends rejecting the email"
42664 .irow &'quarantine'&    "The DMARC check failed and the library recommends keeping it for further inspection"
42665 .irow &'none'&          "The DMARC check passed and the library recommends no specific action, neutral"
42666 .irow &'norecord'&      "No policy section in the DMARC record for this RFC5322.From field"
42667 .irow &'nofrom'&        "Unable to determine the domain of the sender"
42668 .irow &'temperror'&     "Library error or dns error"
42669 .irow &'off'&           "The DMARC check was disabled for this email"
42670 .endtable
42671 You can prefix each string with an exclamation mark to invert its
42672 meaning, for example "!accept" will match all results but
42673 "accept".  The string list is evaluated left-to-right in a
42674 short-circuit fashion.  When a string matches the outcome of the
42675 DMARC check, the condition succeeds.  If none of the listed
42676 strings matches the outcome of the DMARC check, the condition
42677 fails.
42678
42679 Of course, you can also use any other lookup method that Exim
42680 supports, including LDAP, Postgres, MySQL, etc, as long as the
42681 result is a list of colon-separated strings.
42682
42683 Performing the check sets up information used by the
42684 &%authresults%& expansion item.
42685
42686 Several expansion variables are set before the DATA ACL is
42687 processed, and you can use them in this ACL.  The following
42688 expansion variables are available:
42689
42690 .vlist
42691 .vitem &$dmarc_status$&
42692 .vindex &$dmarc_status$&
42693 .cindex DMARC result
42694 A one word status indicating what the DMARC library
42695 thinks of the email.  It is a combination of the results of
42696 DMARC record lookup and the SPF/DKIM/DMARC processing results
42697 (if a DMARC record was found).  The actual policy declared
42698 in the DMARC record is in a separate expansion variable.
42699
42700 .vitem &$dmarc_status_text$&
42701 .vindex &$dmarc_status_text$&
42702 Slightly longer, human readable status.
42703
42704 .vitem &$dmarc_used_domain$&
42705 .vindex &$dmarc_used_domain$&
42706 The domain which DMARC used to look up the DMARC policy record.
42707
42708 .vitem &$dmarc_domain_policy$&
42709 .vindex &$dmarc_domain_policy$&
42710 The policy declared in the DMARC record.  Valid values
42711 are "none", "reject" and "quarantine".  It is blank when there
42712 is any error, including no DMARC record.
42713 .endlist
42714
42715 .subsection Logging SSECDMARCLOGGING
42716 .cindex DMARC logging
42717
42718 By default, Exim's DMARC configuration is intended to be
42719 non-intrusive and conservative.  To facilitate this, Exim will not
42720 create any type of logging files without explicit configuration by
42721 you, the admin.  Nor will Exim send out any emails/reports about
42722 DMARC issues without explicit configuration by you, the admin (other
42723 than typical bounce messages that may come about due to ACL
42724 processing or failure delivery issues).
42725
42726 In order to log statistics suitable to be imported by the opendmarc
42727 tools, you need to:
42728 .ilist
42729 Configure the global option &%dmarc_history_file%&
42730 .next
42731 Configure cron jobs to call the appropriate opendmarc history
42732 import scripts and truncating the dmarc_history_file
42733 .endlist
42734
42735 In order to send forensic reports, you need to:
42736 .ilist
42737 Configure the global option &%dmarc_forensic_sender%&
42738 .next
42739 Configure, somewhere before the DATA ACL, the control option to
42740 enable sending DMARC forensic reports
42741 .endlist
42742
42743 .subsection Example SSECDMARCEXAMPLE
42744 .cindex DMARC example
42745
42746 Example usage:
42747 .code
42748 (RCPT ACL)
42749   warn    domains        = +local_domains
42750           hosts          = +local_hosts
42751           control        = dmarc_disable_verify
42752
42753   warn    !domains       = +screwed_up_dmarc_records
42754           control        = dmarc_enable_forensic
42755
42756   warn    condition      = (lookup if destined to mailing list)
42757           set acl_m_mailing_list = 1
42758
42759 (DATA ACL)
42760   warn    dmarc_status   = accept : none : off
42761           !authenticated = *
42762           log_message    = DMARC DEBUG: $dmarc_status $dmarc_used_domain
42763
42764   warn    dmarc_status   = !accept
42765           !authenticated = *
42766           log_message    = DMARC DEBUG: '$dmarc_status' for $dmarc_used_domain
42767
42768   warn    dmarc_status   = quarantine
42769           !authenticated = *
42770           set $acl_m_quarantine = 1
42771           # Do something in a transport with this flag variable
42772
42773   deny    condition      = ${if eq{$dmarc_domain_policy}{reject}}
42774           condition      = ${if eq{$acl_m_mailing_list}{1}}
42775           message        = Messages from $dmarc_used_domain break mailing lists
42776
42777   deny    dmarc_status   = reject
42778           !authenticated = *
42779           message        = Message from $dmarc_used_domain failed sender's DMARC policy, REJECT
42780
42781   warn    add_header     = :at_start:${authresults {$primary_hostname}}
42782 .endd
42783
42784
42785
42786
42787
42788 . ////////////////////////////////////////////////////////////////////////////
42789 . ////////////////////////////////////////////////////////////////////////////
42790
42791 .chapter "Proxies" "CHAPproxies" &&&
42792          "Proxy support"
42793 .cindex "proxy support"
42794 .cindex "proxy" "access via"
42795
42796 A proxy is an intermediate system through which communication is passed.
42797 Proxies may provide a security, availability or load-distribution function.
42798
42799
42800 .section "Inbound proxies" SECTproxyInbound
42801 .cindex proxy inbound
42802 .cindex proxy "server side"
42803 .cindex proxy "Proxy protocol"
42804 .cindex "Proxy protocol" proxy
42805
42806 Exim has support for receiving inbound SMTP connections via a proxy
42807 that uses &"Proxy Protocol"& to speak to it.
42808 To include this support, include &"SUPPORT_PROXY=yes"&
42809 in Local/Makefile.
42810
42811 It was built on the HAProxy specification, found at
42812 &url(https://www.haproxy.org/download/1.8/doc/proxy-protocol.txt).
42813
42814 The purpose of this facility is so that an application load balancer,
42815 such as HAProxy, can sit in front of several Exim servers
42816 to distribute load.
42817 Exim uses the local protocol communication with the proxy to obtain
42818 the remote SMTP system IP address and port information.
42819 There is no logging if a host passes or
42820 fails Proxy Protocol negotiation, but it can easily be determined and
42821 recorded in an ACL (example is below).
42822
42823 Use of a proxy is enabled by setting the &%hosts_proxy%&
42824 main configuration option to a hostlist; connections from these
42825 hosts will use Proxy Protocol.
42826 Exim supports both version 1 and version 2 of the Proxy Protocol and
42827 automatically determines which version is in use.
42828
42829 The Proxy Protocol header is the first data received on a TCP connection
42830 and is inserted before any TLS-on-connect handshake from the client; Exim
42831 negotiates TLS between Exim-as-server and the remote client, not between
42832 Exim and the proxy server. The Proxy Protocol header must be received
42833 within &%proxy_protocol_timeout%&, which defaults to 3s.
42834
42835 The following expansion variables are usable
42836 (&"internal"& and &"external"& here refer to the interfaces
42837 of the proxy):
42838 .itable none 0 0 2 30* left 70* left
42839 .irow $proxy_external_address   "IP of host being proxied or IP of remote interface of proxy"
42840 .irow $proxy_external_port      "Port of host being proxied or Port on remote interface of proxy"
42841 .irow $proxy_local_address      "IP of proxy server inbound or IP of local interface of proxy"
42842 .irow $proxy_local_port         "Port of proxy server inbound or Port on local interface of proxy"
42843 .irow $proxy_session            "boolean: SMTP connection via proxy"
42844 .endtable
42845 If &$proxy_session$& is set but &$proxy_external_address$& is empty
42846 there was a protocol error.
42847 The variables &$sender_host_address$& and &$sender_host_port$&
42848 will have values for the actual client system, not the proxy.
42849
42850 Since the real connections are all coming from the proxy, and the
42851 per host connection tracking is done before Proxy Protocol is
42852 evaluated, &%smtp_accept_max_per_host%& must be set high enough to
42853 handle all of the parallel volume you expect per inbound proxy.
42854 With the option set so high, you lose the ability
42855 to protect your server from many connections from one IP.
42856 In order to prevent your server from overload, you
42857 need to add a per connection ratelimit to your connect ACL.
42858 A possible solution is:
42859 .display
42860   # Set max number of connections per host
42861   LIMIT   = 5
42862   # Or do some kind of IP lookup in a flat file or database
42863   # LIMIT = ${lookup{$sender_host_address}iplsearch{/etc/exim/proxy_limits}}
42864
42865   defer   ratelimit      = LIMIT / 5s / per_conn / strict
42866           message        = Too many connections from this IP right now
42867 .endd
42868
42869
42870
42871 .section "Outbound proxies" SECTproxySOCKS
42872 .cindex proxy outbound
42873 .cindex proxy "client side"
42874 .cindex proxy SOCKS
42875 .cindex SOCKS proxy
42876 Exim has support for sending outbound SMTP via a proxy
42877 using a protocol called SOCKS5 (defined by RFC1928).
42878 The support can be optionally included by defining SUPPORT_SOCKS=yes in
42879 Local/Makefile.
42880
42881 Use of a proxy is enabled by setting the &%socks_proxy%& option
42882 on an smtp transport.
42883 The option value is expanded and should then be a list
42884 (colon-separated by default) of proxy specifiers.
42885 Each proxy specifier is a list
42886 (space-separated by default) where the initial element
42887 is an IP address and any subsequent elements are options.
42888
42889 Options are a string <name>=<value>.
42890 The list of options is in the following table:
42891 .itable none 0 0 2 10* left 90* left
42892 .irow &'auth'&  "authentication method"
42893 .irow &'name'&  "authentication username"
42894 .irow &'pass'&  "authentication password"
42895 .irow &'port'&  "tcp port"
42896 .irow &'tmo'&   "connection timeout"
42897 .irow &'pri'&   "priority"
42898 .irow &'weight'& "selection bias"
42899 .endtable
42900
42901 More details on each of these options follows:
42902
42903 .ilist
42904 .cindex authentication "to proxy"
42905 .cindex proxy authentication
42906 &%auth%&: Either &"none"& (default) or &"name"&.
42907 Using &"name"& selects username/password authentication per RFC 1929
42908 for access to the proxy.
42909 Default is &"none"&.
42910 .next
42911 &%name%&: sets the username for the &"name"& authentication method.
42912 Default is empty.
42913 .next
42914 &%pass%&: sets the password for the &"name"& authentication method.
42915 Default is empty.
42916 .next
42917 &%port%&: the TCP port number to use for the connection to the proxy.
42918 Default is 1080.
42919 .next
42920 &%tmo%&: sets a connection timeout in seconds for this proxy.
42921 Default is 5.
42922 .next
42923 &%pri%&: specifies a priority for the proxy within the list,
42924 higher values being tried first.
42925 The default priority is 1.
42926 .next
42927 &%weight%&: specifies a selection bias.
42928 Within a priority set servers are queried in a random fashion,
42929 weighted by this value.
42930 The default value for selection bias is 1.
42931 .endlist
42932
42933 Proxies from the list are tried according to their priority
42934 and weight settings until one responds.  The timeout for the
42935 overall connection applies to the set of proxied attempts.
42936
42937 .section Logging SECTproxyLog
42938 To log the (local) IP of a proxy in the incoming or delivery logline,
42939 add &"+proxy"& to the &%log_selector%& option.
42940 This will add a component tagged with &"PRX="& to the line.
42941
42942 . ////////////////////////////////////////////////////////////////////////////
42943 . ////////////////////////////////////////////////////////////////////////////
42944
42945 .chapter "Internationalisation" "CHAPi18n" &&&
42946          "Internationalisation""
42947 .cindex internationalisation "email address"
42948 .cindex EAI
42949 .cindex i18n
42950 .cindex utf8 "mail name handling"
42951
42952 Exim has support for Internationalised mail names.
42953 To include this it must be built with SUPPORT_I18N and the libidn library.
42954 Standards supported are RFCs 2060, 5890, 6530 and 6533.
42955
42956 If Exim is built with SUPPORT_I18N_2008 (in addition to SUPPORT_I18N, not
42957 instead of it) then IDNA2008 is supported; this adds an extra library
42958 requirement, upon libidn2.
42959
42960 .section "MTA operations" SECTi18nMTA
42961 .cindex SMTPUTF8 "ESMTP option"
42962 .cindex "ESMTP extensions" SMTPUTF8
42963 The main configuration option &%smtputf8_advertise_hosts%& specifies
42964 a host list.  If this matches the sending host and
42965 accept_8bitmime is true (the default) then the ESMTP option
42966 SMTPUTF8 will be advertised.
42967
42968 If the sender specifies the SMTPUTF8 option on a MAIL command
42969 international handling for the message is enabled and
42970 the expansion variable &$message_smtputf8$& will have value TRUE.
42971
42972 The option &%allow_utf8_domains%& is set to true for this
42973 message. All DNS lookups are converted to a-label form
42974 whatever the setting of &%allow_utf8_domains%&
42975 when Exim is built with SUPPORT_I18N.
42976
42977 Both localparts and domain are maintained as the original
42978 UTF-8 form internally; any comparison or regular-expression use will
42979 require appropriate care.  Filenames created, eg. by
42980 the appendfile transport, will have UTF-8 names.
42981
42982 HELO names sent by the smtp transport will have any UTF-8
42983 components expanded to a-label form,
42984 and any certificate name checks will be done using the a-label
42985 form of the name.
42986
42987 .cindex log protocol
42988 .cindex SMTPUTF8 logging
42989 .cindex i18n logging
42990 Log lines and Received-by: header lines will acquire a "utf8"
42991 prefix on the protocol element, eg. utf8esmtp.
42992
42993 The following expansion operators can be used:
42994 .code
42995 ${utf8_domain_to_alabel:str}
42996 ${utf8_domain_from_alabel:str}
42997 ${utf8_localpart_to_alabel:str}
42998 ${utf8_localpart_from_alabel:str}
42999 .endd
43000
43001 .cindex utf8 "address downconversion"
43002 .cindex i18n "utf8 address downconversion"
43003 The RCPT ACL
43004 may use the following modifier:
43005 .display
43006 control = utf8_downconvert
43007 control = utf8_downconvert/<value>
43008 .endd
43009 This sets a flag requiring that envelope addresses are converted to
43010 a-label form before smtp delivery.
43011 This is usually for use in a Message Submission Agent context,
43012 but could be used for any message.
43013
43014 If a value is appended it may be:
43015 .itable none 0 0 2 5* right 95* left
43016 .irow &`1`&     "mandatory downconversion"
43017 .irow &`0`&     "no downconversion"
43018 .irow &`-1`&    "if SMTPUTF8 not supported by destination host"
43019 .endtable
43020 If no value is given, 1 is used.
43021
43022 If mua_wrapper is set, the utf8_downconvert control
43023 is initially set to -1.
43024
43025 The smtp transport has an option &%utf8_downconvert%&.
43026 If set it must expand to one of the three values described above,
43027 or an empty string.
43028 If non-empty it overrides value previously set
43029 (due to mua_wrapper or by an ACL control).
43030
43031
43032 There is no explicit support for VRFY and EXPN.
43033 Configurations supporting these should inspect
43034 &$smtp_command_argument$& for an SMTPUTF8 argument.
43035
43036 There is no support for LMTP on Unix sockets.
43037 Using the "lmtp" protocol option on an smtp transport,
43038 for LMTP over TCP, should work as expected.
43039
43040 There is no support for DSN unitext handling,
43041 and no provision for converting logging from or to UTF-8.
43042
43043
43044
43045 .section "MDA operations" SECTi18nMDA
43046 To aid in constructing names suitable for IMAP folders
43047 the following expansion operator can be used:
43048 .code
43049 ${imapfolder {<string>} {<sep>} {<specials>}}
43050 .endd
43051
43052 The string is converted from the charset specified by
43053 the "headers charset" command (in a filter file)
43054 or &%headers_charset%& main configuration option (otherwise),
43055 to the
43056 modified UTF-7 encoding specified by RFC 2060,
43057 with the following exception: All occurrences of <sep>
43058 (which has to be a single character)
43059 are replaced with periods ("."), and all periods and slashes that are not
43060 <sep> and are not in the <specials> string are BASE64 encoded.
43061
43062 The third argument can be omitted, defaulting to an empty string.
43063 The second argument can be omitted, defaulting to "/".
43064
43065 This is the encoding used by Courier for Maildir names on disk, and followed
43066 by many other IMAP servers.
43067
43068 Examples:
43069 .display
43070 &`${imapfolder {Foo/Bar}}       `& yields &`Foo.Bar`&
43071 &`${imapfolder {Foo/Bar}{.}{/}} `& yields &`Foo&&AC8-Bar`&
43072 &`${imapfolder {Räksmörgås}}    `& yields &`R&&AOQ-ksm&&APY-rg&&AOU-s`&
43073 .endd
43074
43075 Note that the source charset setting is vital, and also that characters
43076 must be representable in UTF-16.
43077
43078
43079 . ////////////////////////////////////////////////////////////////////////////
43080 . ////////////////////////////////////////////////////////////////////////////
43081
43082 .chapter "Events" "CHAPevents" &&&
43083          "Events"
43084 .cindex events
43085
43086 The events mechanism in Exim can be used to intercept processing at a number
43087 of points.  It was originally invented to give a way to do customised logging
43088 actions (for example, to a database) but can also be used to modify some
43089 processing actions.
43090
43091 Most installations will never need to use Events.
43092 The support can be left out of a build by defining DISABLE_EVENT=yes
43093 in &_Local/Makefile_&.
43094
43095 There are two major classes of events: main and transport.
43096 The main configuration option &%event_action%& controls reception events;
43097 a transport option &%event_action%& controls delivery events.
43098
43099 Both options are a string which is expanded when the event fires.
43100 An example might look like:
43101 .cindex logging custom
43102 .code
43103 event_action = ${if eq {msg:delivery}{$event_name} \
43104 {${lookup pgsql {SELECT * FROM record_Delivery( \
43105     '${quote_pgsql:$sender_address_domain}',\
43106     '${quote_pgsql:${lc:$sender_address_local_part}}', \
43107     '${quote_pgsql:$domain}', \
43108     '${quote_pgsql:${lc:$local_part}}', \
43109     '${quote_pgsql:$host_address}', \
43110     '${quote_pgsql:${lc:$host}}', \
43111     '${quote_pgsql:$message_exim_id}')}} \
43112 } {}}
43113 .endd
43114
43115 Events have names which correspond to the point in process at which they fire.
43116 The name is placed in the variable &$event_name$& and the event action
43117 expansion must check this, as it will be called for every possible event type.
43118
43119 The current list of events is:
43120 .itable all 0 0 4 25* left 10* center 15* center 50* left
43121 .row auth:fail              after    both       "per driver per authentication attempt"
43122 .row dane:fail              after    transport  "per connection"
43123 .row dns:fail               after    both       "per lookup"
43124 .row msg:complete           after    main       "per message"
43125 .row msg:defer              after    transport  "per message per delivery try"
43126 .row msg:delivery           after    transport  "per recipient"
43127 .row msg:rcpt:host:defer    after    transport  "per recipient per host"
43128 .row msg:rcpt:defer         after    transport  "per recipient"
43129 .row msg:host:defer         after    transport  "per host per delivery try; host errors"
43130 .row msg:fail:delivery      after    transport  "per recipient"
43131 .row msg:fail:internal      after    main       "per recipient"
43132 .row tcp:connect            before   transport  "per connection"
43133 .row tcp:close              after    transport  "per connection"
43134 .row tls:cert               before   both       "per certificate in verification chain"
43135 .row tls:fail:connect       after    main       "per connection"
43136 .row smtp:connect           after    transport  "per connection"
43137 .row smtp:ehlo              after    transport  "per connection"
43138 .endtable
43139 New event types may be added in future.
43140
43141 The event name is a colon-separated list, defining the type of
43142 event in a tree of possibilities.  It may be used as a list
43143 or just matched on as a whole.  There will be no spaces in the name.
43144
43145 The second column in the table above describes whether the event fires
43146 before or after the action is associates with.  Those which fire before
43147 can be used to affect that action (more on this below).
43148
43149 The third column in the table above says what section of the configuration
43150 should define the event action.
43151
43152 An additional variable, &$event_data$&, is filled with information varying
43153 with the event type:
43154 .itable all 0 0 2 20* left 80* left
43155 .row auth:fail            "smtp response"
43156 .row dane:fail            "failure reason"
43157 .row dns:fail             "failure reason, key and lookup-type"
43158 .row msg:defer            "error string"
43159 .row msg:delivery         "smtp confirmation message"
43160 .row msg:fail:internal    "failure reason"
43161 .row msg:fail:delivery    "smtp error message"
43162 .row msg:host:defer       "error string"
43163 .row msg:rcpt:host:defer  "error string"
43164 .row msg:rcpt:defer       "error string"
43165 .row tls:cert             "verification chain depth"
43166 .row tls:fail:connect     "error string"
43167 .row smtp:connect         "smtp banner"
43168 .row smtp:ehlo            "smtp ehlo response"
43169 .endtable
43170
43171 The :defer events populate one extra variable: &$event_defer_errno$&.
43172
43173 For complex operations an ACL expansion can be used in &%event_action%&,
43174 however due to the multiple contexts that Exim operates in during
43175 the course of its processing:
43176 .ilist
43177 variables set in transport events will not be visible outside that
43178 transport call
43179 .next
43180 acl_m variables in a server context are lost on a new connection,
43181 and after smtp helo/ehlo/mail/starttls/rset commands
43182 .endlist
43183 Using an ACL expansion with the logwrite modifier can be
43184 a useful way of writing to the main log.
43185
43186 The expansion of the event_action option should normally
43187 return an empty string.  Should it return anything else the
43188 following will be forced:
43189 .itable all 0 0 2 20* left 80* left
43190 .row auth:fail        "log information to write"
43191 .row tcp:connect      "do not connect"
43192 .row tls:cert         "refuse verification"
43193 .row smtp:connect     "close connection"
43194 .endtable
43195 All other message types ignore the result string, and
43196 no other use is made of it.
43197
43198 For a tcp:connect event, if the connection is being made to a proxy
43199 then the &$host_address$& and &$host_port$& variables
43200 will be that of the proxy and not the target system.
43201
43202 For tls:cert events, if GnuTLS is in use this will trigger only per
43203 chain element received on the connection.
43204 For OpenSSL it will trigger for every chain element including those
43205 loaded locally.
43206
43207 For dns:fail events from dnsdb lookups, a &"defer_never"& option does not
43208 affect the reporting of DNS_AGAIN.
43209
43210 . ////////////////////////////////////////////////////////////////////////////
43211 . ////////////////////////////////////////////////////////////////////////////
43212
43213 .chapter "Adding new drivers or lookup types" "CHID13" &&&
43214          "Adding drivers or lookups"
43215 .cindex "adding drivers"
43216 .cindex "new drivers, adding"
43217 .cindex "drivers" "adding new"
43218 The following actions have to be taken in order to add a new router, transport,
43219 authenticator, or lookup type to Exim:
43220
43221 .olist
43222 Choose a name for the driver or lookup type that does not conflict with any
43223 existing name; I will use &"newdriver"& in what follows.
43224 .next
43225 Add to &_src/EDITME_& the line:
43226 .display
43227 <&'type'&>&`_NEWDRIVER=yes`&
43228 .endd
43229 where <&'type'&> is ROUTER, TRANSPORT, AUTH, or LOOKUP. If the
43230 code is not to be included in the binary by default, comment this line out. You
43231 should also add any relevant comments about the driver or lookup type.
43232 .next
43233 Add to &_src/config.h.defaults_& the line:
43234 .code
43235 #define <type>_NEWDRIVER
43236 .endd
43237 .next
43238 Edit &_src/drtables.c_&, adding conditional code to pull in the private header
43239 and create a table entry as is done for all the other drivers and lookup types.
43240 .next
43241 Edit &_scripts/lookups-Makefile_& if this is a new lookup; there is a for-loop
43242 near the bottom, ranging the &`name_mod`& variable over a list of all lookups.
43243 Add your &`NEWDRIVER`& to that list.
43244 As long as the dynamic module would be named &_newdriver.so_&, you can use the
43245 simple form that most lookups have.
43246 .next
43247 Edit &_Makefile_& in the appropriate sub-directory (&_src/routers_&,
43248 &_src/transports_&, &_src/auths_&, or &_src/lookups_&); add a line for the new
43249 driver or lookup type and add it to the definition of OBJ.
43250 .next
43251 Edit &_OS/Makefile-Base_& adding a &_.o_& file for the predefined-macros, to the
43252 definition of OBJ_MACRO.  Add a set of line to do the compile also.
43253 .next
43254 Create &_newdriver.h_& and &_newdriver.c_& in the appropriate sub-directory of
43255 &_src_&.
43256 .next
43257 Edit &_scripts/MakeLinks_& and add commands to link the &_.h_& and &_.c_& files
43258 as for other drivers and lookups.
43259 .endlist
43260
43261 Then all you need to do is write the code! A good way to start is to make a
43262 proforma by copying an existing module of the same type, globally changing all
43263 occurrences of the name, and cutting out most of the code. Note that any
43264 options you create must be listed in alphabetical order, because the tables are
43265 searched using a binary chop procedure.
43266
43267 There is a &_README_& file in each of the sub-directories of &_src_& describing
43268 the interface that is expected.
43269
43270
43271
43272
43273 . ////////////////////////////////////////////////////////////////////////////
43274 . ////////////////////////////////////////////////////////////////////////////
43275
43276 . /////////////////////////////////////////////////////////////////////////////
43277 . These lines are processing instructions for the Simple DocBook Processor that
43278 . Philip Hazel has developed as a less cumbersome way of making PostScript and
43279 . PDFs than using xmlto and fop. They will be ignored by all other XML
43280 . processors.
43281 . /////////////////////////////////////////////////////////////////////////////
43282
43283 .literal xml
43284 <?sdop
43285   format="newpage"
43286   foot_right_recto="&chaptertitle;"
43287   foot_right_verso="&chaptertitle;"
43288 ?>
43289 .literal off
43290
43291 .makeindex "Options index"   "option"
43292 .makeindex "Variables index" "variable"
43293 .makeindex "Concept index"   "concept"
43294
43295
43296 . /////////////////////////////////////////////////////////////////////////////
43297 . /////////////////////////////////////////////////////////////////////////////